Skip to content

Commit 3a4ecc6

Browse files
authored
fix, docs, ci: readme, packaging, python versions
* docs: update readme * ci: fixup packages CI * ci: fixup doc building and python versions * docs, fix: review suggestions
1 parent ebeb7b9 commit 3a4ecc6

File tree

5 files changed

+110
-75
lines changed

5 files changed

+110
-75
lines changed

.github/workflows/cicd.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ jobs:
4646
uses: actions/setup-python@v4
4747
with:
4848
python-version: ${{ matrix.python-version }}
49+
cache: pip
50+
cache-dependency-path: setup.py
4951

5052
- name: Lint code
5153
if: ${{ matrix.python-version == 3.8 }}
@@ -96,7 +98,7 @@ jobs:
9698
with:
9799
python-version: "3.10"
98100
cache: pip
99-
cache-dependency-path: setup.cfg
101+
cache-dependency-path: setup.py
100102
- name: Install stac-fastapi and stac-api-validator
101103
run: pip install .[server] stac-api-validator==0.4.1
102104
- name: Load data and validate
@@ -118,5 +120,15 @@ jobs:
118120
runs-on: ubuntu-latest
119121
steps:
120122
- uses: actions/checkout@v3
121-
- name: Test generating docs
123+
- name: Setup Python
124+
uses: actions/setup-python@v3
125+
with:
126+
python-version: "3.10"
127+
cache: pip
128+
cache-dependency-path: setup.py
129+
- name: Install with documentation dependencies
130+
run: pip install .[docs,dev,server]
131+
- name: Generate API docs
122132
run: make docs
133+
- name: Build documentation
134+
run: mkdocs build --strict

.github/workflows/packages.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@ on:
55
- main
66
tags:
77
- "*"
8+
workflow_dispatch:
89

910
jobs:
1011
docker-build-push:
1112
runs-on: ubuntu-latest
1213
permissions:
1314
contents: read
1415
packages: write
15-
strategy:
16-
fail-fast: true
17-
matrix:
18-
backend: ["sqlalchemy", "pgstac"]
1916
steps:
2017
- name: Checkout repository
2118
uses: actions/checkout@v3
@@ -29,17 +26,12 @@ jobs:
2926
id: meta
3027
uses: docker/[email protected]
3128
with:
32-
images: ghcr.io/stac-utils/stac-fastapi
33-
tags: |
34-
type=schedule,suffix=-${{ matrix.backend }}
35-
type=ref,event=branch,suffix=-${{ matrix.backend }}
36-
type=ref,event=tag,suffix=-${{ matrix.backend }}
37-
type=ref,event=pr,suffix=-${{ matrix.backend }}
29+
images: ghcr.io/stac-utils/stac-fastapi-pgstac
3830
- name: Build and push Docker image
3931
uses: docker/[email protected]
4032
with:
4133
context: .
42-
file: docker/Dockerfile.${{ matrix.backend }}
34+
file: docker/Dockerfile
4335
push: true
4436
tags: ${{ steps.meta.outputs.tags }}
4537
labels: ${{ steps.meta.outputs.labels }}
Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
name: Publish docs via GitHub Pages
1+
name: Deploy static content to Pages
22

33
on:
44
push:
55
branches:
66
- main
7-
paths:
8-
# Rebuild website when docs have changed or code has changed
9-
- "README.md"
10-
- "docs/**"
11-
- "mkdocs.yml"
12-
- "**.py"
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
concurrency:
15+
group: "pages"
16+
cancel-in-progress: false
1317

1418
jobs:
1519
build:
@@ -19,18 +23,18 @@ jobs:
1923
steps:
2024
- name: Checkout main
2125
uses: actions/checkout@v3
22-
23-
- name: Set up Python 3.8
26+
- name: Setup Pages
27+
uses: actions/configure-pages@v3
28+
- name: Set up Python 3.10
2429
uses: actions/setup-python@v4
2530
with:
26-
python-version: 3.8
27-
31+
python-version: 3.10
32+
cache: pip
33+
cache-dependency-path: setup.py
2834
- name: Install dependencies
2935
run: |
3036
python -m pip install --upgrade pip
31-
python -m pip install -e .
32-
python -m pip install mkdocs mkdocs-material pdocs
33-
37+
python -m pip install -e .[docs]
3438
- name: Update API docs
3539
run: |
3640
pdocs as_markdown \
@@ -46,6 +50,12 @@ jobs:
4650
POSTGRES_PORT: 5432
4751
POSTGRES_HOST_READER: localhost
4852
POSTGRES_HOST_WRITER: localhost
49-
50-
- name: Deploy docs
51-
run: mkdocs gh-deploy --force
53+
- name: Build docs
54+
run: mkdocs build --site-dir site
55+
- name: Upload artifact
56+
uses: actions/upload-pages-artifact@v1
57+
with:
58+
path: site
59+
- name: Deploy to GitHub Pages
60+
id: deployment
61+
uses: actions/deploy-pages@v2

