Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions pcfuncs/funclib/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,20 @@ def __init__(self, extent: RasterExtent) -> None:
self.extent = extent

@abstractmethod
def to_bytes(self, format: str = ExportFormats.PNG) -> io.BytesIO: ...
def to_bytes(self, format: str = ExportFormats.PNG) -> io.BytesIO:
...

@abstractmethod
def crop(self: T, bbox: Bbox) -> T: ...
def crop(self: T, bbox: Bbox) -> T:
...

@abstractmethod
def resample(self: T, cols: int, rows: int) -> T: ...
def resample(self: T, cols: int, rows: int) -> T:
...

@abstractmethod
def mask(self: T, geom: Dict[str, Any]) -> T: ...
def mask(self: T, geom: Dict[str, Any]) -> T:
...
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

format change unrelated to the PR goal



class PILRaster(Raster):
Expand Down
3 changes: 2 additions & 1 deletion pcfuncs/funclib/tiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ def get_tile_url(self, z: int, x: int, y: int) -> str:
return url

@abstractmethod
async def get_mosaic(self, tiles: List[Tile]) -> T: ...
async def get_mosaic(self, tiles: List[Tile]) -> T:
...
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

format change unrelated to the PR goal


@staticmethod
def get_covering_tiles(
Expand Down
26 changes: 0 additions & 26 deletions pcstac/pcstac/api.py

This file was deleted.

4 changes: 2 additions & 2 deletions pcstac/pcstac/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ async def _fetch() -> ItemCollection:
search_request.collections is None
and "collection=" not in str(request.url)
and '{"property":"collection"}'
not in orjson.dumps(search_request.filter).decode("utf-8")
not in orjson.dumps(search_request.filter_expr).decode("utf-8")
Copy link
Collaborator Author

@vincentsarago vincentsarago Jan 15, 2026

Choose a reason for hiding this comment

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

renamed filter to filter_expr input attributes in GET endpoint methods

ref: https://github.com/stac-utils/stac-fastapi-pgstac/blob/main/CHANGES.md#400---2025-02-03

):
raise HTTPException(status_code=422, detail="collection is required")

