Skip to content

Commit 79e458a

Browse files
authored
Merge pull request #4861 from smoors/summary
print summary after the build in trace output
2 parents 354d0b6 + 0dac7fa commit 79e458a

File tree

1 file changed

+32
-8
lines changed

1 file changed

+32
-8
lines changed

easybuild/main.py

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,26 @@ def find_easyconfigs_by_specs(build_specs, robot_path, try_to_generate, testing=
111111
return [(ec_file, generated)]
112112

113113

114-
def build_and_install_software(ecs, init_session_state, exit_on_failure=True):
114+
def summary(ecs_with_res):
115+
"""
116+
Compose summary of the build:
117+
* [S] for a successful build
118+
* [F] for a failed build
119+
* [-] for a build that didn’t run
120+
121+
:param ecs_with_res: list of tuples (ec, ec_res), ec is an EasyConfig object, and ec_res is a dict of the result
122+
"""
123+
summary_fmt = " * [{}] {}"
124+
success_map = {True: 'S', False: 'F', None: '-'}
125+
lines = ["Summary:"]
126+
lines.extend([
127+
summary_fmt.format(success_map[ec_res.get('success', False)], ec['full_mod_name'])
128+
for ec, ec_res in ecs_with_res
129+
])
130+
return '\n'.join(lines)
131+
132+
133+
def build_and_install_software(ecs, init_session_state, exit_on_failure=True, testing=False):
115134
"""
116135
Build and install software for all provided parsed easyconfig files.
117136
@@ -126,7 +145,7 @@ def build_and_install_software(ecs, init_session_state, exit_on_failure=True):
126145

127146
start_progress_bar(STATUS_BAR, size=len(ecs))
128147

129-
res = []
148+
ecs_with_res = []
130149
ec_results = []
131150
failed_cnt = 0
132151

@@ -171,14 +190,17 @@ def build_and_install_software(ecs, init_session_state, exit_on_failure=True):
171190
write_file(test_report_fp, test_report_txt['full'])
172191
adjust_permissions(parent_dir, stat.S_IWUSR, add=False, recursive=False)
173192

193+
ecs_with_res.append((ec, ec_res))
194+
174195
if not ec_res['success'] and exit_on_failure:
196+
ecs_in_res = [res[0] for res in ecs_with_res]
197+
ecs_without_res = [(ec, {'success': None}) for ec in ecs if ec not in ecs_in_res]
198+
print_msg(summary(ecs_with_res + ecs_without_res), log=_log, silent=testing)
175199
error = ec_res['err']
176200
if isinstance(error, EasyBuildError):
177201
error = EasyBuildError(test_msg, exit_code=error.exit_code)
178202
raise error
179203

180-
res.append((ec, ec_res))
181-
182204
if failed_cnt:
183205
# if installations failed: indicate th
184206
status_label = ' (%s): ' % colorize('%s failed!' % failed_cnt, COLOR_RED)
@@ -192,7 +214,7 @@ def build_and_install_software(ecs, init_session_state, exit_on_failure=True):
192214

193215
stop_progress_bar(STATUS_BAR)
194216

195-
return res
217+
return ecs_with_res
196218

197219

198220
def run_contrib_style_checks(ecs, check_contrib, check_style):
@@ -563,11 +585,11 @@ def process_eb_args(eb_args, eb_go, cfg_settings, modtool, testing, init_session
563585

564586
with rich_live_cm():
565587
run_hook(PRE_PREF + BUILD_AND_INSTALL_LOOP, hooks, args=[ordered_ecs])
566-
ecs_with_res = build_and_install_software(ordered_ecs, init_session_state,
567-
exit_on_failure=exit_on_failure)
588+
ecs_with_res = build_and_install_software(
589+
ordered_ecs, init_session_state, exit_on_failure=exit_on_failure, testing=testing)
568590
run_hook(POST_PREF + BUILD_AND_INSTALL_LOOP, hooks, args=[ecs_with_res])
569591
else:
570-
ecs_with_res = [(ec, {}) for ec in ordered_ecs]
592+
ecs_with_res = [(ec, {'success': None}) for ec in ordered_ecs]
571593

572594
correct_builds_cnt = len([ec_res for (_, ec_res) in ecs_with_res if ec_res.get('success', False)])
573595
overall_success = correct_builds_cnt == len(ordered_ecs)
@@ -585,6 +607,8 @@ def process_eb_args(eb_args, eb_go, cfg_settings, modtool, testing, init_session
585607
print_msg(test_report_msg)
586608

587609
print_msg(success_msg, log=_log, silent=testing)
610+
if ecs_with_res:
611+
print_msg(summary(ecs_with_res), log=_log, silent=testing)
588612

589613
# cleanup and spec files
590614
for ec in easyconfigs:

0 commit comments

Comments
 (0)