Skip to content

Commit da929fa

Browse files
authored
Merge branch 'master' into pv/update-ci-run-python-matrix
2 parents c3161da + bda2412 commit da929fa

File tree

42 files changed

+513
-351
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+513
-351
lines changed

.github/dependabot.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: "/"
5+
schedule:
6+
interval: weekly
7+
- package-ecosystem: pip
8+
directory: "/.github/workflows"
9+
schedule:
10+
interval: weekly
11+
- package-ecosystem: pip
12+
directory: "/stac_fastapi/api"
13+
schedule:
14+
interval: weekly
15+
- package-ecosystem: pip
16+
directory: "/stac_fastapi/api"
17+
schedule:
18+
interval: weekly
19+
- package-ecosystem: pip
20+
directory: "/stac_fastapi/types"
21+
schedule:
22+
interval: weekly
23+
- package-ecosystem: pip
24+
directory: "/stac_fastapi/extensions"
25+
schedule:
26+
interval: weekly
27+
- package-ecosystem: pip
28+
directory: "/stac_fastapi/pgstac"
29+
schedule:
30+
interval: weekly
31+
- package-ecosystem: pip
32+
directory: "/stac_fastapi/sqlalchemy"
33+
schedule:
34+
interval: weekly

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ repos:
66
language_version: python3.8
77
-
88
repo: https://github.com/psf/black
9-
rev: 20.8b1
9+
rev: 22.3.0
1010
hooks:
1111
- id: black
1212
args: ['--safe']

CHANGES.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,30 @@
22

33
## Unreleased
44

