Skip to content

Commit cbcf373

Browse files
committed
Store modules as a dict rather than a string
1 parent ceb5d0d commit cbcf373

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

scripts/generate_data_files.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ def suppress_stdout():
4646
sys.stdout.close()
4747
sys.stdout = old_stdout
4848

49+
def module_dict_from_module_string(module):
50+
module_name, module_version = module.split("/", 1)
51+
52+
return {"module_name": module_name, "module_version": module_version}
4953

5054
def load_and_list_modules(module_name):
5155
"""
@@ -66,23 +70,27 @@ def load_and_list_modules(module_name):
6670
raise RuntimeError(f"Failed to load module '{module_name}':\n{result.stdout}")
6771

6872
# Parse module list output
69-
modules = [line for line in result.stdout.splitlines() if "/" in line]
73+
modules = [
74+
module_dict_from_module_string(line)
75+
for line in result.stdout.splitlines()
76+
if "/" in line
77+
]
7078

7179
# Filter out the modules we expect to be loaded
72-
eessi_extend_module_stub = "EESSI-extend/"
73-
eb_module_stub = "EasyBuild/"
74-
if module_name.startswith(eessi_extend_module_stub):
80+
eessi_extend_module_name = "EESSI-extend"
81+
eb_module_name = "EasyBuild"
82+
if module_name.startswith(f"{eessi_extend_module_name}/"):
7583
# Don't filter anything
7684
pass
77-
elif module_name.startswith(eb_module_stub):
85+
elif module_name.startswith(f"{eb_module_name}/"):
7886
# Filter EESSI-extend
79-
modules = [module for module in modules if not module.startswith(eessi_extend_module_stub)]
87+
modules = [module for module in modules if module["name"] != eessi_extend_module_name]
8088
else:
8189
# Filter EESSI-extend and EasyBuild
8290
modules = [
8391
module
8492
for module in modules
85-
if not module.startswith(eessi_extend_module_stub) and not module.startswith(eb_module_stub)
93+
if module["name"] != eessi_extend_module_name and module["name"] != eb_module_name
8694
]
8795

8896
return modules
@@ -257,11 +265,9 @@ def collect_eb_files(base_path):
257265

258266
# Store everything we now know about the installation as a dict
259267
# Add important data that is related to the module environment
268+
eessi_software["eessi_version"][eessi_version][file]["module"] = module_dict_from_module_string(parsed_ec["full_mod_name"])
260269
eessi_software["eessi_version"][eessi_version][file]["full_mod_name"] = parsed_ec["full_mod_name"]
261270
eessi_software["eessi_version"][eessi_version][file]["short_mod_name"] = parsed_ec["short_mod_name"]
262-
eessi_software["eessi_version"][eessi_version][file]["required_modules"] = load_and_list_modules(
263-
parsed_ec["full_mod_name"]
264-
)
265271
# Retain the easyblocks used so we can use a heuristic to figure out the type of extensions (R, Python, Perl)
266272
eessi_software["eessi_version"][eessi_version][file]["easyblocks"] = easyblocks_used
267273

0 commit comments

Comments
 (0)