From e5482edd21caa991d22a01e8ddd491bdf832ba84 Mon Sep 17 00:00:00 2001 From: Deepak Chandan Date: Wed, 8 Nov 2023 23:57:00 -0500 Subject: [PATCH 1/3] fix exception handling --- STACpopulator/implementations/CMIP6_UofT/add_CMIP6.py | 2 +- STACpopulator/populator_base.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/STACpopulator/implementations/CMIP6_UofT/add_CMIP6.py b/STACpopulator/implementations/CMIP6_UofT/add_CMIP6.py index 6d6fedb..6a45118 100644 --- a/STACpopulator/implementations/CMIP6_UofT/add_CMIP6.py +++ b/STACpopulator/implementations/CMIP6_UofT/add_CMIP6.py @@ -162,7 +162,7 @@ def create_stac_item(self, item_name: str, item_data: MutableMapping[str, Any]) dchelper = DataCubeHelper(item_data) dc_ext = DatacubeExtension.ext(item, add_if_missing=True) dc_ext.apply(dimensions=dchelper.dimensions, variables=dchelper.variables) - except: + except Exception: LOGGER.warning(f"Failed to add Datacube extension to item {item_name}") # print(json.dumps(item.to_dict())) diff --git a/STACpopulator/populator_base.py b/STACpopulator/populator_base.py index f8ccb1c..a13abb9 100644 --- a/STACpopulator/populator_base.py +++ b/STACpopulator/populator_base.py @@ -120,4 +120,5 @@ def ingest(self) -> None: for item_name, item_data in self._ingest_pipeline: LOGGER.info(f"Creating STAC representation for {item_name}") stac_item = self.create_stac_item(item_name, item_data) - post_stac_item(self.stac_host, self.collection_id, item_name, stac_item, self.update) + if stac_item != -1: + post_stac_item(self.stac_host, self.collection_id, item_name, stac_item, self.update) From 4f3156b193a4ee746679d30155b11e6a061debde Mon Sep 17 00:00:00 2001 From: Deepak Chandan Date: Wed, 8 Nov 2023 23:58:03 -0500 Subject: [PATCH 2/3] fixing CV generation for source_id --- STACpopulator/implementations/CMIP6_UofT/add_CMIP6.py | 2 +- STACpopulator/stac_utils.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/STACpopulator/implementations/CMIP6_UofT/add_CMIP6.py b/STACpopulator/implementations/CMIP6_UofT/add_CMIP6.py index 6a45118..cbdbd56 100644 --- a/STACpopulator/implementations/CMIP6_UofT/add_CMIP6.py +++ b/STACpopulator/implementations/CMIP6_UofT/add_CMIP6.py @@ -36,7 +36,7 @@ InstitutionID = collection2literal(CV.institution_id) NominalResolution = collection2literal(CV.nominal_resolution) Realm = collection2literal(CV.realm) -SourceID = collection2literal(CV.source_id) +SourceID = collection2literal(CV.source_id, "source_id") SourceType = collection2literal(CV.source_type) SubExperimentID = collection2literal(CV.sub_experiment_id) TableID = collection2literal(CV.table_id) diff --git a/STACpopulator/stac_utils.py b/STACpopulator/stac_utils.py index c245ed1..c8c8aaa 100644 --- a/STACpopulator/stac_utils.py +++ b/STACpopulator/stac_utils.py @@ -74,8 +74,8 @@ def load_collection_configuration() -> MutableMapping[str, Any]: return collection_info -def collection2literal(collection): - terms = tuple(term.label for term in collection) +def collection2literal(collection, property="label"): + terms = tuple(getattr(term, property) for term in collection) return Literal[terms] From d9f40b214cf881c829bf0060a1db5f55427b1914 Mon Sep 17 00:00:00 2001 From: Deepak Chandan Date: Thu, 9 Nov 2023 15:12:32 -0500 Subject: [PATCH 3/3] makefile --- Makefile | 6 +++++- STACpopulator/implementations/CMIP6_UofT/add_CMIP6.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 439f93e..d4b42f3 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,12 @@ IMP_DIR = STACpopulator/implementations STAC_HOST = http://localhost:8880/stac +# CATALOG = https://pavics.ouranos.ca/twitcher/ows/proxy/thredds/catalog/birdhouse/testdata/xclim/cmip6/catalog.html +CATALOG = https://daccs.cs.toronto.edu/twitcher/ows/proxy/thredds/catalog/datasets/CMIP6/catalog.html +# CATALOG = https://daccs.cs.toronto.edu/twitcher/ows/proxy/thredds/catalog/datasets/CMIP6/CMIP/NOAA-GFDL/catalog.html +# CATALOG = https://daccs.cs.toronto.edu/twitcher/ows/proxy/thredds/catalog/datasets/CMIP6/CMIP/AS-RCEC/catalog.html testcmip6: - python $(IMP_DIR)/CMIP6_UofT/add_CMIP6.py $(STAC_HOST) https://pavics.ouranos.ca/twitcher/ows/proxy/thredds/catalog/birdhouse/testdata/xclim/cmip6/catalog.html + python $(IMP_DIR)/CMIP6_UofT/add_CMIP6.py $(STAC_HOST) $(CATALOG) delcmip6: curl --location --request DELETE '$(STAC_HOST)/collections/CMIP6_UofT' diff --git a/STACpopulator/implementations/CMIP6_UofT/add_CMIP6.py b/STACpopulator/implementations/CMIP6_UofT/add_CMIP6.py index cbdbd56..d966ead 100644 --- a/STACpopulator/implementations/CMIP6_UofT/add_CMIP6.py +++ b/STACpopulator/implementations/CMIP6_UofT/add_CMIP6.py @@ -74,7 +74,7 @@ class CMIP6ItemProperties(STACItemProperties, validate_assignment=True): physics_index: int realization_index: int forcing_index: int - tracking_id: str = "" + tracking_id: str = Field("") version: str = Field("") product: str license: str