Skip to content

Commit

Permalink
revert the CMIP6 JSON schema reference to a resolvable content locati…
Browse files Browse the repository at this point in the history
…on (main github branch)
  • Loading branch information
fmigneault committed Dec 21, 2023
1 parent f37f065 commit ec0dd09
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion STACpopulator/extensions/cmip6.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
ExtensionManagementMixin,
PropertiesExtension,
SummariesExtension,
S, # generic pystac.STACObject
)

from STACpopulator.models import AnyGeometry
Expand All @@ -32,7 +33,10 @@
T = TypeVar("T", pystac.Collection, pystac.Item, pystac.Asset, item_assets.AssetDefinition)

SchemaName = Literal["cmip6"]
SCHEMA_URI: str = "https://stac-extensions.github.io/cmip6/v1.0.0/schema.json"
# FIXME: below reference (used as ID in the schema itself) should be updated once the extension is officially released
# SCHEMA_URI: str = "https://stac-extensions.github.io/cmip6/v1.0.0/schema.json"
# below is the temporary resolvable URI
SCHEMA_URI: str = "https://raw.githubusercontent.com/TomAugspurger/cmip6/main/json-schema/schema.json"
PREFIX = f"{get_args(SchemaName)[0]}:"

# CMIP6 controlled vocabulary (CV)
Expand Down Expand Up @@ -200,6 +204,14 @@ def apply(
def get_schema_uri(cls) -> str:
return SCHEMA_URI

@classmethod
def has_extension(cls, obj: S):
# FIXME: this override should be removed once an official and versioned schema is released
# ignore the original implementation logic for a version regex
# since in our case, the VERSION_REGEX is not fulfilled (ie: using 'main' branch, no tag available...)
ext_uri = cls.get_schema_uri()
return obj.stac_extensions is not None and any(uri == ext_uri for uri in obj.stac_extensions)

@classmethod
def ext(cls, obj: T, add_if_missing: bool = False) -> "CMIP6Extension[T]":
"""Extends the given STAC Object with properties from the
Expand Down
2 changes: 1 addition & 1 deletion tests/data/stac_item_testdata_xclim_cmip6_ncml.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,6 @@
89.74176788330078
],
"stac_extensions": [
"https://stac-extensions.github.io/cmip6/v1.0.0/schema.json"
"https://raw.githubusercontent.com/TomAugspurger/cmip6/main/json-schema/schema.json"
]
}

0 comments on commit ec0dd09

Please sign in to comment.