pystac
pystac copied to clipboard
Set schema_URI in 1.2?
I am testing out 1.2 right now with the data cube extension. I am not seeing a way to use the v1.0.0 implementation of the data cube extension.
If I do something like this to create an item:
item = pystac.Item(id=obj.productid,
geometry=geometry,
bbox=obj.bbox,
datetime=dt,
stac_extensions=extensions,
href=os.path.join(obj.href,f'{obj.productid}.json'),
collection=collection,
properties=properties)
and stac_extensions includes: 'https://stac-extensions.github.io/datacube/v1.0.0/schema.json'
, I get a validation error for the wrong schema version:
pystac.errors.ExtensionNotImplemented: Could not find extension schema URI https://stac-extensions.github.io/datacube/v2.0.0/schema.json in object.`
Note the v2.0.0, but I am explicitly specifying v1.0.0. in my extensions. If I use DataCubeExtension.ext(item, add_if_missing=True)
, v1.0.0 is retained and v2.0.0 is added to the list.
Is this user error? I am not seeing a way to set the schema URI here.
What happens if you monkeypatch https://github.com/stac-utils/pystac/blob/6e6e987dcb0e711adcd89432bd495199923cf759/pystac/extensions/datacube.py#L19 by setting
pystac.extensions.datacube.SCHEMA_URI = "https://stac-extensions.github.io/datacube/v1.0.0/schema.json"
before you run validate?
I don't know if I would recommend doing that, in case other places in the library are relying on something being compatible with 2.0, but it might be a stopgap.
I'm not sure if pystac has thought about versioning the actual extension objects (e.g. a V1DataCube
, V2DataCube
, etc.). That sounds like a lot of work.
@TomAugspurger I'll give monkeypatching in the schema uri a go.
Since the extensions are going to version, doesn't pystac need to be able to support different extension versions if it is going to provide schema validation? I understand the amount of work this is. What are the alternatives?
I think it’s that, or you pin to an older version, or you update your STAC objects.
I’m not sure how the extensions work, but subclassing & setting https://github.com/stac-utils/pystac/blob/6e6e987dcb0e711adcd89432bd495199923cf759/pystac/extensions/datacube.py#L653 https://github.com/stac-utils/pystac/blob/6e6e987dcb0e711adcd89432bd495199923cf759/pystac/extensions/datacube.py#L653 might be a bit less invasive and do the trick.
On Dec 11, 2021, at 7:20 AM, jlaura @.***> wrote:
@TomAugspurger https://github.com/TomAugspurger I'll give monkeypatching in the schema uri a go.
Since the extensions are going to version, doesn't pystac need to be able to support different extension versions if it is going to provide schema validation? I understand the amount of work this is. What are the alternatives?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/stac-utils/pystac/issues/668#issuecomment-991641712, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKAOIXYAJPATPNLPPSZYALUQNF2JANCNFSM5IJQZZXQ.
Since the extensions are going to version, doesn't pystac need to be able to support different extension versions if it is going to provide schema validation? I understand the amount of work this is. What are the alternatives?
Thanks for raising this @jlaura. We have an open issue (#448) to discuss how we want to handle versioning of STAC Extensions within PySTAC and it would be great to have you and @TomAugspurger weigh in on that if you have an opinion. For now, we handle extension versions in the same way as the stac_version
: it is automatically updated to the latest supported version and we attempt to apply any migrations from previous versions when we deserialize the object.
Closing as wontfix ... https://github.com/stac-utils/pystac/pull/1231 should help use correctly load older and newer versions, and https://github.com/stac-utils/pystac/issues/448 has been closed as complete. If folks need to use older versions of a given extension, they'll need to install an older version of PySTAC.