Skip to content

Commit 2b8fb25

Browse files
committed
fix: propagate exit code if running workflow fails
1 parent 6ba9851 commit 2b8fb25

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

nibabies/cli/run.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def main():
104104
nibabies_wf.run(**_plugin)
105105
except Exception as e:
106106
config.loggers.workflow.critical('nibabies failed: %s', e)
107+
exitcode = 1
107108
raise
108109
else:
109110
config.loggers.workflow.log(25, 'nibabies finished successfully!')
@@ -147,7 +148,7 @@ def main():
147148
add_hash = config.execution.output_layout == 'multiverse'
148149

149150
# Generate reports phase
150-
generate_reports(
151+
failed_reports = generate_reports(
151152
config.execution.unique_labels,
152153
config.execution.nibabies_dir,
153154
config.execution.run_uuid,
@@ -161,6 +162,16 @@ def main():
161162
)
162163
write_bidsignore(config.execution.nibabies_dir)
163164

165+
if failed_reports:
166+
msg = (
167+
'Report generation was not successful for the following participants '
168+
f': {", ".join(failed_reports)}.'
169+
)
170+
config.loggers.cli.error(msg)
171+
172+
if int(exitcode) or failed_reports:
173+
sys.exit(1)
174+
164175

165176
if __name__ == '__main__':
166177
raise RuntimeError(

0 commit comments

Comments
 (0)