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

Update pgstac to v0.7.1 #535

Merged
merged 7 commits into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
47 changes: 5 additions & 42 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
timeout-minutes: 10
timeout-minutes: 20

services:
db_service:
image: ghcr.io/stac-utils/pgstac:v0.6.13
image: ghcr.io/stac-utils/pgstac:v0.7.1
env:
POSTGRES_USER: username
POSTGRES_PASSWORD: password
Expand All @@ -32,6 +32,7 @@ jobs:
--health-interval 10s
--health-timeout 10s
--health-retries 10
--log-driver none
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
Expand Down Expand Up @@ -130,7 +131,7 @@ jobs:
backend: ["sqlalchemy", "pgstac"]
services:
pgstac:
image: ghcr.io/stac-utils/pgstac:v0.6.13
image: ghcr.io/stac-utils/pgstac:v0.7.1
env:
POSTGRES_USER: username
POSTGRES_PASSWORD: password
Expand All @@ -143,6 +144,7 @@ jobs:
--health-interval 10s
--health-timeout 5s
--health-retries 5
--log-driver none
ports:
- 5432:5432
steps:
Expand Down Expand Up @@ -176,7 +178,6 @@ jobs:
POSTGRES_PORT: 5432
PGUSER: username
PGPASSWORD: password
PGHOST: localhost
pjhartzell marked this conversation as resolved.
Show resolved Hide resolved
PGDATABASE: postgis
APP_HOST: 0.0.0.0
APP_PORT: 8080
Expand All @@ -187,41 +188,3 @@ jobs:
- uses: actions/checkout@v3
- name: Test generating docs
run: make docs

docker-build-push:
runs-on: ubuntu-latest
needs: [test, validate, test-docs]
permissions:
contents: read
packages: write
strategy:
fail-fast: true
matrix:
backend: ["sqlalchemy", "pgstac"]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: ghcr.io/stac-utils/stac-fastapi
tags: |
type=schedule,suffix=-${{ matrix.backend }}
type=ref,event=branch,suffix=-${{ matrix.backend }}
type=ref,event=tag,suffix=-${{ matrix.backend }}
type=ref,event=pr,suffix=-${{ matrix.backend }}
- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
file: docker/Dockerfile.${{ matrix.backend }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
46 changes: 46 additions & 0 deletions .github/workflows/packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: packages
on:
push:
branches:
- master
tags:
- "*"

jobs:
docker-build-push:
runs-on: ubuntu-latest
needs: [test, validate, test-docs]
permissions:
contents: read
packages: write
strategy:
fail-fast: true
matrix:
backend: ["sqlalchemy", "pgstac"]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: ghcr.io/stac-utils/stac-fastapi
tags: |
type=schedule,suffix=-${{ matrix.backend }}
type=ref,event=branch,suffix=-${{ matrix.backend }}
type=ref,event=tag,suffix=-${{ matrix.backend }}
type=ref,event=pr,suffix=-${{ matrix.backend }}
- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
file: docker/Dockerfile.${{ matrix.backend }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Updated CI to test against [pgstac v0.6.12](https://github.com/stac-utils/pgstac/releases/tag/v0.6.12) ([#511](https://github.com/stac-utils/stac-fastapi/pull/511))
* Reworked `update_openapi` and added a test for it ([#523](https://github.com/stac-utils/stac-fastapi/pull/523))
* Limit values above 10,000 are now replaced with 10,000 instead of returning a 400 error ([#526](https://github.com/stac-utils/stac-fastapi/pull/526))
* Updated pgstac to v0.7.1 ([#535](https://github.com/stac-utils/stac-fastapi/pull/535))

### Removed

Expand Down
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,13 @@ services:

database:
container_name: stac-db
image: ghcr.io/stac-utils/pgstac:v0.6.12
image: ghcr.io/stac-utils/pgstac:v0.7.1
environment:
- POSTGRES_USER=username
- POSTGRES_PASSWORD=password
- POSTGRES_DB=postgis
- PGUSER=username
- PGPASSWORD=password
- PGHOST=localhost
- PGDATABASE=postgis
ports:
- "5439:5432"
Expand Down
3 changes: 1 addition & 2 deletions docker/docker-compose.pgstac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ services:
- pgstac

pgstac:
image: ghcr.io/stac-utils/pgstac:v0.6.13
image: ghcr.io/stac-utils/pgstac:v0.7.1
environment:
- POSTGRES_USER=username
- POSTGRES_PASSWORD=password
- POSTGRES_DB=postgis
- PGUSER=username
- PGPASSWORD=password
- PGHOST=localhost
- PGDATABASE=postgis
ports:
- "5439:5432"
Expand Down
3 changes: 1 addition & 2 deletions docker/docker-compose.sqlalchemy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ services:
- pgstac

pgstac:
image: ghcr.io/stac-utils/pgstac:v0.6.13
image: ghcr.io/stac-utils/pgstac:v0.7.1
environment:
- POSTGRES_USER=username
- POSTGRES_PASSWORD=password
- POSTGRES_DB=postgis
- PGUSER=username
- PGPASSWORD=password
- PGHOST=localhost
- PGDATABASE=postgis
ports:
- "5439:5432"
Expand Down
4 changes: 2 additions & 2 deletions stac_fastapi/pgstac/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
"buildpg",
"brotli_asgi",
"pygeofilter>=0.2",
"pypgstac==0.6.*",
"pypgstac==0.7.*",
]

extra_reqs = {
"dev": [
"pypgstac[psycopg]==0.6.*",
"pypgstac[psycopg]==0.7.*",
"pytest",
"pytest-cov",
"pytest-asyncio>=0.17",
Expand Down
45 changes: 45 additions & 0 deletions stac_fastapi/pgstac/tests/api/test_api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from datetime import datetime, timedelta
from typing import Any, Dict, List
from urllib.parse import quote_plus

import orjson
Expand Down Expand Up @@ -577,3 +578,47 @@ async def test_deleting_items_with_identical_ids(app_client):
response = await app_client.get(f"/collections/{collection.id}/items")
assert response.status_code == 200, response.json()
assert not response.json()["features"]


@pytest.mark.parametrize("direction", ("asc", "desc"))
async def test_sorting_and_paging(app_client, load_test_collection, direction: str):
collection_id = load_test_collection.id
for i in range(10):
item = Item(
id=f"item-{i}",
geometry={"type": "Point", "coordinates": [-105.1019, 40.1672]},
bbox=[-105.1019, 40.1672, -105.1019, 40.1672],
datetime=datetime.now(),
properties={
"eo:cloud_cover": 42 + i if i % 3 != 0 else None,
},
)
item.collection_id = collection_id
response = await app_client.post(
f"/collections/{collection_id}/items",
json=item.to_dict(include_self_link=False, transform_hrefs=False),
)
assert response.status_code == 200

async def search(query: Dict[str, Any]) -> List[Item]:
items: List[Item] = list()
while True:
response = await app_client.post("/search", json=query)
json = response.json()
assert response.status_code == 200, json
items.extend((Item.from_dict(d) for d in json["features"]))
next_link = next(
(link for link in json["links"] if link["rel"] == "next"), None
)
if next_link is None:
return items
else:
query = next_link["body"]

query = {
"collections": [collection_id],
"sortby": [{"field": "properties.eo:cloud_cover", "direction": direction}],
"limit": 5,
}
items = await search(query)
assert len(items) == 10, items