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

refactored conformance classes for extensions #790

Merged

Conversation

vincentsarago
Copy link
Member

while working on stac-utils/stac-fastapi-pgstac#192 I realized the extensions where designed first for /search endpoints and might lead to some issues within the application conformance classes list.

This PR aims to create extensions with correct conformances classes but also makes customization easier.

Changelog:

  • renamed collection_search.ConformanceClasses -> collection_search.CollectionSearchConformanceClasses
  • collection_search.CollectionSearchPostExtension.from_extension(ext) method will now use the conformance classes from the input extensions to derived the output conformance classes.
  • added fields.FieldsConformanceClasses Enum
  • renamed filter.FilterConformanceClasses.FEATURES_FILTER -> filter.FilterConformanceClasses.ITEMS
  • renamed filter.FilterConformanceClasses.ITEM_SEARCH_FILTER -> filter.FilterConformanceClasses.SEARCH
  • added filter.FilterConformanceClasses.COLLECTIONS
  • added filter.SearchFilterExtension, filter.ItemCollectionFilterExtension and filter.CollectionSearchFilterExtension endpoint specific extensions
  • removed FreeTextConformanceClasses.COLLECTIONS and FreeTextConformanceClasses.ITEMS in FreeTextExtension and FreeTextAdvancedExtension default conformances classes
  • added query.QueryConformanceClasses Enum
  • added SortConformanceClasses Enum

@vincentsarago vincentsarago requested review from m-mohr and gadomski and removed request for m-mohr January 24, 2025 09:56
FILTER = "https://api.stacspec.org/v1.0.0-rc.1/collection-search#filter"
QUERY = "https://api.stacspec.org/v1.0.0-rc.1/collection-search#query"
SORT = "https://api.stacspec.org/v1.0.0-rc.1/collection-search#sort"
FIELDS = "https://api.stacspec.org/v1.0.0-rc.1/collection-search#fields"
Copy link
Member Author

Choose a reason for hiding this comment

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

Those have been moved to each extensions Enums (will update the changelog to mention it)

]
for ext in extensions:
if conf := known_extension_conformances.get(ext.__class__.__name__, None):
conformance_classes.append(conf)
conformance_classes.extend(ext.conformance_classes)
Copy link
Member Author

Choose a reason for hiding this comment

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

we now extend the conformance classes with the classes found within the extensions


SEARCH = "https://api.stacspec.org/v1.0.0-rc.2/item-search#filter"
ITEMS = "http://www.opengis.net/spec/ogcapi-features-3/1.0/conf/features-filter"
COLLECTIONS = "https://api.stacspec.org/v1.0.0-rc.1/collection-search#filter"
Copy link
Member Author

Choose a reason for hiding this comment

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

For consistency, most extension will have search, items and collections

response_class=self.response_class,
endpoint=create_async_endpoint(self.client.get_queryables, EmptyRequest),
)
app.include_router(self.router, tags=["Filter Extension"])
Copy link
Member Author

Choose a reason for hiding this comment

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

the search extension only register the /queryables endpoint

Returns:
None
"""
pass
Copy link
Member Author

Choose a reason for hiding this comment

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

maybe worth for add a note about why we're not registering default endpoint here

ref: stac-utils/stac-fastapi-pgstac#192 (comment)

ITEMS_ADVANCED = (
"https://api.stacspec.org/v1.0.0-rc.1/ogcapi-features#advanced-free-text"
)
COLLECTIONS_ADVANCED = (
"https://api.stacspec.org/v1.0.0-rc.1/collection-search#advanced-free-text"
)
Copy link
Member Author

Choose a reason for hiding this comment

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

just re-ordering entries (to have search/items/collections)

"""

ITEMS = "https://api.stacspec.org/v1.0.0/ogcapi-features/extensions/transaction"
COLLECTIONS = "https://api.stacspec.org/v1.0.0/collections/extensions/transaction"
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: in pgstac we can register search request. This is used in titiler-pgstac where we register search request to get a uniq ID then used to get map tiles. It might be interesting to work on a transaction specification for search 🤷

cc @bitner @hrodmn

@vincentsarago
Copy link
Member Author

here is an example of full application https://gist.github.com/vincentsarago/4ee0fdf471cf592a8ba642dcc72304d2#file-app-py

@m-mohr
Copy link
Contributor

m-mohr commented Jan 27, 2025

Don't really have time to fully review right now, sorry. If you have specific things you want me to check though, please let me know.

@vincentsarago
Copy link
Member Author

the changes are quite breaking so should we make a 5.0.0 version next?

@gadomski
Copy link
Member

the changes are quite breaking so should we make a 5.0.0 version next?

Makes sense to me.

@vincentsarago vincentsarago merged commit 2fbcfc0 into main Jan 29, 2025
7 checks passed
@vincentsarago vincentsarago deleted the feature/refactor-conformance-classes-for-extensions branch January 29, 2025 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants