You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Deserialization in PySTAC for reading older version of STAC - a proposed solution to Add mechanism to allow for some backwards compatibility #36 could include a JSON transformation from older versions of stac objects to the version that the to_dict on PySTAC objects requires. In order to write this in a sane way, it would be good to know a priori what the STAC object, version, and extensions we are working with.
This method is probably not going to be very pretty - it's hard to imagine a version that is a set of conditionals that looks like when you take headphones out of a messy drawer. The idea is, if we put this method in PySTAC, we can centralize that messy logic to one place so that no duplicates have to exist. This follows what I call the One Monster Rule: if you're going to create a monster, make sure it's only created once.
Another approach we tries was to use jsonschema with a large combined oneOf reference that included all schemas from the STAC repo - jsonschema will try to validate each of the schemas to determine what works. However, if multiple schemas pass validation, this throws an error, which makes a lot of sense.
Any suggestions on how to better solve this are welcome!
/cc Team Validation @ the Arlington STAC Sprint @jbants@anayeaye
The text was updated successfully, but these errors were encountered:
Incomplete strawdog I'm using while developing the stac-spec example validation:
classObjectType:
CATALOG='CATALOG'COLLECTION='COLLECTION'ITEM='ITEM'ITEMCOLLECTION='ITEMCOLLECTION'defidentify_stac_object(d):
"""Determines they object type, version, and extensions of the STAC Object represented by a dictionary. Args: d (dict): The dict to identify Returns: Tuple[str, str, List[str]]: Tuple of (object_type, version, extensions) """stac_version=d.get('stac_version', None)
stac_extensions=set(d.get('stac_extensions', []))
object_type=Noneif'type'ind:
ifd['type'] =='FeatureCollection':
object_type=ObjectType.ITEMCOLLECTIONif'collections'ind:
extensions.add('single-file-stac')
else:
object_type=ObjectType.ITEMelif'extent'ind:
object_type=ObjectType.COLLECTIONelse:
object_type=ObjectType.CATALOGreturn (object_type, stac_version, stac_extensions)
Develop a method that takes in a dict, and returns a tuple
(object_type, version, [extensions])
.This will be used to identify the STAC objects that are contained in dictionaries. This will be useful for two things:
Validation: stac-validator and other validation tools - including one we are building to validate all examples in the stac-spec as part of Update CircleCI to use jsonschema directly radiantearth/stac-spec#623 - can use this method to determine what schema(s) to apply to the validation process.
Deserialization in PySTAC for reading older version of STAC - a proposed solution to Add mechanism to allow for some backwards compatibility #36 could include a JSON transformation from older versions of stac objects to the version that the
to_dict
on PySTAC objects requires. In order to write this in a sane way, it would be good to know a priori what the STAC object, version, and extensions we are working with.This method is probably not going to be very pretty - it's hard to imagine a version that is a set of conditionals that looks like when you take headphones out of a messy drawer. The idea is, if we put this method in PySTAC, we can centralize that messy logic to one place so that no duplicates have to exist. This follows what I call the One Monster Rule: if you're going to create a monster, make sure it's only created once.
Another approach we tries was to use jsonschema with a large combined
oneOf
reference that included all schemas from the STAC repo - jsonschema will try to validate each of the schemas to determine what works. However, if multiple schemas pass validation, this throws an error, which makes a lot of sense.Any suggestions on how to better solve this are welcome!
/cc Team Validation @ the Arlington STAC Sprint @jbants @anayeaye
The text was updated successfully, but these errors were encountered: