Skip to content

Commit ae29588

Browse files
authored
Merge pull request #4519 from Flamefire/refactor-easyblock
Simplify easyblock.py
2 parents e4524c1 + ff82fd6 commit ae29588

File tree

1 file changed

+16
-25
lines changed

1 file changed

+16
-25
lines changed

easybuild/framework/easyblock.py

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,7 @@ def make_module_dep(self, unload_info=None):
13651365
multi_dep_mod_names[dep['name']].append(dep['short_mod_name'])
13661366

13671367
multi_dep_load_defaults = []
1368-
for depname, depmods in sorted(multi_dep_mod_names.items()):
1368+
for _, depmods in sorted(multi_dep_mod_names.items()):
13691369
stmt = self.module_generator.load_module(depmods[0], multi_dep_mods=depmods,
13701370
recursive_unload=recursive_unload,
13711371
depends_on=depends_on)
@@ -1769,10 +1769,7 @@ def make_extension_string(self, name_version_sep='-', ext_sep=', ', sort=True):
17691769
return ext_sep.join(exts_list)
17701770

17711771
def prepare_for_extensions(self):
1772-
"""
1773-
Also do this before (eg to set the template)
1774-
"""
1775-
pass
1772+
"""Ran before installing extensions (eg to set templates)"""
17761773

17771774
def skip_extensions(self):
17781775
"""
@@ -2198,9 +2195,9 @@ def handle_iterate_opts(self):
21982195
self.log.info("Current iteration index: %s", self.iter_idx)
21992196

22002197
# pop first element from all iterative easyconfig parameters as next value to use
2201-
for opt in self.iter_opts:
2202-
if len(self.iter_opts[opt]) > self.iter_idx:
2203-
self.cfg[opt] = self.iter_opts[opt][self.iter_idx]
2198+
for opt, value in self.iter_opts.items():
2199+
if len(value) > self.iter_idx:
2200+
self.cfg[opt] = value[self.iter_idx]
22042201
else:
22052202
self.cfg[opt] = '' # empty list => empty option as next value
22062203
self.log.debug("Next value for %s: %s" % (opt, str(self.cfg[opt])))
@@ -2212,12 +2209,12 @@ def post_iter_step(self):
22122209
"""Restore options that were iterated over"""
22132210
# disable templating, since we're messing about with values in self.cfg
22142211
with self.cfg.disable_templating():
2215-
for opt in self.iter_opts:
2216-
self.cfg[opt] = self.iter_opts[opt]
2212+
for opt, value in self.iter_opts.items():
2213+
self.cfg[opt] = value
22172214

22182215
# also need to take into account extensions, since those were iterated over as well
22192216
for ext in self.ext_instances:
2220-
ext.cfg[opt] = self.iter_opts[opt]
2217+
ext.cfg[opt] = value
22212218

22222219
self.log.debug("Restored value of '%s' that was iterated over: %s", opt, self.cfg[opt])
22232220

@@ -2751,10 +2748,7 @@ def _test_step(self):
27512748
self.report_test_failure(err)
27522749

27532750
def stage_install_step(self):
2754-
"""
2755-
Install in a stage directory before actual installation.
2756-
"""
2757-
pass
2751+
"""Install in a stage directory before actual installation."""
27582752

27592753
def install_step(self):
27602754
"""Install built software (abstract method)."""
@@ -3248,7 +3242,7 @@ def sanity_check_linked_shared_libs(self, subdirs=None):
32483242
required_libs.extend(self.cfg['required_linked_shared_libs'])
32493243

32503244
# early return if there are no banned/required libraries
3251-
if not (banned_libs + required_libs):
3245+
if not banned_libs + required_libs:
32523246
self.log.info("No banned/required libraries specified")
32533247
return []
32543248
else:
@@ -4463,7 +4457,7 @@ def copy_easyblocks_for_reprod(easyblock_instances, reprod_dir):
44634457
else:
44644458
easyblock_paths.add(easyblock_path)
44654459
for easyblock_path in easyblock_paths:
4466-
easyblock_basedir, easyblock_filename = os.path.split(easyblock_path)
4460+
easyblock_filename = os.path.basename(easyblock_path)
44674461
copy_file(easyblock_path, os.path.join(reprod_easyblock_dir, easyblock_filename))
44684462
_log.info("Dumped easyblock %s required for reproduction to %s", easyblock_filename, reprod_easyblock_dir)
44694463

@@ -4594,10 +4588,7 @@ def build_easyconfigs(easyconfigs, output_dir, test_results):
45944588

45954589

45964590
class StopException(Exception):
4597-
"""
4598-
StopException class definition.
4599-
"""
4600-
pass
4591+
"""Exception thrown to stop running steps"""
46014592

46024593

46034594
def inject_checksums_to_json(ecs, checksum_type):
@@ -4645,14 +4636,14 @@ def inject_checksums_to_json(ecs, checksum_type):
46454636

46464637
# actually inject new checksums or overwrite existing ones (if --force)
46474638
existing_checksums = app.get_checksums_from_json(always_read=True)
4648-
for filename in checksums:
4639+
for filename, checksum in checksums.items():
46494640
if filename not in existing_checksums:
4650-
existing_checksums[filename] = checksums[filename]
4641+
existing_checksums[filename] = checksum
46514642
# don't do anything if the checksum already exist and is the same
4652-
elif checksums[filename] != existing_checksums[filename]:
4643+
elif checksum != existing_checksums[filename]:
46534644
if build_option('force'):
46544645
print_warning("Found existing checksums for %s, overwriting them (due to --force)..." % ec_fn)
4655-
existing_checksums[filename] = checksums[filename]
4646+
existing_checksums[filename] = checksum
46564647
else:
46574648
raise EasyBuildError("Found existing checksum for %s, use --force to overwrite them" % filename)
46584649

0 commit comments

Comments
 (0)