Skip to content

Commit 02c01a3

Browse files
committed
update from main
2 parents 4573472 + b65cd97 commit 02c01a3

File tree

16 files changed

+498
-180
lines changed

16 files changed

+498
-180
lines changed

.github/workflows/cicd.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ jobs:
1515
- {python: '3.12', pypgstac: '0.9.*'}
1616
- {python: '3.12', pypgstac: '0.8.*'}
1717
- {python: '3.11', pypgstac: '0.8.*'}
18+
- {python: '3.10', pypgstac: '0.8.*'}
1819
- {python: '3.9', pypgstac: '0.8.*'}
19-
- {python: '3.8', pypgstac: '0.8.*'}
2020

2121
timeout-minutes: 20
2222

.github/workflows/packages.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ jobs:
2424
password: ${{ secrets.GITHUB_TOKEN }}
2525
- name: Extract metadata (tags, labels) for Docker
2626
id: meta
27-
uses: docker/metadata-action@v5.5.1
27+
uses: docker/metadata-action@v5.6.1
2828
with:
2929
images: ghcr.io/stac-utils/stac-fastapi-pgstac
3030
- name: Build and push Docker image
31-
uses: docker/build-push-action@v6.9.0
31+
uses: docker/build-push-action@v6.12.0
3232
with:
3333
context: .
3434
file: Dockerfile

CHANGES.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,27 @@
22

33
## [Unreleased]
44

