From 0afa73f4d6c9968a97894442ae114ce266ddba87 Mon Sep 17 00:00:00 2001 From: Sean Bryan Date: Mon, 18 Mar 2024 16:18:35 +1100 Subject: [PATCH] Add install_dir option --- benchcab/data/config-schema.yml | 3 +++ benchcab/model.py | 16 +++++++++------- docs/user_guide/config_options.md | 12 ++++++++++++ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/benchcab/data/config-schema.yml b/benchcab/data/config-schema.yml index 5546306..b28bfeb 100644 --- a/benchcab/data/config-schema.yml +++ b/benchcab/data/config-schema.yml @@ -58,6 +58,9 @@ realisations: build_script: type: "string" required: false + install_dir: + type: "string" + required: false patch: type: "dict" required: false diff --git a/benchcab/model.py b/benchcab/model.py index 4e8d221..0e6705b 100644 --- a/benchcab/model.py +++ b/benchcab/model.py @@ -31,6 +31,7 @@ def __init__( patch: Optional[dict] = None, patch_remove: Optional[dict] = None, build_script: Optional[str] = None, + install_dir: Optional[str] = None, model_id: Optional[int] = None, ) -> None: """Constructor. @@ -47,6 +48,9 @@ def __init__( Patch remove, by default None build_script : Optional[str], optional Build script, by default None + install_dir : Optional[str], optional + Path to installed executables relative to the project root directory + of the CABLE repository, by default None. model_id : Optional[int], optional Model ID, by default None @@ -56,6 +60,7 @@ def __init__( self.patch = patch self.patch_remove = patch_remove self.build_script = build_script + self.install_dir = install_dir self._model_id = model_id self.src_dir = Path() self.logger = get_logger() @@ -79,13 +84,10 @@ def model_id(self, value: int): def get_exe_path(self, mpi=False) -> Path: """Return the path to the built executable.""" - return ( - internal.SRC_DIR - / self.name - / self.src_dir - / "offline" - / (internal.CABLE_MPI_EXE if mpi else internal.CABLE_EXE) - ) + exe = internal.CABLE_MPI_EXE if mpi else internal.CABLE_EXE + if self.install_dir: + return internal.SRC_DIR / self.name / self.install_dir / exe + return internal.SRC_DIR / self.name / self.src_dir / "offline" / exe def custom_build(self, modules: list[str]): """Build CABLE using a custom build script.""" diff --git a/docs/user_guide/config_options.md b/docs/user_guide/config_options.md index 5dc5880..fce5b29 100644 --- a/docs/user_guide/config_options.md +++ b/docs/user_guide/config_options.md @@ -399,6 +399,18 @@ realisations: build_script: offline/build.sh ``` +### [install_dir](#install-dir) + +: **Default:** unset, _optional key_. :octicons-dash-24: The path to the directory containing the installed executables relative to the project root directory of the CABLE repository. If specified, `benchcab` will look for executables in this directory when building up the run directories. + +```yaml +realisations: + - repo: + git: + branch: my_branch + install_dir: path/to/bin/directory +``` + ### [patch](#patch) : **Default:** unset, _optional key_. :octicons-dash-24: Branch-specific namelist settings for `cable.nml`. Settings specified in `patch` get "patched" to the base namelist settings used for both branches. Any namelist settings specified here will overwrite settings defined in the default namelist file and in the science configurations. This means these settings will be set as stipulated in the `patch` for this branch for all science configurations run by `benchcab`.