Skip to content

Commit 16c222c

Browse files
authored
Merge pull request #18 from stac-utils/tests/rde/ingest-issue
Add dockerized development environment; pypgstac testing; CI - fix issue with ingest
2 parents cb03727 + d999dac commit 16c222c

File tree

26 files changed

+681
-87
lines changed

26 files changed

+681
-87
lines changed

.flake8

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[flake8]
2+
max-line-length = 88
3+
extend-ignore = E203, W503, E731, E722
4+
per-file-ignores = __init__.py:F401
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
test:
11+
name: test
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Execute linters and test suites
16+
run: ./scripts/cibuild

.github/workflows/release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
8+
jobs:
9+
release:
10+
name: release
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
15+
- name: Set up Python 3.x
16+
uses: actions/setup-python@v2
17+
with:
18+
python-version: "3.x"
19+
20+
- name: Install release dependencies
21+
run: |
22+
python -m pip install --upgrade pip
23+
pip install setuptools wheel twine
24+
25+
- name: Build and publish package
26+
env:
27+
TWINE_USERNAME: ${{ secrets.PYPI_STACUTILS_USERNAME }}
28+
TWINE_PASSWORD: ${{ secrets.PYPI_STACUTILS_PASSWORD }}
29+
run: |
30+
scripts/cipublish

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
.envrc
22
pypgstac/dist
3+
*.pyc
4+
*.egg-info
5+
*.eggs
6+
venv

Dockerfile.dev

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM python:3.8-slim
2+
3+
ENV CURL_CA_BUNDLE /etc/ssl/certs/ca-certificates.crt
4+
5+
RUN mkdir -p /opt/src/pypgstac
6+
7+
WORKDIR /opt/src/pypgstac
8+
9+
COPY pypgstac/requirements-dev.txt /opt/src/pypgstac/requirements-dev.txt
10+
RUN pip install -r requirements-dev.txt
11+
12+
COPY pypgstac /opt/src/pypgstac
13+
RUN pip install .
14+
15+
ENV PYTHONPATH=/opt/src/pypgstac:${PYTHONPATH}
16+
17+
WORKDIR /opt/src

README.md

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ poetry build pypgstac
2020
pip install dist/pypgstac-[version]-py3-none-any.whl
2121
```
2222

23-
# Migrations
23+
## Migrations
2424
To install the latest version of pgstac on an empty database, you can directly load the primary source code.
2525
```
2626
psql -f pgstac.sql
@@ -33,20 +33,20 @@ For each new version of PGStac, two migrations should be added to pypgstac/pypgs
3333
- pgstac.[version].sql (equivalent to `cat sql/*.sql > migration.sql && echo "insert into migrations (versions) VALUES ('[version]')" >> migration.sql)
3434
- pgstac.[version].[fromversion].sql (Migration to move from existing version to new version, can be created by hand or using the makemigration.sh tool below)
3535

36-
## Running Migrations
36+
### Running Migrations
3737
Migrations can be installed by either directly running the appropriate migration sql file for from and target PGStac versions:
3838
`psql -f pypgstac/pypgstac/migrations/pgstac.0.1.8.sql`
3939

4040
Or by using pypgstac:
4141
`pypgstac migrate`
4242

43-
## Creating Migrations Using Schema Diff
43+
### Creating Migrations Using Schema Diff
4444
To create a migration from a previous version of pgstac you can calculate the migration from the running instance of pgstac using the makemigration.sh command. This will use docker to copy the schema of the existing database and the new sql into new docker databases and create/test the migration between the two.
4545
```
4646
makemigration.sh postgresql://myuser:mypassword@myhost:myport/mydatabase
4747
```
4848

49-
# Bulk Data Loading
49+
## Bulk Data Loading
5050
A python utility is included which allows to load data from any source openable by smart-open using python in a memory efficient streaming manner using PostgreSQL copy. There are options for collections and items and can be used either as a command line or a library.
5151

5252
To load an ndjson of items directly using copy (will fail on any duplicate ids but is the fastest option to load new data you know will not conflict)
@@ -63,3 +63,41 @@ To upsert any records, adding anything new and replacing anything with the same
6363
```
6464
pypgstac load items --method upsert
6565
```
66+
67+
## Development
68+
69+
PGStac uses a dockerized development environment. You can set this up using:
70+
71+
```bash
72+
scripts/setup
73+
```
74+
75+
To bring up the development database:
76+
```
77+
scripts/server
78+
```
79+
80+
To run tests, use:
81+
```bash
82+
scripts/test
83+
```
84+
85+
To rebuild docker images:
86+
```bash
87+
scripts/update
88+
```
89+
90+
To drop into a console, use
91+
```bash
92+
scripts/console
93+
```
94+
95+
To drop into a psql console on the database container, use:
96+
```bash
97+
scripts/console --db
98+
```
99+
100+
To run migrations on the development database, use
101+
```bash
102+
scripts/migrate
103+
```

docker-compose.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
services:
2+
dev:
3+
container_name: pgstac-dev
4+
image: pgstac-dev
5+
build:
6+
context: .
7+
dockerfile: Dockerfile.dev
8+
depends_on:
9+
- database
10+
volumes:
11+
- ./:/opt/src
12+
environment:
13+
- PGUSER=username
14+
- PGPASSWORD=password
15+
- PGHOST=database
16+
- PGDATABASE=postgis
17+
database:
18+
container_name: pgstac-db
19+
image: pgstac-db
20+
build:
21+
context: .
22+
dockerfile: Dockerfile
23+
environment:
24+
- POSTGRES_USER=username
25+
- POSTGRES_PASSWORD=password
26+
- POSTGRES_DB=postgis
27+
ports:
28+
- "5432:5432"
29+
volumes:
30+
- pgstac-pgdata:/var/lib/postgresql/data
31+
- ./:/opt/src
32+
volumes:
33+
pgstac-pgdata:

mypy.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[mypy]
2+
ignore_missing_imports = True
3+
disallow_untyped_defs = True
4+
namespace_packages = True

pgstac.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ BEGIN;
33
\i sql/002_collections.sql
44
\i sql/003_items.sql
55
\i sql/004_search.sql
6+
\i sql/999_version.sql
67
COMMIT;

pypgstac/pypgstac/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.2.7'
1+
__version__ = "0.2.7"

0 commit comments

Comments
 (0)