Skip to content

Commit

Permalink
Merge pull request #96 from stac-utils/pv/py310-and-es81
Browse files Browse the repository at this point in the history
update to python 3.10 and ES 8.x
  • Loading branch information
Phil Varner authored Apr 26, 2022
2 parents c31ae43 + 7953fad commit 5f9e145
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 91 deletions.
68 changes: 39 additions & 29 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,42 @@ jobs:

services:

elasticsearch_7_svc:
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.1
elasticsearch_8_svc:
image: docker.elastic.co/elasticsearch/elasticsearch:8.1.3
env:
node.name: es01
cluster.name: stac-cluster
discovery.type: single-node
node.name: es01
network.host: 0.0.0.0
transport.host: 0.0.0.0
discovery.type: single-node
http.port: 9200
ES_JAVA_OPTS: -Xms512m -Xmx512m
xpack.license.self_generated.type: basic
xpack.security.enabled: false
xpack.security.transport.ssl.enabled: false
ES_JAVA_OPTS: -Xms512m -Xmx1g
ports:
- 9200:9200

# elasticsearch_8_svc:
# image: docker.elastic.co/elasticsearch/elasticsearch:8.1.0
# env:
# node.name: es01
# cluster.name: stac-cluster
# discovery.type: single-node
# network.host: 0.0.0.0
# http.port: 9200
# ES_JAVA_OPTS: -Xms512m -Xmx512m
# ports:
# - 9200:9200
elasticsearch_7_svc:
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.1
env:
cluster.name: stac-cluster
node.name: es01
network.host: 0.0.0.0
transport.host: 0.0.0.0
discovery.type: single-node
http.port: 9400
xpack.license.self_generated.type: basic
xpack.security.enabled: false
xpack.security.transport.ssl.enabled: false
ES_JAVA_OPTS: -Xms512m -Xmx1g
ports:
- 9400:9400
strategy:
matrix:
python-version: [ "3.8", "3.9", "3.10" ]

name: Python ${{ matrix.python-version }} testing

steps:
- name: Check out repository code
Expand All @@ -47,8 +60,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v3
with:
python-version: "3.8"

python-version: ${{ matrix.python-version }}
- name: Lint code
uses: pre-commit/[email protected]

Expand All @@ -65,19 +77,17 @@ jobs:
cd stac_fastapi/elasticsearch && pipenv run pytest -svvv
env:
ENVIRONMENT: testing
# ES_USER: dev
# ES_PASS: stac
ES_PORT: 9200
ES_HOST: 172.17.0.1
ES_USE_SSL: false
ES_VERIFY_CERTS: false

# - name: Run test suite against Elasticsearch 8.x
# run: |
# cd stac_fastapi/elasticsearch && pipenv run pytest -svvv
# env:
# ENVIRONMENT: testing
# ES_USER: dev
# ES_PASS: stac
# ES_PORT: 9400
# ES_HOST: 172.17.0.1
- name: Run test suite against Elasticsearch 8.x
run: |
cd stac_fastapi/elasticsearch && pipenv run pytest -svvv
env:
ENVIRONMENT: testing
ES_PORT: 9400
ES_HOST: 172.17.0.1
ES_USE_SSL: false
ES_VERIFY_CERTS: false
38 changes: 9 additions & 29 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,51 +1,31 @@
repos:
- repo: https://github.com/PyCQA/isort
rev: 5.8.0
rev: 5.10.1
hooks:
- id: isort
language_version: python3.8
- repo: https://github.com/psf/black
rev: 20.8b1
rev: 22.3.0
hooks:
- id: black
args: [ '--safe' ]
language_version: python3.8
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.0
rev: 4.0.1
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/pre-commit/mirrors-mypy
# rev: v0.942
# hooks:
# - id: mypy
# args: [--no-strict-optional, --ignore-missing-imports]
- repo: https://github.com/PyCQA/pydocstyle
rev: 6.0.0
rev: 6.1.1
hooks:
- id: pydocstyle
language_version: python3.8
exclude: '.*(test|alembic|scripts).*'
#args: [
# Don't require docstrings for tests
Expand Down
21 changes: 18 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,27 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Added

- Support for Elasticsearch 7.x or 8.x

### Fixed

- Fixed search intersects query

### Changed

- Default to Python 3.10
- Default to Elasticsearch 8.x

### Removed

## [0.1.0]

### Deprecated

### Added

### Fixed

