Skip to content

Commit 80b9358

Browse files
authored
Merge pull request #78 from miykael/handle_crashes
Catch crashes, instead of flagging `CRASH`
2 parents b136ea9 + efd7b84 commit 80b9358

File tree

4 files changed

+59
-17
lines changed

4 files changed

+59
-17
lines changed

Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# pull request on our GitHub repository:
66
# https://github.com/kaczmarj/neurodocker
77
#
8-
# Timestamp: 2018-04-23 18:54:53
8+
# Timestamp: 2018-05-07 20:43:57
99

1010
FROM neurodebian:stretch-non-free
1111

@@ -143,7 +143,7 @@ RUN mkdir /output && chmod 777 /output && chmod a+s /output
143143
USER neuro
144144

145145
# User-defined BASH instruction
146-
RUN bash -c "source activate neuro && cd /data && datalad install -r ///workshops/nih-2017/ds000114 && cd ds000114 && datalad get -r sub-01/ses-test/anat sub-01/ses-test/func/*fingerfootlips*"
146+
RUN bash -c "source activate neuro && cd /data && datalad install -r ///workshops/nih-2017/ds000114 && cd ds000114 && datalad update -r && datalad get -r sub-01/ses-test/anat sub-01/ses-test/func/*fingerfootlips*"
147147

148148
# User-defined BASH instruction
149149
RUN bash -c "curl -L https://files.osf.io/v1/resources/fvuh8/providers/osfstorage/580705089ad5a101f17944a9 -o /data/ds000114/derivatives/fmriprep/mni_icbm152_nlin_asym_09c.tar.gz && tar xf /data/ds000114/derivatives/fmriprep/mni_icbm152_nlin_asym_09c.tar.gz -C /data/ds000114/derivatives/fmriprep/. && rm /data/ds000114/derivatives/fmriprep/mni_icbm152_nlin_asym_09c.tar.gz && find /data/ds000114/derivatives/fmriprep/mni_icbm152_nlin_asym_09c -type f -not -name ?mm_T1.nii.gz -not -name ?mm_brainmask.nii.gz -not -name ?mm_tpm*.nii.gz -delete"
@@ -249,7 +249,7 @@ RUN echo '{ \
249249
\n ], \
250250
\n [ \
251251
\n "run_bash", \
252-
\n "source activate neuro && cd /data && datalad install -r ///workshops/nih-2017/ds000114 && cd ds000114 && datalad get -r sub-01/ses-test/anat sub-01/ses-test/func/*fingerfootlips*" \
252+
\n "source activate neuro && cd /data && datalad install -r ///workshops/nih-2017/ds000114 && cd ds000114 && datalad update -r && datalad get -r sub-01/ses-test/anat sub-01/ses-test/func/*fingerfootlips*" \
253253
\n ], \
254254
\n [ \
255255
\n "run_bash", \
@@ -289,6 +289,6 @@ RUN echo '{ \
289289
\n ] \
290290
\n ] \
291291
\n ], \
292-
\n "generation_timestamp": "2018-04-23 18:54:53", \
292+
\n "generation_timestamp": "2018-05-07 20:43:57", \
293293
\n "neurodocker_version": "0.3.2" \
294294
\n}' > /neurodocker/neurodocker_specs.json

create_dockerfile.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
docker run --rm kaczmarj/neurodocker:master generate -b neurodebian:stretch-non-free -p apt \
3+
docker run --rm kaczmarj/neurodocker:v0.3.2 generate -b neurodebian:stretch-non-free -p apt \
44
--install convert3d ants fsl gcc g++ graphviz tree \
55
git-annex-standalone vim emacs-nox nano less ncdu \
66
tig git-annex-remote-rclone octave \
@@ -21,7 +21,7 @@ docker run --rm kaczmarj/neurodocker:master generate -b neurodebian:stretch-non-
2121
--run 'mkdir /data && chmod 777 /data && chmod a+s /data' \
2222
--run 'mkdir /output && chmod 777 /output && chmod a+s /output' \
2323
--user=neuro \
24-
--run-bash 'source activate neuro && cd /data && datalad install -r ///workshops/nih-2017/ds000114 && cd ds000114 && datalad get -r sub-01/ses-test/anat sub-01/ses-test/func/*fingerfootlips*' \
24+
--run-bash 'source activate neuro && cd /data && datalad install -r ///workshops/nih-2017/ds000114 && cd ds000114 && datalad update -r && datalad get -r sub-01/ses-test/anat sub-01/ses-test/func/*fingerfootlips*' \
2525
--run-bash 'curl -L https://files.osf.io/v1/resources/fvuh8/providers/osfstorage/580705089ad5a101f17944a9 -o /data/ds000114/derivatives/fmriprep/mni_icbm152_nlin_asym_09c.tar.gz && tar xf /data/ds000114/derivatives/fmriprep/mni_icbm152_nlin_asym_09c.tar.gz -C /data/ds000114/derivatives/fmriprep/. && rm /data/ds000114/derivatives/fmriprep/mni_icbm152_nlin_asym_09c.tar.gz && find /data/ds000114/derivatives/fmriprep/mni_icbm152_nlin_asym_09c -type f -not -name ?mm_T1.nii.gz -not -name ?mm_brainmask.nii.gz -not -name ?mm_tpm*.nii.gz -delete' \
2626
--copy . "/home/neuro/nipype_tutorial" \
2727
--user=root \

