diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index c01e5bb0..d77f9de2 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -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 @@ -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/action@v2.0.3 @@ -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 \ No newline at end of file + - 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 \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b1512306..c0d64cf9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d85589e..b0f380de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. @@ -28,5 +41,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Removed +## Versions -[Unreleased]: +- [Unreleased]: +- [v0.1.0]: diff --git a/Dockerfile.deploy b/Dockerfile.deploy index 29494721..b993db96 100644 --- a/Dockerfile.deploy +++ b/Dockerfile.deploy @@ -1,4 +1,4 @@ -FROM python:3.8-slim +FROM python:3.10-slim RUN apt-get update && \ apt-get -y upgrade && \ diff --git a/Dockerfile.dev b/Dockerfile.dev index 8386471d..4e2f0f4b 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,4 +1,4 @@ -FROM python:3.8-slim +FROM python:3.10-slim # update apt pkgs, and install build-essential for ciso8601 diff --git a/README.md b/README.md index 9aba10f8..55ff008b 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index 7dd9fdec..b624da47 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3' +version: '3.9' services: app-elasticsearch: @@ -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: @@ -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" diff --git a/elasticsearch/config/elasticsearch.yml b/elasticsearch/config/elasticsearch.yml new file mode 100644 index 00000000..88db5cb9 --- /dev/null +++ b/elasticsearch/config/elasticsearch.yml @@ -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 \ No newline at end of file diff --git a/stac_fastapi/elasticsearch/setup.py b/stac_fastapi/elasticsearch/setup.py index a1b0a89f..17c193c9 100644 --- a/stac_fastapi/elasticsearch/setup.py +++ b/stac_fastapi/elasticsearch/setup.py @@ -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]", @@ -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", diff --git a/stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/config.py b/stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/config.py index 3bf62bbc..8c248f47 100644 --- a/stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/config.py +++ b/stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/config.py @@ -3,7 +3,6 @@ from typing import Any, Dict, Set from elasticsearch import AsyncElasticsearch, Elasticsearch - from stac_fastapi.types.config import ApiSettings diff --git a/stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/database_logic.py b/stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/database_logic.py index 859b98f1..48d7cf54 100644 --- a/stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/database_logic.py +++ b/stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/database_logic.py @@ -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, @@ -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 ( diff --git a/stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/session.py b/stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/session.py index 92e4ddee..d5a7aa3c 100644 --- a/stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/session.py +++ b/stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/session.py @@ -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."""