From 25038a0e56787963f5d369af66ce3e22f97654f6 Mon Sep 17 00:00:00 2001 From: Abhaas Goyal Date: Tue, 9 Jul 2024 13:02:15 +1000 Subject: [PATCH] Updatr --- src/benchcab/coverage.py | 1 - src/benchcab/model.py | 17 ++++++++++++----- src/benchcab/utils/pbs.py | 6 +++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/benchcab/coverage.py b/src/benchcab/coverage.py index 6d3ff68..a77bb94 100644 --- a/src/benchcab/coverage.py +++ b/src/benchcab/coverage.py @@ -5,7 +5,6 @@ import multiprocessing import operator -import os from typing import Optional from benchcab import internal diff --git a/src/benchcab/model.py b/src/benchcab/model.py index dd31779..b1530f8 100644 --- a/src/benchcab/model.py +++ b/src/benchcab/model.py @@ -13,7 +13,7 @@ from benchcab import internal from benchcab.environment_modules import EnvironmentModules, EnvironmentModulesInterface from benchcab.utils import get_logger -from benchcab.utils.fs import chdir, prepend_path +from benchcab.utils.fs import chdir, mkdir, prepend_path from benchcab.utils.repo import GitRepo, LocalRepo, Repo from benchcab.utils.subprocess import SubprocessWrapper, SubprocessWrapperInterface @@ -97,14 +97,18 @@ def get_build_flags(self, mpi: bool, build_option: str, compiler_id: str) -> dic build_flags["flags_init"] = "" if "codecov" in build_option: if compiler_id != "ifort": - msg = f"""For code coverage, the only supported compiler is Intel + msg = f"""For code coverage, the only supported compiler is `ifort` User has {compiler_id} in their environment""" raise RuntimeError(msg) codecov_dir = self.get_coverage_dir() self.logger.info("Building with Intel code coverage using PGO") - self.logger.debug(f"Analysis directory self as {codecov_dir}") + + # `ifort` checks for pre-existing profile directories before compilation + mkdir(codecov_dir, parents=True, exist_ok=True) + + self.logger.debug(f"Analysis directory set as {codecov_dir}") build_flags["flags_init"] += f'"-prof-gen=srcpos -prof-dir={codecov_dir}"' return build_flags @@ -153,9 +157,12 @@ def build(self, modules: list[str], mpi: bool, build_option: str): # $FC is loaded after compiler module is loaded, # but we need runs/ dir relative to project rootdir - build_flags = self.get_build_flags( - mpi, build_option, os.environ.get("FC", "") + env_fc = os.environ.get("FC", "") + self.logger.debug( + f"Getting environment variable for compiler $FC = {env_fc}" ) + build_flags = self.get_build_flags(mpi, build_option, env_fc) + env_fc = None with chdir(path_to_repo): env = os.environ.copy() diff --git a/src/benchcab/utils/pbs.py b/src/benchcab/utils/pbs.py index 2ae8a4f..782c02f 100644 --- a/src/benchcab/utils/pbs.py +++ b/src/benchcab/utils/pbs.py @@ -3,7 +3,7 @@ """Contains helper functions for manipulating PBS job scripts.""" -from typing import TypedDict +from typing import Optional, TypedDict from benchcab.utils import interpolate_file_template @@ -23,8 +23,8 @@ def render_job_script( modules: list, benchcab_path: str, pbs_config: PBSConfig, - verbose=False, - skip_bitwise_cmp=False, + verbose: Optional[bool] = False, + skip_bitwise_cmp: Optional[bool] = False, ) -> str: """Returns the text for a PBS job script that executes all computationally expensive commands.