Skip to content

Commit ddd2060

Browse files
authored
Merge pull request miykael#94 from miykael/circleci_workflow
ENH: run CircleCi in parallel/workflow
2 parents e607d3e + bf7ac41 commit ddd2060

File tree

2 files changed

+94
-21
lines changed

2 files changed

+94
-21
lines changed

.circleci/config.yml

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,72 @@ version: 2
22
jobs:
33
build:
44
docker:
5-
- image: docker:17.10.0-ce-git
5+
- image: docker:18.05.0-ce-git
6+
steps:
7+
- checkout
8+
test_1:
9+
docker:
10+
- image: docker:18.05.0-ce-git
11+
steps:
12+
- checkout
13+
- setup_remote_docker:
14+
docker_layer_caching: true
15+
- run:
16+
name: docker build 1
17+
no_output_timeout: 60m
18+
command: |
19+
docker build -t miykael/nipype_tutorial:$CIRCLE_BRANCH .
20+
- run:
21+
name: run tests 1
22+
no_output_timeout: 120m
23+
command: |
24+
docker run -it --rm miykael/nipype_tutorial:$CIRCLE_BRANCH python /home/neuro/nipype_tutorial/test_notebooks.py 1
25+
test_2:
26+
docker:
27+
- image: docker:18.05.0-ce-git
28+
steps:
29+
- checkout
30+
- setup_remote_docker:
31+
docker_layer_caching: true
32+
- run:
33+
name: docker build 2
34+
no_output_timeout: 60m
35+
command: |
36+
docker build -t miykael/nipype_tutorial:$CIRCLE_BRANCH .
37+
- run:
38+
name: run tests 2
39+
no_output_timeout: 120m
40+
command: |
41+
docker run -it --rm miykael/nipype_tutorial:$CIRCLE_BRANCH python /home/neuro/nipype_tutorial/test_notebooks.py 2
42+
test_3:
43+
docker:
44+
- image: docker:18.05.0-ce-git
645
steps:
746
- checkout
847
- setup_remote_docker:
948
docker_layer_caching: true
1049
- run:
11-
name: docker build
50+
name: docker build 3
1251
no_output_timeout: 60m
1352
command: |
14-
for i in {1..5}; do
15-
docker build -t miykael/nipype_tutorial:$CIRCLE_BRANCH . && break || sleep 15
16-
done
53+
docker build -t miykael/nipype_tutorial:$CIRCLE_BRANCH .
1754
- run:
18-
name: docker run
55+
name: run tests 3
1956
no_output_timeout: 120m
2057
command: |
21-
docker run -it --rm miykael/nipype_tutorial:$CIRCLE_BRANCH python /home/neuro/nipype_tutorial/test_notebooks.py
58+
docker run -it --rm miykael/nipype_tutorial:$CIRCLE_BRANCH python /home/neuro/nipype_tutorial/test_notebooks.py 3
59+
60+
workflows:
61+
version: 2
62+
build_and_test:
63+
jobs:
64+
- build
65+
- test_1:
66+
requires:
67+
- build
68+
- test_2:
69+
requires:
70+
- build
71+
- test_3:
72+
requires:
73+
- build

test_notebooks.py

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import sys
23
import time
34
from glob import glob
45

@@ -55,21 +56,41 @@ def reduce_notebook_load(path):
5556

5657
test_version()
5758

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 = []
6161

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])
6864

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))
7192

7293
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

Comments
 (0)