Skip to content

Commit

Permalink
Add install_dir option
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanBryan51 committed Mar 19, 2024
1 parent 8a1e1a8 commit dc5c0a7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
3 changes: 3 additions & 0 deletions benchcab/data/config-schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ realisations:
build_script:
type: "string"
required: false
install_dir:
type: "string"
required: false
patch:
type: "dict"
required: false
Expand Down
16 changes: 9 additions & 7 deletions benchcab/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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()
Expand All @@ -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

Check warning on line 89 in benchcab/model.py

View check run for this annotation

Codecov / codecov/patch

benchcab/model.py#L89

Added line #L89 was not covered by tests
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."""
Expand Down
12 changes: 12 additions & 0 deletions docs/user_guide/config_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down

0 comments on commit dc5c0a7

Please sign in to comment.