Skip to content

Commit 2c57a0f

Browse files
committed
Switch to just looking in the spider cache for module files
1 parent 6cdfb25 commit 2c57a0f

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

scripts/process_eessi_software_metadata.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import sys
66
import yaml
77
import json
8+
import subprocess
89

910
ARCHITECTURES = [
1011
"aarch64/generic",
@@ -63,17 +64,18 @@ def get_software_information_by_filename(file_metadata, original_path=None, tool
6364

6465
# 2) Construct the modulefile path
6566
before_arch, _, _ = original_path.partition(detected_arch)
66-
modulefile = before_arch + detected_arch + "/modules/all/" + file_metadata["short_mod_name"]
67+
modulefile = before_arch + detected_arch + "/modules/all/" + file_metadata["short_mod_name"] + '.lua'
68+
spider_cache = before_arch + detected_arch + "/.lmod/cache/spiderT.lua"
6769

68-
# 3) Substitute each architecture and test module file existence
69-
modulefile = original_path.replace(detected_arch, arch)
70+
# 3) Substitute each architecture and test module file existence in spider cache
7071
for arch in ARCHITECTURES:
7172
substituted_modulefile = modulefile.replace(detected_arch, arch)
72-
# os.path.exists is very expensive for CVMFS
73-
try:
74-
if os.path.basename(substituted_modulefile) in os.listdir(os.path.dirname(substituted_modulefile)):
75-
base_version_dict["cpu_arch"].append(arch)
76-
except FileNotFoundError as e:
73+
substituted_spider_cache = spider_cache.replace(detected_arch, arch)
74+
# os.path.exists is very expensive for CVMFS so we just look for the file in the spider cache
75+
found = subprocess.run(["grep", "-q", substituted_modulefile, substituted_spider_cache]).returncode == 0
76+
if found:
77+
base_version_dict["cpu_arch"].append(arch)
78+
else:
7779
print(f"No module {substituted_modulefile}...not adding software for archtecture {arch}")
7880
continue
7981

0 commit comments

Comments
 (0)