|
5 | 5 | import sys |
6 | 6 | import yaml |
7 | 7 | import json |
| 8 | +import subprocess |
8 | 9 |
|
9 | 10 | ARCHITECTURES = [ |
10 | 11 | "aarch64/generic", |
@@ -63,17 +64,18 @@ def get_software_information_by_filename(file_metadata, original_path=None, tool |
63 | 64 |
|
64 | 65 | # 2) Construct the modulefile path |
65 | 66 | 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" |
67 | 69 |
|
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 |
70 | 71 | for arch in ARCHITECTURES: |
71 | 72 | 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: |
77 | 79 | print(f"No module {substituted_modulefile}...not adding software for archtecture {arch}") |
78 | 80 | continue |
79 | 81 |
|
|
0 commit comments