Skip to content
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

Create Common opensearch/ elasticsearch core package #186

Merged
merged 37 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
568b1cf
create three packages scratch
jonhealy1 Jan 31, 2024
c40e122
add scratch setup to opensearch folder
jonhealy1 Jan 31, 2024
5a14447
reorg, working
jonhealy1 Jan 31, 2024
e5d71fd
install core library in cicd
jonhealy1 Jan 31, 2024
33ddeb7
remove core.py from es folder
jonhealy1 Jan 31, 2024
57cfbb7
remove models folder
jonhealy1 Jan 31, 2024
1561dec
remove unused types.search.py
jonhealy1 Jan 31, 2024
cea4735
move extensions folder
jonhealy1 Jan 31, 2024
63aeb07
move serializers, update imports
jonhealy1 Jan 31, 2024
d82267d
add scratch database logic to opensearch folder
jonhealy1 Jan 31, 2024
a8d544e
Merge branch 'main' into common_core
jonhealy1 Feb 2, 2024
980125e
clean up
jonhealy1 Feb 2, 2024
2318d6f
Merge AtomicMaps branch into common_core, reorg code
jonhealy1 Feb 2, 2024
d00ec14
add tests
jonhealy1 Feb 2, 2024
322ff19
update workflow, dockerfiles
jonhealy1 Feb 2, 2024
0ff356f
fix dockerfiles, imports
jonhealy1 Feb 2, 2024
70924ef
update update collection method
jonhealy1 Feb 3, 2024
ae9d6ea
update changelog
jonhealy1 Feb 3, 2024
31dcae9
update makefile
jonhealy1 Feb 3, 2024
aeabc34
separate dockerfiles
jonhealy1 Feb 3, 2024
3c1151b
update readme
jonhealy1 Feb 3, 2024
d32a244
Merge branch 'main' into common_core
jonhealy1 Feb 3, 2024
e530e06
revert changelog
jonhealy1 Feb 3, 2024
73fc73a
revert bbox to polygon
jonhealy1 Feb 3, 2024
dff0a6c
update, clean dependencies
jonhealy1 Feb 4, 2024
5930637
update setup url
jonhealy1 Feb 5, 2024
7e5b618
remove type ignores, clean up
jonhealy1 Feb 5, 2024
0322a8a
remove type ignore, clean up types.core
jonhealy1 Feb 5, 2024
def6cf7
fix package versions
jonhealy1 Feb 5, 2024
1ae8e70
move tests to common folder
jonhealy1 Feb 5, 2024
9f54c9b
delete old test files
jonhealy1 Feb 5, 2024
ef05b93
update readme
jonhealy1 Feb 5, 2024
a8d15dd
Merge branch 'main' into common_core
jonhealy1 Feb 6, 2024
a0b0940
changelog fix
jonhealy1 Feb 6, 2024
3cd75ec
fix brackets
jonhealy1 Feb 6, 2024
6c2df64
makefile fixes
jonhealy1 Feb 6, 2024
d530cb8
remove comment
jonhealy1 Feb 6, 2024
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
16 changes: 13 additions & 3 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,29 +88,39 @@ jobs:
run: |
pip install ./stac_fastapi/elasticsearch[dev,server]
- name: Install opensearch stac-fastapi
run: |
pip install ./stac_fastapi/opensearch[dev,server]
- name: Install core library stac-fastapi
run: |
pip install ./stac_fastapi/core
- name: Run test suite against Elasticsearch 7.x
run: |
cd stac_fastapi/elasticsearch && pipenv run pytest -svvv
pipenv run pytest -svvv
env:
ENVIRONMENT: testing
ES_PORT: 9200
ES_HOST: 172.17.0.1
ES_USE_SSL: false
ES_VERIFY_CERTS: false
BACKEND: elasticsearch