notebooks/advanced_create_interfaces.ipynb

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
" <td style=\"text-align:left\">Do not have inputs/outputs, but expose them from the interfaces wrapped inside</td>\n",
4646
" </tr>\n",
4747
" <tr>\n",
48-
" <td style=\"text-align:left\">Do not cache results (unless you use [interface caching](http://nipype.readthedocs.io/en/latest/users/caching_tutorial.html))</td>\n",
48+
" <td style=\"text-align:left\">Do not cache results (unless you use [interface caching](advanced_interfaces_caching.ipynb))</td>\n",
4949
" <td style=\"text-align:left\">Cache results</td>\n",
5050
" </tr>\n",
5151
" <tr>\n",
@@ -383,7 +383,14 @@
383383
"metadata": {},
384384
"outputs": [],
385385
"source": [
386-
"TransformInfo().cmdline # This will CRASH"
386+
"try:\n",
387+
" TransformInfo().cmdline\n",
388+
"\n",
389+
"except(ValueError) as err:\n",
390+
" print('It crashed with...')\n",
391+
" print(\"ValueError:\", err)\n",
392+
"else:\n",
393+
" raise"
387394
]
388395
},
389396
{
@@ -399,7 +406,14 @@
399406
"metadata": {},
400407
"outputs": [],
401408
"source": [
402-
"my_info_interface.inputs.in_file = 'idontexist.tfm' # This will CRASH, too"
409+
"try:\n",
410+
" my_info_interface.inputs.in_file = 'idontexist.tfm'\n",
411+
"\n",
412+
"except(Exception) as err:\n",
413+
" print('It crashed with...')\n",
414+
" print(\"TraitError:\", err)\n",
415+
"else:\n",
416+
" raise"
403417
]
404418
},
405419
{
@@ -928,9 +942,23 @@
928942
"source": [
929943
"will_fail_at_run = TranslateImage(\n",
930944
" in_file='/data/ds000114/sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz',\n",
931-
" out_file='translated.nii.gz')\n",
945+
" out_file='translated.nii.gz')"
946+
]
947+
},
948+
{
949+
"cell_type": "code",
950+
"execution_count": null,
951+
"metadata": {},
952+
"outputs": [],
953+
"source": [
954+
"try:\n",
955+
" result = will_fail_at_run.run()\n",
932956
"\n",
933-
"result = will_fail_at_run.run() # This will CRASH"
957+
"except(NotImplementedError) as err:\n",
958+
" print('It crashed with...')\n",
959+
" print(\"NotImplementedError:\", err)\n",
960+
"else:\n",
961+
" raise"
934962
]
935963
},
936964
{
@@ -978,9 +1006,23 @@
9781006
"source": [
9791007
"half_works = TranslateImage(\n",
9801008
" in_file='/data/ds000114/sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz',\n",
981-
" out_file='translated_nipype.nii.gz')\n",
1009+
" out_file='translated_nipype.nii.gz')"
1010+
]
1011+
},
1012+
{
1013+
"cell_type": "code",
1014+
"execution_count": null,
1015+
"metadata": {},
1016+
"outputs": [],
1017+
"source": [
1018+
"try:\n",
1019+
" result = half_works.run()\n",
9821020
"\n",
983-
"result = half_works.run() # This will CRASH, too"
1021+
"except(NotImplementedError) as err:\n",
1022+
" print('It crashed with...')\n",
1023+
" print(\"NotImplementedError:\", err)\n",
1024+
"else:\n",
1025+
" raise"
9841026
]
9851027
},
9861028
{

test_notebooks.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def _notebook_run(path):
3030
ep.preprocess(nb, {'metadata': {'path': this_file_directory}})
3131

3232
except CellExecutionError as e:
33-
if "TAB" in e.traceback or "CRASH" in e.traceback:
33+
if "TAB" in e.traceback:
3434
print(str(e.traceback).split("\n")[-2])
3535
else:
3636
raise e
@@ -85,9 +85,9 @@ def reduce_notebook_load(path):
8585
Dir_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "notebooks")
8686

8787
@pytest.mark.parametrize("notebook",
88-
glob(os.path.join(Dir_path, "introduction_*.ipynb")) +
89-
glob(os.path.join(Dir_path, "basic*.ipynb")) +
90-
glob(os.path.join(Dir_path, "advanced*.ipynb")) +
88+
sorted(glob(os.path.join(Dir_path, "introduction_*.ipynb"))) +
89+
sorted(glob(os.path.join(Dir_path, "basic*.ipynb"))) +
90+
sorted(glob(os.path.join(Dir_path, "advanced*.ipynb"))) +
9191
[os.path.join(Dir_path, "example_preprocessing.ipynb"),
9292
os.path.join(Dir_path, "example_1stlevel.ipynb"),
9393
os.path.join(Dir_path, "example_normalize.ipynb"),

0 commit comments

Comments
 (0)