Skip to content

Commit 6fb8278

Browse files
update to sfapi v3.0.0 (#282)
**Description:** Update stac-fastapi parent libraries to v3.0.0, a few minor tweaks **PR Checklist:** - [x] Code is formatted and linted (run `pre-commit run --all-files`) - [x] Tests pass (run `make test`) - [x] Documentation has been updated to reflect changes, if applicable - [x] Changes are added to the changelog --------- Co-authored-by: James <jafisher32@gmail.com>
1 parent 3777f21 commit 6fb8278

File tree

10 files changed

+34
-66
lines changed

10 files changed

+34
-66
lines changed

.github/workflows/cicd.yml

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ on:
1212
jobs:
1313
test:
1414
runs-on: ubuntu-latest
15-
timeout-minutes: 10
15+
timeout-minutes: 20
1616

1717
services:
18-
1918
elasticsearch_8_svc:
2019
image: docker.elastic.co/elasticsearch/elasticsearch:8.11.0
2120
env:
@@ -63,22 +62,31 @@ jobs:
6362
OPENSEARCH_JAVA_OPTS: -Xms512m -Xmx512m
6463
ports:
6564
- 9202:9202
65+
6666
strategy:
6767
matrix:
6868
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12"]
69+
backend: [ "elasticsearch7", "elasticsearch8", "opensearch"]
6970

70-
name: Python ${{ matrix.python-version }} testing
71+
name: Python ${{ matrix.python-version }} testing with ${{ matrix.backend }}
7172

7273
steps:
7374
- name: Check out repository code
7475
uses: actions/checkout@v4
7576

76-
# Setup Python (faster than using Python container)
7777
- name: Setup Python
7878
uses: actions/setup-python@v5
7979
with:
8080
python-version: ${{ matrix.python-version }}
8181

82+
- name: Cache pipenv packages
83+
uses: actions/cache@v3
84+
with:
85+
path: ~/.cache/pip
86+
key: ${{ runner.os }}-pip-${{ hashFiles('**/Pipfile.lock') }}
87+
restore-keys: |
88+
${{ runner.os }}-pip-
89+
8290
- name: Lint code
8391
if: ${{ matrix.python-version == 3.11 }}
8492
run: |
@@ -101,35 +109,17 @@ jobs:
101109
run: |
102110
pip install ./stac_fastapi/opensearch[dev,server]
103111

104-
- name: Run test suite against Elasticsearch 7.x
105-
run: |
106-
pipenv run pytest -svvv
107-
env:
108-
ENVIRONMENT: testing
109-
ES_PORT: 9400
110-
ES_HOST: 172.17.0.1
111-
ES_USE_SSL: false
112-
ES_VERIFY_CERTS: false
113-
BACKEND: elasticsearch
114-
115-
- name: Run test suite against Elasticsearch 8.x
112+
- name: Install pytest-timeout
116113
run: |
117-
pipenv run pytest -svvv
118-
env:
119-
ENVIRONMENT: testing
120-
ES_PORT: 9200
121-
ES_HOST: 172.17.0.1
122-
ES_USE_SSL: false
123-
ES_VERIFY_CERTS: false
124-
BACKEND: elasticsearch
114+
pip install pytest-timeout
125115

126-
- name: Run test suite against OpenSearch 2.11.1
116+
- name: Run test suite
127117
run: |
128-
pipenv run pytest -svvv
118+
pipenv run pytest -svvv --timeout=300
129119
env:
130120
ENVIRONMENT: testing
131-
ES_PORT: 9202
121+
ES_PORT: ${{ matrix.backend == 'elasticsearch7' && '9400' || matrix.backend == 'elasticsearch8' && '9200' || '9202' }}
132122
ES_HOST: 172.17.0.1
133123
ES_USE_SSL: false
134124
ES_VERIFY_CERTS: false
135-
BACKEND: opensearch
125+
BACKEND: ${{ matrix.backend == 'elasticsearch7' && 'elasticsearch' || matrix.backend == 'elasticsearch8' && 'elasticsearch' || 'opensearch' }}

CHANGELOG.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8-
## [Unreleased]
8+
## [v3.0.0] - 2024-08-14
99

1010
### Changed
1111
- Aggregation bug fixes [#281](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/281)
12+
- Updated stac-fastapi libraries to v3.0.0 [#282](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/282)
1213

1314
## [v3.0.0a3] - 2024-07-17
1415

@@ -238,11 +239,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
238239
- Added db_to_stac serializer to item_collection method in core.py.
239240

240241

241-
[Unreleased]: <https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v3.0.0a3...main>
242-
[v3.0.0a3]: <https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v3.0.0a2...v3.0.0a3>
243-
[v3.0.0a2]: <https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v3.0.0a1...v3.0.0a2>
244-
[v3.0.0a1]: <https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v3.0.0a0...v3.0.0a1>
245-
[v3.0.0a0]: <https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v2.4.1...v3.0.0a0>
242+
[Unreleased]: <https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v3.0.0...main>
243+
[v3.0.0]: <https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v2.4.1...v3.0.0>
246244
[v2.4.1]: <https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v2.4.0...v2.4.1>
247245
[v2.4.0]: <https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v2.3.0...v2.4.0>
248246
[v2.3.0]: <https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v2.2.0...v2.3.0>

stac_fastapi/core/setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
"attrs>=23.2.0",
1111
"pydantic[dotenv]",
1212
"stac_pydantic>=3",
13-
"stac-fastapi.types==3.0.0a4",
14-
"stac-fastapi.api==3.0.0a4",
15-
"stac-fastapi.extensions==3.0.0a4",
13+
"stac-fastapi.types==3.0.0",
14+
"stac-fastapi.api==3.0.0",
15+
"stac-fastapi.extensions==3.0.0",
1616
"orjson",
1717
"overrides",
1818
"geojson-pydantic",

stac_fastapi/core/stac_fastapi/core/core.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Core client."""
22
import logging
3-
import re
43
from datetime import datetime as datetime_type
54
from datetime import timezone
65
from enum import Enum
@@ -279,8 +278,8 @@ async def item_collection(
279278
collection_id: str,
280279
bbox: Optional[BBox] = None,
281280
datetime: Optional[DateTimeType] = None,
282-
limit: int = 10,
283-
token: str = None,
281+
limit: Optional[int] = 10,
282+
token: Optional[str] = None,
284283
**kwargs,
285284
) -> stac_types.ItemCollection:
286285
"""Read items from a specific collection in the database.
@@ -302,6 +301,8 @@ async def item_collection(
302301
Exception: If any error occurs while reading the items from the database.
303302
"""
304303
request: Request = kwargs["request"]
304+
token = request.query_params.get("token")
305+
305306
base_url = str(request.base_url)
306307

307308
collection = await self.get_collection(
@@ -490,14 +491,6 @@ async def get_search(
490491
"query": orjson.loads(query) if query else query,
491492
}
492493

493-
# this is borrowed from stac-fastapi-pgstac
494-
# Kludgy fix because using factory does not allow alias for filter-lan
495-
query_params = str(request.query_params)
496-
if filter_lang is None:
497-
match = re.search(r"filter-lang=([a-z0-9-]+)", query_params, re.IGNORECASE)
498-
if match:
499-
filter_lang = match.group(1)
500-
501494
if datetime:
502495
base_args["datetime"] = self._format_datetime_range(datetime)
503496

stac_fastapi/core/stac_fastapi/core/extensions/aggregation.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Request model for the Aggregation extension."""
22

3-
import re
43
from datetime import datetime
54
from datetime import datetime as datetime_type
65
from typing import Dict, List, Literal, Optional, Union
@@ -351,18 +350,6 @@ async def aggregate(
351350
if datetime:
352351
base_args["datetime"] = self._format_datetime_range(datetime)
353352

354-
# this is borrowed from stac-fastapi-pgstac
355-
# Kludgy fix because using factory does not allow alias for filter-lang
356-
# If the value is the default, check if the request is different.
357-
query_params = str(request.query_params)
358-
if filter_lang is None:
359-
match = re.search(
360-
r"filter-lang=([a-z0-9-]+)", query_params, re.IGNORECASE
361-
)
362-
if match:
363-
filter_lang = match.group(1)
364-
else:
365-
filter_lang = "cql2-text"
366353
if filter:
367354
base_args["filter"] = self.get_filter(filter, filter_lang)
368355
aggregate_request = EsAggregationExtensionPostRequest(**base_args)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""library version."""
2-
__version__ = "3.0.0a3"
2+
__version__ = "3.0.0"

stac_fastapi/elasticsearch/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
desc = f.read()
77

88
install_requires = [
9-
"stac-fastapi.core==3.0.0a3",
9+
"stac-fastapi.core==3.0.0",
1010
"elasticsearch[async]==8.11.0",
1111
"elasticsearch-dsl==8.11.0",
1212
"uvicorn",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""library version."""
2-
__version__ = "3.0.0a3"
2+
__version__ = "3.0.0"

stac_fastapi/opensearch/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
desc = f.read()
77

88
install_requires = [
9-
"stac-fastapi.core==3.0.0a3",
9+
"stac-fastapi.core==3.0.0",
1010
"opensearch-py==2.4.2",
1111
"opensearch-py[async]==2.4.2",
1212
"uvicorn",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""library version."""
2-
__version__ = "3.0.0a3"
2+
__version__ = "3.0.0"

0 commit comments

Comments
 (0)