5-
* Update error response payloads to match the API spec. ([#361](https://github.com/stac-utils/stac-fastapi/pull/361))
6-
75
### Added
86

97
* Add hook to allow adding dependencies to routes. ([#295](https://github.com/stac-utils/stac-fastapi/pull/295))
8+
* Add STAC API - Collections conformance class. ([383](https://github.com/stac-utils/stac-fastapi/pull/383))
109

1110
### Changed
1211

1312
* Update FastAPI requirement to allow version >=0.73 ([#337](https://github.com/stac-utils/stac-fastapi/pull/337))
1413
* Bump version of PGStac to 0.4.5 ([#346](https://github.com/stac-utils/stac-fastapi/pull/346))
1514
* Add support for PGStac Backend to use PyGeofilter to convert Get Request with cql2-text into cql2-json to send to PGStac backend ([#346](https://github.com/stac-utils/stac-fastapi/pull/346))
15+
* Updated all conformance classes to 1.0.0-rc.1. ([383](https://github.com/stac-utils/stac-fastapi/pull/383))
1616
* Bulk Transactions object Items iterator now returns the Item objects rather than the string IDs of the Item objects
1717
([#355](https://github.com/stac-utils/stac-fastapi/issues/355))
18+
* docker-compose now runs uvicorn with hot-reloading enabled
1819

1920
### Removed
2021

2122
### Fixed
23+
2224
* Bumped uvicorn version to 0.17 (from >=0.12, <=0.14) to resolve security vulnerability related to websockets dependency version ([#343](https://github.com/stac-utils/stac-fastapi/pull/343))
2325
* `AttributeError` and/or missing properties when requesting the complete `properties`-field in searches. Added test. ([#339](https://github.com/stac-utils/stac-fastapi/pull/339))
2426
* Fixes issues (and adds tests) for issues caused by regression in pgstac ([#345](https://github.com/stac-utils/stac-fastapi/issues/345)
27+
* Update error response payloads to match the API spec. ([#361](https://github.com/stac-utils/stac-fastapi/pull/361))
28+
* Fixed stray `/` before the `#` in several extension conformance class strings ([383](https://github.com/stac-utils/stac-fastapi/pull/383))
2529
* SQLAlchemy backend bulk item insert now works ([#356]https://github.com/stac-utils/stac-fastapi/issues/356))
2630

2731
## [2.3.0]

Dockerfile

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
FROM python:3.8-slim as base
22

3-
FROM base as builder
43
# Any python libraries that require system libraries to be installed will likely
54
# need the following packages in order to build
6-
RUN apt-get update && apt-get install -y build-essential git
5+
RUN apt-get update && \
6+
apt-get -y upgrade && \
7+
apt-get install -y build-essential git && \
8+
apt-get clean && \
9+
rm -rf /var/lib/apt/lists/*
710

811
ENV CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
912

10-
ARG install_dev_dependencies=true
13+
FROM base as builder
1114

1215
WORKDIR /app
1316

14-
# Install stac_fastapi.types
1517
COPY . /app
1618

17-
ENV PATH=$PATH:/install/bin
18-
19-
RUN mkdir -p /install && \
20-
pip install -e ./stac_fastapi/types[dev] && \
19+
RUN pip install -e ./stac_fastapi/types[dev] && \
2120
pip install -e ./stac_fastapi/api[dev] && \
2221
pip install -e ./stac_fastapi/extensions[dev] && \
2322
pip install -e ./stac_fastapi/sqlalchemy[dev,server] && \

Dockerfile.docs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
FROM python:3.8-slim
22

3+
# build-essential is required to build a wheel for ciso8601
4+
RUN apt update && apt install -y build-essential
5+
36
RUN python -m pip install --upgrade pip
47
RUN python -m pip install mkdocs mkdocs-material pdocs
58

69
COPY . /opt/src
710

811
WORKDIR /opt/src
912

10-
RUN python -m pip install -e \
13+
RUN python -m pip install \
1114
stac_fastapi/api \
1215
stac_fastapi/types \
1316
stac_fastapi/extensions \
1417
stac_fastapi/sqlalchemy
1518

16-
1719
CMD ["pdocs", \
1820
"as_markdown", \
1921
"--output_dir", \

Makefile

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
APP_HOST ?= 0.0.0.0
33
APP_PORT ?= 8080
44
EXTERNAL_APP_PORT ?= ${APP_PORT}
5-
run_docker = docker-compose run --rm \
5+
run_sqlalchemy = docker-compose run --rm \
66
-p ${EXTERNAL_APP_PORT}:${APP_PORT} \
77
-e APP_HOST=${APP_HOST} \
88
-e APP_PORT=${APP_PORT} \
@@ -18,29 +18,33 @@ run_pgstac = docker-compose run --rm \
1818
image:
1919
docker-compose build
2020

21-
.PHONY: docker-run
22-
docker-run: image
23-
$(run_docker)
21+
.PHONY: docker-run-all
22+
docker-run-all:
23+
docker-compose up
24+
25+
.PHONY: docker-run-sqlalchemy
26+
docker-run-sqlalchemy: image
27+
$(run_sqlalchemy)
2428

2529
.PHONY: docker-run-pgstac
2630
docker-run-pgstac: image
2731
$(run_pgstac)
2832

29-
.PHONY: docker-shell
30-
docker-shell:
31-
$(run_docker) /bin/bash
33+
.PHONY: docker-shell-sqlalchemy
34+
docker-shell-sqlalchemy:
35+
$(run_sqlalchemy) /bin/bash
3236

3337
.PHONY: docker-shell-pgstac
3438
docker-shell-pgstac:
3539
$(run_pgstac) /bin/bash
3640

3741
.PHONY: test-sqlalchemy
3842
test-sqlalchemy: run-joplin-sqlalchemy
39-
$(run_docker) /bin/bash -c 'export && ./scripts/wait-for-it.sh database:5432 && cd /app/stac_fastapi/sqlalchemy/tests/ && pytest'
43+
$(run_sqlalchemy) /bin/bash -c 'export && ./scripts/wait-for-it.sh database:5432 && cd /app/stac_fastapi/sqlalchemy/tests/ && pytest -vvv'
4044

4145
.PHONY: test-pgstac
4246
test-pgstac:
43-
$(run_pgstac) /bin/bash -c 'export && ./scripts/wait-for-it.sh database:5432 && cd /app/stac_fastapi/pgstac/tests/ && pytest -vvv --asyncio-mode=auto'
47+
$(run_pgstac) /bin/bash -c 'export && ./scripts/wait-for-it.sh database:5432 && cd /app/stac_fastapi/pgstac/tests/ && pytest -vvv'
4448

4549
.PHONY: run-database
4650
run-database:

README.md

Lines changed: 55 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,34 +62,71 @@ pip install -e stac_fastapi/pgstac
6262
```
6363

6464
## Local Development
65-
Use docker-compose to deploy the application, migrate the database, and ingest some example data:
66-
```bash
67-
docker-compose build
68-
docker-compose up
6965

70-
# You can also launch application with specific backend (PGSTac or sqlalchemy)
71-
docker-compose up app-sqlalchemy
72-
# or
73-
docker-compose up app-pgstac
66+
Use docker-compose via make to start the application, migrate the database, and ingest some example data:
67+
```bash
68+
make image
69+
make docker-run-all
7470
```
7571

76-
For local development it is often more convenient to run the application outside of docker-compose:
77-
```bash
78-
make docker-run
72+
- The SQLAlchemy backend app will be available on <http://localhost:8081>.
73+
- The PGStac backend app will be available on <http://localhost:8082>.
74+
75+
You can also launch only one of the applications with either of these commands:
76+
77+
```shell
78+
make docker-run-pgstac
79+
make docker-run-sqlalchemy
7980
```
8081

82+
The application will be started on <http://localhost:8080>.
83+
84+
By default, the apps are run with uvicorn hot-reloading enabled. This can be turned off by changing the value
85+
of the `RELOAD` env var in docker-compose.yml to `false`.
86+
8187
#### Note to Docker for Windows users
8288

83-
You'll need to enable experimental features on Docker for Windows in order to run the docker-compose, due to the "--platform" flag that is required to allow the project to run on some Apple architectures. To do this, open Docker Desktop, go to settings, select "Docker Engine", and modify the configuration JSON to have `"experimental": true`.
89+
You'll need to enable experimental features on Docker for Windows in order to run the docker-compose,
90+
due to the "--platform" flag that is required to allow the project to run on some Apple architectures.
91+
To do this, open Docker Desktop, go to settings, select "Docker Engine", and modify the configuration
92+
JSON to have `"experimental": true`.
8493

8594
### Testing
86-
The database container provided by the docker-compose stack must be running. Run all tests:
87-
```bash
95+
96+
Before running the tests, ensure the database and apps run with docker-compose are down:
97+
98+
```shell
99+
docker-compose down
100+
```
101+
102+
The database container provided by the docker-compose stack must be running. This can be started with:
103+
104+
```shell
105+
make run-database
106+
```
107+
108+
To run tests for both the pgstac and sqlalchemy backends, execute:
109+
110+
```shell
88111
make test
89112
```
90113

91-
Run individual tests by running pytest within the docker container:
92-
```bash
93-
make docker-shell
94-
$ pytest -v
114+
To only run pgstac backend tests:
115+
116+
```shell
117+
make test-pgstac
118+
```
119+
120+
To only run sqlalchemy backend tests:
121+
122+
```shell
123+
make test-sqlalchemy
124+
```
125+
126+
Run individual tests by running pytest within a docker container:
127+
128+
```shell
129+
make docker-shell-pgstac # or docker-shell-sqlalchemy
130+
$ pip install -e stac_fastapi/pgstac[dev]
131+
$ pytest -v stac_fastapi/pgstac/tests/api/test_api.py
95132
```

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010
environment:
1111
- APP_HOST=0.0.0.0
1212
- APP_PORT=8081
13-
- RELOAD=false
13+
- RELOAD=true
1414
- ENVIRONMENT=local
1515
- POSTGRES_USER=username
1616
- POSTGRES_PASS=password
@@ -36,7 +36,7 @@ services:
3636
environment:
3737
- APP_HOST=0.0.0.0
3838
- APP_PORT=8082
39-
- RELOAD=false
39+
- RELOAD=true
4040
- ENVIRONMENT=local
4141
- POSTGRES_USER=username
4242
- POSTGRES_PASS=password

stac_fastapi/api/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"License :: OSI Approved :: MIT License",
4141
],
4242
keywords="STAC FastAPI COG",
43-
author=u"Arturo Engineering",
43+
author="Arturo Engineering",
4444
author_email="[email protected]",
4545
url="https://github.com/stac-utils/stac-fastapi",
4646
license="MIT",

stac_fastapi/api/stac_fastapi/api/models.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ class GeoJSONResponse(ORJSONResponse):
160160

161161
media_type = "application/geo+json"
162162

163-
164163
else:
165164
from starlette.responses import JSONResponse
166165

stac_fastapi/api/stac_fastapi/api/routes.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,18 @@
77
from starlette.requests import Request
88
from starlette.responses import JSONResponse, Response
99
from starlette.routing import BaseRoute, Match
10+
from starlette.status import HTTP_204_NO_CONTENT
1011

1112
from stac_fastapi.api.models import APIRequest
1213

1314

1415
def _wrap_response(resp: Any, response_class: Type[Response]) -> Response:
1516
if isinstance(resp, Response):
1617
return resp
17-
else:
18+
elif resp is not None:
1819
return response_class(resp)
20+
else: # None is returned as 204 No Content
21+
return Response(status_code=HTTP_204_NO_CONTENT)
1922

2023

2124
def create_async_endpoint(

stac_fastapi/extensions/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"License :: OSI Approved :: MIT License",
4040
],
4141
keywords="STAC FastAPI COG",
42-
author=u"Arturo Engineering",
42+
author="Arturo Engineering",
4343
author_email="[email protected]",
4444
url="https://github.com/stac-utils/stac-fastapi",
4545
license="MIT",

stac_fastapi/extensions/stac_fastapi/extensions/core/context.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ class ContextExtension(ApiExtension):
1818
"""
1919

2020
conformance_classes: List[str] = attr.ib(
21-
factory=lambda: ["https://api.stacspec.org/v1.0.0-beta.4/item-search/#context"]
21+
factory=lambda: ["https://api.stacspec.org/v1.0.0-rc.1/item-search#context"]
2222
)
2323
schema_href: Optional[str] = attr.ib(
24-
default="https://raw.githubusercontent.com/radiantearth/stac-api-spec/v1.0.0-beta.4/fragments/context/json-schema/schema.json"
24+
default="https://raw.githubusercontent.com/radiantearth/stac-api-spec/v1.0.0-rc.1/fragments/context/json-schema/schema.json"
2525
)
2626

2727
def register(self, app: FastAPI) -> None:

stac_fastapi/extensions/stac_fastapi/extensions/core/fields/fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class FieldsExtension(ApiExtension):
3030
POST = FieldsExtensionPostRequest
3131

3232
conformance_classes: List[str] = attr.ib(
33-
factory=lambda: ["https://api.stacspec.org/v1.0.0-beta.4/item-search/#fields"]
33+
factory=lambda: ["https://api.stacspec.org/v1.0.0-rc.1/item-search#fields"]
3434
)
3535
default_includes: Set[str] = attr.ib(
3636
factory=lambda: {

stac_fastapi/extensions/stac_fastapi/extensions/core/filter/filter.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,25 @@
1818
class FilterConformanceClasses(str, Enum):
1919
"""Conformance classes for the Filter extension.
2020
21-
See https://github.com/radiantearth/stac-api-spec/tree/v1.0.0-beta.4/fragments/filter
21+
See https://github.com/radiantearth/stac-api-spec/tree/v1.0.0-rc.1/fragments/filter
2222
"""
2323

24-
FILTER = "https://api.stacspec.org/v1.0.0-beta.4/item-search#filter:filter"
24+
FILTER = "https://api.stacspec.org/v1.0.0-rc.1/item-search#filter:filter"
2525
ITEM_SEARCH_FILTER = (
26-
"https://api.stacspec.org/v1.0.0-beta.4/item-search#filter:item-search-filter"
26+
"https://api.stacspec.org/v1.0.0-rc.1/item-search#filter:item-search-filter"
2727
)
28-
CQL_TEXT = "https://api.stacspec.org/v1.0.0-beta.4/item-search#filter:cql-text"
29-
CQL_JSON = "https://api.stacspec.org/v1.0.0-beta.4/item-search#filter:cql-json"
30-
BASIC_CQL = "https://api.stacspec.org/v1.0.0-beta.4/item-search#filter:basic-cql"
31-
BASIC_SPATIAL_OPERATORS = "https://api.stacspec.org/v1.0.0-beta.4/item-search#filter:basic-spatial-operators"
32-
BASIC_TEMPORAL_OPERATORS = "https://api.stacspec.org/v1.0.0-beta.4/item-search#filter:basic-temporal-operators"
33-
ENHANCED_COMPARISON_OPERATORS = "https://api.stacspec.org/v1.0.0-beta.4/item-search#filter:enhanced-comparison-operators"
34-
ENHANCED_SPATIAL_OPERATORS = "https://api.stacspec.org/v1.0.0-beta.4/item-search#filter:enhanced-spatial-operators"
35-
ENHANCED_TEMPORAL_OPERATORS = "https://api.stacspec.org/v1.0.0-beta.4/item-search#filter:enhanced-temporal-operators"
36-
FUNCTIONS = "https://api.stacspec.org/v1.0.0-beta.4/item-search#filter:functions"
37-
ARITHMETIC = "https://api.stacspec.org/v1.0.0-beta.4/item-search#filter:arithmetic"
38-
ARRAYS = "https://api.stacspec.org/v1.0.0-beta.4/item-search#filter:arrays"
39-
QUERYABLE_SECOND_OPERAND = "https://api.stacspec.org/v1.0.0-beta.4/item-search#filter:queryable-second-operand"
28+
CQL_TEXT = "https://api.stacspec.org/v1.0.0-rc.1/item-search#filter:cql-text"
29+
CQL_JSON = "https://api.stacspec.org/v1.0.0-rc.1/item-search#filter:cql-json"
30+
BASIC_CQL = "https://api.stacspec.org/v1.0.0-rc.1/item-search#filter:basic-cql"
31+
BASIC_SPATIAL_OPERATORS = "https://api.stacspec.org/v1.0.0-rc.1/item-search#filter:basic-spatial-operators"
32+
BASIC_TEMPORAL_OPERATORS = "https://api.stacspec.org/v1.0.0-rc.1/item-search#filter:basic-temporal-operators"
33+
ENHANCED_COMPARISON_OPERATORS = "https://api.stacspec.org/v1.0.0-rc.1/item-search#filter:enhanced-comparison-operators"
34+
ENHANCED_SPATIAL_OPERATORS = "https://api.stacspec.org/v1.0.0-rc.1/item-search#filter:enhanced-spatial-operators"
35+
ENHANCED_TEMPORAL_OPERATORS = "https://api.stacspec.org/v1.0.0-rc.1/item-search#filter:enhanced-temporal-operators"
36+
FUNCTIONS = "https://api.stacspec.org/v1.0.0-rc.1/item-search#filter:functions"
37+
ARITHMETIC = "https://api.stacspec.org/v1.0.0-rc.1/item-search#filter:arithmetic"
38+
ARRAYS = "https://api.stacspec.org/v1.0.0-rc.1/item-search#filter:arrays"
39+
QUERYABLE_SECOND_OPERAND = "https://api.stacspec.org/v1.0.0-rc.1/item-search#filter:queryable-second-operand"
4040

4141

4242
@attr.s

0 commit comments

Comments
 (0)