Skip to content

Commit b33c91e

Browse files
committed
fix: report report generation report in the cli rather than in generate_reports
1 parent 8692b13 commit b33c91e

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

fmriprep/cli/run.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,11 @@ def main():
225225

226226
if sentry_sdk is not None and failed_reports:
227227
sentry_sdk.capture_message(
228-
"Report generation failed for %d subjects" % failed_reports,
228+
"Report generation was not successful for the following participants : %s.",
229+
", ".join(failed_reports),
229230
level="error",
230231
)
231-
sys.exit(int((errno + failed_reports) > 0))
232+
sys.exit(int((errno + len(failed_reports)) > 0))
232233

233234

234235
if __name__ == "__main__":

fmriprep/cli/workflow.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,19 @@ def build_workflow(config_file, retval):
8686
# Called with reports only
8787
if config.execution.reports_only:
8888
build_log.log(25, "Running --reports-only on participants %s", ", ".join(subject_list))
89-
retval["return_code"] = generate_reports(
89+
failed_reports = generate_reports(
9090
config.execution.participant_label,
9191
config.execution.fmriprep_dir,
9292
config.execution.run_uuid,
9393
config=data.load("reports-spec.yml"),
9494
)
95+
if failed_reports:
96+
config.loggers.cli.error(
97+
"Report generation was not successful for the following participants : %s.",
98+
", ".join(failed_reports),
99+
)
100+
101+
retval["return_code"] = len(failed_reports)
95102
return retval
96103

97104
# Build main workflow

fmriprep/reports/core.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424

2525
from nireports.assembler.report import Report
2626

27-
from .. import config
28-
2927

3028
def generate_reports(subject_list, output_dir, run_uuid, config=None, work_dir=None):
3129
"""Generate reports for a list of subjects."""
@@ -62,9 +60,4 @@ def generate_reports(subject_list, output_dir, run_uuid, config=None, work_dir=N
6260
file=str(Path(output_dir) / "logs" / f"report-{run_uuid}-{subject_label}.err"),
6361
)
6462

65-
if errors:
66-
logger.debug(
67-
"Report generation was not successful for the following participants : %s.",
68-
", ".join(errors),
69-
)
70-
return len(errors)
63+
return errors

0 commit comments

Comments
 (0)