Skip to content

Commit 5f9e145

Browse files
author
Phil Varner
authored
Merge pull request #96 from stac-utils/pv/py310-and-es81
update to python 3.10 and ES 8.x
2 parents c31ae43 + 7953fad commit 5f9e145

File tree

12 files changed

+93
-91
lines changed

12 files changed

+93
-91
lines changed

Diff for: .github/workflows/cicd.yml

+39-29
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,42 @@ jobs:
1515

1616
services:
1717

18-
elasticsearch_7_svc:
19-
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.1
18+
elasticsearch_8_svc:
19+
image: docker.elastic.co/elasticsearch/elasticsearch:8.1.3
2020
env:
21-
node.name: es01
2221
cluster.name: stac-cluster
23-
discovery.type: single-node
22+
node.name: es01
2423
network.host: 0.0.0.0
24+
transport.host: 0.0.0.0
25+
discovery.type: single-node
2526
http.port: 9200
26-
ES_JAVA_OPTS: -Xms512m -Xmx512m
27+
xpack.license.self_generated.type: basic
28+
xpack.security.enabled: false
29+
xpack.security.transport.ssl.enabled: false
30+
ES_JAVA_OPTS: -Xms512m -Xmx1g
2731
ports:
2832
- 9200:9200
2933

30-
# elasticsearch_8_svc:
31-
# image: docker.elastic.co/elasticsearch/elasticsearch:8.1.0
32-
# env:
33-
# node.name: es01
34-
# cluster.name: stac-cluster
35-
# discovery.type: single-node
36-
# network.host: 0.0.0.0
37-
# http.port: 9200
38-
# ES_JAVA_OPTS: -Xms512m -Xmx512m
39-
# ports:
40-
# - 9200:9200
34+
elasticsearch_7_svc:
35+
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.1
36+
env:
37+
cluster.name: stac-cluster
38+
node.name: es01
39+
network.host: 0.0.0.0
40+
transport.host: 0.0.0.0
41+
discovery.type: single-node
42+
http.port: 9400
43+
xpack.license.self_generated.type: basic
44+
xpack.security.enabled: false
45+
xpack.security.transport.ssl.enabled: false
46+
ES_JAVA_OPTS: -Xms512m -Xmx1g
47+
ports:
48+
- 9400:9400
49+
strategy:
50+
matrix:
51+
python-version: [ "3.8", "3.9", "3.10" ]
52+
53+
name: Python ${{ matrix.python-version }} testing
4154

4255
steps:
4356
- name: Check out repository code
@@ -47,8 +60,7 @@ jobs:
4760
- name: Setup Python
4861
uses: actions/setup-python@v3
4962
with:
50-
python-version: "3.8"
51-
63+
python-version: ${{ matrix.python-version }}
5264
- name: Lint code
5365
uses: pre-commit/[email protected]
5466

@@ -65,19 +77,17 @@ jobs:
6577
cd stac_fastapi/elasticsearch && pipenv run pytest -svvv
6678
env:
6779
ENVIRONMENT: testing
68-
# ES_USER: dev
69-
# ES_PASS: stac
7080
ES_PORT: 9200
7181
ES_HOST: 172.17.0.1
7282
ES_USE_SSL: false
7383
ES_VERIFY_CERTS: false
7484

75-
# - name: Run test suite against Elasticsearch 8.x
76-
# run: |
77-
# cd stac_fastapi/elasticsearch && pipenv run pytest -svvv
78-
# env:
79-
# ENVIRONMENT: testing
80-
# ES_USER: dev
81-
# ES_PASS: stac
82-
# ES_PORT: 9400
83-
# ES_HOST: 172.17.0.1
85+
- name: Run test suite against Elasticsearch 8.x
86+
run: |
87+
cd stac_fastapi/elasticsearch && pipenv run pytest -svvv
88+
env:
89+
ENVIRONMENT: testing
90+
ES_PORT: 9400
91+
ES_HOST: 172.17.0.1
92+
ES_USE_SSL: false
93+
ES_VERIFY_CERTS: false

Diff for: .pre-commit-config.yaml

+9-29
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,31 @@
11
repos:
22
- repo: https://github.com/PyCQA/isort
3-
rev: 5.8.0
3+
rev: 5.10.1
44
hooks:
55
- id: isort
6-
language_version: python3.8
76
- repo: https://github.com/psf/black
8-
rev: 20.8b1
7+
rev: 22.3.0
98
hooks:
109
- id: black
1110
args: [ '--safe' ]
12-
language_version: python3.8
1311
- repo: https://gitlab.com/pycqa/flake8
14-
rev: 3.9.0
12+
rev: 4.0.1
1513
hooks:
1614
- id: flake8
17-
language_version: python3.8
1815
args: [
1916
# E501 let black handle all line length decisions
2017
# W503 black conflicts with "line break before operator" rule
2118
# E203 black conflicts with "whitespace before ':'" rule
2219
'--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',
33-
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]
20+
# - repo: https://github.com/pre-commit/mirrors-mypy
21+
# rev: v0.942
22+
# hooks:
23+
# - id: mypy
24+
# args: [--no-strict-optional, --ignore-missing-imports]
4425
- repo: https://github.com/PyCQA/pydocstyle
45-
rev: 6.0.0
26+
rev: 6.1.1
4627
hooks:
4728
- id: pydocstyle
48-
language_version: python3.8
4929
exclude: '.*(test|alembic|scripts).*'
5030
#args: [
5131
# Don't require docstrings for tests

Diff for: CHANGELOG.md

