Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add install_dir option #268

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@
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 @@
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 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
Loading