diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml index d4a03663..0ae6f963 100644 --- a/.github/workflows/cicd.yaml +++ b/.github/workflows/cicd.yaml @@ -11,7 +11,13 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + include: + - {python: '3.12', pypgstac: '0.9.*'} + - {python: '3.12', pypgstac: '0.8.*'} + - {python: '3.11', pypgstac: '0.8.*'} + - {python: '3.9', pypgstac: '0.8.*'} + - {python: '3.8', pypgstac: '0.8.*'} + timeout-minutes: 20 steps: @@ -22,12 +28,12 @@ jobs: - name: Setup Python uses: actions/setup-python@v5 with: - python-version: ${{ matrix.python-version }} + python-version: ${{ matrix.python }} cache: pip cache-dependency-path: setup.py - name: Lint code - if: ${{ matrix.python-version == 3.11 }} + if: ${{ matrix.python == 3.11 }} run: | python -m pip install pre-commit pre-commit run --all-files @@ -39,6 +45,7 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install .[dev,server] + python -m pip install "pypgstac==${{ matrix.pypgstac }}" - name: Run test suite run: python -m pytest --cov stac_fastapi.pgstac --cov-report xml --cov-report term-missing diff --git a/CHANGES.md b/CHANGES.md index ba739ac7..dd70a316 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,9 +3,12 @@ ## [Unreleased] - Fix Docker compose file, so example data can be loaded into database (author @zstatmanweil, ) +- Handle `next` and `dev` tokens now returned as links from pgstac>=0.9.0 (author @zstatmanweil, https://github.com/stac-utils/stac-fastapi-pgstac/pull/140) - Add collection search extension ([#139](https://github.com/stac-utils/stac-fastapi-pgstac/pull/139)) - keep `/search` and `/collections` extensions separate ([#158](https://github.com/stac-utils/stac-fastapi-pgstac/pull/158)) - Fix `filter` extension implementation in `CoreCrudClient` +- update `pypgstac` requirement to `>=0.8,<0.10` +- set `pypgstac==0.9.*` for test requirements ## [3.0.0] - 2024-08-02 diff --git a/docker-compose.yml b/docker-compose.yml index ec1080aa..02158a68 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,7 +44,7 @@ services: database: container_name: stac-db - image: ghcr.io/stac-utils/pgstac:v0.8.5 + image: ghcr.io/stac-utils/pgstac:v0.9.1 environment: - POSTGRES_USER=username - POSTGRES_PASSWORD=password diff --git a/setup.py b/setup.py index 74b63833..e9abcae2 100644 --- a/setup.py +++ b/setup.py @@ -17,13 +17,13 @@ "buildpg", "brotli_asgi", "pygeofilter>=0.2", - "pypgstac==0.8.*", + "pypgstac>=0.8,<0.10", ] extra_reqs = { "dev": [ "pystac[validation]", - "pypgstac[psycopg]==0.8.*", + "pypgstac[psycopg]==0.9.*", "pytest-postgresql", "pytest", "pytest-cov", diff --git a/stac_fastapi/pgstac/core.py b/stac_fastapi/pgstac/core.py index e7dcab21..0917ab16 100644 --- a/stac_fastapi/pgstac/core.py +++ b/stac_fastapi/pgstac/core.py @@ -244,8 +244,17 @@ async def _search_base( # noqa: C901 f"Datetime parameter {search_request.datetime} is invalid." ) from e - next: Optional[str] = items.pop("next", None) - prev: Optional[str] = items.pop("prev", None) + # Starting in pgstac 0.9.0, the `next` and `prev` tokens are returned in spec-compliant links with method GET + next_from_link: Optional[str] = None + prev_from_link: Optional[str] = None + for link in items.get("links", []): + if link.get("rel") == "next": + next_from_link = link.get("href").split("token=next:")[1] + if link.get("rel") == "prev": + prev_from_link = link.get("href").split("token=prev:")[1] + + next: Optional[str] = items.pop("next", next_from_link) + prev: Optional[str] = items.pop("prev", prev_from_link) collection = ItemCollection(**items) fields = getattr(search_request, "fields", None)