- name: Run test suite against Elasticsearch 8.x
run: |
cd stac_fastapi/elasticsearch && pipenv run pytest -svvv
pipenv run pytest -svvv
env:
ENVIRONMENT: testing
ES_PORT: 9400
ES_HOST: 172.17.0.1
ES_USE_SSL: false
ES_VERIFY_CERTS: false
BACKEND: elasticsearch

- name: Run test suite against OpenSearch 2.11.1
run: |
cd stac_fastapi/elasticsearch && pipenv run pytest -svvv
pipenv run pytest -svvv
env:
ENVIRONMENT: testing
ES_PORT: 9202
Expand Down
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Added

- Added core library package for common logic [#186](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/186)

### Changed

- Moved Elasticsearch and Opensearch backends into separate packages [#186](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/186)

### Fixed

- Allow additional top-level properties on collections [#191](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/191)

## [v1.1.0]

### Added
Expand All @@ -28,7 +34,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Fixed

- Allow additional top-level properties on collections [#191](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/191)
- Exclude unset fields in search response [#166](https://github.com/stac-utils/stac-fastapi-elasticsearch/issues/166)
- Upgrade stac-fastapi to v2.4.9 [#172](https://github.com/stac-utils/stac-fastapi-elasticsearch/pull/172)
- Set correct default filter-lang for GET /search requests [#179](https://github.com/stac-utils/stac-fastapi-elasticsearch/issues/179)
Expand Down Expand Up @@ -115,4 +120,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
[v1.0.0]: <https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v0.3.0...v1.0.0>
[v0.3.0]: <https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v0.2.0...v0.3.0>
[v0.2.0]: <https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v0.1.0...v0.2.0>
[v0.1.0]: <https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v0.1.0>
[v0.1.0]: <https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v0.1.0>
1 change: 1 addition & 0 deletions Dockerfile.deploy → Dockerfile.deploy.es
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ WORKDIR /app

COPY . /app

RUN pip install --no-cache-dir -e ./stac_fastapi/core
RUN pip install --no-cache-dir ./stac_fastapi/elasticsearch[server]

EXPOSE 8080
Expand Down
20 changes: 20 additions & 0 deletions Dockerfile.deploy.os
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM python:3.10-slim

RUN apt-get update && \
apt-get -y upgrade && \
apt-get -y install gcc && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

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

WORKDIR /app

COPY . /app

RUN pip install --no-cache-dir -e ./stac_fastapi/core
RUN pip install --no-cache-dir ./stac_fastapi/opensearch[server]

EXPOSE 8080

CMD ["uvicorn", "stac_fastapi.opensearch.app:app", "--host", "0.0.0.0", "--port", "8080"]
1 change: 1 addition & 0 deletions Dockerfile.dev → Dockerfile.dev.es
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ WORKDIR /app

COPY . /app

RUN pip install --no-cache-dir -e ./stac_fastapi/core
RUN pip install --no-cache-dir -e ./stac_fastapi/elasticsearch[dev,server]
19 changes: 19 additions & 0 deletions Dockerfile.dev.os
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM python:3.10-slim


# update apt pkgs, and install build-essential for ciso8601
RUN apt-get update && \
apt-get -y upgrade && \
apt-get install -y build-essential && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# update certs used by Requests
ENV CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt

WORKDIR /app

COPY . /app

RUN pip install --no-cache-dir -e ./stac_fastapi/core
RUN pip install --no-cache-dir -e ./stac_fastapi/opensearch[dev,server]
50 changes: 33 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#!make
APP_HOST ?= 0.0.0.0
ES_APP_PORT ?= 8080
EXTERNAL_APP_PORT ?= ${APP_PORT}

ES_APP_PORT ?= 8080
ES_HOST ?= docker.for.mac.localhost
ES_PORT ?= 9200

OS_APP_PORT ?= 8082
ES_HOST ?= docker.for.mac.localhost
OS_HOST ?= docker.for.mac.localhost
OS_PORT ?= 9202

run_es = docker-compose \
Expand All @@ -27,9 +26,13 @@ run_os = docker-compose \
-e APP_PORT=${OS_APP_PORT} \
app-opensearch

.PHONY: image-deploy
image-deploy:
docker build -f Dockerfile.deploy -t stac-fastapi-elasticsearch:latest .
.PHONY: image-deploy-es
image-deploy-es:
docker build -f Dockerfile.dev.es -t stac-fastapi-elasticsearch:latest .

.PHONY: image-deploy-os
image-deploy-os:
docker build -f Dockerfile.dev.os -t stac-fastapi-opensearch:latest .

.PHONY: run-deploy-locally
run-deploy-locally:
Expand All @@ -44,30 +47,38 @@ run-deploy-locally:
image-dev:
docker-compose build

.PHONY: docker-run
docker-run: image-dev
.PHONY: docker-run-es
docker-run-es: image-dev
$(run_es)

.PHONY: docker-shell
docker-shell:
.PHONY: docker-run-os
docker-run-os: image-dev
$(run_os)

.PHONY: docker-shell-es
docker-shell-es:
$(run_es) /bin/bash

.PHONY: docker-shell-os
docker-shell-os:
$(run_os) /bin/bash

.PHONY: test-elasticsearch
test:
-$(run_es) /bin/bash -c 'export && ./scripts/wait-for-it-es.sh elasticsearch:9200 && cd /app/stac_fastapi/elasticsearch/tests/ && pytest'
test-elasticsearch:
-$(run_es) /bin/bash -c 'export && ./scripts/wait-for-it-es.sh elasticsearch:9200 && cd stac_fastapi/tests/ && pytest'
docker-compose down

.PHONY: test-opensearch
test-opensearch:
-$(run_os) /bin/bash -c 'export && ./scripts/wait-for-it-es.sh opensearch:9202 && cd /app/stac_fastapi/elasticsearch/tests/ && pytest'
-$(run_os) /bin/bash -c 'export && ./scripts/wait-for-it-es.sh opensearch:9202 && cd stac_fastapi/tests/ && pytest'
docker-compose down

.PHONY: test
test:
-$(run_es) /bin/bash -c 'export && ./scripts/wait-for-it-es.sh elasticsearch:9200 && cd /app/stac_fastapi/elasticsearch/tests/ && pytest'
-$(run_es) /bin/bash -c 'export && ./scripts/wait-for-it-es.sh elasticsearch:9200 && cd stac_fastapi/tests/ && pytest'
docker-compose down

-$(run_os) /bin/bash -c 'export && ./scripts/wait-for-it-es.sh opensearch:9202 && cd /app/stac_fastapi/elasticsearch/tests/ && pytest'
-$(run_os) /bin/bash -c 'export && ./scripts/wait-for-it-es.sh opensearch:9202 && cd stac_fastapi/tests/ && pytest'
docker-compose down

.PHONY: run-database-es
Expand All @@ -83,12 +94,17 @@ pybase-install:
pip install wheel && \
pip install -e ./stac_fastapi/api[dev] && \
pip install -e ./stac_fastapi/types[dev] && \
pip install -e ./stac_fastapi/extensions[dev]
pip install -e ./stac_fastapi/extensions[dev] && \
pip install -e ./stac_fastapi/core

.PHONY: install
install: pybase-install
.PHONY: install-es
install-es: pybase-install
pip install -e ./stac_fastapi/elasticsearch[dev,server]

.PHONY: install-os
install-os: pybase-install
pip install -e ./stac_fastapi/opensearch[dev,server]

.PHONY: ingest
ingest:
python3 data_loader/data_loader.py
33 changes: 23 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
# STAC FastAPI Elasticsearch (sfes)
# stac-fastapi-elasticsearch-opensearch (sfeos)

## Elasticsearch backend for stac-fastapi with Opensearch support
## Elasticsearch and Opensearch backends for the stac-fastapi project

#### Join our [Gitter](https://gitter.im/stac-fastapi-elasticsearch/community) page
[![PyPI version](https://badge.fury.io/py/stac-fastapi.elasticsearch.svg)](https://badge.fury.io/py/stac-fastapi.elasticsearch)

#### Check out the public Postman documentation [Postman](https://documenter.getpostman.com/view/12888943/2s8ZDSdRHA)
To install from PyPI:

#### Check out the examples folder for deployment options, ex. running sfes from pip in docker
```shell
pip install stac_fastapi.elasticsearch
```
or
```
pip install stac_fastapi.opensearch
```

#### For changes, see the [Changelog](CHANGELOG.md)

Expand All @@ -19,6 +25,13 @@ To install the classes in your local Python env, run:
pip install -e 'stac_fastapi/elasticsearch[dev]'
```

or

```shell
pip install -e 'stac_fastapi/opensearch[dev]'
```


### Pre-commit

Install [pre-commit](https://pre-commit.com/#install).
Expand All @@ -29,17 +42,17 @@ Prior to commit, run:
pre-commit run --all-files
```


## Building
## Build Elasticsearh API backend

```shell
docker-compose build
docker-compose up elasticsearch
docker-compose build app-elasticsearch
```

## Running API on localhost:8080
## Running Elasticsearh API on localhost:8080

```shell
docker-compose up
docker-compose up app-elasticsearch
```

By default, docker-compose uses Elasticsearch 8.x and OpenSearch 2.11.1.
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
restart: always
build:
context: .
dockerfile: Dockerfile.dev
dockerfile: Dockerfile.dev.es
environment:
- APP_HOST=0.0.0.0
- APP_PORT=8080
Expand Down Expand Up @@ -36,7 +36,7 @@ services:
restart: always
build:
context: .
dockerfile: Dockerfile.dev
dockerfile: Dockerfile.dev.os
environment:
- APP_HOST=0.0.0.0
- APP_PORT=8082
Expand All @@ -57,7 +57,7 @@ services:
depends_on:
- opensearch
command:
bash -c "./scripts/wait-for-it-es.sh os-container:9202 && python -m stac_fastapi.elasticsearch.app"
bash -c "./scripts/wait-for-it-es.sh os-container:9202 && python -m stac_fastapi.opensearch.app"

elasticsearch:
container_name: es-container
Expand Down
2 changes: 1 addition & 1 deletion examples/pip_docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ WORKDIR /app

COPY . /app

RUN pip install stac-fastapi.elasticsearch==0.3.0
RUN pip install stac-fastapi.elasticsearch==1.1.0
1 change: 1 addition & 0 deletions stac_fastapi/core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# stac-fastapi core library for Elasticsearch and Opensearch backends
2 changes: 2 additions & 0 deletions stac_fastapi/core/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[metadata]
version = attr: stac_fastapi.core.version.__version__
44 changes: 44 additions & 0 deletions stac_fastapi/core/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"""stac_fastapi: core elasticsearch/ opensearch module."""

from setuptools import find_namespace_packages, setup

with open("README.md") as f:
desc = f.read()

install_requires = [
"fastapi",
"attrs",
"pydantic[dotenv]<2",
"stac_pydantic==2.0.*",
"stac-fastapi.types==2.4.9",
"stac-fastapi.api==2.4.9",
"stac-fastapi.extensions==2.4.9",
"pystac[validation]",
"orjson",
"overrides",
"geojson-pydantic",
"pygeofilter==0.2.1",
]

setup(
name="stac-fastapi.core",
description="Core library for the Elasticsearch and Opensearch stac-fastapi backends.",
long_description=desc,
long_description_content_type="text/markdown",
python_requires=">=3.8",
classifiers=[
"Intended Audience :: Developers",
"Intended Audience :: Information Technology",
"Intended Audience :: Science/Research",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"License :: OSI Approved :: MIT License",
],
url="https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch",
license="MIT",
packages=find_namespace_packages(),
zip_safe=False,
install_requires=install_requires,
)
1 change: 1 addition & 0 deletions stac_fastapi/core/stac_fastapi/core/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Core library."""
Loading
Loading