-
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 5 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,42 @@ | ||
| name: run python demos | ||
|
|
||
| on: | ||
| push: | ||
| branches: ["*"] | ||
| pull_request: | ||
| branches: ["*"] | ||
|
|
||
| jobs: | ||
| demos: | ||
| continue-on-error: true | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| matrix: | ||
| os: [ubuntu-20.04] | ||
| python-version: ["3.7"] | ||
|
|
||
| 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 tests and generate coverage report | ||
| run: pytest --nbmake --nbmake-timeout=3000 "./examples" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| name: tests and coverage with python | ||
|
|
||
| on: | ||
| push: | ||
| branches: ["*"] | ||
| pull_request: | ||
| branches: ["*"] | ||
|
|
||
| jobs: | ||
| tests: | ||
| continue-on-error: true | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| matrix: | ||
| os: [ubuntu-20.04] | ||
|
||
| python-version: ["3.7", "3.8", "3.9", "3.10"] | ||
|
|
||
| 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,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 |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| [flake8] | ||
| max-line-length = 99 | ||
|
|
||
| ignore = D203, W503 | ||
|
|
||
| exclude = | ||
| .git, | ||
| docs, | ||
| __pycache__, | ||
| old, | ||
| build, | ||
| dist | ||
| 'matlab/fracridge' | ||
|
|
||
| max-complexity = 10 | ||
|
|
||
| [tool:pytest] | ||
| branch = True | ||
| source = glmsingle/* | ||
| include = glmsingle/* | ||
| testpaths = tests |
| 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,34 @@ | ||
| from os.path import join | ||
| from os.path import abspath | ||
| from os.path import dirname | ||
| import scipy | ||
| import scipy.io as sio | ||
| from glmsingle.glmsingle import GLM_single | ||
|
|
||
| test_dir = dirname(abspath(__file__)) | ||
| data_dir = join(test_dir, "data") | ||
| data_file = join(data_dir, "nsdcoreexampledataset.mat") | ||
|
|
||
| output_dir = join(test_dir, "outputs") | ||
|
|
||
|
|
||
| def test_smoke_test(): | ||
|
|
||
| X = sio.loadmat(data_file) | ||
|
|
||
| data = [] | ||
| design = [] | ||
| for r in range(3): # range(len(X['data'][0])): | ||
| data.append(X["data"][0, r][50:70, 7:27, 0:1, :]) | ||
| design.append(scipy.sparse.csr_matrix.toarray(X["design"][0, r])) | ||
|
|
||
| stimdur = X["stimdur"][0][0] | ||
| tr = X["tr"][0][0] | ||
|
|
||
| opt = {"wantmemoryoutputs": [1, 1, 1, 1]} | ||
|
|
||
| # OPTIONAL: PUT THIS IN? | ||
| # opt['wantlibrary'] = 0 | ||
|
|
||
| glmsingle_obj = GLM_single(opt) | ||
| glmsingle_obj.fit(design, data, stimdur, tr, outputdir=join(output_dir, "python")) | ||
Remi-Gau marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Uh oh!
There was an error while loading. Please reload this page.