Skip to content
Snippets Groups Projects

Toolchain becomes package set part2

Merged Hans Fangohr requested to merge toolchain_becomes_package_set_part2 into main
2 files
+ 53
53
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 34
34
@@ -865,83 +865,83 @@ def get_native_microarchitecture():
def install_environment(
mpsd_release: str,
toolchains: List[str],
package_sets: List[str],
root_dir: Path,
enable_build_cache: bool = False,
) -> None:
"""
Install the specified MPSD release and toolchains.
Install the specified MPSD release and package_sets.
The function installs the toolchain to the specified directory, using Spack.
The function installs the package_set to the specified directory, using Spack.
Parameters
----------
mpsd_release : str
A string representing the MPSD release version.
toolchains : list of str
A list of strings representing the toolchains to install
package_sets : list of str
A list of strings representing the package_sets to install
(e.g., "foss2021a-mpi", "global_generic", "ALL").
root_dir : pathlib.Path
A Path object representing the path to the directory where
the release and toolchains will be installed.
the release and package_sets will be installed.
enable_build_cache : bool, optional
A boolean indicating whether to build the build cache
when installing toolchains. Defaults to False.
when installing package_sets. Defaults to False.
Raises
------
ValueError
If a requested toolchain is not available in the specified release.
If a requested package_set is not available in the specified release.
Returns
-------
None
"""
logging.info(
f"Installing release {mpsd_release} with toolchains {toolchains} "
f"Installing release {mpsd_release} with package_sets {package_sets} "
f"to {root_dir}"
)
# Set required variables
release_base_dir = root_dir / mpsd_release
microarch = get_native_microarchitecture()
toolchain_dir = release_base_dir / microarch
toolchain_dir.mkdir(parents=True, exist_ok=True)
package_set_dir = release_base_dir / microarch
package_set_dir.mkdir(parents=True, exist_ok=True)
spack_setup_script = release_base_dir / "spack-environments" / "spack_setup.sh"
install_flags = []
if not enable_build_cache:
install_flags.append("-b")
# run the prepare_environment function
available_toolchains = prepare_environment(mpsd_release, root_dir)
# Ensure that the requested toolchains are available in the release
if toolchains == "ALL":
toolchains = available_toolchains
elif toolchains == "NONE":
# No toolchains requested, so we only create the env and print the
# list of available toolchains
available_package_sets = prepare_environment(mpsd_release, root_dir)
# Ensure that the requested package_sets are available in the release
if package_sets == "ALL":
package_sets = available_package_sets
elif package_sets == "NONE":
# No package_sets requested, so we only create the env and print the
# list of available package_sets
logging.warning(
"No toolchains requested. Available toolchains for release "
f"{mpsd_release} are: \n {available_toolchains}"
"No package_sets requested. Available package_sets for release "
f"{mpsd_release} are: \n {available_package_sets}"
)
print_log = logging.getLogger("print")
print_log.info(f"{available_toolchains=}")
print_log.info(f"{available_package_sets=}")
return
for toolchain in toolchains:
if toolchain not in available_toolchains:
msg = f"Toolchain '{toolchain}' is not available in release {mpsd_release}."
msg += "Use 'available' command to see list of available toolchains."
for package_set in package_sets:
if package_set not in available_package_sets:
msg = f"Package_Set '{package_set}' is not available in release {mpsd_release}."
msg += "Use 'available' command to see list of available package_sets."
logging.error(msg)
sys.exit(1)
# Install the toolchains
with os_chdir(toolchain_dir):
# run spack_setup_script with the toolchains as arguments
for toolchain in toolchains:
# Install the package_sets
with os_chdir(package_set_dir):
# run spack_setup_script with the package_sets as arguments
for package_set in package_sets:
# Set the install log file name from create_log_file_names
build_log_file_name = create_log_file_names(
mpsd_release, microarch, "install", package_set=toolchain
mpsd_release, microarch, "install", package_set=package_set
)
build_log_folder = release_base_dir / "logs"
build_log_path = build_log_folder / build_log_file_name
@@ -949,24 +949,24 @@ def install_environment(
if not os.path.exists(build_log_folder):
os.makedirs(build_log_folder)
logging.info(f"Installing toolchain {toolchain} to {toolchain_dir}")
logging.info(f"Installing package_set {package_set} to {package_set_dir}")
# log the command
record_script_execution_summary(
mpsd_release,
root_dir,
msg=f"installing {toolchain} and logging at {build_log_path}",
msg=f"installing {package_set} and logging at {build_log_path}",
)
record_script_execution_summary(
mpsd_release,
root_dir,
msg=(
f"CMD: bash {spack_setup_script} {' '.join(install_flags)} "
f"{toolchain}"
f"{package_set}"
),
)
run(
f"bash {spack_setup_script} {' '.join(install_flags)} {toolchain} 2>&1 "
f"bash {spack_setup_script} {' '.join(install_flags)} {package_set} 2>&1 "
f"| tee -a {build_log_path} ",
shell=True,
check=True,
Loading