stac-fastapi-core 4.0.0a1__tar.gz → 4.0.0a2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. {stac_fastapi_core-4.0.0a1 → stac_fastapi_core-4.0.0a2}/PKG-INFO +19 -7
  2. {stac_fastapi_core-4.0.0a1 → stac_fastapi_core-4.0.0a2}/README.md +18 -6
  3. {stac_fastapi_core-4.0.0a1 → stac_fastapi_core-4.0.0a2}/setup.py +3 -3
  4. {stac_fastapi_core-4.0.0a1 → stac_fastapi_core-4.0.0a2}/stac_fastapi/core/core.py +6 -3
  5. {stac_fastapi_core-4.0.0a1 → stac_fastapi_core-4.0.0a2}/stac_fastapi/core/extensions/query.py +2 -2
  6. {stac_fastapi_core-4.0.0a1 → stac_fastapi_core-4.0.0a2}/stac_fastapi/core/utilities.py +29 -0
  7. stac_fastapi_core-4.0.0a2/stac_fastapi/core/version.py +2 -0
  8. {stac_fastapi_core-4.0.0a1 → stac_fastapi_core-4.0.0a2}/stac_fastapi_core.egg-info/PKG-INFO +19 -7
  9. {stac_fastapi_core-4.0.0a1 → stac_fastapi_core-4.0.0a2}/stac_fastapi_core.egg-info/requires.txt +3 -3
  10. stac_fastapi_core-4.0.0a1/stac_fastapi/core/version.py +0 -2
  11. {stac_fastapi_core-4.0.0a1 → stac_fastapi_core-4.0.0a2}/setup.cfg +0 -0
  12. {stac_fastapi_core-4.0.0a1 → stac_fastapi_core-4.0.0a2}/stac_fastapi/core/__init__.py +0 -0
  13. {stac_fastapi_core-4.0.0a1 → stac_fastapi_core-4.0.0a2}/stac_fastapi/core/base_database_logic.py +0 -0
  14. {stac_fastapi_core-4.0.0a1 → stac_fastapi_core-4.0.0a2}/stac_fastapi/core/base_settings.py +0 -0
  15. {stac_fastapi_core-4.0.0a1 → stac_fastapi_core-4.0.0a2}/stac_fastapi/core/basic_auth.py +0 -0
  16. {stac_fastapi_core-4.0.0a1 → stac_fastapi_core-4.0.0a2}/stac_fastapi/core/database_logic.py +0 -0
  17. {stac_fastapi_core-4.0.0a1 → stac_fastapi_core-4.0.0a2}/stac_fastapi/core/datetime_utils.py +0 -0
  18. {stac_fastapi_core-4.0.0a1 → stac_fastapi_core-4.0.0a2}/stac_fastapi/core/extensions/__init__.py +0 -0
  19. {stac_fastapi_core-4.0.0a1 → stac_fastapi_core-4.0.0a2}/stac_fastapi/core/extensions/aggregation.py +0 -0
  20. {stac_fastapi_core-4.0.0a1 → stac_fastapi_core-4.0.0a2}/stac_fastapi/core/extensions/fields.py +0 -0
  21. {stac_fastapi_core-4.0.0a1 → stac_fastapi_core-4.0.0a2}/stac_fastapi/core/extensions/filter.py +0 -0
  22. {stac_fastapi_core-4.0.0a1 → stac_fastapi_core-4.0.0a2}/stac_fastapi/core/models/__init__.py +0 -0
  23. {stac_fastapi_core-4.0.0a1 → stac_fastapi_core-4.0.0a2}/stac_fastapi/core/models/links.py +0 -0
  24. {stac_fastapi_core-4.0.0a1 → stac_fastapi_core-4.0.0a2}/stac_fastapi/core/models/search.py +0 -0
  25. {stac_fastapi_core-4.0.0a1 → stac_fastapi_core-4.0.0a2}/stac_fastapi/core/rate_limit.py +0 -0
  26. {stac_fastapi_core-4.0.0a1 → stac_fastapi_core-4.0.0a2}/stac_fastapi/core/route_dependencies.py +0 -0
  27. {stac_fastapi_core-4.0.0a1 → stac_fastapi_core-4.0.0a2}/stac_fastapi/core/serializers.py +0 -0
  28. {stac_fastapi_core-4.0.0a1 → stac_fastapi_core-4.0.0a2}/stac_fastapi/core/session.py +0 -0
  29. {stac_fastapi_core-4.0.0a1 → stac_fastapi_core-4.0.0a2}/stac_fastapi_core.egg-info/SOURCES.txt +0 -0
  30. {stac_fastapi_core-4.0.0a1 → stac_fastapi_core-4.0.0a2}/stac_fastapi_core.egg-info/dependency_links.txt +0 -0
  31. {stac_fastapi_core-4.0.0a1 → stac_fastapi_core-4.0.0a2}/stac_fastapi_core.egg-info/not-zip-safe +0 -0
  32. {stac_fastapi_core-4.0.0a1 → stac_fastapi_core-4.0.0a2}/stac_fastapi_core.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: stac_fastapi_core
