Skip to content

Commit fe0efb2

Browse files
Yuri ZmytrakovYuri Zmytrakov
authored andcommitted
fix: resolve merge conflicts
2 parents dbfe1b2 + dc20246 commit fe0efb2

File tree

26 files changed

+430
-268
lines changed

26 files changed

+430
-268
lines changed

.github/workflows/publish.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Install build dependencies
2222
run: |
2323
python -m pip install --upgrade pip
24-
pip install setuptools wheel twine
24+
pip install build twine
2525
2626
- name: Build and publish stac-fastapi-core
2727
working-directory: stac_fastapi/core
@@ -30,7 +30,7 @@ jobs:
3030
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
3131
run: |
3232
# Build package
33-
python setup.py sdist bdist_wheel
33+
python -m build
3434
3535
# Publish to PyPI
3636
twine upload dist/*
@@ -42,7 +42,7 @@ jobs:
4242
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
4343
run: |
4444
# Build package
45-
python setup.py sdist bdist_wheel
45+
python -m build
4646
4747
# Publish to PyPI
4848
twine upload dist/*
@@ -54,7 +54,7 @@ jobs:
5454
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
5555
run: |
5656
# Build package
57-
python setup.py sdist bdist_wheel
57+
python -m build
5858
5959
# Publish to PyPI
6060
twine upload dist/*
@@ -66,7 +66,7 @@ jobs:
6666
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
6767
run: |
6868
# Build package
69-
python setup.py sdist bdist_wheel
69+
python -m build
7070
7171
# Publish to PyPI
7272
twine upload dist/*

CHANGELOG.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
99

1010
### Added
1111

12+
### Changed
13+
14+
### Fixed
15+
16+
### Removed
17+
18+
### Updated
19+
20+
21+
## [v6.6.0] - 2025-10-21
22+
23+
### Added
24+
1225
- Spatial search support for collections via `bbox` parameter on `/collections` endpoint. Collections are now indexed with a `bbox_shape` field (GeoJSON polygon) derived from their spatial extent for efficient geospatial queries when created or updated. [#481](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/481
1326
- Introduced SFEOS Tools (`sfeos_tools/`) - An installable Click-based CLI package for managing SFEOS deployments. Initial command `add-bbox-shape` adds the `bbox_shape` field to existing collections for spatial search compatibility. Install with `pip install sfeos-tools[elasticsearch]` or `pip install sfeos-tools[opensearch]`. [#481](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/481)
1427
- Moved SFEOS Tools to its own repository at [Healy-Hyperspatial/sfeos-tools](https://github.com/Healy-Hyperspatial/sfeos-tools). The CLI package is now maintained separately. [#PR_NUMBER]
@@ -22,6 +35,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2235
- Removed ENV_MAX_LIMIT environment variable; maximum limits are now handled by the default global limit environment variable. [#482](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/482)
2336
- Changed the default and maximum pagination limits for collections/items endpoints. [#482](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/482)
2437
- Removed the `rel=child` links to the collections from the landing page, as the listing was incomplete due to pagination. [#496](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/496)
38+
- Changed to pyproject.toml file from setup.py [#505](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/505)
2539

2640
### Fixed
2741

@@ -577,7 +591,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
577591
- Use genexp in execute_search and get_all_collections to return results.
578592
- Added db_to_stac serializer to item_collection method in core.py.
579593

580-
[Unreleased]: https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/compare/v6.5.1...main
594+
[Unreleased]: https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/compare/v6.6.0...main
595+
[v6.6.0]: https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/compare/v6.5.1...v6.6.0
581596
[v6.5.1]: https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/compare/v6.5.0...v6.5.1
582597
[v6.5.0]: https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/compare/v6.4.0...v6.5.0
583598
[v6.4.0]: https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/compare/v6.3.0...v6.4.0

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ These Redis configuration variables to enable proper navigation functionality in
356356
| `REDIS_HOST` | Redis server hostname or IP address for Redis configuration. | `""` | Conditional (required for standalone Redis) |
357357
| `REDIS_PORT` | Redis server port for Redis configuration. | `6379` | Conditional (required for standalone Redis) |
358358
| **Both** | | | |
359-
| `REDIS_DB` | Redis database number to use for caching. | `0` (Sentinel) / `0` (Standalone) | Optional |
359+
| `REDIS_DB` | Redis database number to use for caching. | `0` (Sentinel) / `15` (Standalone) | Optional |
360360
| `REDIS_MAX_CONNECTIONS` | Maximum number of connections in the Redis connection pool. | `10` | Optional |
361361
| `REDIS_RETRY_TIMEOUT` | Enable retry on timeout for Redis operations. | `true` | Optional |
362362
| `REDIS_DECODE_RESPONSES` | Automatically decode Redis responses to strings. | `true` | Optional |

stac_fastapi/core/README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

stac_fastapi/core/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# stac-fastapi-core
2+
3+
Core functionality for stac-fastapi. For full documentation, please see the [main README](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/blob/main/README.md).
4+
5+
## Package Information
6+
7+
- **Package name**: stac-fastapi-core
8+
- **Description**: Core functionality for STAC API implementations.
9+
- **Documentation**: [https://stac-utils.github.io/stac-fastapi-elasticsearch-opensearch/](https://stac-utils.github.io/stac-fastapi-elasticsearch-opensearch/)
10+
- **Source**: [GitHub Repository](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/)
11+
12+
## Installation
13+
14+
```bash
15+
pip install stac-fastapi-core
16+
```
17+
18+
## Quick Start
19+
20+
For detailed usage and examples, please refer to the [main documentation](https://stac-utils.github.io/stac-fastapi-elasticsearch-opensearch/).

stac_fastapi/core/pyproject.toml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "stac_fastapi_core"
7+
description = "Core library for the Elasticsearch and Opensearch stac-fastapi backends."
8+
readme = "README.md"
9+
requires-python = ">=3.9"
10+
license = {text = "MIT"}
11+
authors = []
12+
classifiers = [
13+
"Intended Audience :: Developers",
14+
"Intended Audience :: Information Technology",
15+
"Intended Audience :: Science/Research",
16+
"Programming Language :: Python :: 3.9",
17+
"Programming Language :: Python :: 3.10",
18+
"Programming Language :: Python :: 3.11",
19+
"Programming Language :: Python :: 3.12",
20+
"Programming Language :: Python :: 3.13",
21+
"Programming Language :: Python :: 3.14",
22+
"License :: OSI Approved :: MIT License",
23+
]
24+
keywords = [
25+
"STAC",
26+
"STAC-API",
27+
"FastAPI",
28+
"stac-fastapi",
29+
"Elasticsearch",
30+
"Opensearch",
31+
]
32+
dynamic = ["version"]
33+
dependencies = [
34+
"fastapi~=0.109.0",
35+
"attrs>=23.2.0",
36+
"pydantic>=2.4.1,<3.0.0",
37+
"stac_pydantic~=3.3.0",
38+
"stac-fastapi.types==6.0.0",
39+
"stac-fastapi.api==6.0.0",
40+
"stac-fastapi.extensions==6.0.0",
41+
"orjson~=3.11.0",
42+
"overrides~=7.4.0",
43+
"geojson-pydantic~=1.0.0",
44+
"pygeofilter~=0.3.1",
45+
"jsonschema~=4.0.0",
46+
"slowapi~=0.1.9",
47+
"redis==6.4.0",
48+
]
49+
50+
[project.urls]
51+
Homepage = "https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch"
52+
53+
[tool.hatch.version]
54+
path = "stac_fastapi/core/version.py"
55+
56+
[tool.hatch.build.targets.sdist]
57+
exclude = ["alembic", "tests", "scripts"]
58+
59+
[tool.hatch.build.targets.wheel]
60+
only-include = ["stac_fastapi"]

stac_fastapi/core/setup.cfg

Lines changed: 0 additions & 2 deletions
This file was deleted.

stac_fastapi/core/setup.py

Lines changed: 0 additions & 49 deletions
This file was deleted.

stac_fastapi/core/stac_fastapi/core/redis_utils.py

Lines changed: 56 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import json
44
import logging
55
from typing import List, Optional, Tuple
6+
from urllib.parse import parse_qs, urlencode, urlparse, urlunparse
67

78
from pydantic import field_validator
89
from pydantic_settings import BaseSettings
@@ -108,7 +109,7 @@ class RedisSettings(BaseSettings):
108109

109110
REDIS_HOST: str = ""
110111
REDIS_PORT: int = 6379
111-
REDIS_DB: int = 0
112+
REDIS_DB: int = 15
112113

113114
REDIS_MAX_CONNECTIONS: int = 10
114115
REDIS_RETRY_TIMEOUT: bool = True
@@ -218,23 +219,54 @@ async def connect_redis() -> Optional[aioredis.Redis]:
218219
return None
219220

220221

221-
async def save_self_link(
222-
redis: aioredis.Redis, token: Optional[str], self_href: str
222+
def get_redis_key(url: str, token: str) -> str:
223+
"""Create Redis key using URL path and token."""
224+
parsed = urlparse(url)
225+
return f"nav:{parsed.path}:{token}"
226+
227+
228+
def build_url_with_token(base_url: str, token: str) -> str:
229+
"""Build URL with token parameter."""
230+
parsed = urlparse(base_url)
231+
query_params = parse_qs(parsed.query)
232+
233+
query_params["token"] = [token]
234+
235+
new_query = urlencode(query_params, doseq=True)
236+
237+
return urlunparse(
238+
(
239+
parsed.scheme,
240+
parsed.netloc,
241+
parsed.path,
242+
parsed.params,
243+
new_query,
244+
parsed.fragment,
245+
)
246+
)
247+
248+
249+
async def save_prev_link(
250+
redis: aioredis.Redis, next_url: str, current_url: str, next_token: str
223251
) -> None:
224-
"""Save the self link for the current token."""
225-
if token:
252+
"""Save the current page as the previous link for the next URL."""
253+
if next_url and next_token:
226254
if sentinel_settings.REDIS_SENTINEL_HOSTS:
227255
ttl_seconds = sentinel_settings.REDIS_SELF_LINK_TTL
228256
elif standalone_settings.REDIS_HOST:
229257
ttl_seconds = standalone_settings.REDIS_SELF_LINK_TTL
230-
await redis.setex(f"nav:self:{token}", ttl_seconds, self_href)
258+
key = get_redis_key(next_url, next_token)
259+
await redis.setex(key, ttl_seconds, current_url)
231260

232261

233-
async def get_prev_link(redis: aioredis.Redis, token: Optional[str]) -> Optional[str]:
262+
async def get_prev_link(
263+
redis: aioredis.Redis, current_url: str, current_token: str
264+
) -> Optional[str]:
234265
"""Get the previous page link for the current token."""
235-
if not token:
266+
if not current_url or not current_token:
236267
return None
237-
return await redis.get(f"nav:self:{token}")
268+
key = get_redis_key(current_url, current_token)
269+
return await redis.get(key)
238270

239271

240272
async def redis_pagination_links(
@@ -248,19 +280,21 @@ async def redis_pagination_links(
248280

249281
try:
250282
if next_token:
251-
await save_self_link(redis, next_token, current_url)
252-
253-
prev_link = await get_prev_link(redis, token)
254-
if prev_link:
255-
links.insert(
256-
0,
257-
{
258-
"rel": "previous",
259-
"type": "application/json",
260-
"method": "GET",
261-
"href": prev_link,
262-
},
263-
)
283+
next_url = build_url_with_token(current_url, next_token)
284+
await save_prev_link(redis, next_url, current_url, next_token)
285+
286+
if token:
287+
prev_link = await get_prev_link(redis, current_url, token)
288+
if prev_link:
289+
links.insert(
290+
0,
291+
{
292+
"rel": "previous",
293+
"type": "application/json",
294+
"method": "GET",
295+
"href": prev_link,
296+
},
297+
)
264298
except Exception as e:
265299
logger.warning(f"Redis pagination operation failed: {e}")
266300
finally:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""library version."""
2-
__version__ = "6.5.1"
2+
__version__ = "6.6.0"

0 commit comments

Comments
 (0)