Skip to content
Snippets Groups Projects
Commit 6320c385 authored by Ashwin Kumar Karnad's avatar Ashwin Kumar Karnad
Browse files

change the logging file format

parent 8532623a
No related branches found
No related tags found
2 merge requests!19Move linux-debian11 into main,!1Resolve "First draft for user interface for top level install command"
......@@ -7,7 +7,7 @@ import argparse
import sys
from pathlib import Path
from typing import List, Tuple
import datetime
about_tool = """
Build toolchains using Spack.\n
......@@ -18,7 +18,7 @@ The toolchains are built using the bash script spack_setup.sh, and the results a
"""
config_vars = {
"cmd_log_file": "install.log",
"build_log_file": f"build_toolchains_mpsd_spack_ver_{time.strftime('%Y%m%d-%H%M%S')}.log", # TODO: modify toolchains,mpsd_spack_ver when the variable is available
"build_log_file": f"logs/mpsd_spack_ver_toolchains_{datetime.datetime.now().replace(microsecond=0).isoformat()}.log", # TODO: modify toolchains,mpsd_spack_ver when the variable is available
"spack_environments_repo": "https://gitlab.gwdg.de/mpsd-cs/spack-environments.git",
}
......@@ -243,14 +243,18 @@ def install_environment(
# Install the toolchains
with os_chdir(toolchain_dir):
# run spack_setup_script with the toolchains as arguments
# if the log folder doesn't exist, create it
if not os.path.exists("logs"):
os.mkdir("logs")
for toolchain in toolchains:
# Set the install log file name to config_vars["install_log_file"]
# and replace _toolchains_ with the toolchain name and _mpsd_spack_ver_ with mpsd_release
print(f"Installing toolchain {toolchain} to {toolchain_dir}")
install_log_file = (
config_vars["build_log_file"]
.replace("mpsd_spack_ver_", f"{mpsd_release}_")
.replace("_toolchains_", f"_{toolchain}_")
.replace("_mpsd_spack_ver_", f"_{mpsd_release}_")
)
subprocess.run(
f"bash {spack_setup_script} {' '.join(install_flags)} {toolchain} 2>&1 | tee -a {install_log_file} ",
......@@ -332,5 +336,6 @@ def main():
prepare_environment(args.release, script_dir)
if __name__ == "__main__":
main()
......@@ -118,7 +118,9 @@ def test_install_environment(tmp_path):
# prepare dev-23a release
# script_dir = tmp_path / "test_global_generic"
# for actaual installation avoid tmp_path as the lenght of the path is too long and spack complains
script_dir = Path('/tmp/test_global_generic')
script_dir = Path('/tmp/test_global_generic')
if script_dir.exists():
shutil.rmtree(script_dir)
script_dir.mkdir(exist_ok=True, parents=True)
spack_environments = "spack-environments"
mpsd_release_to_test = "dev-23a"
......@@ -162,8 +164,9 @@ def test_install_environment(tmp_path):
script_dir=script_dir,
enable_build_cache=False
)
# assert that log files exists
# assert that install log files exists
assert os.path.exists(release_base_dir/'install.log')
# assert that the module files are created correctly
assert os.path.exists(release_base_dir/mpsd_microarch)
assert os.path.exists(release_base_dir/mpsd_microarch/'lmod')
# assert that lmod/module-index.yaml contains zlib
......@@ -173,7 +176,9 @@ def test_install_environment(tmp_path):
# test that the build log is created correctly
# check that a file with glob build_globale_generic_dev-23a*.log exists at release_base_dir/mpsd_microarch
build_log = list((release_base_dir/mpsd_microarch).glob(f'build_{toolchain_to_test}_{mpsd_release_to_test}*.log'))
# print("Debug here ")
# time.sleep(10)
build_log = list((release_base_dir/mpsd_microarch/"logs").glob(f'{mpsd_release_to_test}_{toolchain_to_test}_*.log'))
assert len(build_log) > 0
# take the most recent build log
build_log = sorted(build_log)[0]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment