-
Notifications
You must be signed in to change notification settings - Fork 53
[INFRA] Python test automation #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 16 commits
5dfcecd
ddbf5b2
8a7c1f5
53c1804
922c8d0
3ee979b
d251cee
5886906
78e0727
d5ee9bf
f4aaecb
e4cb204
e1aa83b
f76552c
a27c0aa
66a5d19
0331ef5
71c3a53
14d83d9
a972d94
9daa42d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| name: Python demos | ||
|
|
||
| # Uses the cron schedule for github actions | ||
| # | ||
| # will run at 00H00 run on the 1 and 15 of every month | ||
| # | ||
| # https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#scheduled-events | ||
| # | ||
| # ┌───────────── minute (0 - 59) | ||
| # │ ┌───────────── hour (0 - 23) | ||
| # │ │ ┌───────────── day of the month (1 - 31) | ||
| # │ │ │ ┌───────────── month (1 - 12 or JAN-DEC): * means all | ||
| # │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT): * means all | ||
| # │ │ │ │ │ | ||
| # │ │ │ │ │ | ||
| # │ │ │ │ │ | ||
| # | ||
| # - cron "0 0 1,15 * *" | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: "0 0 1,15 * *" | ||
|
|
||
| push: | ||
| branches: ["*"] | ||
|
|
||
| jobs: | ||
| demos: | ||
| continue-on-error: true | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| matrix: | ||
| os: [ubuntu-latest] | ||
| python-version: ["3.9"] | ||
|
|
||
| steps: | ||
| - name: Shallow clone GLMsingle | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| submodules: "recursive" | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@v2 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip setuptools | ||
| pip install . | ||
| pip install -r requirements_dev.txt | ||
|
|
||
| - name: Display Python version and packages | ||
| run: | | ||
| python -c "import sys; print(sys.version)" | ||
| pip list | ||
|
|
||
| - name: Run notebooks | ||
| run: pytest --nbmake --nbmake-timeout=3000 "./examples" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| name: Python tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: ["*"] | ||
| pull_request: | ||
| branches: ["*"] | ||
|
|
||
| jobs: | ||
| tests: | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| matrix: | ||
| os: [ubuntu-latest, macOS-latest, windows-latest] | ||
| python-version: ["3.7", "3.8", "3.9"] # fails on 3.10 | ||
| fail-fast: true # cancel all jobs if one fails | ||
|
|
||
| steps: | ||
| - name: Shallow clone GLMsingle | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| submodules: "recursive" | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@v2 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip setuptools | ||
| pip install . | ||
| pip install -r requirements_dev.txt | ||
|
|
||
| - name: Display Python version and packages | ||
| run: | | ||
| python -c "import sys; print(sys.version)" | ||
| pip list | ||
|
|
||
| - name: Prepare data | ||
| run: make tests/data/nsdcoreexampledataset.mat | ||
|
|
||
| - name: Run tests and generate coverage report | ||
| run: pytest -v --cov glmsingle --cov-report xml tests | ||
|
|
||
| - name: Upload coverage to Codecov | ||
| uses: codecov/codecov-action@v1 | ||
| with: | ||
| file: ./coverage.xml | ||
| flags: python | ||
| name: codecov-umbrella | ||
| fail_ci_if_error: true | ||
| verbose: true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,8 @@ | ||
|
|
||
|
|
||
| [](https://github.com/cvnlab/GLMsingle/actions/workflows/run_tests_python.yml) | ||
| [](https://github.com/cvnlab/GLMsingle/actions/workflows/run_demos_python.yml) | ||
| [](https://codecov.io/gh/Remi-Gau/GLMsingle) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code coverage is not yet uploaded and so this might require some tweaking after merging:
But once set up you can know how pull request change the code coverage: like this |
||
| # GLMsingle | ||
|
|
||
|  | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| numpy | ||
| scipy | ||
| sklearn | ||
| matplotlib | ||
| tqdm | ||
| fracridge | ||
| nibabel | ||
| h5py | ||
| fracridge>=1.4.3 | ||
| h5py>=3.1.0 | ||
| matplotlib>=3.3.4 | ||
| nibabel>=3.2.2 | ||
| numpy>=1.17.0 | ||
| scikit-learn>=0.23.2 | ||
| scipy>=1.5.4 | ||
| tqdm>=4.63.1 | ||
|
Comment on lines
+1
to
+8
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have pinned the dependency minimum version for GLMsingle to be those that were installed by default when using python 3.6. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,13 @@ | ||
| # Base requirements | ||
| -r requirements.txt | ||
|
|
||
| # Matlab dev | ||
| miss_hit | ||
|
|
||
| # Python dev | ||
| black | ||
| flake8 | ||
| tox | ||
| coverage | ||
| pytest | ||
| black | ||
| nbmake | ||
| pytest-cov | ||
| nbmake | ||
| tox |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| [flake8] | ||
| max-line-length = 99 | ||
|
|
||
| ignore = D203, W503 | ||
|
|
||
| exclude = | ||
| .git, | ||
| docs, | ||
| __pycache__, | ||
| old, | ||
| build, | ||
| dist | ||
| 'matlab/fracridge' | ||
|
|
||
| max-complexity = 10 | ||
|
|
||
| [tool:pytest] | ||
| testpaths = tests |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ | |
|
|
||
| setup( | ||
| name='GLMsingle', | ||
| version='0.0.1', | ||
| version='1.0.0', | ||
|
||
| description='Python GLMsingle', | ||
| url='https://github.com/kendrickkay/GLMsingle', | ||
| long_description=long_description, | ||
|
|
@@ -28,5 +28,6 @@ | |
| packages=find_packages(), | ||
| include_package_data=True, | ||
| zip_safe=False, | ||
| install_requires=requires | ||
| install_requires=requires, | ||
| python_requires='>=3.6, <3.10' | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Specifying which python version to use |
||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| """Unit test package for glmsingle.""" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # Generate expected data | ||
|
|
||
| Generated from the output of one run from the files in `tests/outputs/python` | ||
|
|
||
| ```python | ||
| import numpy as np | ||
|
|
||
| tmp = np.load("TYPEB_FITHRF.npy", allow_pickle=True) | ||
| results = tmp.item(0)["HRFindex"] | ||
| np.save("TYPEB_FITHRF_HRFindex.npy", results) | ||
|
|
||
| tmp = np.load("TYPEC_FITHRF_GLMDENOISE.npy", allow_pickle=True) | ||
| results = tmp.item(0)["HRFindex"] | ||
| np.save("TYPEC_FITHRF_HRFindex.npy", results) | ||
|
|
||
| tmp = np.load("TYPED_FITHRF_GLMDENOISE_RR.npy", allow_pickle=True) | ||
| results = tmp.item(0)["HRFindex"] | ||
| np.save("TYPED_FITHRF_HRFindex.npy", results) | ||
|
|
||
| results = tmp.item(0)["R2"] | ||
| np.save("TYPED_FITHRF_R2.npy", results) | ||
| ``` | ||
|
|
||
| <!-- TODO ? | ||
| ## For CSV | ||
|
|
||
| ```python | ||
| import numpy as np | ||
|
|
||
| tmp = np.load("TYPEB_FITHRF.npy", allow_pickle=True) | ||
| results = tmp.item(0)["HRFindex"] | ||
| results = results.squeeze(); | ||
| np.savetxt("TYPEB_FITHRF_HRFindex.csv", results, delimiter=",", fmt="%i") | ||
|
|
||
| tmp = np.load("TYPEC_FITHRF_GLMDENOISE.npy", allow_pickle=True) | ||
| results = tmp.item(0)["HRFindex"] | ||
| results = results.squeeze(); | ||
| np.savetxt("TYPEC_FITHRF_HRFindex.csv", results, delimiter=",", fmt="%i") | ||
|
|
||
| tmp = np.load("TYPED_FITHRF_GLMDENOISE_RR.npy", allow_pickle=True) | ||
| results = tmp.item(0)["HRFindex"] | ||
| results = results.squeeze(); | ||
| np.savetxt("TYPED_FITHRF_HRFindex.csv", results, delimiter=",", fmt="%i") | ||
| ``` | ||
|
|
||
| Read from csv | ||
|
|
||
| ```python | ||
| from numpy import genfromtxt | ||
|
|
||
| my_data = genfromtxt('TYPEB_FITHRF_HRFindex.csv', delimiter=',') | ||
| ``` --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of those are for code styling, so it does not have to be done manually. Only applies to the test code base.
Can remove it if you want.