### Changed

- Elasticsearch index mappings updated to be more thorough.
- Endpoints that return items (e.g., /search) now sort the results by 'properties.datetime,id,collection'.
Previously, there was no sort order defined.
Expand All @@ -28,5 +41,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Removed

## Versions

[Unreleased]: <https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/main>
- [Unreleased]: <https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v0.1.0...main>
- [v0.1.0]: <https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v0.1.0>
2 changes: 1 addition & 1 deletion Dockerfile.deploy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.8-slim
FROM python:3.10-slim

RUN apt-get update && \
apt-get -y upgrade && \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.8-slim
FROM python:3.10-slim


# update apt pkgs, and install build-essential for ciso8601
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,14 @@ docker-compose build
docker-compose up
```

By default, docker-compose uses Elasticsearch 7.x. If you wish to use a different version, put the following in a
By default, docker-compose uses Elasticsearch 8.x. However, most recent 7.x versions should also work.
If you wish to use a different version, put the following in a
file named `.env` in the same directory you run docker-compose from:

```shell
ELASTICSEARCH_VERSION=7.12.0
ELASTICSEARCH_VERSION=7.17.1
```

TBD: how to run this with 8.x with a password enabled and TLS.

To create a new Collection:

```shell
Expand Down
13 changes: 4 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3'
version: '3.9'

services:
app-elasticsearch:
Expand All @@ -16,8 +16,6 @@ services:
- WEB_CONCURRENCY=10
- ES_HOST=172.17.0.1
- ES_PORT=9200
# - ES_USER=dev
# - ES_PASS=stac
- ES_USE_SSL=false
- ES_VERIFY_CERTS=false
ports:
Expand All @@ -33,13 +31,10 @@ services:

elasticsearch:
container_name: es-container
image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-7.17.1}
image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-8.1.3}
environment:
node.name: es01
cluster.name: stac-cluster
discovery.type: single-node
network.host: 0.0.0.0
http.port: 9200
ES_JAVA_OPTS: -Xms512m -Xmx1g
volumes:
- ./elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
ports:
- "9200:9200"
14 changes: 14 additions & 0 deletions elasticsearch/config/elasticsearch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Cluster Settings
cluster.name: stac-cluster
node.name: es01
network.host: 0.0.0.0
transport.host: 0.0.0.0
discovery.type: single-node
http.port: 9200

## License
xpack.license.self_generated.type: basic

# Security
xpack.security.enabled: false
xpack.security.transport.ssl.enabled: false
3 changes: 2 additions & 1 deletion stac_fastapi/elasticsearch/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"stac-fastapi.types==2.3.0",
"stac-fastapi.api==2.3.0",
"stac-fastapi.extensions==2.3.0",
"fastapi-utils",
"elasticsearch[async]==7.17.2",
"elasticsearch-dsl==7.4.0",
"pystac[validation]",
Expand Down Expand Up @@ -47,6 +46,8 @@
"Intended Audience :: Information Technology",
"Intended Audience :: Science/Research",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"License :: OSI Approved :: MIT License",
],
url="https://github.com/stac-utils/stac-fastapi-elasticsearch",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from typing import Any, Dict, Set

from elasticsearch import AsyncElasticsearch, Elasticsearch

from stac_fastapi.types.config import ApiSettings


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
from typing import Any, Dict, Iterable, List, Optional, Tuple, Type, Union

import attr
import elasticsearch
from elasticsearch import helpers
from elasticsearch_dsl import Q, Search
from geojson_pydantic.geometries import (
GeometryCollection,
Expand All @@ -18,6 +16,8 @@
Polygon,
)

import elasticsearch
from elasticsearch import helpers
from stac_fastapi.elasticsearch import serializers
from stac_fastapi.elasticsearch.config import AsyncElasticsearchSettings
from stac_fastapi.elasticsearch.config import (
Expand Down
11 changes: 0 additions & 11 deletions stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/session.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
"""database session management."""
import logging
from contextlib import contextmanager

import attr
from fastapi_utils.session import FastAPISessionMaker as _FastAPISessionMaker

logger = logging.getLogger(__name__)


class FastAPISessionMaker(_FastAPISessionMaker):
"""FastAPISessionMaker."""

@contextmanager
def context_session(self):
"""Override base method to include exception handling."""
...


@attr.s
class Session:
"""Database session management."""
Expand Down

0 comments on commit 5f9e145

Please sign in to comment.