Skip to content

Commit e385f14

Browse files
author
Phil Varner
authored
Reformat transactions, add docs, etc. (#45)
*fix type and signature problems with transactions methods, add overrides * add creating collection to Readme
1 parent 8fb8a8e commit e385f14

File tree

7 files changed

+173
-133
lines changed

7 files changed

+173
-133
lines changed

.pre-commit-config.yaml

Lines changed: 51 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,53 @@
11
repos:
2-
- repo: https://github.com/PyCQA/isort
3-
rev: 5.8.0
4-
hooks:
5-
- id: isort
6-
language_version: python3.8
7-
-
8-
repo: https://github.com/psf/black
9-
rev: 20.8b1
10-
hooks:
11-
- id: black
12-
args: ['--safe']
13-
language_version: python3.8
14-
-
15-
repo: https://gitlab.com/pycqa/flake8
16-
rev: 3.9.0
17-
hooks:
18-
- id: flake8
19-
language_version: python3.8
20-
args: [
21-
# E501 let black handle all line length decisions
22-
# W503 black conflicts with "line break before operator" rule
23-
# E203 black conflicts with "whitespace before ':'" rule
24-
'--ignore=E501,W503,E203,C901']
25-
-
26-
repo: https://github.com/chewse/pre-commit-mirrors-pydocstyle
27-
# 2.1.1
28-
rev: v2.1.1
29-
hooks:
30-
- id: pydocstyle
31-
language_version: python3.8
32-
exclude: '.*(test|alembic|scripts).*'
33-
args: [
34-
# Check for docstring presence only
35-
'--select=D1',
2+
- repo: https://github.com/PyCQA/isort
3+
rev: 5.8.0
4+
hooks:
5+
- id: isort
6+
language_version: python3.8
7+
- repo: https://github.com/psf/black
8+
rev: 20.8b1
9+
hooks:
10+
- id: black
11+
args: [ '--safe' ]
12+
language_version: python3.8
13+
- repo: https://gitlab.com/pycqa/flake8
14+
rev: 3.9.0
15+
hooks:
16+
- id: flake8
17+
language_version: python3.8
18+
args: [
19+
# E501 let black handle all line length decisions
20+
# W503 black conflicts with "line break before operator" rule
21+
# E203 black conflicts with "whitespace before ':'" rule
22+
'--ignore=E501,W503,E203,C901' ]
23+
- repo: https://github.com/chewse/pre-commit-mirrors-pydocstyle
24+
# 2.1.1
25+
rev: v2.1.1
26+
hooks:
27+
- id: pydocstyle
28+
language_version: python3.8
29+
exclude: '.*(test|alembic|scripts).*'
30+
args: [
31+
# Check for docstring presence only
32+
'--select=D1',
3633

37-
]
38-
# Don't require docstrings for tests
39-
# '--match=(?!test).*\.py']
40-
# -
41-
# repo: https://github.com/pre-commit/mirrors-mypy
42-
# rev: v0.770
43-
# hooks:
44-
# - id: mypy
45-
# language_version: python3.8
46-
# args: [--no-strict-optional, --ignore-missing-imports]
47-
-
48-
repo: https://github.com/PyCQA/pydocstyle
49-
rev: 6.0.0
50-
hooks:
51-
- id: pydocstyle
52-
language_version: python3.8
53-
exclude: '.*(test|alembic|scripts).*'
54-
#args: [
55-
# Don't require docstrings for tests
56-
#'--match=(?!test|alembic|scripts).*\.py',
57-
#]
34+
]
35+
# Don't require docstrings for tests
36+
# '--match=(?!test).*\.py']
37+
# -
38+
# repo: https://github.com/pre-commit/mirrors-mypy
39+
# rev: v0.770
40+
# hooks:
41+
# - id: mypy
42+
# language_version: python3.8
43+
# args: [--no-strict-optional, --ignore-missing-imports]
44+
- repo: https://github.com/PyCQA/pydocstyle
45+
rev: 6.0.0
46+
hooks:
47+
- id: pydocstyle
48+
language_version: python3.8
49+
exclude: '.*(test|alembic|scripts).*'
50+
#args: [
51+
# Don't require docstrings for tests
52+
#'--match=(?!test|alembic|scripts).*\.py',
53+
#]

Dockerfile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@ FROM python:3.8-slim as base
33
FROM base as builder
44
# Any python libraries that require system libraries to be installed will likely
55
# need the following packages in order to build
6-
RUN apt-get update && apt-get install -y build-essential git
6+
RUN apt-get update && \
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

1013
ARG install_dev_dependencies=true
1114

1215
WORKDIR /app
1316

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

1719
ENV PATH=$PATH:/install/bin
1820

19-
RUN mkdir -p /install && \
20-
pip install -e ./stac_fastapi/elasticsearch[dev,server]
21+
RUN mkdir -p /install
22+
RUN pip install --no-cache-dir -e ./stac_fastapi/elasticsearch[dev,server]

README.md

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,51 @@ Install [pre-commit](https://pre-commit.com/#install).
1010

1111
Prior to commit, run:
1212

13-
```
13+
```shell
1414
pre-commit run --all-files`
1515
```
1616

17+
```shell
18+
cd stac_fastapi/elasticsearch
19+
pip install .[dev]
20+
```
21+
1722
## Building
1823

19-
```
24+
```shell
2025
docker-compose build
2126
```
2227

2328
## Running API on localhost:8083
2429

25-
```
30+
```shell
2631
docker-compose up
2732
```
2833

29-
## Testing
34+
To create a new Collection:
3035

36+
```shell
37+
curl -X "POST" "http://localhost:8083/collections" \
38+
-H 'Content-Type: application/json; charset=utf-8' \
39+
-d $'{
40+
"id": "my_collection"
41+
}'
3142
```
43+
44+
Note: this "Collections Transaction" behavior is not part of the STAC API, but may be soon.
45+
46+
## Testing
47+
48+
```shell
3249
make test
3350
```
3451

3552
## Ingest sample data
3653

37-
```
54+
```shell
3855
make ingest
3956
```
57+
58+
## Elasticsearch Mappings
59+
60+
Mappings apply to search index, not source.

stac_fastapi/elasticsearch/setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"pre-commit",
2828
"requests",
2929
"ciso8601",
30+
"overrides",
3031
],
3132
"docs": ["mkdocs", "mkdocs-material", "pdocs"],
3233
"server": ["uvicorn[standard]>=0.12.0,<0.14.0"],

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/core.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ def get_search(
227227

228228
return resp
229229

230-
def bbox2poly(self, b0, b1, b2, b3):
230+
@staticmethod
231+
def bbox2poly(b0, b1, b2, b3):
231232
"""Transform bbox to polygon."""
232233
poly = [[[b0, b1], [b2, b1], [b2, b3], [b0, b3], [b0, b1]]]
233234
return poly

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ItemSerializer(Serializer):
2424
"""Serialization methods for STAC items."""
2525

2626
@classmethod
27-
def stac_to_db(cls, stac_data: TypedDict, base_url: str) -> stac_types.Item:
27+
def stac_to_db(cls, stac_data: stac_types.Item, base_url: str) -> stac_types.Item:
2828
"""Transform STAC Item to database-ready STAC Item."""
2929
item_links = ItemLinks(
3030
collection_id=stac_data["collection"],

0 commit comments

Comments
 (0)