Skip to content

Reformat transactions, add docs, etc. #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 51 additions & 55 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,57 +1,53 @@
repos:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just reformatting

- repo: https://github.com/PyCQA/isort
rev: 5.8.0
hooks:
- id: isort
language_version: python3.8
-
repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
args: ['--safe']
language_version: python3.8
-
repo: https://gitlab.com/pycqa/flake8
rev: 3.9.0
hooks:
- id: flake8
language_version: python3.8
args: [
# E501 let black handle all line length decisions
# W503 black conflicts with "line break before operator" rule
# E203 black conflicts with "whitespace before ':'" rule
'--ignore=E501,W503,E203,C901']
-
repo: https://github.com/chewse/pre-commit-mirrors-pydocstyle
# 2.1.1
rev: v2.1.1
hooks:
- id: pydocstyle
language_version: python3.8
exclude: '.*(test|alembic|scripts).*'
args: [
# Check for docstring presence only
'--select=D1',
- repo: https://github.com/PyCQA/isort
rev: 5.8.0
hooks:
- id: isort
language_version: python3.8
- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
args: [ '--safe' ]
language_version: python3.8
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.0
hooks:
- id: flake8
language_version: python3.8
args: [
# E501 let black handle all line length decisions
# W503 black conflicts with "line break before operator" rule
# E203 black conflicts with "whitespace before ':'" rule
'--ignore=E501,W503,E203,C901' ]
- repo: https://github.com/chewse/pre-commit-mirrors-pydocstyle
# 2.1.1
rev: v2.1.1
hooks:
- id: pydocstyle
language_version: python3.8
exclude: '.*(test|alembic|scripts).*'
args: [
# Check for docstring presence only
'--select=D1',

]
# Don't require docstrings for tests
# '--match=(?!test).*\.py']
# -
# repo: https://github.com/pre-commit/mirrors-mypy
# rev: v0.770
# hooks:
# - id: mypy
# language_version: python3.8
# args: [--no-strict-optional, --ignore-missing-imports]
-
repo: https://github.com/PyCQA/pydocstyle
rev: 6.0.0
hooks:
- id: pydocstyle
language_version: python3.8
exclude: '.*(test|alembic|scripts).*'
#args: [
# Don't require docstrings for tests
#'--match=(?!test|alembic|scripts).*\.py',
#]
]
# Don't require docstrings for tests
# '--match=(?!test).*\.py']
# -
# repo: https://github.com/pre-commit/mirrors-mypy
# rev: v0.770
# hooks:
# - id: mypy
# language_version: python3.8
# args: [--no-strict-optional, --ignore-missing-imports]
- repo: https://github.com/PyCQA/pydocstyle
rev: 6.0.0
hooks:
- id: pydocstyle
language_version: python3.8
exclude: '.*(test|alembic|scripts).*'
#args: [
# Don't require docstrings for tests
#'--match=(?!test|alembic|scripts).*\.py',
#]
10 changes: 6 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ FROM python:3.8-slim as base
FROM base as builder
# Any python libraries that require system libraries to be installed will likely
# need the following packages in order to build
RUN apt-get update && apt-get install -y build-essential git
RUN apt-get update && \
apt-get install -y build-essential git && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

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

ARG install_dev_dependencies=true

WORKDIR /app

# Install stac_fastapi.types
COPY . /app

ENV PATH=$PATH:/install/bin

RUN mkdir -p /install && \
pip install -e ./stac_fastapi/elasticsearch[dev,server]
RUN mkdir -p /install
RUN pip install --no-cache-dir -e ./stac_fastapi/elasticsearch[dev,server]
31 changes: 26 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,51 @@ Install [pre-commit](https://pre-commit.com/#install).

Prior to commit, run:

```
```shell
pre-commit run --all-files`
```

```shell
cd stac_fastapi/elasticsearch
pip install .[dev]
```

## Building

```
```shell
docker-compose build
```

## Running API on localhost:8083

```
```shell
docker-compose up
```

## Testing
To create a new Collection:

```shell
curl -X "POST" "http://localhost:8083/collections" \
-H 'Content-Type: application/json; charset=utf-8' \
-d $'{
"id": "my_collection"
}'
```

Note: this "Collections Transaction" behavior is not part of the STAC API, but may be soon.

## Testing

```shell
make test
```

## Ingest sample data

```
```shell
make ingest
```

## Elasticsearch Mappings

Mappings apply to search index, not source.
1 change: 1 addition & 0 deletions stac_fastapi/elasticsearch/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"pre-commit",
"requests",
"ciso8601",
"overrides",
],
"docs": ["mkdocs", "mkdocs-material", "pdocs"],
"server": ["uvicorn[standard]>=0.12.0,<0.14.0"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ def get_search(

return resp

def bbox2poly(self, b0, b1, b2, b3):
@staticmethod
def bbox2poly(b0, b1, b2, b3):
"""Transform bbox to polygon."""
poly = [[[b0, b1], [b2, b1], [b2, b3], [b0, b3], [b0, b1]]]
return poly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ItemSerializer(Serializer):
"""Serialization methods for STAC items."""

@classmethod
def stac_to_db(cls, stac_data: TypedDict, base_url: str) -> stac_types.Item:
def stac_to_db(cls, stac_data: stac_types.Item, base_url: str) -> stac_types.Item:
"""Transform STAC Item to database-ready STAC Item."""
item_links = ItemLinks(
collection_id=stac_data["collection"],
Expand Down
Loading