Skip to content

Commit 719566c

Browse files
committed
Specify met_forcings key as a dictionary
Changes requested by @ccarouge: #136 (comment)
1 parent 9d02f99 commit 719566c

5 files changed

Lines changed: 31 additions & 44 deletions

File tree

benchcab/data/config-schema.yml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,13 @@ spatial:
8080
required: false
8181
schema:
8282
met_forcings:
83-
type: "list"
83+
type: "dict"
8484
required: false
85-
schema:
86-
type: "dict"
87-
required: true
88-
schema:
89-
name:
90-
type: "string"
91-
required: true
92-
payu_experiment:
93-
type: "string"
94-
required: true
85+
minlength: 1
86+
keysrules:
87+
type: "string"
88+
valuesrules:
89+
type: "string"
9590
payu:
9691
type: "dict"
9792
required: false

benchcab/internal.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,12 @@
9090
# Path to PLUMBER2 site forcing data directory (doi: 10.25914/5fdb0902607e1):
9191
MET_DIR = Path("/g/data/ks32/CLEX_Data/PLUMBER2/v1-0/Met/")
9292

93-
# List of default met forcings to use in the spatial test suite. Each met
93+
# Default met forcings to use in the spatial test suite. Each met
9494
# forcing has a corresponding payu experiment that is configured to run CABLE
9595
# with that forcing.
96-
SPATIAL_DEFAULT_MET_FORCINGS = [
97-
{
98-
"name": "crujra_access",
99-
"payu_experiment": "https://github.com/CABLE-LSM/cable_example.git",
100-
}
101-
]
96+
SPATIAL_DEFAULT_MET_FORCINGS = {
97+
"crujra_access": "https://github.com/CABLE-LSM/cable_example.git",
98+
}
10299

103100
# CABLE SVN root url:
104101
CABLE_SVN_ROOT = "https://trac.nci.org.au/svn/cable"

benchcab/spatial.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,22 +148,22 @@ def run_tasks(tasks: list[SpatialTask], verbose=False):
148148

149149
def get_spatial_tasks(
150150
repos: list[CableRepository],
151-
met_forcings: list[dict[str, str]],
151+
met_forcings: dict[str, str],
152152
science_configurations: list[dict],
153153
payu_args: Optional[str] = None,
154154
):
155155
"""Returns a list of spatial tasks to run."""
156156
tasks = [
157157
SpatialTask(
158158
repo=repo,
159-
met_forcing_name=met_forcing["name"],
160-
met_forcing_payu_experiment=met_forcing["payu_experiment"],
159+
met_forcing_name=met_forcing_name,
160+
met_forcing_payu_experiment=met_forcing_payu_experiment,
161161
sci_conf_id=sci_conf_id,
162162
sci_config=sci_config,
163163
payu_args=payu_args,
164164
)
165165
for repo in repos
166-
for met_forcing in met_forcings
166+
for met_forcing_name, met_forcing_payu_experiment in met_forcings.items()
167167
for sci_conf_id, sci_config in enumerate(science_configurations)
168168
]
169169
return tasks

tests/conftest.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,10 @@ def config():
9292
"multiprocessing": True,
9393
},
9494
"spatial": {
95-
"met_forcings": [
96-
{
97-
"name": "crujra_access",
98-
"payu_experiment": "https://github.com/CABLE-LSM/cable_example.git",
99-
},
100-
{"name": "gswp", "payu_experiment": "foo"},
101-
],
95+
"met_forcings": {
96+
"crujra_access": "https://github.com/CABLE-LSM/cable_example.git",
97+
"gswp": "foo",
98+
},
10299
"payu": {
103100
"config": {
104101
"ncpus": 16,

tests/test_spatial.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,10 @@ def repos(self, config):
158158
@pytest.fixture()
159159
def met_forcings(self):
160160
"""Return a list of spatial met forcing specifications."""
161-
return [
162-
{
163-
"name": "crujra_access",
164-
"payu_experiment": "https://github.com/CABLE-LSM/cable_example.git",
165-
},
166-
{"name": "gswp", "payu_experiment": "foo"},
167-
]
161+
return {
162+
"crujra_access": "https://github.com/CABLE-LSM/cable_example.git",
163+
"gswp": "foo",
164+
}
168165

169166
@pytest.fixture()
170167
def science_configurations(self, config):
@@ -180,15 +177,16 @@ def test_task_product_across_branches_forcings_and_configurations(
180177
met_forcings=met_forcings,
181178
science_configurations=science_configurations,
182179
)
180+
met_forcing_names = list(met_forcings.keys())
183181
assert [
184182
(task.repo, task.met_forcing_name, task.sci_config) for task in tasks
185183
] == [
186-
(repos[0], met_forcings[0]["name"], science_configurations[0]),
187-
(repos[0], met_forcings[0]["name"], science_configurations[1]),
188-
(repos[0], met_forcings[1]["name"], science_configurations[0]),
189-
(repos[0], met_forcings[1]["name"], science_configurations[1]),
190-
(repos[1], met_forcings[0]["name"], science_configurations[0]),
191-
(repos[1], met_forcings[0]["name"], science_configurations[1]),
192-
(repos[1], met_forcings[1]["name"], science_configurations[0]),
193-
(repos[1], met_forcings[1]["name"], science_configurations[1]),
184+
(repos[0], met_forcing_names[0], science_configurations[0]),
185+
(repos[0], met_forcing_names[0], science_configurations[1]),
186+
(repos[0], met_forcing_names[1], science_configurations[0]),
187+
(repos[0], met_forcing_names[1], science_configurations[1]),
188+
(repos[1], met_forcing_names[0], science_configurations[0]),
189+
(repos[1], met_forcing_names[0], science_configurations[1]),
190+
(repos[1], met_forcing_names[1], science_configurations[0]),
191+
(repos[1], met_forcing_names[1], science_configurations[1]),
194192
]

0 commit comments

Comments
 (0)