Skip to content

Commit 067b1f4

Browse files
authored
Merge pull request #205 from CABLE-LSM/204-rename-CableRepository-to-Model
Rename `CableRepository` to `Model`
2 parents adea352 + bb7ab15 commit 067b1f4

File tree

5 files changed

+34
-34
lines changed

5 files changed

+34
-34
lines changed

benchcab/benchcab.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
run_tasks_in_parallel,
2020
)
2121
from benchcab.internal import get_met_forcing_file_names
22-
from benchcab.repository import CableRepository
22+
from benchcab.model import Model
2323
from benchcab.utils.fs import mkdir, next_path
2424
from benchcab.utils.pbs import render_job_script
2525
from benchcab.utils.subprocess import SubprocessWrapper, SubprocessWrapperInterface
@@ -42,7 +42,7 @@ def __init__(
4242
self.validate_env = validate_env
4343

4444
self._config: Optional[dict] = None
45-
self._repos: list[CableRepository] = []
45+
self._repos: list[Model] = []
4646
self.tasks: list[Task] = [] # initialise fluxsite tasks lazily
4747

4848
def _validate_environment(self, project: str, modules: list):
@@ -99,10 +99,10 @@ def _get_config(self, config_path: str) -> dict:
9999
self._config = read_config(config_path)
100100
return self._config
101101

102-
def _get_repos(self, config: dict) -> list[CableRepository]:
102+
def _get_repos(self, config: dict) -> list[Model]:
103103
if not self._repos:
104104
self._repos = [
105-
CableRepository(**repo_config, repo_id=id)
105+
Model(**repo_config, repo_id=id)
106106
for id, repo_config in enumerate(config["realisations"])
107107
]
108108
return self._repos
@@ -189,7 +189,7 @@ def checkout(self, config_path: str, verbose: bool):
189189
)
190190

191191
# TODO(Sean) we should archive revision numbers for CABLE-AUX
192-
cable_aux_repo = CableRepository(path=internal.CABLE_AUX_RELATIVE_SVN_PATH)
192+
cable_aux_repo = Model(path=internal.CABLE_AUX_RELATIVE_SVN_PATH)
193193
cable_aux_repo.checkout(verbose=verbose)
194194

