Skip to content
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

Merged
merged 6 commits into from
Jul 18, 2024
Merged

Conversation

benschs
Copy link
Contributor

@benschs benschs commented Jul 11, 2024

These changes are not required to conform with STAC v1, but are possible and nice to have for our use-cases.

  • Add roles field to assets to describe the purpose of the asset.
  • Add assets to collections directly that do not belong to an item.

@benschs benschs force-pushed the feat-PB-769-assets branch 4 times, most recently from 86ed021 to e44c31e Compare July 16, 2024 09:13
benschs added 4 commits July 16, 2024 11:31
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.
@benschs benschs force-pushed the feat-PB-769-assets branch from dde7938 to 0d31456 Compare July 16, 2024 09:31
@benschs benschs marked this pull request as ready for review July 16, 2024 09:35
@benschs benschs requested review from boecklic and schtibe July 16, 2024 09:35
Copy link
Contributor

@boecklic boecklic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

'fields': ('title', 'description', 'roles')
}),
('Attributes', {
'fields': ('eo_gsd', 'proj_epsg', 'geoadmin_variant', 'geoadmin_lang')
Copy link
Contributor

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)
)

Copy link
Contributor

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)

Comment on lines 223 to 225
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
Copy link
Contributor

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')
Copy link
Contributor

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...

Copy link
Contributor

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

Comment on lines 244 to 246
summaries_geoadmin_variant = collection_summaries.geoadmin_variant,
summaries_geoadmin_lang = collection_summaries.geoadmin_lang,
summaries_eo_gsd = collection_summaries.eo_gsd
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Comment on lines +254 to +269
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;
'''
Copy link
Contributor

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

Copy link
Contributor Author

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.
@benschs benschs requested a review from boecklic July 16, 2024 14:59
Rename eo:gsd field to gsd in v1 of the spec.
@benschs benschs merged commit bd7e36a into develop Jul 18, 2024
3 checks passed
@benschs benschs deleted the feat-PB-769-assets branch July 18, 2024 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants