Skip to content

Commit 3e7a5f4

Browse files
author
Caspar van Leeuwen
committed
Initial version of reproduction script for EESSI
1 parent 26babc0 commit 3e7a5f4

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

eessi_software_reproduce_stack.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import os
2+
import re
3+
from datetime import datetime
4+
5+
# Define the directory to crawl
6+
root_dir = "/cvmfs/software.eessi.io/versions/2025.06/software/linux/x86_64/amd/zen2/reprod"
7+
8+
# Define the maximum build time per easystack file
9+
max_build_time = 1000
10+
11+
# Initialize the list to store software information
12+
software_info = {}
13+
14+
# Crawl the directory
15+
for software_name in os.listdir(root_dir):
16+
software_dir = os.path.join(root_dir, software_name)
17+
if os.path.isdir(software_dir):
18+
for software_version in os.listdir(software_dir):
19+
software_version_dir = os.path.join(software_dir, software_version)
20+
if os.path.isdir(software_version_dir):
21+
# Extract the date/time of the initial software build
22+
datestamp_dir_first_build = os.path.join(software_version_dir, os.listdir(software_version_dir)[0])
23+
datestamp = os.path.basename(datestamp_dir_first_build)
24+
initial_build_time = datetime.strptime(datestamp, "%Y%m%d_%H%M%SUTC")
25+
26+
# Extract the total build time from the build log of the first build
27+
build_log_path = os.path.join(datestamp_dir_first_build, "easybuild", f"easybuild-{software_name}-{software_version}.txt")
28+
with open(build_log_path, "r") as build_log_file:
29+
build_log_content = build_log_file.read()
30+
total_build_time = re.search(r"Total build time: (\d+) seconds", build_log_content).group(1)
31+
32+
# Extract the EasyBuild version from the build log of the last build
33+
datestamp_dir_last_build = os.path.join(software_version_dir, os.listdir(software_version_dir)[-1])
34+
last_build_log_path = os.path.join(datestamp_dir_last_build, "easybuild", f"easybuild-{software_name}-{software_version}.txt")
35+
with open(last_build_log_path, "r") as last_build_log_file:
36+
last_build_log_content = last_build_log_file.read()
37+
easybuild_version = re.search(r"This is EasyBuild ([0-9]+\.[0-9]+\.[0-9]+)", last_build_log_content).group(1)
38+
39+
# Extract the paths to the easyblock and easyconfig files used for the last installation
40+
easyblock_path = os.path.join(software_version_dir, "easybuild", "reprod", "easyblocks", "*.py")
41+
easyconfig_path = os.path.join(software_version_dir, "easybuild", "*.eb")
42+
43+
# Store the software information
44+
software_info[software_name + "-" + software_version] = {
45+
"initial_build_time": initial_build_time,
46+
"total_build_time": total_build_time,
47+
"easybuild_version": easybuild_version,
48+
"toolchain": toolchain,
49+
"toolchain_version": toolchain_version,
50+
"easyblock_path": easyblock_path,
51+
"easyconfig_path": easyconfig_path
52+
}
53+
54+
# Order the list of software chronologically
55+
software_info = dict(sorted(software_info.items(), key=lambda item: item[1]["initial_build_time"]))
56+
57+
# Write the list to an easystack file
58+
easystack_file = "easystack-eb-{}.yml"
59+
sequence_number = 1
60+
for software_name, info in software_info.items():
61+
if info["toolchain"] != software_info[list(software_info.keys())[0]]["toolchain"] or info["total_build_time"] > max_build_time:
62+
sequence_number += 1
63+
with open(easystack_file.format(sequence_number), "a") as easystack_file_handle:
64+
easystack_file_handle.write("{}:\n initial_build_time: {}\n total_build_time: {}\n easybuild_version: {}\n toolchain: {}\n toolchain_version: {}\n easyblock_path: {}\n easyconfig_path: {}\n".format(software_name, info["initial_build_time"], info["total_build_time"], info["easybuild_version"], info["toolchain"], info["toolchain_version"], info["easyblock_path"], info["easyconfig_path"]))

0 commit comments

Comments
 (0)