195195
rev_number_log_path = self.root_dir / next_path(

benchcab/fluxsite.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
from benchcab import __version__, internal
1616
from benchcab.comparison import ComparisonTask
17-
from benchcab.repository import CableRepository
17+
from benchcab.model import Model
1818
from benchcab.utils.fs import chdir, mkdir
1919
from benchcab.utils.subprocess import SubprocessWrapper, SubprocessWrapperInterface
2020

@@ -95,7 +95,7 @@ class Task:
9595

9696
def __init__(
9797
self,
98-
repo: CableRepository,
98+
repo: Model,
9999
met_forcing_file: str,
100100
sci_conf_id: int,
101101
sci_config: dict,
@@ -358,7 +358,7 @@ def add_provenance_info(self, verbose=False):
358358

359359

360360
def get_fluxsite_tasks(
361-
repos: list[CableRepository],
361+
repos: list[Model],
362362
science_configurations: list[dict],
363363
fluxsite_forcing_file_names: list[str],
364364
) -> list[Task]:
@@ -431,8 +431,8 @@ def get_fluxsite_comparisons(
431431

432432

433433
def get_comparison_name(
434-
repo_a: CableRepository,
435-
repo_b: CableRepository,
434+
repo_a: Model,
435+
repo_b: Model,
436436
met_forcing_file: str,
437437
sci_conf_id: int,
438438
) -> str:

benchcab/repository.py renamed to benchcab/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from benchcab.utils.subprocess import SubprocessWrapper, SubprocessWrapperInterface
1414

1515

16-
class CableRepository:
16+
class Model:
1717
"""A class used to represent a CABLE repository."""
1818

1919
root_dir: Path = internal.CWD

tests/test_fluxsite.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
patch_namelist,
2525
patch_remove_namelist,
2626
)
27-
from benchcab.repository import CableRepository
27+
from benchcab.model import Model
2828

2929

3030
@pytest.fixture()
3131
def repo(mock_cwd, mock_subprocess_handler):
32-
"""Returns a `CableRepository` instance."""
33-
_repo = CableRepository(
32+
"""Returns a `Model` instance."""
33+
_repo = Model(
3434
repo_id=1,
3535
path="path/to/test-branch",
3636
patch={"cable": {"some_branch_specific_setting": True}},
@@ -419,9 +419,9 @@ class TestGetFluxsiteTasks:
419419

420420
@pytest.fixture()
421421
def repos(self, config):
422-
"""Return a list of `CableRepository` instances used for testing."""
422+
"""Return a list of `Model` instances used for testing."""
423423
return [
424-
CableRepository(**branch_config, repo_id=id)
424+
Model(**branch_config, repo_id=id)
425425
for id, branch_config in enumerate(config["realisations"])
426426
]
427427

@@ -465,7 +465,7 @@ def test_comparisons_for_two_branches_with_two_tasks(self, mock_cwd):
465465
"""Success case: comparisons for two branches with two tasks."""
466466
tasks = [
467467
Task(
468-
repo=CableRepository("path/to/repo", repo_id=repo_id),
468+
repo=Model("path/to/repo", repo_id=repo_id),
469469
met_forcing_file="foo.nc",
470470
sci_config={"foo": "bar"},
471471
sci_conf_id=0,
@@ -492,7 +492,7 @@ def test_comparisons_for_three_branches_with_three_tasks(self, mock_cwd):
492492
"""Success case: comparisons for three branches with three tasks."""
493493
tasks = [
494494
Task(
495-
repo=CableRepository("path/to/repo", repo_id=repo_id),
495+
repo=Model("path/to/repo", repo_id=repo_id),
496496
met_forcing_file="foo.nc",
497497
sci_config={"foo": "bar"},
498498
sci_conf_id=0,
@@ -541,8 +541,8 @@ def test_comparison_name_convention(self):
541541
"""Success case: check comparison name convention."""
542542
assert (
543543
get_comparison_name(
544-
CableRepository("path/to/repo", repo_id=0),
545-
CableRepository("path/to/repo", repo_id=1),
544+
Model("path/to/repo", repo_id=0),
545+
Model("path/to/repo", repo_id=1),
546546
met_forcing_file="foo.nc",
547547
sci_conf_id=0,
548548
)

tests/test_repository.py renamed to tests/test_model.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""`pytest` tests for `repository.py`.
1+
"""`pytest` tests for `model.py`.
22
33
Note: explicit teardown for generated files and directories are not required as
44
the working directory used for testing is cleaned up in the `_run_around_tests`
@@ -13,23 +13,23 @@
1313
import pytest
1414

1515
from benchcab import internal
16-
from benchcab.repository import CableRepository, remove_module_lines
16+
from benchcab.model import Model, remove_module_lines
1717

1818
from .conftest import DEFAULT_STDOUT
1919

2020

2121
@pytest.fixture()
2222
def repo(mock_cwd, mock_subprocess_handler, mock_environment_modules_handler):
23-
"""Return a mock `CableRepository` instance for testing against."""
24-
_repo = CableRepository(path="trunk")
23+
"""Return a mock `Model` instance for testing against."""
24+
_repo = Model(path="trunk")
2525
_repo.root_dir = mock_cwd
2626
_repo.subprocess_handler = mock_subprocess_handler
2727
_repo.modules_handler = mock_environment_modules_handler
2828
return _repo
2929

3030

3131
class TestRepoID:
32-
"""Tests for `CableRepository.repo_id`."""
32+
"""Tests for `Model.repo_id`."""
3333

3434
def test_set_and_get_repo_id(self, repo):
3535
"""Success case: set and get repository ID."""
@@ -47,7 +47,7 @@ def test_undefined_repo_id(self, repo):
4747

4848

4949
class TestCheckout:
50-
"""Tests for `CableRepository.checkout()`."""
50+
"""Tests for `Model.checkout()`."""
5151

5252
def test_checkout_command_execution(self, repo, mock_cwd, mock_subprocess_handler):
5353
"""Success case: `svn checkout` command is executed."""
@@ -83,7 +83,7 @@ def test_standard_output(self, repo, verbosity, expected):
8383

8484

8585
class TestSVNInfoShowItem:
86-
"""Tests for `CableRepository.svn_info_show_item()`."""
86+
"""Tests for `Model.svn_info_show_item()`."""
8787

8888
def test_svn_info_command_execution(self, repo, mock_subprocess_handler, mock_cwd):
8989
"""Success case: call svn info command and get result."""
@@ -107,11 +107,11 @@ def test_white_space_removed_from_standard_output(
107107

108108

109109
class TestPreBuild:
110-
"""Tests for `CableRepository.pre_build()`."""
110+
"""Tests for `Model.pre_build()`."""
111111

112112
@pytest.fixture(autouse=True)
113113
def _setup(self, repo):
114-
"""Setup precondition for `CableRepository.pre_build()`."""
114+
"""Setup precondition for `Model.pre_build()`."""
115115
(internal.SRC_DIR / repo.name / "offline").mkdir(parents=True)
116116
(internal.SRC_DIR / repo.name / "offline" / "Makefile").touch()
117117
(internal.SRC_DIR / repo.name / "offline" / "parallel_cable").touch()
@@ -152,7 +152,7 @@ def test_standard_output(self, repo, verbosity, expected):
152152

153153

154154
class TestRunBuild:
155-
"""Tests for `CableRepository.run_build()`."""
155+
"""Tests for `Model.run_build()`."""
156156

157157
@pytest.fixture()
158158
def netcdf_root(self):
@@ -178,7 +178,7 @@ def env(self, netcdf_root):
178178

179179
@pytest.fixture(autouse=True)
180180
def _setup(self, repo, netcdf_root):
181-
"""Setup precondition for `CableRepository.run_build()`."""
181+
"""Setup precondition for `Model.run_build()`."""
182182
(internal.SRC_DIR / repo.name / "offline" / ".tmp").mkdir(parents=True)
183183

184184
# This is required so that we can use the NETCDF_ROOT environment variable
@@ -232,11 +232,11 @@ def test_standard_output(self, repo, modules, verbosity, expected):
232232

233233

234234
class TestPostBuild:
235-
"""Tests for `CableRepository.post_build()`."""
235+
"""Tests for `Model.post_build()`."""
236236

237237
@pytest.fixture(autouse=True)
238238
def _setup(self, repo):
239-
"""Setup precondition for `CableRepository.post_build()`."""
239+
"""Setup precondition for `Model.post_build()`."""
240240
(internal.SRC_DIR / repo.name / "offline" / ".tmp").mkdir(parents=True)
241241
(internal.SRC_DIR / repo.name / "offline" / ".tmp" / internal.CABLE_EXE).touch()
242242

@@ -263,7 +263,7 @@ def test_standard_output(self, repo, verbosity, expected):
263263

264264

265265
class TestCustomBuild:
266-
"""Tests for `CableRepository.custom_build()`."""
266+
"""Tests for `Model.custom_build()`."""
267267

268268
@pytest.fixture()
269269
def build_script(self, repo):

0 commit comments

Comments
 (0)