+18-3
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,27 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1111

1212
### Added
1313

14-
- Support for Elasticsearch 7.x or 8.x
15-
1614
### Fixed
1715

1816
- Fixed search intersects query
1917

2018
### Changed
2119

20+
- Default to Python 3.10
21+
- Default to Elasticsearch 8.x
22+
23+
### Removed
24+
25+
## [0.1.0]
26+
27+
### Deprecated
28+
29+
### Added
30+
31+
### Fixed
32+
33+
### Changed
34+
2235
- Elasticsearch index mappings updated to be more thorough.
2336
- Endpoints that return items (e.g., /search) now sort the results by 'properties.datetime,id,collection'.
2437
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.
2841

2942
### Removed
3043

44+
## Versions
3145

32-
[Unreleased]: <https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/main>
46+
- [Unreleased]: <https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v0.1.0...main>
47+
- [v0.1.0]: <https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v0.1.0>

Diff for: Dockerfile.deploy

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.8-slim
1+
FROM python:3.10-slim
22

33
RUN apt-get update && \
44
apt-get -y upgrade && \

Diff for: Dockerfile.dev

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.8-slim
1+
FROM python:3.10-slim
22

33

44
# update apt pkgs, and install build-essential for ciso8601

Diff for: README.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,14 @@ docker-compose build
3737
docker-compose up
3838
```
3939

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

4344
```shell
44-
ELASTICSEARCH_VERSION=7.12.0
45+
ELASTICSEARCH_VERSION=7.17.1
4546
```
4647

47-
TBD: how to run this with 8.x with a password enabled and TLS.
48-
4948
To create a new Collection:
5049

5150
```shell

Diff for: docker-compose.yml

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '3'
1+
version: '3.9'
22

33
services:
44
app-elasticsearch:
@@ -16,8 +16,6 @@ services:
1616
- WEB_CONCURRENCY=10
1717
- ES_HOST=172.17.0.1
1818
- ES_PORT=9200
19-
# - ES_USER=dev
20-
# - ES_PASS=stac
2119
- ES_USE_SSL=false
2220
- ES_VERIFY_CERTS=false
2321
ports:
@@ -33,13 +31,10 @@ services:
3331

3432
elasticsearch:
3533
container_name: es-container
36-
image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-7.17.1}
34+
image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-8.1.3}
3735
environment:
38-
node.name: es01
39-
cluster.name: stac-cluster
40-
discovery.type: single-node
41-
network.host: 0.0.0.0
42-
http.port: 9200
4336
ES_JAVA_OPTS: -Xms512m -Xmx1g
37+
volumes:
38+
- ./elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
4439
ports:
4540
- "9200:9200"

Diff for: elasticsearch/config/elasticsearch.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## Cluster Settings
2+
cluster.name: stac-cluster
3+
node.name: es01
4+
network.host: 0.0.0.0
5+
transport.host: 0.0.0.0
6+
discovery.type: single-node
7+
http.port: 9200
8+
9+
## License
10+
xpack.license.self_generated.type: basic
11+
12+
# Security
13+
xpack.security.enabled: false
14+
xpack.security.transport.ssl.enabled: false

Diff for: stac_fastapi/elasticsearch/setup.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"stac-fastapi.types==2.3.0",
1414
"stac-fastapi.api==2.3.0",
1515
"stac-fastapi.extensions==2.3.0",
16-
"fastapi-utils",
1716
"elasticsearch[async]==7.17.2",
1817
"elasticsearch-dsl==7.4.0",
1918
"pystac[validation]",
@@ -47,6 +46,8 @@
4746
"Intended Audience :: Information Technology",
4847
"Intended Audience :: Science/Research",
4948
"Programming Language :: Python :: 3.8",
49+
"Programming Language :: Python :: 3.9",
50+
"Programming Language :: Python :: 3.10",
5051
"License :: OSI Approved :: MIT License",
5152
],
5253
url="https://github.com/stac-utils/stac-fastapi-elasticsearch",

Diff for: stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/config.py

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from typing import Any, Dict, Set
44

55
from elasticsearch import AsyncElasticsearch, Elasticsearch
6-
76
from stac_fastapi.types.config import ApiSettings
87

98

Diff for: stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/database_logic.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
from typing import Any, Dict, Iterable, List, Optional, Tuple, Type, Union
66

77
import attr
8-
import elasticsearch
9-
from elasticsearch import helpers
108
from elasticsearch_dsl import Q, Search
119
from geojson_pydantic.geometries import (
1210
GeometryCollection,
@@ -18,6 +16,8 @@
1816
Polygon,
1917
)
2018

19+
import elasticsearch
20+
from elasticsearch import helpers
2121
from stac_fastapi.elasticsearch import serializers
2222
from stac_fastapi.elasticsearch.config import AsyncElasticsearchSettings
2323
from stac_fastapi.elasticsearch.config import (

Diff for: stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/session.py

-11
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
11
"""database session management."""
22
import logging
3-
from contextlib import contextmanager
43

54
import attr
6-
from fastapi_utils.session import FastAPISessionMaker as _FastAPISessionMaker
75

86
logger = logging.getLogger(__name__)
97

108

11-
class FastAPISessionMaker(_FastAPISessionMaker):
12-
"""FastAPISessionMaker."""
13-
14-
@contextmanager
15-
def context_session(self):
16-
"""Override base method to include exception handling."""
17-
...
18-
19-
209
@attr.s
2110
class Session:
2211
"""Database session management."""

0 commit comments

Comments
 (0)