Skip to content

Commit e4b821f

Browse files
authored
Update pgstac to v0.7.1 (#535)
* deps: bump pgstac to v0.7.1 * ci: only build packages on main or tags * ci: don't log on services * ci: up timeout minutes * chore: update changelog * test: add sorting test Confirming that stac-utils/stac-fastapi#514 is fixed with pgstac v0.7.0.
1 parent 0cb5460 commit e4b821f

File tree

6 files changed

+100
-46
lines changed

6 files changed

+100
-46
lines changed

.github/workflows/cicd.yaml

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ jobs:
1111
strategy:
1212
matrix:
1313
python-version: ["3.8", "3.9", "3.10", "3.11"]
14-
timeout-minutes: 10
14+
timeout-minutes: 20
1515

1616
services:
1717
db_service:
18-
image: ghcr.io/stac-utils/pgstac:v0.6.13
18+
image: ghcr.io/stac-utils/pgstac:v0.7.1
1919
env:
2020
POSTGRES_USER: username
2121
POSTGRES_PASSWORD: password
@@ -32,6 +32,7 @@ jobs:
3232
--health-interval 10s
3333
--health-timeout 10s
3434
--health-retries 10
35+
--log-driver none
3536
ports:
3637
# Maps tcp port 5432 on service container to the host
3738
- 5432:5432
@@ -130,7 +131,7 @@ jobs:
130131
backend: ["sqlalchemy", "pgstac"]
131132
services:
132133
pgstac:
133-
image: ghcr.io/stac-utils/pgstac:v0.6.13
134+
image: ghcr.io/stac-utils/pgstac:v0.7.1
134135
env:
135136
POSTGRES_USER: username
136137
POSTGRES_PASSWORD: password
@@ -143,6 +144,7 @@ jobs:
143144
--health-interval 10s
144145
--health-timeout 5s
145146
--health-retries 5
147+
--log-driver none
146148
ports:
147149
- 5432:5432
148150
steps:
@@ -176,7 +178,6 @@ jobs:
176178
POSTGRES_PORT: 5432
177179
PGUSER: username
178180
PGPASSWORD: password
179-
PGHOST: localhost
180181
PGDATABASE: postgis
181182
APP_HOST: 0.0.0.0
182183
APP_PORT: 8080
@@ -187,41 +188,3 @@ jobs:
187188
- uses: actions/checkout@v3
188189
- name: Test generating docs
189190
run: make docs
190-
191-
docker-build-push:
192-
runs-on: ubuntu-latest
193-
needs: [test, validate, test-docs]
194-
permissions:
195-
contents: read
196-
packages: write
197-
strategy:
198-
fail-fast: true
199-
matrix:
200-
backend: ["sqlalchemy", "pgstac"]
201-
steps:
202-
- name: Checkout repository
203-
uses: actions/checkout@v3
204-
- name: Log in to the Container registry
205-
uses: docker/[email protected]
206-
with:
207-
registry: ghcr.io
208-
username: ${{ github.actor }}
209-
password: ${{ secrets.GITHUB_TOKEN }}
210-
- name: Extract metadata (tags, labels) for Docker
211-
id: meta
212-
uses: docker/[email protected]
213-
with:
214-
images: ghcr.io/stac-utils/stac-fastapi
215-
tags: |
216-
type=schedule,suffix=-${{ matrix.backend }}
217-
type=ref,event=branch,suffix=-${{ matrix.backend }}
218-
type=ref,event=tag,suffix=-${{ matrix.backend }}
219-
type=ref,event=pr,suffix=-${{ matrix.backend }}
220-
- name: Build and push Docker image
221-
uses: docker/[email protected]
222-
with:
223-
context: .
224-
file: docker/Dockerfile.${{ matrix.backend }}
225-
push: true
226-
tags: ${{ steps.meta.outputs.tags }}
227-
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/packages.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: packages
2+
on:
3+
push:
4+
branches:
5+
- master
6+
tags:
7+
- "*"
8+
9+
jobs:
10+
docker-build-push:
11+
runs-on: ubuntu-latest
12+
needs: [test, validate, test-docs]
13+
permissions:
14+
contents: read
15+
packages: write
16+
strategy:
17+
fail-fast: true
18+
matrix:
19+
backend: ["sqlalchemy", "pgstac"]
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v3
23+
- name: Log in to the Container registry
24+
uses: docker/[email protected]
25+
with:
26+
registry: ghcr.io
27+
username: ${{ github.actor }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
- name: Extract metadata (tags, labels) for Docker
30+
id: meta
31+
uses: docker/[email protected]
32+
with:
33+
images: ghcr.io/stac-utils/stac-fastapi
34+
tags: |
35+
type=schedule,suffix=-${{ matrix.backend }}
36+
type=ref,event=branch,suffix=-${{ matrix.backend }}
37+
type=ref,event=tag,suffix=-${{ matrix.backend }}
38+
type=ref,event=pr,suffix=-${{ matrix.backend }}
39+
- name: Build and push Docker image
40+
uses: docker/[email protected]
41+
with:
42+
context: .
43+
file: docker/Dockerfile.${{ matrix.backend }}
44+
push: true
45+
tags: ${{ steps.meta.outputs.tags }}
46+
labels: ${{ steps.meta.outputs.labels }}

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* 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))
1515
* Reworked `update_openapi` and added a test for it ([#523](https://github.com/stac-utils/stac-fastapi/pull/523))
1616
* 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))
17+
* Updated pgstac to v0.7.1 ([#535](https://github.com/stac-utils/stac-fastapi/pull/535))
1718

1819
### Removed
1920

docker-compose.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,13 @@ services:
6161

6262
database:
6363
container_name: stac-db
64-
image: ghcr.io/stac-utils/pgstac:v0.6.12
64+
image: ghcr.io/stac-utils/pgstac:v0.7.1
6565
environment:
6666
- POSTGRES_USER=username
6767
- POSTGRES_PASSWORD=password
6868
- POSTGRES_DB=postgis
6969
- PGUSER=username
7070
- PGPASSWORD=password
71-
- PGHOST=localhost
7271
- PGDATABASE=postgis
7372
ports:
7473
- "5439:5432"

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
"buildpg",
1818
"brotli_asgi",
1919
"pygeofilter>=0.2",
20-
"pypgstac==0.6.*",
20+
"pypgstac==0.7.*",
2121
]
2222

2323
extra_reqs = {
2424
"dev": [
25-
"pypgstac[psycopg]==0.6.*",
25+
"pypgstac[psycopg]==0.7.*",
2626
"pytest",
2727
"pytest-cov",
2828
"pytest-asyncio>=0.17",

tests/api/test_api.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from datetime import datetime, timedelta
2+
from typing import Any, Dict, List
23
from urllib.parse import quote_plus
34

45
import orjson
@@ -577,3 +578,47 @@ async def test_deleting_items_with_identical_ids(app_client):
577578
response = await app_client.get(f"/collections/{collection.id}/items")
578579
assert response.status_code == 200, response.json()
579580
assert not response.json()["features"]
581+
582+
583+
@pytest.mark.parametrize("direction", ("asc", "desc"))
584+
async def test_sorting_and_paging(app_client, load_test_collection, direction: str):
585+
collection_id = load_test_collection.id
586+
for i in range(10):
587+
item = Item(
588+
id=f"item-{i}",
589+
geometry={"type": "Point", "coordinates": [-105.1019, 40.1672]},
590+
bbox=[-105.1019, 40.1672, -105.1019, 40.1672],
591+
datetime=datetime.now(),
592+
properties={
593+
"eo:cloud_cover": 42 + i if i % 3 != 0 else None,
594+
},
595+
)
596+
item.collection_id = collection_id
597+
response = await app_client.post(
598+
f"/collections/{collection_id}/items",
599+
json=item.to_dict(include_self_link=False, transform_hrefs=False),
600+
)
601+
assert response.status_code == 200
602+
603+
async def search(query: Dict[str, Any]) -> List[Item]:
604+
items: List[Item] = list()
605+
while True:
606+
response = await app_client.post("/search", json=query)
607+
json = response.json()
608+
assert response.status_code == 200, json
609+
items.extend((Item.from_dict(d) for d in json["features"]))
610+
next_link = next(
611+
(link for link in json["links"] if link["rel"] == "next"), None
612+
)
613+
if next_link is None:
614+
return items
615+
else:
616+
query = next_link["body"]
617+
618+
query = {
619+
"collections": [collection_id],
620+
"sortby": [{"field": "properties.eo:cloud_cover", "direction": direction}],
621+
"limit": 5,
622+
}
623+
items = await search(query)
624+
assert len(items) == 10, items

0 commit comments

Comments
 (0)