Expand Down Expand Up @@ -303,6 +303,6 @@ def create(
title=API_TITLE,
description=API_DESCRIPTION,
extra_conformance_classes=extra_conformance_classes,
post_request_model=post_request_model,
pgstac_search_model=post_request_model,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

renamed post_request_model attribute to pgstac_search_model in CoreCrudClient class

ref: https://github.com/stac-utils/stac-fastapi-pgstac/blob/main/CHANGES.md#400---2025-02-03

)
return it
2 changes: 1 addition & 1 deletion pcstac/pcstac/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
client=PCFiltersClient(),
conformance_classes=[
FilterConformanceClasses.FILTER,
FilterConformanceClasses.ITEM_SEARCH_FILTER,
FilterConformanceClasses.SEARCH,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

renamed filter.FilterConformanceClasses.ITEM_SEARCH_FILTER -> filter.FilterConformanceClasses.SEARCH

ref: renamed filter.FilterConformanceClasses.ITEM_SEARCH_FILTER -> filter.FilterConformanceClasses.SEARCH

FilterConformanceClasses.BASIC_CQL2,
FilterConformanceClasses.CQL2_JSON,
FilterConformanceClasses.CQL2_TEXT,
Expand Down
16 changes: 12 additions & 4 deletions pcstac/pcstac/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from fastapi.exceptions import RequestValidationError, StarletteHTTPException
from fastapi.openapi.utils import get_openapi
from fastapi.responses import ORJSONResponse
from stac_fastapi.api.app import StacApi as PCStacApi
from stac_fastapi.api.errors import DEFAULT_STATUS_CODES
from stac_fastapi.api.middleware import ProxyHeaderMiddleware
from stac_fastapi.api.models import (
Expand All @@ -29,13 +30,13 @@
from pccommon.middleware import TraceMiddleware, add_timeout, http_exception_handler
from pccommon.openapi import fixup_schema
from pccommon.redis import connect_to_redis
from pcstac.api import PCStacApi
from pcstac.client import PCClient
from pcstac.config import (
API_DESCRIPTION,
API_TITLE,
API_VERSION,
EXTENSIONS,
STAC_API_VERSION,
get_settings,
)
from pcstac.errors import PC_DEFAULT_STATUS_CODES
Expand Down Expand Up @@ -92,6 +93,7 @@ async def lifespan(app: FastAPI) -> AsyncGenerator:
db_min_conn_size=app_settings.db_min_conn_size,
base_item_cache=RedisBaseItemCache,
debug=DEBUG,
root_path=APP_ROOT_PATH,
),
client=PCClient.create(post_request_model=search_post_request_model),
extensions=EXTENSIONS,
Expand Down Expand Up @@ -148,9 +150,15 @@ def custom_openapi() -> Dict[str, Any]:
return app.openapi_schema
else:
schema = get_openapi(
title="Planetary Computer STAC API",
title=API_TITLE,
version=app_settings.api_version,
routes=app.routes,
)
app.openapi_schema = fixup_schema(app.root_path, schema)
return schema
fixed_schema = fixup_schema(
app.root_path, schema, tag=f"STAC API {STAC_API_VERSION}"
)
app.openapi_schema = fixed_schema
return fixed_schema
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is maybe the biggest change with this PR that doesn't seem well tested in tests



app.openapi = custom_openapi # type: ignore
32 changes: 21 additions & 11 deletions pcstac/pcstac/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from stac_fastapi.api.models import BaseSearchGetRequest, ItemCollectionUri
from stac_fastapi.pgstac.types.base_item_cache import BaseItemCache
from stac_fastapi.pgstac.types.search import PgstacSearch
from stac_fastapi.types.rfc3339 import DateTimeType, str_to_interval
from stac_fastapi.types.search import DateTimeQueryType, Limit, _validate_datetime
from starlette.requests import Request
from typing_extensions import Annotated

Expand Down Expand Up @@ -71,21 +71,31 @@ async def _fetch() -> Dict[str, Any]:

@attr.s
class PCItemCollectionUri(ItemCollectionUri):
limit: Annotated[Optional[int], Query()] = attr.ib(
default=LEGACY_ITEM_DEFAULT_LIMIT
)
limit: Annotated[
Optional[Limit],
Query(
description="Limits the number of results that are included in each page of the response (capped to 10_000)." # noqa: E501
),
] = attr.ib(default=LEGACY_ITEM_DEFAULT_LIMIT)


def patch_and_convert(interval: Optional[str]) -> Optional[DateTimeType]:
def patch_and_convert(value: Optional[str]) -> Optional[str]:
"""Patch datetime to add hh-mm-ss and timezone info."""
if interval:
interval = _patch_datetime(interval)
return str_to_interval(interval)
if value:
value = _patch_datetime(value)
return value


@attr.s
class PCSearchGetRequest(BaseSearchGetRequest):
datetime: Annotated[Optional[DateTimeType], Query()] = attr.ib(
default=None, converter=patch_and_convert
datetime: DateTimeQueryType = attr.ib(
default=None,
converter=patch_and_convert,
validator=_validate_datetime,
)
limit: Annotated[Optional[int], Query()] = attr.ib(default=DEFAULT_LIMIT)
limit: Annotated[
Optional[Limit],
Query(
description="Limits the number of results that are included in each page of the response (capped to 10_000)." # noqa: E501
),
] = attr.ib(default=DEFAULT_LIMIT)
8 changes: 4 additions & 4 deletions pcstac/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ dependencies = [
"orjson==3.10.4",
"pypgstac[psycopg]>=0.8.5,<0.9",
"pystac==1.10.1",
"stac-fastapi.api==3.0.0b2",
"stac-fastapi.extensions==3.0.0b2",
"stac-fastapi.pgstac==3.0.0a4",
"stac-fastapi.types==3.0.0b2",
"stac-fastapi.api==5.0.3",
"stac-fastapi.extensions==5.0.3",
"stac-fastapi.pgstac==4.0.4",
"stac-fastapi.types==5.0.3",
"typing_extensions>=4.6.1",
"urllib3>=2.2.2",
]
Expand Down
18 changes: 10 additions & 8 deletions pcstac/requirements-server.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#
# pip-compile --extra=dev --extra=server --output-file=pcstac/requirements-server.txt ./pcstac/pyproject.toml
#
annotated-doc==0.0.4
# via fastapi
annotated-types==0.7.0
# via pydantic
anyio==4.10.0
Expand Down Expand Up @@ -32,7 +34,7 @@ click==8.1.8
# uvicorn
dateparser==1.2.2
# via pygeofilter
fastapi-slim==0.116.1
fastapi==0.128.0
# via stac-fastapi-types
fire==0.4.0
# via pypgstac
Expand Down Expand Up @@ -65,7 +67,7 @@ psycopg-pool==3.1.9
# via pypgstac
pydantic==2.11.7
# via
# fastapi-slim
# fastapi
# geojson-pydantic
# pydantic-settings
# pypgstac
Expand Down Expand Up @@ -108,18 +110,18 @@ smart-open==7.3.0.post1
# via pypgstac
sniffio==1.3.1
# via anyio
stac-fastapi-api==3.0.0b2
stac-fastapi-api==5.0.3
# via
# pcstac (pcstac/pyproject.toml)
# stac-fastapi-extensions
# stac-fastapi-pgstac
stac-fastapi-extensions==3.0.0b2
stac-fastapi-extensions==5.0.3
# via
# pcstac (pcstac/pyproject.toml)
# stac-fastapi-pgstac
stac-fastapi-pgstac==3.0.0a4
stac-fastapi-pgstac==4.0.4
# via pcstac (pcstac/pyproject.toml)
stac-fastapi-types==3.0.0b2
stac-fastapi-types==5.0.3
# via
# pcstac (pcstac/pyproject.toml)
# stac-fastapi-api
Expand All @@ -132,7 +134,7 @@ stac-pydantic==3.1.5
starlette==0.47.2
# via
# brotli-asgi
# fastapi-slim
# fastapi
tenacity==8.1.0
# via pypgstac
termcolor==3.1.0
Expand All @@ -142,7 +144,7 @@ types-requests==2.32.4.20250809
typing-extensions==4.14.1
# via
# anyio
# fastapi-slim
# fastapi
# pcstac (pcstac/pyproject.toml)
# psycopg
# psycopg-pool
Expand Down
8 changes: 4 additions & 4 deletions pcstac/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from httpx import ASGITransport, AsyncClient
from pypgstac.db import PgstacDB
from pypgstac.migrate import Migrate
from stac_fastapi.api.app import StacApi as PCStacApi
from stac_fastapi.api.models import (
create_get_request_model,
create_post_request_model,
Expand All @@ -23,7 +24,6 @@

from pccommon.logging import ServiceName
from pccommon.redis import connect_to_redis
from pcstac.api import PCStacApi
from pcstac.client import PCClient
from pcstac.config import EXTENSIONS, TILER_HREF_ENV_VAR
from pcstac.search import PCItemCollectionUri, PCSearch, PCSearchGetRequest
Expand Down Expand Up @@ -85,7 +85,7 @@ def api_client(pqe_pg):
title="test title",
description="test description",
api_version="1.0.0",
settings=Settings(debug=True),
settings=Settings(debug=True, root_path="/stac"),
client=PCClient.create(
post_request_model=search_post_request_model,
),
Expand Down Expand Up @@ -118,8 +118,8 @@ async def app(api_client) -> AsyncGenerator[FastAPI, None]:
@pytest.fixture(scope="session")
async def app_client(app) -> AsyncGenerator[AsyncClient, None]:
async with AsyncClient(
transport=ASGITransport(app=app),
base_url="http://test/stac",
transport=ASGITransport(app=app, root_path="/stac"),
base_url="http://test",
headers={"X-Forwarded-For": "127.0.0.1"},
) as c:
yield c
Expand Down
Loading