.github/workflows/publish.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,17 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v3
14-
1514
- name: Set up Python 3.x
1615
uses: actions/setup-python@v4
1716
with:
1817
python-version: "3.x"
19-
2018
- name: Install release dependencies
2119
run: |
2220
python -m pip install --upgrade pip
2321
pip install setuptools wheel twine
24-
2522
- name: Build and publish package
2623
env:
2724
TWINE_USERNAME: ${{ secrets.PYPI_STACUTILS_USERNAME }}
2825
TWINE_PASSWORD: ${{ secrets.PYPI_STACUTILS_PASSWORD }}
2926
run: |
30-
scripts/publish
27+
scripts/publish

README.md

Lines changed: 65 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,90 @@
1+
# stac-fastapi-pgstac
2+
3+
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/stac-utils/stac-fastapi-pgstac/cicd.yaml?style=for-the-badge)](https://github.com/stac-utils/stac-fastapi-pgstac/actions/workflows/cicd.yaml)
4+
[![PyPI](https://img.shields.io/pypi/v/stac-fastapi.pgstac?style=for-the-badge)](https://pypi.org/project/stac-fastapi.pgstac)
5+
[![Documentation](https://img.shields.io/github/actions/workflow/status/stac-utils/stac-fastapi-pgstac/pages.yml?label=Docs&style=for-the-badge)](https://stac-utils.github.io/stac-fastapi-pgstac/)
6+
[![License](https://img.shields.io/github/license/stac-utils/stac-fastapi-pgstac?style=for-the-badge)](https://github.com/stac-utils/stac-fastapi-pgstac/blob/main/LICENSE)
7+
18
<p align="center">
2-
<img src="https://github.com/radiantearth/stac-site/raw/master/images/logo/stac-030-long.png" width=400>
3-
<p align="center">FastAPI implemention of the STAC API spec using <a href="https://github.com/stac-utils/pgstac">PGStac</a></p>
4-
</p>
5-
<p align="center">
6-
<a href="https://github.com/stac-utils/stac-fastapi/actions?query=workflow%3Acicd" target="_blank">
7-
<img src="https://github.com/stac-utils/stac-fastapi/workflows/stac-fastapi/badge.svg" alt="Test">
8-
</a>
9-
<a href="https://pypi.org/project/stac-fastapi" target="_blank">
10-
<img src="https://img.shields.io/pypi/v/stac-fastapi?color=%2334D058&label=pypi%20package" alt="Package version">
11-
</a>
12-
<a href="https://github.com/stac-utils/stac-fastapi/blob/main/LICENSE" target="_blank">
13-
<img src="https://img.shields.io/github/license/stac-utils/stac-fastapi.svg" alt="Downloads">
14-
</a>
9+
<img src="https://user-images.githubusercontent.com/10407788/174893876-7a3b5b7a-95a5-48c4-9ff2-cc408f1b6af9.png" style="vertical-align: middle; max-width: 400px; max-height: 100px;" height=100 />
10+
<img src="https://fastapi.tiangolo.com/img/logo-margin/logo-teal.png" alt="FastAPI" style="vertical-align: middle; max-width: 400px; max-height: 100px;" width=200 />
1511
</p>
1612

17-
---
13+
[PgSTAC](https://github.com/stac-utils/pgstac) backend for [stac-fastapi](https://github.com/stac-utils/stac-fastapi), the [FastAPI](https://fastapi.tiangolo.com/) implementation of the [STAC API spec](https://github.com/radiantearth/stac-api-spec)
1814

19-
**Documentation**: [https://stac-utils.github.io/stac-fastapi/](https://stac-utils.github.io/stac-fastapi/)
15+
## Overview
2016

21-
**Source Code**: [https://github.com/stac-utils/stac-fastapi](https://github.com/stac-utils/stac-fastapi)
17+
**stac-fastapi-pgstac** is an HTTP interface built in FastAPI.
18+
It validates requests and data sent to a [PgSTAC](https://github.com/stac-utils/pgstac) backend, and adds [links](https://github.com/radiantearth/stac-spec/blob/master/item-spec/item-spec.md#link-object) to the returned data.
19+
All other processing and search is provided directly using PgSTAC procedural sql / plpgsql functions on the database.
20+
PgSTAC stores all collection and item records as jsonb fields exactly as they come in allowing for any custom fields to be stored and retrieved transparently.
2221

23-
---
22+
## Usage
2423

25-
Stac FastAPI using the [PGStac](https://github.com/stac-utils/pgstac) backend.
24+
PgSTAC is an external project and may be used by multiple front ends.
25+
For Stac FastAPI development, a Docker image (which is pulled as part of the docker-compose) is available via the [Github container registry](https://github.com/stac-utils/pgstac/pkgs/container/pgstac/81689794?tag=latest).
26+
The PgSTAC version required by **stac-fastapi-pgstac** is found in the [setup](http://github.com/stac-utils/stac-fastapi-pgstac/blob/main/setup.py) file.
2627

27-
[PGStac](https://github.com/stac-utils/pgstac) is a separately managed PostgreSQL database that is designed for enhanced performance to be able to scale Stac FastAPI to be able to efficiently handle hundreds of millions of records. [PGStac](https://github.com/stac-utils/pgstac) automatically includes indexes on Item id, Collection id, Item Geometry, Item Datetime, and an Index for equality checks on any key in Item Properties. Additional indexes may be added to Item Properties to speed up the use of order, <, <=, >, and >= queries.
28+
### Sorting
2829

29-
Stac FastAPI acts as the HTTP interface validating any requests and data that is sent to the [PGStac](https://github.com/stac-utils/pgstac) backend and adds in Link items on data return relative to the service host. All other processing and search is provided directly using PGStac procedural sql / plpgsql functions on the database.
30+
While the STAC [Sort Extension](https://github.com/stac-api-extensions/sort) is fully supported, [PgSTAC](https://github.com/stac-utils/pgstac) is particularly enhanced to be able to sort by datetime (either ascending or descending).
31+
Sorting by anything other than datetime (the default if no sort is specified) on very large STAC repositories without very specific query limits (ie selecting a single day date range) will not have the same performance.
32+
For more than millions of records it is recommended to either set a low connection timeout on PostgreSQL or to disable use of the Sort Extension.
3033

31-
PGStac stores all collection and item records as jsonb fields exactly as they come in allowing for any custom fields to be stored and retrieved transparently.
34+
### Hydration
3235

33-
While the Stac Sort Extension is fully supported, [PGStac](https://github.com/stac-utils/pgstac) is particularly enhanced to be able to sort by datetime (either ascending or descending). Sorting by anything other than datetime (the default if no sort is specified) on very large Stac repositories without very specific query limits (ie selecting a single day date range) will not have the same performance. For more than millions of records it is recommended to either set a low connection timeout on PostgreSQL or to disable use of the Sort Extension.
36+
To configure **stac-fastapi-pgstac** to [hydrate search result items in the API](https://stac-utils.github.io/pgstac/pgstac/#runtime-configurations), set the `USE_API_HYDRATE` environment variable to `true` or explicitly set the option in the PGStac Settings object.
3437

35-
`stac-fastapi pgstac` was initially added to `stac-fastapi` by [developmentseed](https://github.com/developmentseed).
38+
### Migrations
3639

37-
## Installation
40+
There is a Python utility as part of PgSTAC ([pypgstac](https://stac-utils.github.io/pgstac/pypgstac/)) that includes a migration utility.
41+
To use:
3842

3943
```shell
40-
git clone https://github.com/stac-utils/stac-fastapi.git
41-
cd stac-fastapi
42-
pip install -e \
43-
stac_fastapi/api[dev] \
44-
stac_fastapi/types[dev] \
45-
stac_fastapi/extensions[dev] \
46-
stac_fastapi/pgstac[dev,server]
44+
pypgstac migrate
4745
```
4846

49-
### Settings
47+
## Contributing
5048

51-
To configure PGStac stac-fastapi to [hydrate search result items in the API](https://github.com/stac-utils/pgstac#runtime-configurations), set the `USE_API_HYDRATE` environment variable to `true` or explicitly set the option in the PGStac Settings object.
49+
See [CONTRIBUTING](https://github.com/stac-utils/stac-fastapi-pgstac/blob/main/CONTRIBUTING.md) for detailed contribution instructions.
5250

53-
### Migrations
51+
To install:
52+
53+
```shell
54+
git clone https://github.com/stac-utils/stac-fastapi-pgstac
55+
cd stac-fastapi-pgstac
56+
pip install -e ".[dev,server,docs]"
57+
```
58+
59+
To test:
60+
61+
```shell
62+
make test
63+
```
5464

55-
PGStac is an external project and the may be used by multiple front ends.
56-
For Stac FastAPI development, a docker image (which is pulled as part of the docker-compose) is available at
57-
bitner/pgstac:[version] that has the full database already set up for PGStac.
65+
Use Github [Pull Requests](https://github.com/stac-utils/stac-fastapi-pgstac/pulls) to provide new features or to request review of draft code, and use [Issues](https://github.com/stac-utils/stac-fastapi-pgstac/issues) to report bugs or request new features.
5866

59-
There is also a python utility as part of PGStac (pypgstac) that includes a migration utility. The pgstac
60-
version required by stac-fastapi/pgstac is pinned by using the pinned version of pypgstac in the [setup](http://github.com/stac-utils/stac-fastapi-pgstac/blob/main/setup.py) file.
67+
### Documentation
6168

62-
In order to migrate database versions you can use the migration utility:
69+
To build the docs:
6370

6471
```shell
65-
pypgstac migrate
72+
make docs
73+
```
74+
75+
Then, serve the docs via a local HTTP server:
76+
77+
```shell
78+
mkdocs serve
6679
```
80+
81+
## History
82+
83+
**stac-fastapi-pgstac** was initially added to **stac-fastapi** by [developmentseed](https://github.com/developmentseed).
84+
In April of 2023, it was removed from the core **stac-fastapi** repository and moved to its current location (<http://github.com/stac-util/stac-fastapi-pgstac>).
85+
86+
## License
87+
88+
[MIT](https://github.com/stac-utils/stac-fastapi-pgstac/blob/main/LICENSE)
89+
90+
<!-- markdownlint-disable-file MD033 -->

0 commit comments

Comments
 (0)