Skip to content

Commit

Permalink
Rename CableRepository to Model
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanBryan51 committed Nov 17, 2023
1 parent a6784de commit bb7ab15
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 34 deletions.
10 changes: 5 additions & 5 deletions benchcab/benchcab.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
run_tasks_in_parallel,
)
from benchcab.internal import get_met_forcing_file_names
from benchcab.repository import CableRepository
from benchcab.model import Model
from benchcab.utils.fs import mkdir, next_path
from benchcab.utils.pbs import render_job_script
from benchcab.utils.subprocess import SubprocessWrapper, SubprocessWrapperInterface
Expand All @@ -42,7 +42,7 @@ def __init__(
self.validate_env = validate_env

self._config: Optional[dict] = None
self._repos: list[CableRepository] = []
self._repos: list[Model] = []
self.tasks: list[Task] = [] # initialise fluxsite tasks lazily

def _validate_environment(self, project: str, modules: list):
Expand Down Expand Up @@ -99,10 +99,10 @@ def _get_config(self, config_path: str) -> dict:
self._config = read_config(config_path)
return self._config

def _get_repos(self, config: dict) -> list[CableRepository]:
def _get_repos(self, config: dict) -> list[Model]:
if not self._repos:
self._repos = [
CableRepository(**repo_config, repo_id=id)
Model(**repo_config, repo_id=id)
for id, repo_config in enumerate(config["realisations"])
]
return self._repos
Expand Down Expand Up @@ -189,7 +189,7 @@ def checkout(self, config_path: str, verbose: bool):
)

# TODO(Sean) we should archive revision numbers for CABLE-AUX
cable_aux_repo = CableRepository(path=internal.CABLE_AUX_RELATIVE_SVN_PATH)
cable_aux_repo = Model(path=internal.CABLE_AUX_RELATIVE_SVN_PATH)

Check warning on line 192 in benchcab/benchcab.py

View check run for this annotation

Codecov / codecov/patch

benchcab/benchcab.py#L192

Added line #L192 was not covered by tests
cable_aux_repo.checkout(verbose=verbose)