3
- Version: 4.0.0a1
3
+ Version: 4.0.0a2
4
4
  Summary: Core library for the Elasticsearch and Opensearch stac-fastapi backends.
5
5
  Home-page: https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch
6
6
  License: MIT
@@ -47,8 +47,18 @@ Description-Content-Type: text/markdown
47
47
  - 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.
48
48
  - 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.
49
49
 
50
- - For changes, see the [Changelog](CHANGELOG.md)
51
- - We are always welcoming contributions. For the development notes: [Contributing](CONTRIBUTING.md)
50
+
51
+ ### Performance Note
52
+
53
+ 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.
54
+
55
+ **You can now control this setting via the `ENABLE_DIRECT_RESPONSE` environment variable.**
56
+
57
+ 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.**
58
+
59
+ This mode is best suited for public or read-only APIs where authentication and custom logic are not required. Default is `false` for safety.
60
+
61
+ See: [issue #347](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/issues/347)
52
62
 
53
63
 
54
64
  ### To install from PyPI:
@@ -92,8 +102,9 @@ If you wish to use a different version, put the following in a
92
102
  file named `.env` in the same directory you run Docker Compose from:
93
103
 
94
104
  ```shell
95
- ELASTICSEARCH_VERSION=7.17.1
96
- OPENSEARCH_VERSION=2.11.0
105
+ ELASTICSEARCH_VERSION=8.11.0
106
+ OPENSEARCH_VERSION=2.11.1
107
+ ENABLE_DIRECT_RESPONSE=false
97
108
  ```
98
109
  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.
99
110
 
@@ -118,8 +129,9 @@ You can customize additional settings in your `.env` file:
118
129
  | `RELOAD` | Enable auto-reload for development. | `true` | Optional |
119
130
  | `STAC_FASTAPI_RATE_LIMIT` | API rate limit per client. | `200/minute` | Optional |
120
131
  | `BACKEND` | Tests-related variable | `elasticsearch` or `opensearch` based on the backend | Optional |
121
- | `ELASTICSEARCH_VERSION` | ElasticSearch version | `7.17.1` | Optional |
122
- | `OPENSEARCH_VERSION` | OpenSearch version | `2.11.0` | Optional |
132
+ | `ELASTICSEARCH_VERSION` | Version of Elasticsearch to use. | `8.11.0` | Optional |
133
+ | `ENABLE_DIRECT_RESPONSE` | Enable direct response for maximum performance (disables all FastAPI dependencies, including authentication, custom status codes, and validation) | `false` | Optional |
134
+ | `OPENSEARCH_VERSION` | OpenSearch version | `2.11.1` | Optional |
123
135
 
124
136
  > [!NOTE]
125
137
  > 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.
@@ -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.
42
+
43
+ See: [issue #347](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/issues/347)
34
44
 
35
45
 
36
46
  ### To install from PyPI:
@@ -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.
@@ -10,9 +10,9 @@ install_requires = [
10
10
  "attrs>=23.2.0",
11
11
  "pydantic>=2.4.1,<3.0.0",
12
12
  "stac_pydantic~=3.1.0",
13
- "stac-fastapi.api==5.1.1",
14
- "stac-fastapi.extensions==5.1.1",
15
- "stac-fastapi.types==5.1.1",
13
+ "stac-fastapi.api==5.2.0",
14
+ "stac-fastapi.extensions==5.2.0",
15
+ "stac-fastapi.types==5.2.0",
16
16
  "orjson~=3.9.0",
17
17
  "overrides~=7.4.0",
18
18
  "geojson-pydantic~=1.0.0",
@@ -334,7 +334,7 @@ class CoreClient(AsyncBaseCoreClient):
334
334
  search=search,
335
335
  limit=limit,
336
336
  sort=None,
337
- token=token, # type: ignore
337
+ token=token,
338
338
  collection_ids=[collection_id],
339
339
  )
340
340
 
@@ -633,7 +633,7 @@ class CoreClient(AsyncBaseCoreClient):
633
633
  items, maybe_count, next_token = await self.database.execute_search(
634
634
  search=search,
635
635
  limit=limit,
636
- token=search_request.token, # type: ignore
636
+ token=search_request.token,
637
637
  sort=sort,
638
638
  collection_ids=search_request.collections,
639
639
  )
@@ -701,7 +701,10 @@ class TransactionsClient(AsyncBaseTransactionsClient):
701
701
  database=self.database, settings=self.settings
702
702
  )
703
703
  processed_items = [
704
- bulk_client.preprocess_item(item, base_url, BulkTransactionMethod.INSERT) for item in item["features"] # type: ignore
704
+ bulk_client.preprocess_item(
705
+ item, base_url, BulkTransactionMethod.INSERT
706
+ )
707
+ for item in item["features"]
705
708
  ]
706
709
 
707
710
  await self.database.bulk_async(
@@ -10,7 +10,7 @@ from enum import auto
10
10
  from types import DynamicClassAttribute
11
11
  from typing import Any, Callable, Dict, Optional
12
12
 
13
- from pydantic import BaseModel, root_validator
13
+ from pydantic import BaseModel, model_validator
14
14
  from stac_pydantic.utils import AutoValueEnum
15
15
 
16
16
  from stac_fastapi.extensions.core.query import QueryExtension as QueryExtensionBase
@@ -63,7 +63,7 @@ class QueryExtensionPostRequest(BaseModel):
63
63
 
64
64
  query: Optional[Dict[str, Dict[Operator, Any]]] = None
65
65
 
66
- @root_validator(pre=True)
66
+ @model_validator(mode="before")
67
67
  def validate_query_fields(cls, values: Dict) -> Dict:
68
68
  """Validate query fields."""
69
69
  ...
@@ -3,6 +3,8 @@
3
3
  This module contains functions for transforming geospatial coordinates,
4
4
  such as converting bounding boxes to polygon representations.
5
5
  """
6
+ import logging
7
+ import os
6
8
  from typing import Any, Dict, List, Optional, Set, Union
7
9
 
8
10
  from stac_fastapi.types.stac import Item
@@ -10,6 +12,33 @@ from stac_fastapi.types.stac import Item
10
12
  MAX_LIMIT = 10000
11
13
 
12
14
 
15
+ def get_bool_env(name: str, default: bool = False) -> bool:
16
+ """
17
+ Retrieve a boolean value from an environment variable.
18
+
19
+ Args:
20
+ name (str): The name of the environment variable.
21
+ default (bool, optional): The default value to use if the variable is not set or unrecognized. Defaults to False.
22
+
23
+ Returns:
24
+ bool: The boolean value parsed from the environment variable.
25
+ """
26
+ value = os.getenv(name, str(default).lower())
27
+ true_values = ("true", "1", "yes", "y")
28
+ false_values = ("false", "0", "no", "n")
29
+ if value.lower() in true_values:
30
+ return True
31
+ elif value.lower() in false_values:
32
+ return False
33
+ else:
34
+ logger = logging.getLogger(__name__)
35
+ logger.warning(
36
+ f"Environment variable '{name}' has unrecognized value '{value}'. "
37
+ f"Expected one of {true_values + false_values}. Using default: {default}"
38
+ )
39
+ return default
40
+
41
+
13
42
  def bbox2polygon(b0: float, b1: float, b2: float, b3: float) -> List[List[List[float]]]:
14
43
  """Transform a bounding box represented by its four coordinates `b0`, `b1`, `b2`, and `b3` into a polygon.
15
44
 
@@ -0,0 +1,2 @@
1
+ """library version."""
2
+ __version__ = "4.0.0a2"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: stac-fastapi-core
3
- Version: 4.0.0a1
3
+ Version: 4.0.0a2
4
4
  Summary: Core library for the Elasticsearch and Opensearch stac-fastapi backends.
5
5
  Home-page: https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch
6
6
  License: MIT
@@ -47,8 +47,18 @@ Description-Content-Type: text/markdown
47
47
  - 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.
48
48
  - 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.
49
49
 
50
- - For changes, see the [Changelog](CHANGELOG.md)
51
- - We are always welcoming contributions. For the development notes: [Contributing](CONTRIBUTING.md)
50
+
51
+ ### Performance Note
52
+
53
+ 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.
54
+
55
+ **You can now control this setting via the `ENABLE_DIRECT_RESPONSE` environment variable.**
56
+
57
+ 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.**
58
+
59
+ This mode is best suited for public or read-only APIs where authentication and custom logic are not required. Default is `false` for safety.
60
+
61
+ See: [issue #347](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/issues/347)
52
62
 
53
63
 
54
64
  ### To install from PyPI:
@@ -92,8 +102,9 @@ If you wish to use a different version, put the following in a
92
102
  file named `.env` in the same directory you run Docker Compose from:
93
103
 
94
104
  ```shell
95
- ELASTICSEARCH_VERSION=7.17.1
96
- OPENSEARCH_VERSION=2.11.0
105
+ ELASTICSEARCH_VERSION=8.11.0
106
+ OPENSEARCH_VERSION=2.11.1
107
+ ENABLE_DIRECT_RESPONSE=false
97
108
  ```
98
109
  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.
99
110
 
@@ -118,8 +129,9 @@ You can customize additional settings in your `.env` file:
118
129
  | `RELOAD` | Enable auto-reload for development. | `true` | Optional |
119
130
  | `STAC_FASTAPI_RATE_LIMIT` | API rate limit per client. | `200/minute` | Optional |
120
131
  | `BACKEND` | Tests-related variable | `elasticsearch` or `opensearch` based on the backend | Optional |
121
- | `ELASTICSEARCH_VERSION` | ElasticSearch version | `7.17.1` | Optional |
122
- | `OPENSEARCH_VERSION` | OpenSearch version | `2.11.0` | Optional |
132
+ | `ELASTICSEARCH_VERSION` | Version of Elasticsearch to use. | `8.11.0` | Optional |
133
+ | `ENABLE_DIRECT_RESPONSE` | Enable direct response for maximum performance (disables all FastAPI dependencies, including authentication, custom status codes, and validation) | `false` | Optional |
134
+ | `OPENSEARCH_VERSION` | OpenSearch version | `2.11.1` | Optional |
123
135
 
124
136
  > [!NOTE]
125
137
  > 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.
@@ -2,9 +2,9 @@ fastapi~=0.109.0
2
2
  attrs>=23.2.0
3
3
  pydantic<3.0.0,>=2.4.1
4
4
  stac_pydantic~=3.1.0
5
- stac-fastapi.api==5.1.1
6
- stac-fastapi.extensions==5.1.1
7
- stac-fastapi.types==5.1.1
5
+ stac-fastapi.api==5.2.0
6
+ stac-fastapi.extensions==5.2.0
7
+ stac-fastapi.types==5.2.0
8
8
  orjson~=3.9.0
9
9
  overrides~=7.4.0
10
10
  geojson-pydantic~=1.0.0
@@ -1,2 +0,0 @@
1
- """library version."""
2
- __version__ = "4.0.0a1"