Skip to content

Commit

Permalink
Merge pull request #35 from CMIP-REF/add-version
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisjared authored Dec 9, 2024
2 parents 16db7fb + b0f439c commit f65b0de
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 22 deletions.
1 change: 1 addition & 0 deletions changelog/35.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Adds `version` field to the `instance_id` field for CMIP6 datasets
4 changes: 2 additions & 2 deletions packages/ref-core/tests/unit/test_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_hash(self, metric_dataset, cmip6_data_catalog):
)

def test_slug(self, metric_dataset):
assert metric_dataset.hash == "69165f25de10cc0b682e6d1acd1026c0ad27448c"
assert metric_dataset.hash == "33cf5324201ff57067b548077f3bb26d9a7d9def"


class TestDatasetCollection:
Expand All @@ -57,7 +57,7 @@ def test_get_attr(self, dataset_collection):
def test_hash(self, dataset_collection, cmip6_data_catalog):
dataset_hash = hash(dataset_collection)
assert isinstance(dataset_hash, int)
assert dataset_hash == 162057064475757030
assert dataset_hash == 1411607912180158146

assert dataset_hash == hash(DatasetCollection(cmip6_data_catalog, "instance_id"))
assert dataset_hash != hash(
Expand Down
1 change: 1 addition & 0 deletions packages/ref/src/ref/datasets/cmip6.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ def find_local_datasets(self, file_or_directory: Path) -> pd.DataFrame:
"table_id",
"variable_id",
"grid_label",
"version",
]
datasets["instance_id"] = datasets.apply(
lambda row: "CMIP6." + ".".join([row[item] for item in drs_items]), axis=1
Expand Down
18 changes: 9 additions & 9 deletions packages/ref/tests/unit/datasets/test_cmip6/cmip6_catalog_db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
grid: native atmosphere N96 grid (145x192 latxlon)
grid_label: gn
init_year: null
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.rlut.gn
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.rlut.gn.v20210318
institution_id: CSIRO
long_name: TOA Outgoing Longwave Radiation
member_id: r1i1p1f1
Expand Down Expand Up @@ -45,7 +45,7 @@
grid: native atmosphere N96 grid (145x192 latxlon)
grid_label: gn
init_year: null
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.rlut.gn
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.rlut.gn.v20210318
institution_id: CSIRO
long_name: TOA Outgoing Longwave Radiation
member_id: r1i1p1f1
Expand Down Expand Up @@ -81,7 +81,7 @@
grid: native atmosphere N96 grid (145x192 latxlon)
grid_label: gn
init_year: null
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.rsdt.gn
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.rsdt.gn.v20210318
institution_id: CSIRO
long_name: TOA Incident Shortwave Radiation
member_id: r1i1p1f1
Expand Down Expand Up @@ -117,7 +117,7 @@
grid: native atmosphere N96 grid (145x192 latxlon)
grid_label: gn
init_year: null
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.rsdt.gn
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.rsdt.gn.v20210318
institution_id: CSIRO
long_name: TOA Incident Shortwave Radiation
member_id: r1i1p1f1
Expand Down Expand Up @@ -153,7 +153,7 @@
grid: native atmosphere N96 grid (145x192 latxlon)
grid_label: gn
init_year: null
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.rsut.gn
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.rsut.gn.v20210318
institution_id: CSIRO
long_name: TOA Outgoing Shortwave Radiation
member_id: r1i1p1f1
Expand Down Expand Up @@ -189,7 +189,7 @@
grid: native atmosphere N96 grid (145x192 latxlon)
grid_label: gn
init_year: null
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.rsut.gn
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.rsut.gn.v20210318
institution_id: CSIRO
long_name: TOA Outgoing Shortwave Radiation
member_id: r1i1p1f1
Expand Down Expand Up @@ -225,7 +225,7 @@
grid: native atmosphere N96 grid (145x192 latxlon)
grid_label: gn
init_year: null
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.tas.gn
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.tas.gn.v20210318
institution_id: CSIRO
long_name: Near-Surface Air Temperature
member_id: r1i1p1f1
Expand Down Expand Up @@ -261,7 +261,7 @@
grid: native atmosphere N96 grid (145x192 latxlon)
grid_label: gn
init_year: null
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.tas.gn
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.tas.gn.v20210318
institution_id: CSIRO
long_name: Near-Surface Air Temperature
member_id: r1i1p1f1
Expand Down Expand Up @@ -297,7 +297,7 @@
grid: native atmosphere N96 grid (145x192 latxlon)
grid_label: gn
init_year: null
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.fx.areacella.gn
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.fx.areacella.gn.v20210318
institution_id: CSIRO
long_name: Grid-Cell Area for Atmospheric Grid Variables
member_id: r1i1p1f1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
grid: native atmosphere N96 grid (145x192 latxlon)
grid_label: gn
init_year: null
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.rlut.gn
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.rlut.gn.v20210318
institution_id: CSIRO
long_name: TOA Outgoing Longwave Radiation
member_id: r1i1p1f1
Expand Down Expand Up @@ -46,7 +46,7 @@
grid: native atmosphere N96 grid (145x192 latxlon)
grid_label: gn
init_year: null
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.rlut.gn
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.rlut.gn.v20210318
institution_id: CSIRO
long_name: TOA Outgoing Longwave Radiation
member_id: r1i1p1f1
Expand Down Expand Up @@ -83,7 +83,7 @@
grid: native atmosphere N96 grid (145x192 latxlon)
grid_label: gn
init_year: null
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.rsdt.gn
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.rsdt.gn.v20210318
institution_id: CSIRO
long_name: TOA Incident Shortwave Radiation
member_id: r1i1p1f1
Expand Down Expand Up @@ -120,7 +120,7 @@
grid: native atmosphere N96 grid (145x192 latxlon)
grid_label: gn
init_year: null
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.rsdt.gn
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.rsdt.gn.v20210318
institution_id: CSIRO
long_name: TOA Incident Shortwave Radiation
member_id: r1i1p1f1
Expand Down Expand Up @@ -157,7 +157,7 @@
grid: native atmosphere N96 grid (145x192 latxlon)
grid_label: gn
init_year: null
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.rsut.gn
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.rsut.gn.v20210318
institution_id: CSIRO
long_name: TOA Outgoing Shortwave Radiation
member_id: r1i1p1f1
Expand Down Expand Up @@ -194,7 +194,7 @@
grid: native atmosphere N96 grid (145x192 latxlon)
grid_label: gn
init_year: null
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.rsut.gn
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.rsut.gn.v20210318
institution_id: CSIRO
long_name: TOA Outgoing Shortwave Radiation
member_id: r1i1p1f1
Expand Down Expand Up @@ -231,7 +231,7 @@
grid: native atmosphere N96 grid (145x192 latxlon)
grid_label: gn
init_year: null
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.tas.gn
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.tas.gn.v20210318
institution_id: CSIRO
long_name: Near-Surface Air Temperature
member_id: r1i1p1f1
Expand Down Expand Up @@ -268,7 +268,7 @@
grid: native atmosphere N96 grid (145x192 latxlon)
grid_label: gn
init_year: null
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.tas.gn
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.tas.gn.v20210318
institution_id: CSIRO
long_name: Near-Surface Air Temperature
member_id: r1i1p1f1
Expand Down Expand Up @@ -305,7 +305,7 @@
grid: native atmosphere N96 grid (145x192 latxlon)
grid_label: gn
init_year: null
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.fx.areacella.gn
instance_id: CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.fx.areacella.gn.v20210318
institution_id: CSIRO
long_name: Grid-Cell Area for Atmospheric Grid Variables
member_id: r1i1p1f1
Expand Down
4 changes: 2 additions & 2 deletions packages/ref/tests/unit/test_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ def test_solve_metrics(mock_executor, db_seeded, solver):
definitions = [call.kwargs["definition"] for call in mock_executor.return_value.run_metric.mock_calls]

expected_instance_ids = [
["CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.tas.gn"],
["CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.rsut.gn"],
["CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.tas.gn.v20210318"],
["CMIP6.ScenarioMIP.CSIRO.ACCESS-ESM1-5.ssp126.r1i1p1f1.Amon.rsut.gn.v20210318"],
]
expected_keys = [
"ACCESS-ESM1-5_rsut_ssp126_r1i1p1f1",
Expand Down

0 comments on commit f65b0de

Please sign in to comment.