rev_number_log_path = self.root_dir / next_path(
Expand Down
10 changes: 5 additions & 5 deletions benchcab/fluxsite.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from benchcab import __version__, internal
from benchcab.comparison import ComparisonTask
from benchcab.repository import CableRepository
from benchcab.model import Model
from benchcab.utils.fs import chdir, mkdir
from benchcab.utils.subprocess import SubprocessWrapper, SubprocessWrapperInterface

Expand Down Expand Up @@ -95,7 +95,7 @@ class Task:

def __init__(
self,
repo: CableRepository,
repo: Model,
met_forcing_file: str,
sci_conf_id: int,
sci_config: dict,
Expand Down Expand Up @@ -358,7 +358,7 @@ def add_provenance_info(self, verbose=False):


def get_fluxsite_tasks(
repos: list[CableRepository],
repos: list[Model],
science_configurations: list[dict],
fluxsite_forcing_file_names: list[str],
) -> list[Task]:
Expand Down Expand Up @@ -431,8 +431,8 @@ def get_fluxsite_comparisons(


def get_comparison_name(
repo_a: CableRepository,
repo_b: CableRepository,
repo_a: Model,
repo_b: Model,
met_forcing_file: str,
sci_conf_id: int,
) -> str:
Expand Down
2 changes: 1 addition & 1 deletion benchcab/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from benchcab.utils.subprocess import SubprocessWrapper, SubprocessWrapperInterface


class CableRepository:
class Model:
"""A class used to represent a CABLE repository."""

root_dir: Path = internal.CWD
Expand Down
18 changes: 9 additions & 9 deletions tests/test_fluxsite.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
patch_namelist,
patch_remove_namelist,
)
from benchcab.repository import CableRepository
from benchcab.model import Model


@pytest.fixture()
def repo(mock_cwd, mock_subprocess_handler):
"""Returns a `CableRepository` instance."""
_repo = CableRepository(
"""Returns a `Model` instance."""
_repo = Model(
repo_id=1,
path="path/to/test-branch",
patch={"cable": {"some_branch_specific_setting": True}},
Expand Down Expand Up @@ -419,9 +419,9 @@ class TestGetFluxsiteTasks:

@pytest.fixture()
def repos(self, config):
"""Return a list of `CableRepository` instances used for testing."""
"""Return a list of `Model` instances used for testing."""
return [
CableRepository(**branch_config, repo_id=id)
Model(**branch_config, repo_id=id)
for id, branch_config in enumerate(config["realisations"])
]

Expand Down Expand Up @@ -465,7 +465,7 @@ def test_comparisons_for_two_branches_with_two_tasks(self, mock_cwd):
"""Success case: comparisons for two branches with two tasks."""
tasks = [
Task(
repo=CableRepository("path/to/repo", repo_id=repo_id),
repo=Model("path/to/repo", repo_id=repo_id),
met_forcing_file="foo.nc",
sci_config={"foo": "bar"},
sci_conf_id=0,
Expand All @@ -492,7 +492,7 @@ def test_comparisons_for_three_branches_with_three_tasks(self, mock_cwd):
"""Success case: comparisons for three branches with three tasks."""
tasks = [
Task(
repo=CableRepository("path/to/repo", repo_id=repo_id),
repo=Model("path/to/repo", repo_id=repo_id),
met_forcing_file="foo.nc",
sci_config={"foo": "bar"},
sci_conf_id=0,
Expand Down Expand Up @@ -541,8 +541,8 @@ def test_comparison_name_convention(self):
"""Success case: check comparison name convention."""
assert (
get_comparison_name(
CableRepository("path/to/repo", repo_id=0),
CableRepository("path/to/repo", repo_id=1),
Model("path/to/repo", repo_id=0),
Model("path/to/repo", repo_id=1),
met_forcing_file="foo.nc",
sci_conf_id=0,
)
Expand Down
28 changes: 14 additions & 14 deletions tests/test_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""`pytest` tests for `repository.py`.
"""`pytest` tests for `model.py`.
Note: explicit teardown for generated files and directories are not required as
the working directory used for testing is cleaned up in the `_run_around_tests`
Expand All @@ -13,23 +13,23 @@
import pytest

from benchcab import internal
from benchcab.repository import CableRepository, remove_module_lines
from benchcab.model import Model, remove_module_lines

from .conftest import DEFAULT_STDOUT


@pytest.fixture()
def repo(mock_cwd, mock_subprocess_handler, mock_environment_modules_handler):
"""Return a mock `CableRepository` instance for testing against."""
_repo = CableRepository(path="trunk")
"""Return a mock `Model` instance for testing against."""
_repo = Model(path="trunk")
_repo.root_dir = mock_cwd
_repo.subprocess_handler = mock_subprocess_handler
_repo.modules_handler = mock_environment_modules_handler
return _repo


class TestRepoID:
"""Tests for `CableRepository.repo_id`."""
"""Tests for `Model.repo_id`."""

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


class TestCheckout:
"""Tests for `CableRepository.checkout()`."""
"""Tests for `Model.checkout()`."""

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


class TestSVNInfoShowItem:
"""Tests for `CableRepository.svn_info_show_item()`."""
"""Tests for `Model.svn_info_show_item()`."""

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


class TestPreBuild:
"""Tests for `CableRepository.pre_build()`."""
"""Tests for `Model.pre_build()`."""

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


class TestRunBuild:
"""Tests for `CableRepository.run_build()`."""
"""Tests for `Model.run_build()`."""

@pytest.fixture()
def netcdf_root(self):
Expand All @@ -178,7 +178,7 @@ def env(self, netcdf_root):

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

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


class TestPostBuild:
"""Tests for `CableRepository.post_build()`."""
"""Tests for `Model.post_build()`."""

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

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


class TestCustomBuild:
"""Tests for `CableRepository.custom_build()`."""
"""Tests for `Model.custom_build()`."""

@pytest.fixture()
def build_script(self, repo):
Expand Down

0 comments on commit bb7ab15

Please sign in to comment.