-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PB-769: STAC v1 optional asset features #431
Conversation
86ed021
to
e44c31e
Compare
Assets can optionally have a field roles to describe the purpose of the asset. Add property roles to asset model, described by comma separated string.
Add assets to collection directly. Can only add via admin gui.
Add test cases for collection assets. Fix triggers for collection summary update.
Add assets to response of get single collection in spec.
dde7938
to
0d31456
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
app/stac_api/admin.py
Outdated
'fields': ('title', 'description', 'roles') | ||
}), | ||
('Attributes', { | ||
'fields': ('eo_gsd', 'proj_epsg', 'geoadmin_variant', 'geoadmin_lang') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think only proj_epsg
is relevant on collection asset level, I'd use the other ones only on item asset level
on_delete=models.PROTECT, | ||
help_text=_(SEARCH_TEXT_HELP_ITEM) | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add the item asset specific parameters (eo_gsd
, geoadmin...
only here)
app/stac_api/pgtriggers.py
Outdated
array_remove(array_agg(DISTINCT(a.geoadmin_variant)), null) AS geoadmin_variant, | ||
array_remove(array_agg(DISTINCT(a.geoadmin_lang)), null) AS geoadmin_lang, | ||
array_remove(array_agg(DISTINCT(a.eo_gsd)), null) AS eo_gsd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not necessary here
}), | ||
( | ||
'File', { | ||
'fields': ('file', 'media_type', 'href', 'checksum_multihash', 'update_interval') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we need the update_interval
here... would it be considered at all? If I remember correctly we had set a fixed cache duration for assets uploaded via admin...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From discussion: cachecontrol header is set to a fixed value for assets uploaded via admin ui, so update_interval
has no effect. We decided to keep it mainly to keep the two asset models and logic similar
app/stac_api/pgtriggers.py
Outdated
summaries_geoadmin_variant = collection_summaries.geoadmin_variant, | ||
summaries_geoadmin_lang = collection_summaries.geoadmin_lang, | ||
summaries_eo_gsd = collection_summaries.eo_gsd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
class UpdateCollectionUpdateIntervalTrigger(pgtrigger.Trigger): | ||
when = pgtrigger.After | ||
declare = [ | ||
('asset_instance', 'stac_api_collectionasset%ROWTYPE'), | ||
] | ||
func = ''' | ||
asset_instance = COALESCE(NEW, OLD); | ||
-- Update related collection update_interval variables | ||
-- if new value is lower than existing one. | ||
UPDATE stac_api_collection SET | ||
update_interval = COALESCE(LEAST(NULLIF(asset_instance.update_interval, -1), update_interval), -1) | ||
WHERE id = asset_instance.collection_id; | ||
RAISE INFO 'collection.id=% update_interval updated, due to collectionasset.name=% updates.', | ||
asset_instance.collection_id, asset_instance.name; | ||
RETURN asset_instance; | ||
''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can probably be removed completely, see comment above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we keep the update_interval in the model we should also keep the trigger to avoid issues down the road.
Remove gsd, geoadmin variant and language from collection level assets as they are not relevant.
Rename eo:gsd field to gsd in v1 of the spec.
These changes are not required to conform with STAC v1, but are possible and nice to have for our use-cases.
roles
field to assets to describe the purpose of the asset.