Skip to content

Commit

Permalink
fix: report report generation report in the cli rather than in genera…
Browse files Browse the repository at this point in the history
…te_reports
  • Loading branch information
celprov committed Jan 18, 2024
1 parent 8692b13 commit b33c91e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
5 changes: 3 additions & 2 deletions fmriprep/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,11 @@ def main():

if sentry_sdk is not None and failed_reports:
sentry_sdk.capture_message(
"Report generation failed for %d subjects" % failed_reports,
"Report generation was not successful for the following participants : %s.",
", ".join(failed_reports),
level="error",
)
sys.exit(int((errno + failed_reports) > 0))
sys.exit(int((errno + len(failed_reports)) > 0))


if __name__ == "__main__":
Expand Down
9 changes: 8 additions & 1 deletion fmriprep/cli/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,19 @@ def build_workflow(config_file, retval):
# Called with reports only
if config.execution.reports_only:
build_log.log(25, "Running --reports-only on participants %s", ", ".join(subject_list))
retval["return_code"] = generate_reports(
failed_reports = generate_reports(
config.execution.participant_label,
config.execution.fmriprep_dir,
config.execution.run_uuid,
config=data.load("reports-spec.yml"),
)
if failed_reports:
config.loggers.cli.error(
"Report generation was not successful for the following participants : %s.",
", ".join(failed_reports),
)

retval["return_code"] = len(failed_reports)
return retval

# Build main workflow
Expand Down
9 changes: 1 addition & 8 deletions fmriprep/reports/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

from nireports.assembler.report import Report

from .. import config


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

if errors:
logger.debug(
"Report generation was not successful for the following participants : %s.",
", ".join(errors),
)
return len(errors)
return errors

0 comments on commit b33c91e

Please sign in to comment.