Skip to content

Commit 7a85933

Browse files
author
Caspar van Leeuwen
committed
Make sure we get leading zeroes, so that the alphabetical order of easystacks produced matches the original build order
1 parent e720934 commit 7a85933

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

eessi_software_reproduce_stack.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
description = """
1111
This script creates a sequence of easystack files that may be used to replicate the software installed
1212
in a reference software subdirectory.
13-
14-
The script
13+
14+
The script
1515
- Determines all software that was installed in the reference prefix
1616
- Sorts it in order of installation. For software that was later rebuild, the original installation time is used.
1717
- In the installation order, easyconfig names are added to easystack files
@@ -89,7 +89,7 @@ def get_build_duration(file: pathlib.Path, encoding: str = "utf-8") -> float:
8989

9090
return duration.total_seconds()/60
9191

92-
92+
9393
def get_easybuild_version(file: pathlib.Path, encoding: str = "utf-8") -> str:
9494
"""
9595
Returns the EasyBuild version that was used to build this software, obtained from the first line of the
@@ -126,7 +126,7 @@ def inner_loop(software_name):
126126
for software_version in os.listdir(software_dir):
127127
software_version_dir = os.path.join(software_dir, software_version)
128128
if os.path.isdir(software_version_dir):
129-
# Determine if this is about EasyBuild itself, and if it should
129+
# Determine if this is about EasyBuild itself, and if it should
130130
override_easybuild_version = False
131131
if software_name == "EasyBuild" and eb_override_version:
132132
override_easybuild_version = True
@@ -160,11 +160,11 @@ def inner_loop(software_name):
160160
if len(matching_files) != 1:
161161
raise ValueError(f"Expected only one file to match {build_log_path_glob}. Instead got: {matching_files}")
162162
easybuild_version = get_easybuild_version(matching_files[0])
163-
163+
164164
# Extract the paths to the easyblock and easyconfig files used for the last installation
165165
easyblock_path = os.path.join(datestamp_dir_last_build, "easybuild", "reprod", "easyblocks", "*.py")
166166
easyconfig_path = os.path.join(datestamp_dir_last_build, "easybuild", f"{software_name}-{software_version}.eb")
167-
167+
168168
# Store the software information
169169
software_info[software_name + "-" + software_version] = {
170170
"initial_build_time": initial_build_time,
@@ -173,9 +173,9 @@ def inner_loop(software_name):
173173
"easyblock_path": easyblock_path,
174174
"easyconfig_path": easyconfig_path
175175
}
176-
176+
177177
return software_info
178-
178+
179179
# Use as many workers as we have cores in our cgroup
180180
n_workers = len(os.sched_getaffinity(0))
181181

@@ -221,20 +221,20 @@ def inner_loop(software_name):
221221
(build_duration_current_easystack + info["build_duration"]) > max_build_time
222222
)
223223
):
224-
easystack_file = f'easystack-{sequence_number}-eb-{previous_eb_ver}.yml'
224+
easystack_file = f'easystack-{sequence_number:03d}-eb-{previous_eb_ver}.yml'
225225
write_software_info(local_software_info, easystack_file, build_duration_current_easystack)
226226
build_duration_current_easystack = 0
227227
local_software_info = {}
228228
sequence_number += 1
229-
229+
230230
# Add the current software to the local_software_info
231231
local_software_info[software_name] = info
232232
build_duration_current_easystack = build_duration_current_easystack + info["build_duration"]
233233
total_build_duration = total_build_duration + info["build_duration"]
234234
previous_eb_ver = info["easybuild_version"]
235235

236236
# Flush the local_software_info to disk on last time
237-
easystack_file = f'easystack-{sequence_number}-eb-{previous_eb_ver}.yml'
237+
easystack_file = f'easystack-{sequence_number:03d}-eb-{previous_eb_ver}.yml'
238238
write_software_info(local_software_info, easystack_file, build_duration_current_easystack)
239239

240240
print(f"Total of {sequence_number} easystacks with a total build time of {total_build_duration:.0f} minutes")

0 commit comments

Comments
 (0)