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

rename mpsd_microarch to sys_microarch

parent 0d1cbdf1
No related branches found
No related tags found
1 merge request!40Rename a few variables and function names for clarity
Pipeline #370323 passed
......@@ -46,7 +46,7 @@ config_vars = {
def create_log_file_names(
mpsd_release: str,
mpsd_microarch: str,
sys_microarch: str,
action: str,
date: str = call_date_iso,
toolchain: str = None,
......@@ -66,7 +66,7 @@ def create_log_file_names(
----------
mpsd_release : str
MPSD software stack version
mpsd_microarch : str
sys_microarch : str
system architecture
date : str
date of the call ins iso format
......@@ -89,13 +89,13 @@ def create_log_file_names(
# if toolchain is given, then we build the build_log_file_name
if action in ["install", "remove"]:
log_file_name = (
f"{mpsd_release}_{mpsd_microarch}_{date}_BUILD_{toolchain}_{action}.log"
f"{mpsd_release}_{sys_microarch}_{date}_BUILD_{toolchain}_{action}.log"
)
else:
return None
else:
# if toolchain is not given, then we build the installer_log_file_name
log_file_name = f"{mpsd_release}_{mpsd_microarch}_{date}_APEX_{action}.log"
log_file_name = f"{mpsd_release}_{sys_microarch}_{date}_APEX_{action}.log"
return log_file_name
......@@ -151,11 +151,11 @@ def get_installer_log_file_path(mpsd_release: str, cmd: str, root_dir: str) -> s
"""Get installer log file path."""
# Get machine configs
os.environ.get("MPSD_OS", "UNKNOWN_OS")
mpsd_microarch = get_native_microarchitecture()
sys_microarch = get_native_microarchitecture()
# parse logging first
# decide the log_file_name
installer_log_name = create_log_file_names(
mpsd_release=mpsd_release, mpsd_microarch=mpsd_microarch, action=cmd
mpsd_release=mpsd_release, sys_microarch=sys_microarch, action=cmd
)
log_folder = root_dir / mpsd_release / "logs"
# if the log_folder dosent exist, dont log this message if
......@@ -644,13 +644,13 @@ def prepare_environment(mpsd_release: str, root_dir: Path) -> List[str]:
def get_native_microarchitecture():
"""Return native microarchitecture.
On MPSD machines, there should be an environment variable "MPSD_MICROARCH".
On MPSD machines, there should be an environment variable "sys_microarch".
We try to read that. If it fails, we use the 'archspec cpu' command.
If that fails, we ask the user to install it.
Returns
-------
MPSD_MICROARCH : str
sys_microarch : str
Example
-------
......@@ -660,13 +660,13 @@ def get_native_microarchitecture():
# attempt to get MICRO_ARCH from environment variable (should work on
# MPSD_HPC and MPSD linux laptops). If not defined, return
# "UNKNOWN_MICROARCH"
microarch = os.environ.get("MPSD_MICROARCH", "UNKNOWN_MICROARCH")
microarch = os.environ.get("sys_microarch", "UNKNOWN_MICROARCH")
# if we have not found the microarchitecture environment variable,
# try calling archspec
if microarch == "UNKNOWN_MICROARCH":
logging.debug(
"Couldn't find MPSD_MICROARCH environment variable. Will try archspec."
"Couldn't find sys_microarch environment variable. Will try archspec."
)
try:
process = run(["archspec", "cpu"], stdout=subprocess.PIPE, text=True)
......@@ -741,8 +741,8 @@ def install_environment(
# Set required variables
release_base_dir = root_dir / mpsd_release
mpsd_microarch = get_native_microarchitecture()
toolchain_dir = release_base_dir / mpsd_microarch
sys_microarch = get_native_microarchitecture()
toolchain_dir = release_base_dir / sys_microarch
toolchain_dir.mkdir(parents=True, exist_ok=True)
spack_setup_script = release_base_dir / "spack-environments" / "spack_setup.sh"
install_flags = []
......@@ -781,7 +781,7 @@ def install_environment(
for toolchain in toolchains:
# Set the install log file name from create_log_file_names
build_log_file_name = create_log_file_names(
mpsd_release, mpsd_microarch, "install", toolchain=toolchain
mpsd_release, sys_microarch, "install", toolchain=toolchain
)
build_log_folder = release_base_dir / "logs"
build_log_path = build_log_folder / build_log_file_name
......
......@@ -228,7 +228,7 @@ def test_install_environment_zlib():
mpsd_release_to_test = "dev-23a"
toolchain_to_test = "global_generic"
cmd_log_file = mod.config_vars["cmd_log_file"]
mpsd_microarch = mod.get_native_microarchitecture()
sys_microarch = mod.get_native_microarchitecture()
release_base_dir = root_dir / mpsd_release_to_test
create_mock_git_repository(target_directory=root_dir, create_directory=False)
mod.prepare_environment(mpsd_release=mpsd_release_to_test, root_dir=(root_dir))
......@@ -283,13 +283,13 @@ def test_install_environment_zlib():
)
# 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
# release_base_dir/sys_microarch
# print("Debug here ")
# time.sleep(10)
build_log = list(
(release_base_dir / "logs").glob(
f"{mpsd_release_to_test}_{mpsd_microarch}_*_install.log"
f"{mpsd_release_to_test}_{sys_microarch}_*_install.log"
)
)
assert len(build_log) == 2
......@@ -312,11 +312,11 @@ def test_install_environment_zlib():
f"installing {toolchain_to_test} and logging at {str(build_log)}" in lines
)
# 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 os.path.exists(release_base_dir / sys_microarch)
assert os.path.exists(release_base_dir / sys_microarch / "lmod")
# assert that lmod/module-index.yaml contains zlib
with open(
release_base_dir / mpsd_microarch / "lmod" / "module-index.yaml", "r"
release_base_dir / sys_microarch / "lmod" / "module-index.yaml", "r"
) as f:
lines = f.read()
assert "zlib" in lines
......@@ -338,7 +338,7 @@ def test_install_environment_zlib():
)
build_log = list(
(release_base_dir / "logs").glob(
f"{mpsd_release_to_test}_{mpsd_microarch}_*_install.log"
f"{mpsd_release_to_test}_{sys_microarch}_*_install.log"
)
)
assert len(build_log) == 4
......@@ -387,13 +387,13 @@ def test_create_log_file_names():
"""Test that the log file names are created correctly."""
create_log_file_names = mod.create_log_file_names
mpsd_release = "dev-23a"
mpsd_microarch = "sandybridge"
sys_microarch = "sandybridge"
date = datetime.datetime.now().replace(microsecond=0).isoformat()
action = "install"
toolchain = "foss2021a"
# test build_log_file_name generation
build_log_file_name = create_log_file_names(
mpsd_microarch=mpsd_microarch,
sys_microarch=sys_microarch,
mpsd_release=mpsd_release,
date=date,
action=action,
......@@ -401,21 +401,21 @@ def test_create_log_file_names():
)
assert (
build_log_file_name
== f"{mpsd_release}_{mpsd_microarch}_{date}_BUILD_{toolchain}_{action}.log"
== f"{mpsd_release}_{sys_microarch}_{date}_BUILD_{toolchain}_{action}.log"
)
installer_log_file_name = create_log_file_names(
mpsd_microarch=mpsd_microarch,
sys_microarch=sys_microarch,
mpsd_release=mpsd_release,
date=date,
action=action,
)
assert (
installer_log_file_name
== f"{mpsd_release}_{mpsd_microarch}_{date}_APEX_{action}.log"
== f"{mpsd_release}_{sys_microarch}_{date}_APEX_{action}.log"
)
# test no build log file for incorrect action
build_log_file_name = create_log_file_names(
mpsd_microarch=mpsd_microarch,
sys_microarch=sys_microarch,
mpsd_release=mpsd_release,
date=date,
action="status",
......
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