Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Markiewicz <[email protected]>
Co-authored-by: Oscar Esteban <[email protected]>
  • Loading branch information
3 people authored Jan 18, 2024
1 parent e66fd05 commit 8692b13
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions fmriprep/reports/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@

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."""
reportlets_dir = None
if work_dir is not None:
reportlets_dir = Path(work_dir) / "reportlets"

error_list = ""
errors = []
for subject_label in subject_list:
entities = {}
entities["subject"] = subject_label
Expand All @@ -48,19 +50,21 @@ def generate_reports(subject_list, output_dir, run_uuid, config=None, work_dir=N
)

# Count nbr of subject for which report generation failed
errno = 0
try:
robj.generate_report()
except:
errno += 1
error_list = error_list + f"{subject_label}, "
import sys
import traceback

if errno:
import logging
errors.append(subject_label)
traceback.print_exception(
*sys.exc_info(),
file=str(Path(output_dir) / "logs" / f"report-{run_uuid}-{subject_label}.err"),
)

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

0 comments on commit 8692b13

Please sign in to comment.