Skip to content

Create shared sfeos helpers module #376

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

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5e99c8a
sfeos helpers module
jonhealy1 May 14, 2025
d3d4b16
move date fns, fliter fns
jonhealy1 May 14, 2025
d5b5009
db logic helpers
jonhealy1 May 15, 2025
8ad2cd6
Merge branch 'main' into sfeos-helpers
jonhealy1 May 16, 2025
14d88b2
update version
jonhealy1 May 16, 2025
67e1c4c
move to_es filter update to sfeos_helpers
jonhealy1 May 16, 2025
7ab88d4
es filter methods to sfeos helpers
jonhealy1 May 16, 2025
820c028
Merge branch 'main' into sfeos-helpers
jonhealy1 May 18, 2025
9ab8e99
create shared filter methods
jonhealy1 May 18, 2025
30ea1c7
shared delete items index
jonhealy1 May 18, 2025
e674381
share aggregations mapping
jonhealy1 May 18, 2025
b956bae
move logic to utilities
jonhealy1 May 18, 2025
149be4e
share queryables mapping
jonhealy1 May 18, 2025
9a68168
organization
jonhealy1 May 19, 2025
c0d5aac
create filter package
jonhealy1 May 19, 2025
a432274
database package
jonhealy1 May 19, 2025
36504af
move utility functions
jonhealy1 May 19, 2025
c39a85d
move return_date
jonhealy1 May 19, 2025
6903791
move format date range
jonhealy1 May 19, 2025
45dee7d
move refactor aggregations
jonhealy1 May 19, 2025
fc1488e
update banner
jonhealy1 May 19, 2025
e58cb68
update banner
jonhealy1 May 19, 2025
1f4e87d
update banner
jonhealy1 May 20, 2025
4664737
revert banner
jonhealy1 May 20, 2025
53c88e3
redesign readme
jonhealy1 May 20, 2025
aa6a256
add descriptions
jonhealy1 May 21, 2025
6426c56
move toc
jonhealy1 May 21, 2025
8fe1927
add readme updates
jonhealy1 May 23, 2025
2a71db9
Merge branch 'main' into sfeos-helpers
jonhealy1 May 23, 2025
7568d0c
add note
jonhealy1 May 23, 2025
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
4 changes: 4 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ jobs:
run: |
pip install ./stac_fastapi/core

- name: Install helpers library stac-fastapi
run: |
pip install ./stac_fastapi/sfeos_helpers

