diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index b15494c4..85a7ca60 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -12,10 +12,9 @@ on: jobs: test: runs-on: ubuntu-latest - timeout-minutes: 10 + timeout-minutes: 20 services: - elasticsearch_8_svc: image: docker.elastic.co/elasticsearch/elasticsearch:8.11.0 env: @@ -63,22 +62,31 @@ jobs: OPENSEARCH_JAVA_OPTS: -Xms512m -Xmx512m ports: - 9202:9202 + strategy: matrix: python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12"] + backend: [ "elasticsearch7", "elasticsearch8", "opensearch"] - name: Python ${{ matrix.python-version }} testing + name: Python ${{ matrix.python-version }} testing with ${{ matrix.backend }} steps: - name: Check out repository code uses: actions/checkout@v4 - # Setup Python (faster than using Python container) - name: Setup Python uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + - name: Cache pipenv packages + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/Pipfile.lock') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Lint code if: ${{ matrix.python-version == 3.11 }} run: | @@ -101,35 +109,17 @@ jobs: run: | pip install ./stac_fastapi/opensearch[dev,server] - - name: Run test suite against Elasticsearch 7.x - run: | - 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 Elasticsearch 8.x + - name: Install pytest-timeout run: | - 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 + pip install pytest-timeout - - name: Run test suite against OpenSearch 2.11.1 + - name: Run test suite run: | - pipenv run pytest -svvv + pipenv run pytest -svvv --timeout=300 env: ENVIRONMENT: testing - ES_PORT: 9202 + ES_PORT: ${{ matrix.backend == 'elasticsearch7' && '9400' || matrix.backend == 'elasticsearch8' && '9200' || '9202' }} ES_HOST: 172.17.0.1 ES_USE_SSL: false ES_VERIFY_CERTS: false - BACKEND: opensearch \ No newline at end of file + BACKEND: ${{ matrix.backend == 'elasticsearch7' && 'elasticsearch' || matrix.backend == 'elasticsearch8' && 'elasticsearch' || 'opensearch' }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 870366c9..1c2dbd1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,11 @@ 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] +## [v3.0.0] - 2024-08-14 ### Changed - Aggregation bug fixes [#281](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/281) +- Updated stac-fastapi libraries to v3.0.0 [#282](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/282) ## [v3.0.0a3] - 2024-07-17 @@ -238,11 +239,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Added db_to_stac serializer to item_collection method in core.py. -[Unreleased]: -[v3.0.0a3]: -[v3.0.0a2]: -[v3.0.0a1]: -[v3.0.0a0]: +[Unreleased]: +[v3.0.0]: [v2.4.1]: [v2.4.0]: [v2.3.0]: diff --git a/stac_fastapi/core/setup.py b/stac_fastapi/core/setup.py index bb894b9b..ac16bfc8 100644 --- a/stac_fastapi/core/setup.py +++ b/stac_fastapi/core/setup.py @@ -10,9 +10,9 @@ "attrs>=23.2.0", "pydantic[dotenv]", "stac_pydantic>=3", - "stac-fastapi.types==3.0.0a4", - "stac-fastapi.api==3.0.0a4", - "stac-fastapi.extensions==3.0.0a4", + "stac-fastapi.types==3.0.0", + "stac-fastapi.api==3.0.0", + "stac-fastapi.extensions==3.0.0", "orjson", "overrides", "geojson-pydantic", diff --git a/stac_fastapi/core/stac_fastapi/core/core.py b/stac_fastapi/core/stac_fastapi/core/core.py index 6cc8f7a5..df20c103 100644 --- a/stac_fastapi/core/stac_fastapi/core/core.py +++ b/stac_fastapi/core/stac_fastapi/core/core.py @@ -1,6 +1,5 @@ """Core client.""" import logging -import re from datetime import datetime as datetime_type from datetime import timezone from enum import Enum @@ -279,8 +278,8 @@ async def item_collection( collection_id: str, bbox: Optional[BBox] = None, datetime: Optional[DateTimeType] = None, - limit: int = 10, - token: str = None, + limit: Optional[int] = 10, + token: Optional[str] = None, **kwargs, ) -> stac_types.ItemCollection: """Read items from a specific collection in the database. @@ -302,6 +301,8 @@ async def item_collection( Exception: If any error occurs while reading the items from the database. """ request: Request = kwargs["request"] + token = request.query_params.get("token") + base_url = str(request.base_url) collection = await self.get_collection( @@ -490,14 +491,6 @@ async def get_search( "query": orjson.loads(query) if query else query, } - # this is borrowed from stac-fastapi-pgstac - # Kludgy fix because using factory does not allow alias for filter-lan - query_params = str(request.query_params) - if filter_lang is None: - match = re.search(r"filter-lang=([a-z0-9-]+)", query_params, re.IGNORECASE) - if match: - filter_lang = match.group(1) - if datetime: base_args["datetime"] = self._format_datetime_range(datetime) diff --git a/stac_fastapi/core/stac_fastapi/core/extensions/aggregation.py b/stac_fastapi/core/stac_fastapi/core/extensions/aggregation.py index facc8bcc..241373e7 100644 --- a/stac_fastapi/core/stac_fastapi/core/extensions/aggregation.py +++ b/stac_fastapi/core/stac_fastapi/core/extensions/aggregation.py @@ -1,6 +1,5 @@ """Request model for the Aggregation extension.""" -import re from datetime import datetime from datetime import datetime as datetime_type from typing import Dict, List, Literal, Optional, Union @@ -351,18 +350,6 @@ async def aggregate( if datetime: base_args["datetime"] = self._format_datetime_range(datetime) - # this is borrowed from stac-fastapi-pgstac - # Kludgy fix because using factory does not allow alias for filter-lang - # If the value is the default, check if the request is different. - query_params = str(request.query_params) - if filter_lang is None: - match = re.search( - r"filter-lang=([a-z0-9-]+)", query_params, re.IGNORECASE - ) - if match: - filter_lang = match.group(1) - else: - filter_lang = "cql2-text" if filter: base_args["filter"] = self.get_filter(filter, filter_lang) aggregate_request = EsAggregationExtensionPostRequest(**base_args) diff --git a/stac_fastapi/core/stac_fastapi/core/version.py b/stac_fastapi/core/stac_fastapi/core/version.py index ad0a12bd..e0db94fc 100644 --- a/stac_fastapi/core/stac_fastapi/core/version.py +++ b/stac_fastapi/core/stac_fastapi/core/version.py @@ -1,2 +1,2 @@ """library version.""" -__version__ = "3.0.0a3" +__version__ = "3.0.0" diff --git a/stac_fastapi/elasticsearch/setup.py b/stac_fastapi/elasticsearch/setup.py index eee387e0..37fc81b3 100644 --- a/stac_fastapi/elasticsearch/setup.py +++ b/stac_fastapi/elasticsearch/setup.py @@ -6,7 +6,7 @@ desc = f.read() install_requires = [ - "stac-fastapi.core==3.0.0a3", + "stac-fastapi.core==3.0.0", "elasticsearch[async]==8.11.0", "elasticsearch-dsl==8.11.0", "uvicorn", diff --git a/stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/version.py b/stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/version.py index ad0a12bd..e0db94fc 100644 --- a/stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/version.py +++ b/stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/version.py @@ -1,2 +1,2 @@ """library version.""" -__version__ = "3.0.0a3" +__version__ = "3.0.0" diff --git a/stac_fastapi/opensearch/setup.py b/stac_fastapi/opensearch/setup.py index 689b3894..c79f669e 100644 --- a/stac_fastapi/opensearch/setup.py +++ b/stac_fastapi/opensearch/setup.py @@ -6,7 +6,7 @@ desc = f.read() install_requires = [ - "stac-fastapi.core==3.0.0a3", + "stac-fastapi.core==3.0.0", "opensearch-py==2.4.2", "opensearch-py[async]==2.4.2", "uvicorn", diff --git a/stac_fastapi/opensearch/stac_fastapi/opensearch/version.py b/stac_fastapi/opensearch/stac_fastapi/opensearch/version.py index ad0a12bd..e0db94fc 100644 --- a/stac_fastapi/opensearch/stac_fastapi/opensearch/version.py +++ b/stac_fastapi/opensearch/stac_fastapi/opensearch/version.py @@ -1,2 +1,2 @@ """library version.""" -__version__ = "3.0.0a3" +__version__ = "3.0.0"