Skip to content

Commit 25192f3

Browse files
authored
Merge branch 'main' into feature/pgstac/customize-conn-getter
2 parents 435eefe + 4a5d72f commit 25192f3

File tree

19 files changed

+78
-47
lines changed

19 files changed

+78
-47
lines changed

.github/pull_request_template.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
**Related Issue(s):**
1+
**Related Issue(s):**
22

33
- #
44

55
**Description:**
66

7-
87
**PR Checklist:**
98

10-
- [ ] Code is formatted and linted (run `pre-commit run --all-files`)
9+
- [ ] `pre-commit` hooks pass locally
1110
- [ ] Tests pass (run `make test`)
1211
- [ ] Documentation has been updated to reflect changes, if applicable, and docs build successfully (run `make docs`)
13-
- [ ] Changes are added to the [CHANGELOG](https://github.com/stac-utils/stac-fastapi/blob/master/CHANGES.md).
12+
- [ ] Changes are added to the [CHANGELOG](https://github.com/stac-utils/stac-fastapi/blob/main/CHANGES.md).

.github/workflows/cicd.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: stac-fastapi
22
on:
33
push:
4-
branches: [master]
4+
branches: [main]
55
pull_request:
6-
branches: [master]
6+
branches: [main]
77

88
jobs:
99
test:

.github/workflows/deploy_mkdocs.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@ name: Publish docs via GitHub Pages
33
on:
44
push:
55
branches:
6-
- master
6+
- main
77
paths:
88
# Rebuild website when docs have changed or code has changed
9-
- 'README.md'
10-
- 'docs/**'
11-
- 'mkdocs.yml'
12-
- '**.py'
9+
- "README.md"
10+
- "docs/**"
11+
- "mkdocs.yml"
12+
- "**.py"
1313

1414
jobs:
1515
build:
1616
name: Deploy docs
1717
runs-on: ubuntu-latest
1818

1919
steps:
20-
- name: Checkout master
20+
- name: Checkout main
2121
uses: actions/checkout@v3
2222

2323
- name: Set up Python 3.8

.github/workflows/packages.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ name: packages
22
on:
33
push:
44
branches:
5-
- master
5+
- main
66
tags:
77
- "*"
88

99
jobs:
1010
docker-build-push:
1111
runs-on: ubuntu-latest
12-
needs: [test, validate, test-docs]
1312
permissions:
1413
contents: read
1514
packages: write

CHANGES.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
## [Unreleased]
44

5+
## [2.4.5] - 2023-04-04
6+
7+
### Changed
8+
9+
* Default branch to **main** ([#544](https://github.com/stac-utils/stac-fastapi/pull/544))
10+
11+
### Fixed
12+
13+
* Use `V()` instead of f-strings for pgstac queries ([#554](https://github.com/stac-utils/stac-fastapi/pull/554))
14+
15+
## [2.4.4] - 2023-03-09
16+
517
### Added
618

719
* Nginx service as second docker-compose stack to demonstrate proxy ([#503](https://github.com/stac-utils/stac-fastapi/pull/503))
@@ -239,7 +251,9 @@
239251

240252
* First PyPi release!
241253

242-
[Unreleased]: <https://github.com/stac-utils/stac-fastapi/compare/2.4.3..master>
254+
[Unreleased]: <https://github.com/stac-utils/stac-fastapi/compare/2.4.5..main>
255+
[2.4.5]: <https://github.com/stac-utils/stac-fastapi/compare/2.4.4..2.4.5>
256+
[2.4.4]: <https://github.com/stac-utils/stac-fastapi/compare/2.4.3..2.4.4>
243257
[2.4.3]: <https://github.com/stac-utils/stac-fastapi/compare/2.4.2..2.4.3>
244258
[2.4.2]: <https://github.com/stac-utils/stac-fastapi/compare/2.4.1..2.4.2>
245259
[2.4.1]: <https://github.com/stac-utils/stac-fastapi/compare/2.4.0..2.4.1>

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<a href="https://pypi.org/project/stac-fastapi" target="_blank">
1212
<img src="https://img.shields.io/pypi/v/stac-fastapi.api?color=%2334D058&label=pypi%20package" alt="Package version">
1313
</a>
14-
<a href="https://github.com/stac-utils/stac-fastapi/blob/master/LICENSE" target="_blank">
14+
<a href="https://github.com/stac-utils/stac-fastapi/blob/main/LICENSE" target="_blank">
1515
<img src="https://img.shields.io/github/license/stac-utils/stac-fastapi.svg" alt="License">
1616
</a>
1717
</p>
@@ -67,11 +67,11 @@ pip install -e stac_fastapi/pgstac
6767
### Pre-built Docker images
6868

6969
Pre-built images are available from the [Github Container Registry](https://github.com/stac-utils/stac-fastapi/pkgs/container/stac-fastapi).
70-
The latest images are tagged with `master-pgstac` and `master-sqlalchemy`.
70+
The latest images are tagged with `main-pgstac` and `main-sqlalchemy`.
7171
To pull the image to your local system:
7272

7373
```shell
74-
docker pull ghcr.io/stac-utils/stac-fastapi:master-pgstac # or latest-sqlalchemy
74+
docker pull ghcr.io/stac-utils/stac-fastapi:main-pgstac # or main-sqlalchemy
7575
```
7676

7777
This repository provides two example [Docker compose](https://docs.docker.com/compose/) files that demonstrate how you might link the pre-built images with a postgres/pgstac database:

RELEASING.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Releasing
2+
3+
This is a checklist for releasing a new version of **stac-fastapi**.
4+
5+
1. Determine the next version. We currently do not have published versioning guidelines, but there is some text on the subject here: <https://github.com/radiantearth/stac-spec/discussions/1184>.
6+
2. Create a release branch named `release/vX.Y.Z`, where `X.Y.Z` is the new version.
7+
3. Search and replace all instances of the current version number with the new version. As of this writing, there's five different `version.py` files, and one `VERSION` file, in the repo.
8+
4. Update [CHANGES.md](./CHANGES.md) for the new version. Add the appropriate header, and update the links at the bottom of the file.
9+
5. Audit CHANGES.md for completeness and accuracy. Also, ensure that the changes in this version are appropriate for the version number change (i.e. if you're making breaking changes, you should be increasing the `MAJOR` version number).
10+
6. (optional) If you have permissions, run `scripts/publish --test` to test your PyPI publish. If successful, the published packages will be available on <http://test.pypy.org>.
11+
7. Push your release branch, create a PR, and get approval.
12+
8. Once the PR is merged, create a new (annotated, signed) tag on the appropriate commit. Name the tag `X.Y.Z`, and include `vX.Y.Z` as its annotation message.
13+
9. Push your tag to Github, which will kick off the [publishing workflow](.github/workflows/publish.yml).
14+
10. Create a [new release](https://github.com/stac-utils/stac-fastapi/releases/new) targeting the new tag, and use the "Generate release notes" feature to populate the description. Publish the release and mark it as the latest.
15+
11. Publicize the release via the appropriate social channels, including [Gitter](https://matrix.to/#/#SpatioTemporal-Asset-Catalog_python:gitter.im).

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.4.3
1+
2.4.5

docker/docker-compose.pgstac.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: '3'
22
services:
33
stac-fastapi-pgstac:
4-
image: ghcr.io/stac-utils/stac-fastapi:latest-pgstac
4+
image: ghcr.io/stac-utils/stac-fastapi:main-pgstac
55
platform: linux/amd64
66
environment:
77
- APP_HOST=0.0.0.0

docker/docker-compose.sqlalchemy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: '3'
22
services:
33
stac-fastapi-sqlalchemy:
4-
image: ghcr.io/stac-utils/stac-fastapi:latest-sqlalchemy
4+
image: ghcr.io/stac-utils/stac-fastapi:main-sqlalchemy
55
platform: linux/amd64
66
environment:
77
- APP_HOST=0.0.0.0
@@ -32,7 +32,7 @@ services:
3232
command: postgres -N 500
3333

3434
migrate:
35-
image: ghcr.io/stac-utils/stac-fastapi:latest-sqlalchemy
35+
image: ghcr.io/stac-utils/stac-fastapi:main-sqlalchemy
3636
command: bash -c "cd /app && alembic upgrade head"
3737
environment:
3838
- POSTGRES_USER=username
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""library version."""
2-
__version__ = "2.4.3"
2+
__version__ = "2.4.5"

stac_fastapi/api/tests/test_api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ def _assert_dependency_applied(api, routes):
3434
), "Unauthenticated requests should be rejected"
3535
assert response.json() == {"detail": "Not authenticated"}
3636

37-
make_request = getattr(client, route["method"].lower())
3837
path = route["path"].format(
3938
collectionId="test_collection", itemId="test_item"
4039
)
41-
response = make_request(
42-
path,
40+
response = client.request(
41+
method=route["method"].lower(),
42+
url=path,
4343
auth=("bob", "dobbs"),
4444
data='{"dummy": "payload"}',
4545
headers={"content-type": "application/json"},
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""library version."""
2-
__version__ = "2.4.3"
2+
__version__ = "2.4.5"

stac_fastapi/pgstac/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<a href="https://pypi.org/project/stac-fastapi" target="_blank">
1010
<img src="https://img.shields.io/pypi/v/stac-fastapi?color=%2334D058&label=pypi%20package" alt="Package version">
1111
</a>
12-
<a href="https://github.com/stac-utils/stac-fastapi/blob/master/LICENSE" target="_blank">
12+
<a href="https://github.com/stac-utils/stac-fastapi/blob/main/LICENSE" target="_blank">
1313
<img src="https://img.shields.io/github/license/stac-utils/stac-fastapi.svg" alt="Downloads">
1414
</a>
1515
</p>

stac_fastapi/pgstac/stac_fastapi/pgstac/db.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
import attr
88
import orjson
9-
from asyncpg import Connection, exceptions
10-
from buildpg import asyncpg, render
11-
from fastapi import FastAPI, Request
9+
from asyncpg import exceptions, pool
10+
from buildpg import V, asyncpg, render
11+
from fastapi import FastAPI
1212

1313
from stac_fastapi.types.errors import (
1414
ConflictError,
@@ -82,21 +82,25 @@ async def dbfunc(conn: Connection, func: str, arg: Union[str, Dict]):
8282
"""
8383
with translate_pgstac_errors():
8484
if isinstance(arg, str):
85-
q, p = render(
86-
f"""
87-
SELECT * FROM {func}(:item::text);
85+
async with pool.acquire() as conn:
86+
q, p = render(
87+
"""
88+
SELECT * FROM :func(:item::text);
8889
""",
89-
item=arg,
90-
)
91-
return await conn.fetchval(q, *p)
90+
func=V(func),
91+
item=arg,
92+
)
93+
return await conn.fetchval(q, *p)
9294
else:
93-
q, p = render(
94-
f"""
95-
SELECT * FROM {func}(:item::text::jsonb);
95+
async with pool.acquire() as conn:
96+
q, p = render(
97+
"""
98+
SELECT * FROM :func(:item::text::jsonb);
9699
""",
97-
item=json.dumps(arg),
98-
)
99-
return await conn.fetchval(q, *p)
100+
func=V(func),
101+
item=json.dumps(arg),
102+
)
103+
return await conn.fetchval(q, *p)
100104

101105

102106
@contextmanager
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""library version."""
2-
__version__ = "2.4.3"
2+
__version__ = "2.4.5"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""library version."""
2-
__version__ = "2.4.3"
2+
__version__ = "2.4.5"

stac_fastapi/types/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
desc = f.read()
77

88
install_requires = [
9-
"fastapi>=0.73.0,<0.87",
9+
"fastapi>=0.73.0",
1010
"attrs",
1111
"pydantic[dotenv]",
1212
"stac_pydantic==2.0.*",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""library version."""
2-
__version__ = "2.4.3"
2+
__version__ = "2.4.5"

0 commit comments

Comments
 (0)