You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enable direct response, stac-fastapi 5.2.0, deprecation warnings (#359)
**Related Issue(s):**
- #347
**Description:**
#### v4.0.0a2 release
#### Added
- Added support for high-performance direct response mode for both
Elasticsearch and Opensearch backends, controlled by the
`ENABLE_DIRECT_RESPONSE` environment variable. When enabled
(`ENABLE_DIRECT_RESPONSE=true`), endpoints return Starlette Response
objects directly, bypassing FastAPI's jsonable_encoder and Pydantic
serialization for significantly improved performance on large search
responses. **Note:** In this mode, all FastAPI dependencies (including
authentication, custom status codes, and validation) are disabled for
all routes. Default is `false` for safety. A warning is logged at
startup if enabled. See [issue
#347](#347)
#### Changed
- Updated test suite to use `httpx.ASGITransport(app=...)` for FastAPI
app testing (removes deprecation warning).
- Updated stac-fastapi parent libraries to 5.2.0.
- Migrated Elasticsearch index template creation from legacy
`put_template` to composable `put_index_template` API in
`database_logic.py`. This resolves deprecation warnings and ensures
compatibility with Elasticsearch 7.x and 8.x.
- Updated all Pydantic models to use `ConfigDict` instead of class-based
`Config` for Pydantic v2 compatibility. This resolves deprecation
warnings and prepares for Pydantic v3.
- Migrated all Pydantic `@root_validator` validators to
`@model_validator` for Pydantic v2 compatibility.
- Migrated startup event handling from deprecated
`@app.on_event("startup")` to FastAPI's recommended lifespan context
manager. This removes deprecation warnings and ensures compatibility
with future FastAPI versions.
**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
Copy file name to clipboardExpand all lines: CHANGELOG.md
+41-22
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,24 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
11
11
12
12
### Changed
13
13
14
+
### Fixed
15
+
16
+
## [v4.0.0a2] - 2025-04-20
17
+
18
+
### Added
19
+
- Added support for high-performance direct response mode for both Elasticsearch and Opensearch backends, controlled by the `ENABLE_DIRECT_RESPONSE` environment variable. When enabled (`ENABLE_DIRECT_RESPONSE=true`), endpoints return Starlette Response objects directly, bypassing FastAPI's jsonable_encoder and Pydantic serialization for significantly improved performance on large search responses. **Note:** In this mode, all FastAPI dependencies (including authentication, custom status codes, and validation) are disabled for all routes. Default is `false` for safety. A warning is logged at startup if enabled. See [issue #347](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/issues/347) and [PR #359](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/359).
20
+
- Added robust tests for the `ENABLE_DIRECT_RESPONSE` environment variable, covering both Elasticsearch and OpenSearch backends. Tests gracefully handle missing backends by attempting to import both configs and skipping if neither is available. [#359](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/359)
21
+
22
+
### Changed
23
+
- Updated test suite to use `httpx.ASGITransport(app=...)` for FastAPI app testing (removes deprecation warning). [#359](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/359)
24
+
- Updated stac-fastapi parent libraries to 5.2.0. [#359](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/359)
25
+
- Migrated Elasticsearch index template creation from legacy `put_template` to composable `put_index_template` API in `database_logic.py`. This resolves deprecation warnings and ensures compatibility with Elasticsearch 7.x and 8.x. [#359](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/359)
26
+
- Updated all Pydantic models to use `ConfigDict` instead of class-based `Config` for Pydantic v2 compatibility. This resolves deprecation warnings and prepares for Pydantic v3. [#359](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/359)
27
+
- Migrated all Pydantic `@root_validator` validators to `@model_validator` for Pydantic v2 compatibility. [#359](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/359)
28
+
- Migrated startup event handling from deprecated `@app.on_event("startup")` to FastAPI's recommended lifespan context manager. This removes deprecation warnings and ensures compatibility with future FastAPI versions. [#359](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/359)
29
+
- Refactored all boolean environment variable parsing in both Elasticsearch and OpenSearch backends to use the shared `get_bool_env` utility. This ensures robust and consistent handling of environment variables such as `ES_USE_SSL`, `ES_HTTP_COMPRESS`, and `ES_VERIFY_CERTS` across both backends. [#359](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/359)
30
+
31
+
14
32
### Fixed
15
33
16
34
## [v4.0.0a1] - 2925-04-17
@@ -343,25 +361,26 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
343
361
- Use genexp in execute_search and get_all_collections to return results.
344
362
- Added db_to_stac serializer to item_collection method in core.py.
Copy file name to clipboardExpand all lines: README.md
+18-6
Original file line number
Diff line number
Diff line change
@@ -29,8 +29,18 @@
29
29
- There is [Postman](https://documenter.getpostman.com/view/12888943/2s8ZDSdRHA) documentation here for examples on how to run some of the API routes locally - after starting the elasticsearch backend via the compose.yml file.
30
30
- The `/examples` folder shows an example of running stac-fastapi-elasticsearch from PyPI in docker without needing any code from the repository. There is also a Postman collection here that you can load into Postman for testing the API routes.
31
31
32
-
- For changes, see the [Changelog](CHANGELOG.md)
33
-
- We are always welcoming contributions. For the development notes: [Contributing](CONTRIBUTING.md)
32
+
33
+
### Performance Note
34
+
35
+
The `enable_direct_response` option is provided by the stac-fastapi core library (introduced in stac-fastapi 5.2.0) and is available in this project starting from v4.0.0.
36
+
37
+
**You can now control this setting via the `ENABLE_DIRECT_RESPONSE` environment variable.**
38
+
39
+
When enabled (`ENABLE_DIRECT_RESPONSE=true`), endpoints return Starlette Response objects directly, bypassing FastAPI's default serialization for improved performance. **However, all FastAPI dependencies (including authentication, custom status codes, and validation) are disabled for all routes.**
40
+
41
+
This mode is best suited for public or read-only APIs where authentication and custom logic are not required. Default is `false` for safety.
@@ -74,8 +84,9 @@ If you wish to use a different version, put the following in a
74
84
file named `.env` in the same directory you run Docker Compose from:
75
85
76
86
```shell
77
-
ELASTICSEARCH_VERSION=7.17.1
78
-
OPENSEARCH_VERSION=2.11.0
87
+
ELASTICSEARCH_VERSION=8.11.0
88
+
OPENSEARCH_VERSION=2.11.1
89
+
ENABLE_DIRECT_RESPONSE=false
79
90
```
80
91
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.
81
92
@@ -100,8 +111,9 @@ You can customize additional settings in your `.env` file:
100
111
|`RELOAD`| Enable auto-reload for development. |`true`| Optional |
101
112
|`STAC_FASTAPI_RATE_LIMIT`| API rate limit per client. |`200/minute`| Optional |
102
113
|`BACKEND`| Tests-related variable |`elasticsearch` or `opensearch` based on the backend | Optional |
103
-
|`ELASTICSEARCH_VERSION`| ElasticSearch version |`7.17.1`| Optional |
104
-
|`OPENSEARCH_VERSION`| OpenSearch version |`2.11.0`| Optional |
114
+
|`ELASTICSEARCH_VERSION`| Version of Elasticsearch to use. |`8.11.0`| Optional |
115
+
|`ENABLE_DIRECT_RESPONSE`| Enable direct response for maximum performance (disables all FastAPI dependencies, including authentication, custom status codes, and validation) |`false`| Optional |
116
+
|`OPENSEARCH_VERSION`| OpenSearch version |`2.11.1`| Optional |
105
117
106
118
> [!NOTE]
107
119
> The variables `ES_HOST`, `ES_PORT`, `ES_USE_SSL`, and `ES_VERIFY_CERTS` apply to both Elasticsearch and OpenSearch backends, so there is no need to rename the key names to `OS_` even if you're using OpenSearch.
0 commit comments