Skip to content

Commit 72ab97c

Browse files
authored
fix: remove providers in items and collections (#6)
Providers are not a required field in STAC spec. Besides, what we currently have in EODAG is the backend which is already set in federation:backend field. The added value would be to have providers with roles such as producer, licensor or processor, but it is not yet possible with EODAG Signed-off-by: Aubin Lambaré <aubin.lambare@cs-soprasteria.com>
1 parent 42033c1 commit 72ab97c

6 files changed

Lines changed: 2 additions & 80 deletions

File tree

stac_fastapi/eodag/core.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@
4747
from eodag.plugins.search.build_search_result import ECMWFSearch
4848
from eodag.utils import deepcopy, get_geometry_from_various
4949
from eodag.utils.exceptions import NoMatchingProductType as EodagNoMatchingProductType
50+
from stac_fastapi.eodag.client import CustomCoreClient
5051
from stac_fastapi.eodag.config import get_settings
5152
from stac_fastapi.eodag.cql_evaluate import EodagEvaluator
5253
from stac_fastapi.eodag.errors import NoMatchingProductType, ResponseSearchError
53-
from stac_fastapi.eodag.landing_page import CustomCoreClient
5454
from stac_fastapi.eodag.models.links import (
5555
CollectionLinks,
5656
ItemCollectionLinks,
@@ -59,9 +59,7 @@
5959
from stac_fastapi.eodag.models.stac_metadata import (
6060
CommonStacMetadata,
6161
create_stac_item,
62-
get_provider_dict,
6362
get_sortby_to_post,
64-
merge_providers,
6563
)
6664
from stac_fastapi.eodag.utils import (
6765
dt_range_to_eodag,
@@ -153,10 +151,6 @@ def has_ecmwf_search_plugin(federation_backends, request):
153151
request=request,
154152
).get_links(extensions=extension_names, extra_links=product_type.get("links", []) + collection.get("links", []))
155153

156-
collection["providers"] = merge_providers(
157-
collection.get("providers", []) + [get_provider_dict(request, fb) for fb in federation_backends]
158-
)
159-
160154
return collection
161155

162156
def _search_base(self, search_request: BaseSearchPostRequest, request: Request) -> ItemCollection:

stac_fastapi/eodag/extensions/datacube_download.py

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

stac_fastapi/eodag/models/stac_metadata.py

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -222,24 +222,6 @@ def create_stac_metadata_model(
222222
return model
223223

224224

225-
def get_provider_dict(request: Request, provider: str) -> dict[str, Any]:
226-
"""Generate STAC provider dict
227-
228-
:param request: FastAPI request
229-
:param provider: provider name
230-
:return: Provider dictionary
231-
"""
232-
provider_config = next(
233-
p for p in request.app.state.dag.providers_config.values() if provider in [p.name, getattr(p, "group", None)]
234-
)
235-
return {
236-
"name": getattr(provider_config, "group", provider_config.name),
237-
"description": getattr(provider_config, "description", None),
238-
"roles": getattr(provider_config, "roles", None),
239-
"url": getattr(provider_config, "url", None),
240-
}
241-
242-
243225
def get_federation_backend_dict(request: Request, provider: str) -> dict[str, Any]:
244226
"""Generate Federation backend dict
245227
@@ -257,27 +239,6 @@ def get_federation_backend_dict(request: Request, provider: str) -> dict[str, An
257239
}
258240

259241

260-
def merge_providers(provider_list: list[dict[str, Any]]) -> list[dict[str, Any]]:
261-
"""Merges a list of provider dictionaries, combining roles for duplicate names while keeping original properties.
262-
263-
:param provider_list: list of provider dictionaries
264-
:return: list of merged provider dictionaries
265-
"""
266-
merged_providers: dict[str, dict[str, Any]] = {}
267-
268-
for provider in provider_list:
269-
name = provider["name"]
270-
271-
if merged := merged_providers.get("name"):
272-
m_roles = set(merged[name].get("roles", []))
273-
m_roles.update(set(provider.get("roles", [])))
274-
merged[name]["roles"] = list(m_roles)
275-
else:
276-
merged_providers[name] = provider
277-
278-
return list(merged_providers.values())
279-
280-
281242
def create_stac_item(
282243
product: EOProduct,
283244
model: type[CommonStacMetadata],
@@ -362,13 +323,7 @@ def create_stac_item(
362323
},
363324
}
364325

365-
provider_dict = get_provider_dict(request, product.provider)
366-
feature_model = model.model_validate(
367-
{
368-
**product.properties,
369-
**{"federation:backends": [product.provider], "providers": [provider_dict]},
370-
}
371-
)
326+
feature_model = model.model_validate({**product.properties, **{"federation:backends": [product.provider]}})
372327
stac_extensions.update(feature_model.get_conformance_classes())
373328

374329
feature["properties"] = feature_model.model_dump(exclude_none=True, exclude=ITEM_PROPERTIES_EXCLUDE)

tests/test_collections.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ async def test_collection(
3333
assert result["id"] == defaults.product_type
3434
assert all(isinstance(v, list) for v in result["summaries"].values())
3535
assert len(result["summaries"]["federation:backends"]) > 0
36-
assert len(result["providers"]) > 0
3736
for link in result["links"]:
3837
assert link["rel"] in ["self", "items", "http://www.opengis.net/def/rel/ogc/1.0/queryables"]
3938

tests/test_search.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,6 @@ async def test_items_response(request_valid, defaults):
7676
"geometry",
7777
"properties",
7878
}
79-
assert len(first_props["providers"]) == 1
80-
assert first_props["providers"][0] == {
81-
"name": "peps",
82-
"description": ANY,
83-
"roles": ["host"],
84-
"url": "https://peps.cnes.fr",
85-
}
86-
assert "id" not in first_props
8779
assert first_props["federation:backends"] == ["peps"]
8880
assert first_props["datetime"] == "2018-02-15T23:53:22.871Z"
8981
assert first_props["start_datetime"] == "2018-02-15T23:53:22.871Z"

0 commit comments

Comments
 (0)