Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ Reach to [stac-fastapi documentation](https://stac-utils.github.io/stac-fastapi/
| name | description | default value |
| --- | --- | --- |
| `DEBUG` | When set to `True`, set the EODAG logging level to `3`. Otherwise, set EODAG logging level to `2`. | False |
| `DATABASE_TYPE` | The type of database used by EODAG to store data (`sqlite` or `postgresql`). | "sqlite" |
| `KEEP_ORIGIN_URL` | Keep origin as alternate URL when data-download extension is enabled. | False |
| `ORIGIN_URL_BLACKLIST` | Hide from clients items assets' origin URLs starting with URLs from the list. A string of comma separated values is expected. | "" |
| `COUNT` | Whether to run a query with a count request or not. | False |
Expand Down Expand Up @@ -133,6 +134,20 @@ export APP_PORT=8080 # change app port because otel-collector uses 8000
python stac_fastapi/eodag/app.py
```

### PostgreSQL database parameters

When `DATABASE_TYPE` is set to `postgresql`, the connection is configured through the standard libpq environment variables.

| name | description | default value |
| --- | --- | --- |
| `PGHOST` | Hostname or IP address of the PostgreSQL server. | "" |
| `PGPORT` | Port on which the PostgreSQL server is listening. | "" |
| `PGUSER` | PostgreSQL user name used to authenticate. | "" |
| `PGDATABASE` | Name of the database to connect to. | "" |
| `PGPASSWORD` | Password used to authenticate the PostgreSQL user. | "" |

Any variable that is left unset is omitted from the connection string, letting libpq apply its own defaults (e.g. `PGHOST` defaults to a local connection on the same machine, `PGPORT` to `5432`, `PGUSER` to the current OS user name, `PGDATABASE` to the value of `PGUSER`).

### EODAG parameters

EODAG configuration parameters are available from [EODAG documentation](https://eodag.readthedocs.io/en/stable/getting_started_guide/configure.html).
Expand Down
16 changes: 13 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ license = { file = "LICENSE" }
requires-python = ">= 3.9"
dependencies = [
"attr",
"eodag[all-providers] @ git+https://github.com/CS-SI/eodag.git@develop",
"eodag[all-providers] @ git+https://github.com/CS-SI/eodag.git@db-for-collections-storage",
"fastapi",
"geojson",
"geojson-pydantic",
"orjson",
"pydantic",
"pydantic_core",
"cql2",
"pygeofilter",
"stac-fastapi.api >= 4.0",
"stac-fastapi.extensions",
Expand All @@ -32,7 +33,10 @@ Repository = "https://github.com/CS-SI/stac-fastapi-eodag.git"
"Bug Tracker" = "https://github.com/CS-SI/stac-fastapi-eodag/issues/"

[project.optional-dependencies]
server = ["uvicorn[standard]"]
server = ["uvicorn[standard]", "stac_fastapi.eodag[postgresql]"]
postgresql = [
"psycopg[binary] >= 3.1.10",
]
telemetry = [
"opentelemetry-api",
"opentelemetry-sdk",
Expand Down Expand Up @@ -65,7 +69,13 @@ explicit_package_bases = true
exclude = ["tests", ".venv"]

[[tool.mypy.overrides]]
module = ["geojson", "pygeofilter", "pygeofilter.*", "stac_fastapi", "stac_fastapi.*"]
module = [
"geojson",
"pygeofilter",
"pygeofilter.*",
"stac_fastapi",
"stac_fastapi.*",
]
ignore_missing_imports = true

[tool.pytest.ini_options]
Expand Down
24 changes: 11 additions & 13 deletions stac_fastapi/eodag/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
from fastapi.responses import ORJSONResponse
from stac_fastapi.api.app import StacApi
from stac_fastapi.api.models import (
EmptyRequest,
ItemCollectionUri,
create_get_request_model,
create_post_request_model,
create_request_model,
)
from stac_fastapi.extensions.core import (
CollectionSearchExtension,
CollectionSearchFilterExtension,
FilterExtension,
FreeTextExtension,
QueryExtension,
Expand Down Expand Up @@ -114,10 +114,12 @@

# collection_search extensions
cs_extensions_map = {
"query": QueryExtension(conformance_classes=[QueryConformanceClasses.COLLECTIONS]),
"offset-pagination": OffsetPaginationExtension(),
"collection-search": CollectionSearchExtension(),
"free-text": FreeTextExtension(conformance_classes=[FreeTextConformanceClasses.COLLECTIONS]),
"sort": SortExtension(conformance_classes=[SortConformanceClasses.COLLECTIONS]),
"filter": CollectionSearchFilterExtension(client=FiltersClient()),
"free_text": FreeTextExtension(
conformance_classes=[FreeTextConformanceClasses.COLLECTIONS],
),
"pagination": OffsetPaginationExtension(),
}

# item_collection extensions
Expand All @@ -128,11 +130,14 @@
"filter": FilterExtension(client=FiltersClient(stac_metadata_model=stac_metadata_model)),
}

collection_search_extension = CollectionSearchExtension.from_extensions(cs_extensions_map.values())

all_extensions = {
**search_extensions_map,
**cs_extensions_map,
**itm_col_extensions_map,
**{
"collection-search": collection_search_extension,
"data-download": DataDownload(),
"collection-order": CollectionOrderExtension(
client=BaseCollectionOrderClient(stac_metadata_model=stac_metadata_model)
Expand Down Expand Up @@ -194,13 +199,6 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
search_post_model = create_post_request_model(search_extensions)
search_get_model = create_get_request_model(search_extensions)

collections_model = create_request_model(
"CollectionsRequest",
base_model=EmptyRequest,
extensions=get_enabled_extensions(cs_extensions_map),
request_type="GET",
)

item_collection_model = create_request_model(
"ItemsRequest",
base_model=ItemCollectionUri,
Expand All @@ -221,7 +219,7 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
response_class=ORJSONResponse,
search_get_request_model=search_get_model,
search_post_request_model=search_post_model,
collections_get_request_model=collections_model,
collections_get_request_model=collection_search_extension.GET,
items_get_request_model=item_collection_model,
middlewares=[
Middleware(BrotliMiddleware),
Expand Down
15 changes: 14 additions & 1 deletion stac_fastapi/eodag/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from __future__ import annotations

from functools import lru_cache
from typing import Annotated, Union
from typing import Annotated, Literal, Union

from pydantic import Field
from pydantic.functional_validators import BeforeValidator
Expand All @@ -34,6 +34,12 @@ class Settings(ApiSettings):

debug: bool = False

database_type: Annotated[Literal["sqlite", "postgresql"], Field] = Field(
default="sqlite",
description="Type of database to use for STAC API backend",
validate_default=False,
)

keep_origin_url: bool = Field(
default=False,
description=("Keep origin as alternate URL when data-download extension is enabled."),
Expand Down Expand Up @@ -71,6 +77,13 @@ class Settings(ApiSettings):
alias="validate",
)

provider_online_status_threshold: float = Field(
default=0.8,
description="Threshold for considering a provider as online based"
"on the statuses of the all collections provided",
alias="provider_online_status_threshold",
)


@lru_cache(maxsize=1)
def get_settings() -> Settings:
Expand Down
Loading