Skip to content

Commit 8692b13

Browse files
celproveffigiesoesteban
authored
Apply suggestions from code review
Co-authored-by: Chris Markiewicz <[email protected]> Co-authored-by: Oscar Esteban <[email protected]>
1 parent e66fd05 commit 8692b13

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

fmriprep/reports/core.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,16 @@
2424

2525
from nireports.assembler.report import Report
2626

27+
from .. import config
28+
2729

2830
def generate_reports(subject_list, output_dir, run_uuid, config=None, work_dir=None):
2931
"""Generate reports for a list of subjects."""
3032
reportlets_dir = None
3133
if work_dir is not None:
3234
reportlets_dir = Path(work_dir) / "reportlets"
3335

34-
error_list = ""
36+
errors = []
3537
for subject_label in subject_list:
3638
entities = {}
3739
entities["subject"] = subject_label
@@ -48,19 +50,21 @@ def generate_reports(subject_list, output_dir, run_uuid, config=None, work_dir=N
4850
)
4951

5052
# Count nbr of subject for which report generation failed
51-
errno = 0
5253
try:
5354
robj.generate_report()
5455
except:
55-
errno += 1
56-
error_list = error_list + f"{subject_label}, "
56+
import sys
57+
import traceback
5758

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

61-
logger = logging.getLogger("cli")
65+
if errors:
6266
logger.debug(
6367
"Report generation was not successful for the following participants : %s.",
64-
error_list,
68+
", ".join(errors),
6569
)
66-
return errno
70+
return len(errors)

0 commit comments

Comments
 (0)