- name: Install elasticsearch stac-fastapi
run: |
pip install ./stac_fastapi/elasticsearch[dev,server]
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ jobs:
# Publish to PyPI
twine upload dist/*

- name: Build and publish sfeos_helpers
working-directory: stac_fastapi/sfeos_helpers
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
# Build package
python setup.py sdist bdist_wheel

# Publish to PyPI
twine upload dist/*

- name: Build and publish stac-fastapi-elasticsearch
working-directory: stac_fastapi/elasticsearch
env:
Expand Down
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,30 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).


## [Unreleased]

### Added

- Created new `sfeos_helpers` package to improve code organization and maintainability [#376](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/376)

### Changed

- Refactored utility functions into dedicated modules within `sfeos_helpers` [#376](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/376):
- Created `database` package with specialized modules for index, document, and utility operations
- Created `aggregation` package for Elasticsearch/OpenSearch-specific aggregation functionality
- Moved shared logic from core module to helper functions for better code reuse
- Separated utility functions from constant mappings for clearer code organization
- Updated documentation to reflect recent code refactoring [#376](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/376)
- Improved README documentation with consistent formatting and enhanced sections [#381](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/381):
- Added sfeos logo and banner
- Added a comprehensive Quick Start guide
- Reorganized sections for better navigation
- Reformatted content with bullet points for improved readability
- Added more detailed examples for API interaction

### Fixed


## [v4.2.0] - 2025-05-15

### Added
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ pybase-install:
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/core
pip install -e ./stac_fastapi/core && \
pip install -e ./stac_fastapi/sfeos_helpers

.PHONY: install-es
install-es: pybase-install
Expand Down
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<!-- markdownlint-disable MD033 MD041 -->



<p align="left">
<img src="assets/sfeos.png" width=1200>
</p>
Expand Down Expand Up @@ -45,6 +44,7 @@ This project is built on the following technologies: STAC, stac-fastapi, FastAPI
## Table of Contents

- [Documentation & Resources](#documentation--resources)
- [Package Structure](#package-structure)
- [Examples](#examples)
- [Performance](#performance)
- [Quick Start](#quick-start)
Expand Down Expand Up @@ -72,6 +72,21 @@ This project is built on the following technologies: STAC, stac-fastapi, FastAPI
- [Gitter Chat](https://app.gitter.im/#/room/#stac-fastapi-elasticsearch_community:gitter.im) - For real-time discussions
- [GitHub Discussions](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/discussions) - For longer-form questions and answers

## Package Structure

This project is organized into several packages, each with a specific purpose:

- **stac_fastapi_core**: Core functionality that's database-agnostic, including API models, extensions, and shared utilities. This package provides the foundation for building STAC API implementations with any database backend. See [stac-fastapi-mongo](https://github.com/Healy-Hyperspatial/stac-fastapi-mongo) for a working example.

- **sfeos_helpers**: Shared helper functions and utilities used by both the Elasticsearch and OpenSearch backends. This package includes:
- `database`: Specialized modules for index, document, and database utility operations
- `aggregation`: Elasticsearch/OpenSearch-specific aggregation functionality
- Shared logic and utilities that improve code reuse between backends

- **stac_fastapi_elasticsearch**: Complete implementation of the STAC API using Elasticsearch as the backend database. This package depends on both `stac_fastapi_core` and `sfeos_helpers`.
-
- **stac_fastapi_opensearch**: Complete implementation of the STAC API using OpenSearch as the backend database. This package depends on both `stac_fastapi_core` and `sfeos_helpers`.

## Examples

The `/examples` directory contains several useful examples and reference implementations:
Expand Down Expand Up @@ -158,6 +173,7 @@ There are two main ways to run the API locally:
- **Compatibility**: The most recent Elasticsearch 7.x versions should also work. See the [opensearch-py docs](https://github.com/opensearch-project/opensearch-py/blob/main/COMPATIBILITY.md) for compatibility information.



## Configuration Reference

You can customize additional settings in your `.env` file:
Expand Down Expand Up @@ -495,5 +511,6 @@ You can customize additional settings in your `.env` file:
- Limits each client to a specified number of requests per time period (e.g., 500 requests per minute)
- Helps prevent API abuse and maintains system stability
- Ensures fair resource allocation among all clients

- **Examples**: Implementation examples are available in the [examples/rate_limit](examples/rate_limit) directory.

1 change: 1 addition & 0 deletions dockerfiles/Dockerfile.ci.es
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ RUN apt-get update && \
COPY . /app/

RUN pip3 install --no-cache-dir -e ./stac_fastapi/core && \
pip3 install --no-cache-dir -e ./stac_fastapi/sfeos_helpers && \
pip3 install --no-cache-dir ./stac_fastapi/elasticsearch[server]

USER root
Expand Down
1 change: 1 addition & 0 deletions dockerfiles/Dockerfile.ci.os
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ RUN apt-get update && \
COPY . /app/

RUN pip3 install --no-cache-dir -e ./stac_fastapi/core && \
pip3 install --no-cache-dir -e ./stac_fastapi/sfeos_helpers && \
pip3 install --no-cache-dir ./stac_fastapi/opensearch[server]

USER root
Expand Down
1 change: 1 addition & 0 deletions dockerfiles/Dockerfile.deploy.es
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ WORKDIR /app
COPY . /app

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

EXPOSE 8080
Expand Down
1 change: 1 addition & 0 deletions dockerfiles/Dockerfile.deploy.os
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ WORKDIR /app
COPY . /app

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

EXPOSE 8080
Expand Down
1 change: 1 addition & 0 deletions dockerfiles/Dockerfile.dev.es
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ WORKDIR /app
COPY . /app

RUN pip install --no-cache-dir -e ./stac_fastapi/core
RUN pip install --no-cache-dir -e ./stac_fastapi/sfeos_helpers
RUN pip install --no-cache-dir -e ./stac_fastapi/elasticsearch[dev,server]
1 change: 1 addition & 0 deletions dockerfiles/Dockerfile.dev.os
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ WORKDIR /app
COPY . /app

RUN pip install --no-cache-dir -e ./stac_fastapi/core
RUN pip install --no-cache-dir -e ./stac_fastapi/sfeos_helpers
RUN pip install --no-cache-dir -e ./stac_fastapi/opensearch[dev,server]
1 change: 1 addition & 0 deletions dockerfiles/Dockerfile.docs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ WORKDIR /opt/src

RUN python -m pip install \
stac_fastapi/core \
stac_fastapi/sfeos_helpers \
stac_fastapi/elasticsearch \
stac_fastapi/opensearch

Expand Down
Loading