5-
- Fix Docker compose file, so example data can be loaded into database (author @zstatmanweil, <https://github.com/stac-utils/stac-fastapi-pgstac/pull/142>)
5+
### Changed
6+
67
- 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)
78
- Add collection search extension ([#139](https://github.com/stac-utils/stac-fastapi-pgstac/pull/139))
89
- keep `/search` and `/collections` extensions separate ([#158](https://github.com/stac-utils/stac-fastapi-pgstac/pull/158))
9-
- Fix `filter` extension implementation in `CoreCrudClient`
1010
- update `pypgstac` requirement to `>=0.8,<0.10`
1111
- set `pypgstac==0.9.*` for test requirements
12+
- update `stac-fastapi-*` requirement to `~=4.0`
13+
- remove `python 3.8` support
14+
- renamed `post_request_model` attribute to `pgstac_search_model` in `CoreCrudClient` class
15+
- changed `datetime` input type to `string` in GET endpoint methods
16+
- renamed `filter` to `filter_expr` input attributes in GET endpoint methods
17+
- delete `utils.format_datetime_range` function
18+
19+
### Fixed
20+
21+
- Fix Docker compose file, so example data can be loaded into database (author @zstatmanweil, <https://github.com/stac-utils/stac-fastapi-pgstac/pull/142>)
22+
- Fix `filter` extension implementation in `CoreCrudClient`
1223

1324
## [3.0.1] - 2024-11-14
25+
1426
- Enable runtime `CORS` configuration using environment variables (`CORS_ORIGIN="https://...,https://..."`, `CORS_METHODS="PUT,OPTIONS"`) (https://github.com/stac-utils/stac-fastapi-pgstac/pull/168)
1527

1628
## [3.0.0] - 2024-08-02

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG PYTHON_VERSION=3.11
1+
ARG PYTHON_VERSION=3.12
22

33
FROM python:${PYTHON_VERSION}-slim as base
44

Dockerfile.docs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.8-slim
1+
FROM python:3.10-slim
22

33
# build-essential is required to build a wheel for ciso8601
44
RUN apt update && apt install -y build-essential

Dockerfile.tests

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG PYTHON_VERSION=3.11
1+
ARG PYTHON_VERSION=3.12
22

33
FROM python:${PYTHON_VERSION}-slim as base
44

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ PgSTAC stores all collection and item records as jsonb fields exactly as they co
2727
| --| --|
2828
| 2.5 | >=0.7,<0.8 |
2929
| 3.0 | >=0.8,<0.9 |
30+
| 4.0 | >=0.8,<0.10 |
3031

3132
## Usage
3233

docker-compose.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ services:
3535
build:
3636
context: .
3737
dockerfile: Dockerfile.tests
38+
volumes:
39+
- .:/app
3840
environment:
3941
- ENVIRONMENT=local
4042
- DB_MIN_CONN_SIZE=1
@@ -44,7 +46,7 @@ services:
4446

4547
database:
4648
container_name: stac-db
47-
image: ghcr.io/stac-utils/pgstac:v0.9.1
49+
image: ghcr.io/stac-utils/pgstac:v0.9.2
4850
environment:
4951
- POSTGRES_USER=username
5052
- POSTGRES_PASSWORD=password

setup.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
"orjson",
1111
"pydantic",
1212
"stac_pydantic==3.1.*",
13-
"stac-fastapi.api~=3.0.2",
14-
"stac-fastapi.extensions~=3.0.2",
15-
"stac-fastapi.types~=3.0.2",
13+
"stac-fastapi.api~=4.0",
14+
"stac-fastapi.extensions~=4.0",
15+
"stac-fastapi.types~=4.0",
1616
"asyncpg",
1717
"buildpg",
1818
"brotli_asgi",
@@ -27,7 +27,7 @@
2727
"pytest-postgresql",
2828
"pytest",
2929
"pytest-cov",
30-
"pytest-asyncio>=0.17,<0.25.0",
30+
"pytest-asyncio>=0.17,<0.26.0",
3131
"pre-commit",
3232
"requests",
3333
"shapely",
@@ -36,7 +36,7 @@
3636
"wheel",
3737
],
3838
"docs": ["mkdocs", "mkdocs-material", "pdocs"],
39-
"server": ["uvicorn[standard]==0.32.0"],
39+
"server": ["uvicorn[standard]==0.34.0"],
4040
"awslambda": ["mangum"],
4141
}
4242

@@ -46,12 +46,15 @@
4646
description="An implementation of STAC API based on the FastAPI framework and using the pgstac backend.",
4747
long_description=desc,
4848
long_description_content_type="text/markdown",
49-
python_requires=">=3.8",
49+
python_requires=">=3.9",
5050
classifiers=[
5151
"Intended Audience :: Developers",
5252
"Intended Audience :: Information Technology",
5353
"Intended Audience :: Science/Research",
54-
"Programming Language :: Python :: 3.8",
54+
"Programming Language :: Python :: 3.9",
55+
"Programming Language :: Python :: 3.10",
56+
"Programming Language :: Python :: 3.11",
57+
"Programming Language :: Python :: 3.12",
5558
"License :: OSI Approved :: MIT License",
5659
],
5760
keywords="STAC FastAPI COG",

stac_fastapi/pgstac/app.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
"""
77

88
import os
9+
from contextlib import asynccontextmanager
910

1011
from brotli_asgi import BrotliMiddleware
12+
from fastapi import FastAPI
1113
from fastapi.responses import ORJSONResponse
1214
from stac_fastapi.api.app import StacApi
1315
from stac_fastapi.api.middleware import CORSMiddleware, ProxyHeaderMiddleware
@@ -18,10 +20,12 @@
1820
create_post_request_model,
1921
create_request_model,
2022
)
23+
from stac_fastapi.api.openapi import update_openapi
2124
from stac_fastapi.extensions.core import (
2225
FieldsExtension,
2326
FilterExtension,
2427
FreeTextExtension,
28+
OffsetPaginationExtension,
2529
SortExtension,
2630
TokenPaginationExtension,
2731
TransactionExtension,
@@ -61,6 +65,7 @@
6165
"fields": FieldsExtension(),
6266
"filter": FilterExtension(client=FiltersClient()),
6367
"free_text": FreeTextExtension(),
68+
"pagination": OffsetPaginationExtension(),
6469
}
6570

6671
enabled_extensions = (
@@ -102,12 +107,31 @@
102107
post_request_model = create_post_request_model(extensions, base_model=PgstacSearch)
103108
get_request_model = create_get_request_model(extensions)
104109

110+
111+
@asynccontextmanager
112+
async def lifespan(app: FastAPI):
113+
"""FastAPI Lifespan."""
114+
await connect_to_db(app)
115+
yield
116+
await close_db_connection(app)
117+
118+
119+
fastapp = FastAPI(
120+
openapi_url=settings.openapi_url,
121+
docs_url=settings.docs_url,
122+
redoc_url=None,
123+
root_path=settings.root_path,
124+
lifespan=lifespan,
125+
)
126+
127+
105128
api = StacApi(
129+
app=update_openapi(fastapp),
106130
settings=settings,
107131
extensions=extensions + [collection_search_extension]
108132
if collection_search_extension
109133
else extensions,
110-
client=CoreCrudClient(post_request_model=post_request_model), # type: ignore
134+
client=CoreCrudClient(pgstac_search_model=post_request_model),
111135
response_class=ORJSONResponse,
112136
items_get_request_model=items_get_request_model,
113137
search_get_request_model=get_request_model,
@@ -126,18 +150,6 @@
126150
app = api.app
127151

128152

129-
@app.on_event("startup")
130-
async def startup_event():
131-
"""Connect to database on startup."""
132-
await connect_to_db(app)
133-
134-
135-
@app.on_event("shutdown")
136-
async def shutdown_event():
137-
"""Close database connection."""
138-
await close_db_connection(app)
139-
140-
141153
def run():
142154
"""Run app from command line using uvicorn if available."""
143155
try:

0 commit comments

Comments
 (0)