|
1 | 1 | import os
|
| 2 | +import sys |
2 | 3 | import time
|
3 | 4 | from glob import glob
|
4 | 5 |
|
@@ -55,21 +56,41 @@ def reduce_notebook_load(path):
|
55 | 56 |
|
56 | 57 | test_version()
|
57 | 58 |
|
58 |
| - notebooks = sorted(glob("/home/neuro/nipype_tutorial/notebooks/introduction_*.ipynb")) + \ |
59 |
| - sorted(glob("/home/neuro/nipype_tutorial/notebooks/basic*.ipynb")) + \ |
60 |
| - sorted(glob("/home/neuro/nipype_tutorial/notebooks/advanced*.ipynb")) |
| 59 | + # Notebooks that should be tested |
| 60 | + notebooks = [] |
61 | 61 |
|
62 |
| - for n in ["/home/neuro/nipype_tutorial/notebooks/example_preprocessing.ipynb", |
63 |
| - "/home/neuro/nipype_tutorial/notebooks/example_1stlevel.ipynb", |
64 |
| - "/home/neuro/nipype_tutorial/notebooks/example_normalize.ipynb", |
65 |
| - "/home/neuro/nipype_tutorial/notebooks/example_2ndlevel.ipynb", |
66 |
| - "/home/neuro/nipype_tutorial/notebooks/handson_preprocessing.ipynb", |
67 |
| - "/home/neuro/nipype_tutorial/notebooks/handson_analysis.ipynb"]: |
| 62 | + # Test mode that should be run |
| 63 | + test_mode = int(sys.argv[1]) |
68 | 64 |
|
69 |
| - print('Reducing: %s' % n) |
70 |
| - notebooks.append(reduce_notebook_load(n)) |
| 65 | + # Specifies which tests should be run |
| 66 | + if test_mode == 1: |
| 67 | + |
| 68 | + # Test introduction, basic and advanced notebooks |
| 69 | + notebooks += sorted(glob("/home/neuro/nipype_tutorial/notebooks/introduction*.ipynb")) |
| 70 | + notebooks += sorted(glob("/home/neuro/nipype_tutorial/notebooks/basic*.ipynb")) |
| 71 | + notebooks += sorted(glob("/home/neuro/nipype_tutorial/notebooks/advanced*.ipynb")) |
| 72 | + |
| 73 | + elif test_mode == 2: |
| 74 | + |
| 75 | + # Test example notebooks |
| 76 | + for n in ["/home/neuro/nipype_tutorial/notebooks/example_preprocessing.ipynb", |
| 77 | + "/home/neuro/nipype_tutorial/notebooks/example_1stlevel.ipynb", |
| 78 | + "/home/neuro/nipype_tutorial/notebooks/example_normalize.ipynb", |
| 79 | + "/home/neuro/nipype_tutorial/notebooks/example_2ndlevel.ipynb"]: |
| 80 | + |
| 81 | + print('Reducing: %s' % n) |
| 82 | + notebooks.append(reduce_notebook_load(n)) |
| 83 | + |
| 84 | + elif test_mode == 3: |
| 85 | + |
| 86 | + # Test hands-on notebooks |
| 87 | + for n in ["/home/neuro/nipype_tutorial/notebooks/handson_preprocessing.ipynb", |
| 88 | + "/home/neuro/nipype_tutorial/notebooks/handson_analysis.ipynb"]: |
| 89 | + |
| 90 | + print('Reducing: %s' % n) |
| 91 | + notebooks.append(reduce_notebook_load(n)) |
71 | 92 |
|
72 | 93 | for test in notebooks:
|
73 |
| - t0 = time.time() |
74 |
| - os.system('pytest --nbval-lax --nbval-cell-timeout 7200 -v -s %s' % test) |
75 |
| - print("time", time.time() - t0) |
| 94 | + pytest_cmd = 'pytest --nbval-lax --nbval-cell-timeout 7200 -v -s %s' % test |
| 95 | + print(pytest_cmd) |
| 96 | + os.system(pytest_cmd) |
0 commit comments