From 2719ccf6ead3e06de0784c39a2918d4d1811368b Mon Sep 17 00:00:00 2001 From: Pete Gadomski Date: Mon, 12 Jun 2023 15:37:57 -0600 Subject: [PATCH 1/2] deps: update to stac-fastapi v2.4.8 --- pcstac/requirements.txt | 90 +++++++++++++++++++++-------------------- pcstac/setup.py | 8 ++-- 2 files changed, 50 insertions(+), 48 deletions(-) diff --git a/pcstac/requirements.txt b/pcstac/requirements.txt index a9000342..fefc26e9 100644 --- a/pcstac/requirements.txt +++ b/pcstac/requirements.txt @@ -4,23 +4,23 @@ # # pip-compile --extra=server --output-file=pcstac/requirements.txt --resolver=backtracking pccommon/setup.py pcstac/setup.py # -anyio==3.6.2 +anyio==3.7.0 # via # starlette # watchgod -asgiref==3.6.0 +asgiref==3.7.2 # via uvicorn async-timeout==4.0.2 # via redis asyncpg==0.27.0 # via stac-fastapi-pgstac -attrs==22.2.0 +attrs==23.1.0 # via # stac-fastapi-api # stac-fastapi-extensions # stac-fastapi-pgstac # stac-fastapi-types -azure-core==1.26.3 +azure-core==1.27.0 # via # azure-data-tables # azure-identity @@ -32,7 +32,7 @@ azure-identity==1.7.1 # via pccommon (pccommon/setup.py) azure-storage-blob==12.12.0 # via pccommon (pccommon/setup.py) -beautifulsoup4==4.12.1 +beautifulsoup4==4.12.2 # via html-sanitizer brotli==1.0.9 # via brotli-asgi @@ -42,12 +42,12 @@ brotli-asgi==1.3.0 # stac-fastapi-pgstac buildpg==0.4 # via stac-fastapi-pgstac -cachetools==5.3.0 +cachetools==5.3.1 # via # google-auth # pccommon (pccommon/setup.py) # pypgstac -certifi==2022.12.7 +certifi==2023.5.7 # via # msrest # requests @@ -59,7 +59,7 @@ click==8.1.3 # via # stac-pydantic # uvicorn -cryptography==40.0.1 +cryptography==41.0.1 # via # azure-identity # azure-storage-blob @@ -67,21 +67,23 @@ cryptography==40.0.1 # pyjwt dateparser==1.1.8 # via pygeofilter -deprecated==1.2.13 +deprecated==1.2.14 # via redis +exceptiongroup==1.1.1 + # via anyio fastapi==0.90.1 # via # pccommon (pccommon/setup.py) # stac-fastapi-types fire==0.4.0 # via pypgstac -geojson-pydantic==0.5.0 +geojson-pydantic==0.6.2 # via stac-pydantic google-api-core==2.11.0 # via opencensus -google-auth==2.17.2 +google-auth==2.19.1 # via google-api-core -googleapis-common-protos==1.59.0 +googleapis-common-protos==1.59.1 # via google-api-core h11==0.14.0 # via uvicorn @@ -93,7 +95,7 @@ idna==3.4 # via # anyio # requests -iso8601==1.0.2 +iso8601==1.1.0 # via stac-fastapi-types isodate==0.6.1 # via msrest @@ -101,7 +103,7 @@ lark==0.12.0 # via pygeofilter lxml==4.9.2 # via html-sanitizer -msal==1.21.0 +msal==1.22.0 # via # azure-identity # msal-extensions @@ -128,33 +130,33 @@ orjson==3.5.2 # pccommon (pccommon/setup.py) # pypgstac # stac-fastapi-pgstac -packaging==23.0 +packaging==23.1 # via redis plpygis==0.2.1 # via pypgstac portalocker==2.7.0 # via msal-extensions -protobuf==4.22.1 +protobuf==4.23.2 # via # google-api-core # googleapis-common-protos -psutil==5.9.4 +psutil==5.9.5 # via opencensus-ext-azure -psycopg[binary]==3.1.8 +psycopg[binary]==3.1.9 # via pypgstac -psycopg-binary==3.1.8 +psycopg-binary==3.1.9 # via psycopg psycopg-pool==3.1.7 # via pypgstac -pyasn1==0.4.8 +pyasn1==0.5.0 # via # pyasn1-modules # rsa -pyasn1-modules==0.2.8 +pyasn1-modules==0.3.0 # via google-auth pycparser==2.21 # via cffi -pydantic[dotenv]==1.10.7 +pydantic[dotenv]==1.10.9 # via # fastapi # geojson-pydantic @@ -165,19 +167,19 @@ pydantic[dotenv]==1.10.7 # stac-fastapi-pgstac # stac-fastapi-types # stac-pydantic -pygeofilter==0.2.0 +pygeofilter==0.2.1 # via stac-fastapi-pgstac -pygeoif==0.7 +pygeoif==1.0.0 # via pygeofilter pyhumps==3.5.3 # via pccommon (pccommon/setup.py) -pyjwt[crypto]==2.6.0 +pyjwt[crypto]==2.7.0 # via msal -pypgstac[psycopg]==0.7.3 +pypgstac[psycopg]==0.7.9 # via # pcstac (pcstac/setup.py) # stac-fastapi-pgstac -pystac==1.7.1 +pystac==1.7.3 # via # pcstac (pcstac/setup.py) # stac-fastapi-types @@ -192,15 +194,13 @@ python-dotenv==1.0.0 # uvicorn pytz==2023.3 # via dateparser -pytz-deprecation-shim==0.1.0.post0 - # via tzlocal pyyaml==6.0 # via uvicorn redis==4.2.0rc1 # via pccommon (pccommon/setup.py) -regex==2023.3.23 +regex==2023.6.3 # via dateparser -requests==2.28.2 +requests==2.31.0 # via # azure-core # google-api-core @@ -224,20 +224,20 @@ smart-open==6.3.0 # via pypgstac sniffio==1.3.0 # via anyio -soupsieve==2.4 +soupsieve==2.4.1 # via beautifulsoup4 -stac-fastapi-api==2.4.5 +stac-fastapi-api==2.4.8 # via # pcstac (pcstac/setup.py) # stac-fastapi-extensions # stac-fastapi-pgstac -stac-fastapi-extensions==2.4.5 +stac-fastapi-extensions==2.4.8 # via # pcstac (pcstac/setup.py) # stac-fastapi-pgstac -stac-fastapi-pgstac==2.4.5 +stac-fastapi-pgstac==2.4.8 # via pcstac (pcstac/setup.py) -stac-fastapi-types==2.4.5 +stac-fastapi-types==2.4.8 # via # pcstac (pcstac/setup.py) # stac-fastapi-api @@ -256,24 +256,26 @@ starlette==0.22.0 # pccommon (pccommon/setup.py) tenacity==8.1.0 # via pypgstac -termcolor==2.2.0 +termcolor==2.3.0 # via fire types-cachetools==4.2.9 # via pccommon (pccommon/setup.py) -typing-extensions==4.5.0 +typing-extensions==4.6.3 # via + # asgiref # azure-core # psycopg # psycopg-pool # pydantic + # pygeoif # redis # starlette -tzdata==2023.3 - # via pytz-deprecation-shim -tzlocal==4.3 +tzlocal==5.0.1 # via dateparser -urllib3==1.26.15 - # via requests +urllib3==1.26.16 + # via + # google-auth + # requests uvicorn[standard]==0.17.6 # via pcstac (pcstac/setup.py) uvloop==0.17.0 @@ -282,7 +284,7 @@ version-parser==1.0.1 # via pypgstac watchgod==0.8.2 # via uvicorn -websockets==11.0 +websockets==11.0.3 # via uvicorn wrapt==1.15.0 # via deprecated diff --git a/pcstac/setup.py b/pcstac/setup.py index 2b1496b3..a862c61e 100644 --- a/pcstac/setup.py +++ b/pcstac/setup.py @@ -4,10 +4,10 @@ # Runtime requirements. inst_reqs = [ - "stac-fastapi.api==2.4.5", - "stac-fastapi.extensions==2.4.5", - "stac-fastapi.pgstac==2.4.5", - "stac-fastapi.types==2.4.5", + "stac-fastapi.api==2.4.8", + "stac-fastapi.extensions==2.4.8", + "stac-fastapi.pgstac==2.4.8", + "stac-fastapi.types==2.4.8", # Required due to some imports related to pypgstac CLI usage in startup script "pypgstac[psycopg]~=0.7", "pystac==1.*", From 89913d1ee10d5ddb436101c385ed68b648158021 Mon Sep 17 00:00:00 2001 From: Pete Gadomski Date: Wed, 21 Jun 2023 15:36:59 -0600 Subject: [PATCH 2/2] fix: update stac-fastapi-pgstac --- pcstac/pcstac/client.py | 55 ++++++++++++++++++++++------------------- pcstac/pcstac/config.py | 2 +- pcstac/requirements.txt | 2 +- pcstac/setup.py | 2 +- 4 files changed, 33 insertions(+), 28 deletions(-) diff --git a/pcstac/pcstac/client.py b/pcstac/pcstac/client.py index 69714572..9e162d74 100644 --- a/pcstac/pcstac/client.py +++ b/pcstac/pcstac/client.py @@ -107,7 +107,7 @@ def inject_item_links(self, item: Item, request: Request) -> Item: settings.back_pressures.collections.req_per_sec, settings.back_pressures.collections.inc_ms, ) - async def all_collections(self, **kwargs: Any) -> Collections: + async def all_collections(self, request: Request, **kwargs: Any) -> Collections: """Read collections from the database and inject PQE links. Called with `GET /collections`. @@ -118,10 +118,9 @@ async def all_collections(self, **kwargs: Any) -> Collections: Collections. """ _super: CoreCrudClient = super() - _request = kwargs["request"] async def _fetch() -> Collections: - collections = await _super.all_collections(**kwargs) + collections = await _super.all_collections(request=request, **kwargs) render_configs = get_all_render_configs() modified_collections = [] for col in collections.get("collections", []): @@ -136,12 +135,12 @@ async def _fetch() -> Collections: pass else: modified_collections.append( - self.inject_collection_extras(col, _request, render_config) + self.inject_collection_extras(col, request, render_config) ) collections["collections"] = modified_collections return collections - return await cached_result(_fetch, CACHE_KEY_COLLECTIONS, kwargs["request"]) + return await cached_result(_fetch, CACHE_KEY_COLLECTIONS, request) @rate_limit(CACHE_KEY_COLLECTION, settings.rate_limits.collection) @back_pressure( @@ -149,7 +148,9 @@ async def _fetch() -> Collections: settings.back_pressures.collection.req_per_sec, settings.back_pressures.collection.inc_ms, ) - async def get_collection(self, collection_id: str, **kwargs: Any) -> Collection: + async def get_collection( + self, collection_id: str, request: Request, **kwargs: Any + ) -> Collection: """Get collection by id and inject PQE links. Called with `GET /collections/{collection_id}`. @@ -162,7 +163,6 @@ async def get_collection(self, collection_id: str, **kwargs: Any) -> Collection: Collection. """ _super: CoreCrudClient = super() - _request = kwargs["request"] async def _fetch() -> Collection: try: @@ -173,13 +173,15 @@ async def _fetch() -> Collection: if render_config and render_config.hidden: raise NotFoundError - result = await _super.get_collection(collection_id, **kwargs) + result = await _super.get_collection( + collection_id, request=request, **kwargs + ) except NotFoundError: raise NotFoundError(f"No collection with id '{collection_id}' found!") - return self.inject_collection_extras(result, _request, render_config) + return self.inject_collection_extras(result, request, render_config) cache_key = f"{CACHE_KEY_COLLECTION}:{collection_id}" - return await cached_result(_fetch, cache_key, kwargs["request"]) + return await cached_result(_fetch, cache_key, request) @rate_limit(CACHE_KEY_SEARCH, settings.rate_limits.search) @back_pressure( @@ -188,7 +190,7 @@ async def _fetch() -> Collection: settings.back_pressures.search.inc_ms, ) async def _search_base( - self, search_request: PCSearch, **kwargs: Any + self, search_request: PCSearch, request: Request, **kwargs: Any ) -> ItemCollection: """Cross catalog search (POST). Called with `POST /search`. @@ -198,10 +200,11 @@ async def _search_base( ItemCollection containing items which match the search criteria. """ _super: CoreCrudClient = super() - request = kwargs["request"] async def _fetch() -> ItemCollection: - result = await _super._search_base(search_request, **kwargs) + result = await _super._search_base( + search_request, request=request, **kwargs + ) # Remove context extension until we fully support it. result.pop("context", None) @@ -231,19 +234,16 @@ async def _fetch() -> ItemCollection: hashed_search = hash(search_json) cache_key = f"{CACHE_KEY_SEARCH}:{hashed_search}" - return await cached_result(_fetch, cache_key, kwargs["request"]) + return await cached_result(_fetch, cache_key, request) - async def landing_page(self, **kwargs: Any) -> LandingPage: + async def landing_page(self, request: Request, **kwargs: Any) -> LandingPage: _super: CoreCrudClient = super() async def _fetch() -> LandingPage: - landing = await _super.landing_page(**kwargs) - # Remove once - # https://github.com/stac-utils/stac-fastapi/issues/334 is fixed. - del landing["stac_extensions"] + landing = await _super.landing_page(request=request, **kwargs) return landing - return await cached_result(_fetch, CACHE_KEY_LANDING_PAGE, kwargs["request"]) + return await cached_result(_fetch, CACHE_KEY_LANDING_PAGE, request) @rate_limit(CACHE_KEY_ITEMS, settings.rate_limits.items) @back_pressure( @@ -254,6 +254,7 @@ async def _fetch() -> LandingPage: async def item_collection( self, collection_id: str, + request: Request, limit: Optional[int] = None, token: Optional[str] = None, **kwargs: Any, @@ -262,11 +263,11 @@ async def item_collection( async def _fetch() -> ItemCollection: return await _super.item_collection( - collection_id, limit=limit, token=token, **kwargs + collection_id, request=request, limit=limit, token=token, **kwargs ) cache_key = f"{CACHE_KEY_ITEMS}:{collection_id}:limit:{limit}:token:{token}" - return await cached_result(_fetch, cache_key, kwargs["request"]) + return await cached_result(_fetch, cache_key, request) @rate_limit(CACHE_KEY_ITEM, settings.rate_limits.item) @back_pressure( @@ -274,15 +275,19 @@ async def _fetch() -> ItemCollection: settings.back_pressures.item.req_per_sec, settings.back_pressures.item.inc_ms, ) - async def get_item(self, item_id: str, collection_id: str, **kwargs: Any) -> Item: + async def get_item( + self, item_id: str, collection_id: str, request: Request, **kwargs: Any + ) -> Item: _super: CoreCrudClient = super() async def _fetch() -> Item: - item = await _super.get_item(item_id, collection_id, **kwargs) + item = await _super.get_item( + item_id, collection_id, request=request, **kwargs + ) return item cache_key = f"{CACHE_KEY_ITEM}:{collection_id}:{item_id}" - return await cached_result(_fetch, cache_key, kwargs["request"]) + return await cached_result(_fetch, cache_key, request) @classmethod def create( diff --git a/pcstac/pcstac/config.py b/pcstac/pcstac/config.py index 3f001c8a..7bceda91 100644 --- a/pcstac/pcstac/config.py +++ b/pcstac/pcstac/config.py @@ -16,7 +16,7 @@ from pcstac.filter import PCFiltersClient API_VERSION = "1.2" -STAC_API_VERSION = "v1.0.0-rc.1" +STAC_API_VERSION = "v1.0.0" API_LANDING_PAGE_ID = "microsoft-pc" API_TITLE = "Microsoft Planetary Computer STAC API" diff --git a/pcstac/requirements.txt b/pcstac/requirements.txt index fefc26e9..667001e9 100644 --- a/pcstac/requirements.txt +++ b/pcstac/requirements.txt @@ -235,7 +235,7 @@ stac-fastapi-extensions==2.4.8 # via # pcstac (pcstac/setup.py) # stac-fastapi-pgstac -stac-fastapi-pgstac==2.4.8 +stac-fastapi-pgstac==2.4.9 # via pcstac (pcstac/setup.py) stac-fastapi-types==2.4.8 # via diff --git a/pcstac/setup.py b/pcstac/setup.py index a862c61e..1dd088e4 100644 --- a/pcstac/setup.py +++ b/pcstac/setup.py @@ -6,7 +6,7 @@ inst_reqs = [ "stac-fastapi.api==2.4.8", "stac-fastapi.extensions==2.4.8", - "stac-fastapi.pgstac==2.4.8", + "stac-fastapi.pgstac==2.4.9", "stac-fastapi.types==2.4.8", # Required due to some imports related to pypgstac CLI usage in startup script "pypgstac[psycopg]~=0.7",