Skip to content

Commit 674764d

Browse files
committed
fix: changes due to rebase
renaming and fixing some configuration, code and tests
1 parent b630ae2 commit 674764d

File tree

10 files changed

+128
-140
lines changed

10 files changed

+128
-140
lines changed

eodag/api/core.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@
3434
import geojson
3535
import yaml
3636

37-
from eodag.api.collection import Collection, CollectionsDict
37+
from eodag.api.collection import Collection, CollectionsDict, CollectionsList
3838
from eodag.api.product.metadata_mapping import mtd_cfg_as_conversion_and_querypath
3939
from eodag.api.provider import Provider, ProvidersDict
4040
from eodag.api.search_result import SearchResult
4141
from eodag.config import (
4242
PLUGINS_TOPICS_KEYS,
43-
DiscoverProductTypes,
43+
DiscoverCollections,
4444
PluginConfig,
4545
SimpleYamlProxyConfig,
4646
credentials_in_auth,
@@ -171,7 +171,7 @@ def __init__(
171171
strict_mode = is_env_var_true("EODAG_STRICT_COLLECTIONS")
172172

173173
for provider in self.providers.values():
174-
provider.sync_product_types(self, strict_mode)
174+
provider.sync_collections(self, strict_mode)
175175

176176
# re-build _plugins_manager using up-to-date providers_config
177177
self._plugins_manager.rebuild(self.providers)
@@ -504,7 +504,7 @@ def list_collections(
504504
)
505505

506506
for p in providers_iter:
507-
for collection_id in p.product_types: # type: ignore
507+
for collection_id in p.collections: # type: ignore
508508
if collection_id == GENERIC_COLLECTION:
509509
continue
510510

@@ -531,7 +531,7 @@ def fetch_collections_list(self, provider: Optional[str] = None) -> None:
531531
return
532532

533533
# providers discovery confs that are fetchable
534-
providers_discovery_configs_fetchable: dict[str, DiscoverProductTypes] = {}
534+
providers_discovery_configs_fetchable: dict[str, DiscoverCollections] = {}
535535
# check if any provider has not already been fetched for collections
536536
already_fetched = True
537537
for provider_to_fetch in self.providers.filter_by_name_or_group(provider):
@@ -585,7 +585,7 @@ def fetch_collections_list(self, provider: Optional[str] = None) -> None:
585585
default_discovery_conf["results_entry"], str
586586
):
587587
default_discovery_conf_parsed = cast(
588-
DiscoverProductTypes,
588+
DiscoverCollections,
589589
dict(
590590
default_discovery_conf,
591591
**{
@@ -689,7 +689,7 @@ def discover_collections(
689689
kwargs["auth"] = auth
690690
else:
691691
logger.debug(
692-
f"Could not authenticate on {p} for product types discovery"
692+
f"Could not authenticate on {p} for collections discovery"
693693
)
694694
ext_collections_conf[p.name] = None
695695
continue
@@ -716,7 +716,7 @@ def update_collections_list(
716716
continue
717717

718718
provider_products_config = (
719-
self.providers[provider].product_types or {}
719+
self.providers[provider].collections or {}
720720
)
721721
except UnsupportedProvider:
722722
logger.debug(
@@ -795,7 +795,8 @@ def update_collections_list(
795795
)
796796
if bad_formatted_col_count > 0:
797797
logger.debug(
798-
f"bad formatted attributes skipped for {bad_formatted_col_count} collection(s) on {provider}"
798+
"bad formatted attributes skipped for "
799+
f"{bad_formatted_col_count} collection(s) on {provider}"
799800
)
800801

801802
elif provider not in self.providers:
@@ -824,7 +825,7 @@ def available_providers(
824825
candidates = []
825826

826827
for key, provider in self.providers.items():
827-
if collection and collection not in provider.product_types:
828+
if collection and collection not in provider.collections:
828829
continue
829830

830831
group = getattr(provider.config, "group", None)

eodag/api/provider.py

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,18 @@
5151
update_nested_dict,
5252
)
5353
from eodag.utils.exceptions import (
54-
UnsupportedProductType,
54+
UnsupportedCollection,
5555
UnsupportedProvider,
5656
ValidationError,
5757
)
5858
from eodag.utils.free_text_search import compile_free_text_query
5959
from eodag.utils.repr import html_table
6060

6161
if TYPE_CHECKING:
62-
from eodag.api.core import EODataAccessGateway
6362
from typing_extensions import Self
6463

64+
from eodag.api.core import EODataAccessGateway
65+
6566
logger = logging.getLogger("eodag.provider")
6667

6768
AUTH_TOPIC_KEYS = ("auth", "search_auth", "download_auth")
@@ -259,7 +260,7 @@ class Provider:
259260
>>> provider = Provider(config)
260261
>>> provider.name
261262
'example_provider'
262-
>>> 'S2_MSI_L1C' in provider.product_types
263+
>>> 'S2_MSI_L1C' in provider.collections
263264
True
264265
>>> provider.priority # Default priority
265266
0
@@ -329,7 +330,7 @@ def _repr_html_(self, show_name: bool = True) -> str:
329330
{html_table(summaries)}
330331
<br />
331332
<br />
332-
{html_table(list(self.product_types.keys()))}
333+
{html_table(list(self.collections.keys()))}
333334
</div>
334335
"""
335336

@@ -354,8 +355,8 @@ def name(self) -> str:
354355
return self._name
355356

356357
@property
357-
def product_types(self) -> dict[str, Any]:
358-
"""Return the product types dictionary for this provider."""
358+
def collections(self) -> dict[str, Any]:
359+
"""Return the collections dictionary for this provider."""
359360
return getattr(self.config, "products", {})
360361

361362
@property
@@ -375,20 +376,20 @@ def search_config(self) -> Optional[PluginConfig]:
375376

376377
@property
377378
def fetchable(self) -> bool:
378-
"""Return True if the provider can fetch product types."""
379+
"""Return True if the provider can fetch collections."""
379380
return bool(
380-
getattr(self.search_config, "discover_product_types", {}).get("fetch_url")
381+
getattr(self.search_config, "discover_collections", {}).get("fetch_url")
381382
)
382383

383384
@property
384385
def unparsable_properties(self) -> set[str]:
385-
"""Return set of unparsable properties for generic product types, if any."""
386+
"""Return set of unparsable properties for generic collections, if any."""
386387
if not self.fetchable or self.search_config is None:
387388
return set()
388389

389390
props = getattr(
390-
getattr(self.search_config, "discover_product_types", None),
391-
"generic_product_type_unparsable_properties",
391+
getattr(self.search_config, "discover_collections", None),
392+
"generic_collection_unparsable_properties",
392393
{},
393394
)
394395
return set(props.keys()) if isinstance(props, dict) else set()
@@ -434,37 +435,37 @@ def _copy_matching_credentials(
434435
self.config, key
435436
).credentials = conf_with_creds.credentials
436437

437-
def delete_product_type(self, name: str) -> None:
438-
"""Remove a product type from this provider.
438+
def delete_collection(self, name: str) -> None:
439+
"""Remove a collection from this provider.
439440
440-
:param name: The product type name.
441+
:param name: The collection name.
441442
442-
:raises UnsupportedProductType: If the product type is not found.
443+
:raises UnsupportedCollection: If the collection is not found.
443444
"""
444445
try:
445-
del self.product_types[name]
446+
del self.collections[name]
446447
except KeyError:
447-
msg = f"Product type '{name}' not found in provider '{self.name}'."
448-
raise UnsupportedProductType(msg)
448+
msg = f"Collection '{name}' not found in provider '{self.name}'."
449+
raise UnsupportedCollection(msg)
449450

450-
def sync_product_types(
451+
def sync_collections(
451452
self,
452453
dag: EODataAccessGateway,
453454
strict_mode: bool,
454455
) -> None:
455456
"""
456-
Synchronize product types for a provider based on strict or permissive mode.
457+
Synchronize collections for a provider based on strict or permissive mode.
457458
458459
In strict mode, removes collections not in "dag.collections_config".
459460
In permissive mode, adds empty collection to config for missing types.
460461
461462
:param dag: The gateway instance to use to list existing collections and to create new collection instances.
462-
:param strict_mode: If True, remove unknown product types; if False, add empty configs for them.
463+
:param strict_mode: If True, remove unknown collections; if False, add empty configs for them.
463464
"""
464465
products_to_remove: list[str] = []
465466
products_to_add: list[str] = []
466467

467-
for product_id in self.product_types:
468+
for product_id in self.collections:
468469
if product_id == GENERIC_COLLECTION:
469470
continue
470471

@@ -476,26 +477,24 @@ def sync_product_types(
476477
empty_product = Collection(
477478
dag=dag, id=product_id, title=product_id, description=NOT_AVAILABLE
478479
)
479-
dag.collections_config[
480-
product_id
481-
] = empty_product # will update available_product_types
480+
dag.collections_config[product_id] = empty_product
482481
products_to_add.append(product_id)
483482

484483
if products_to_add:
485484
logger.debug(
486-
"Product types permissive mode, %s added (provider %s)",
485+
"Collections permissive mode, %s added (provider %s)",
487486
", ".join(products_to_add),
488487
self,
489488
)
490489

491490
if products_to_remove:
492491
logger.debug(
493-
"Product types strict mode, ignoring %s (provider %s)",
492+
"Collections strict mode, ignoring %s (provider %s)",
494493
", ".join(products_to_remove),
495494
self,
496495
)
497496
for id in products_to_remove:
498-
self.delete_product_type(id)
497+
self.delete_collection(id)
499498

500499
def _mm_already_built(self) -> bool:
501500
"""Check if metadata mapping is already built (converted to querypaths/conversion)."""
@@ -759,20 +758,20 @@ def filter_by_name_or_group(
759758
):
760759
yield provider
761760

762-
def delete_product_type(self, provider: str, product_type: str) -> None:
761+
def delete_collection(self, provider: str, collection: str) -> None:
763762
"""
764-
Delete a product type from a provider.
763+
Delete a collection from a provider.
765764
766765
:param provider: The provider's name.
767-
:param product_ID: The product type to delete.
766+
:param product_ID: The collection to delete.
768767
:raises UnsupportedProvider: If the provider or product is not found.
769768
"""
770769
if provider_obj := self.get(provider):
771-
if product_type in provider_obj.product_types:
772-
provider_obj.delete_product_type(product_type)
770+
if collection in provider_obj.collections:
771+
provider_obj.delete_collection(collection)
773772
else:
774-
msg = f"Product type '{product_type}' not found for provider '{provider}'."
775-
raise UnsupportedProductType(msg)
773+
msg = f"Collection '{collection}' not found for provider '{provider}'."
774+
raise UnsupportedCollection(msg)
776775
else:
777776
msg = f"Provider '{provider}' not found."
778777
raise UnsupportedProvider(msg)

eodag/config.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,14 @@ class DiscoverMetadata(TypedDict):
151151
raise_mtd_discovery_error: bool
152152

153153

154-
class DiscoverProductTypes(TypedDict, total=False):
155-
"""Configuration for product types discovery"""
154+
class DiscoverCollections(TypedDict, total=False):
155+
"""Configuration for collections discovery"""
156156

157-
#: URL from which the product types can be fetched
157+
#: URL from which the collections can be fetched
158158
fetch_url: Optional[str]
159-
#: HTTP method used to fetch product types
159+
#: HTTP method used to fetch collections
160160
fetch_method: str
161-
#: Request body to fetch product types using POST method
161+
#: Request body to fetch collections using POST method
162162
fetch_body: dict[str, Any]
163163
#: Maximum number of connections for concurrent HTTP requests
164164
max_connections: int
@@ -168,33 +168,33 @@ class DiscoverProductTypes(TypedDict, total=False):
168168
start_page: int
169169
#: Type of the provider result
170170
result_type: str
171-
#: JsonPath to the list of product types
171+
#: JsonPath to the list of collections
172172
results_entry: Union[str, JSONPath]
173-
#: Mapping for the product type id
174-
generic_product_type_id: str
175-
#: Mapping for product type metadata (e.g. ``abstract``, ``licence``) which can be parsed from the provider
173+
#: Mapping for the collection id
174+
generic_collection_id: str
175+
#: Mapping for collection metadata (e.g. ``abstract``, ``licence``) which can be parsed from the provider
176176
#: result
177-
generic_product_type_parsable_metadata: dict[str, str]
178-
#: Mapping for product type properties which can be parsed from the result and are not product type metadata
179-
generic_product_type_parsable_properties: dict[str, str]
180-
#: Mapping for product type properties which cannot be parsed from the result and are not product type metadata
181-
generic_product_type_unparsable_properties: dict[str, str]
177+
generic_collection_parsable_metadata: dict[str, str]
178+
#: Mapping for collection properties which can be parsed from the result and are not collection metadata
179+
generic_collection_parsable_properties: dict[str, str]
180+
#: Mapping for collection properties which cannot be parsed from the result and are not collection metadata
181+
generic_collection_unparsable_properties: dict[str, str]
182182
#: URL to fetch data for a single collection
183183
single_collection_fetch_url: str
184184
#: Query string to be added to the fetch_url to filter for a collection
185185
single_collection_fetch_qs: str
186-
#: Mapping for product type metadata returned by the endpoint given in single_collection_fetch_url. If ``ID``
187-
#: is redefined in this mapping, it will replace ``generic_product_type_id`` value
188-
single_product_type_parsable_metadata: dict[str, str]
186+
#: Mapping for collection metadata returned by the endpoint given in single_collection_fetch_url. If ``ID``
187+
#: is redefined in this mapping, it will replace ``generic_collection_id`` value
188+
single_collection_parsable_metadata: dict[str, str]
189189

190190

191191
class DiscoverQueryables(TypedDict, total=False):
192192
"""Configuration for queryables discovery"""
193193

194-
#: URL to fetch the queryables valid for all product types
194+
#: URL to fetch the queryables valid for all collections
195195
fetch_url: Optional[str]
196-
#: URL to fetch the queryables for a specific product type
197-
product_type_fetch_url: Optional[str]
196+
#: URL to fetch the queryables for a specific collection
197+
collection_fetch_url: Optional[str]
198198
#: Type of the result
199199
result_type: str
200200
#: JsonPath to retrieve the queryables from the provider result
@@ -320,8 +320,8 @@ class PluginConfig(yaml.YAMLObject):
320320
# search & api -----------------------------------------------------------------------------------------------------
321321
# copied from ProviderConfig in PluginManager.get_search_plugins()
322322
priority: int
323-
# per product type metadata-mapping, set in core._prepare_search
324-
product_type_config: dict[str, Any]
323+
# per collection metadata-mapping, set in core._prepare_search
324+
collection_config: dict[str, Any]
325325

326326
#: :class:`~eodag.plugins.search.base.Search` Plugin API endpoint
327327
api_endpoint: str
@@ -338,14 +338,14 @@ class PluginConfig(yaml.YAMLObject):
338338
sort: Sort
339339
#: :class:`~eodag.plugins.search.base.Search` Configuration for the metadata auto-discovery
340340
discover_metadata: DiscoverMetadata
341-
#: :class:`~eodag.plugins.search.base.Search` Configuration for the product types auto-discovery
342-
discover_product_types: DiscoverProductTypes
341+
#: :class:`~eodag.plugins.search.base.Search` Configuration for the collections auto-discovery
342+
discover_collections: DiscoverCollections
343343
#: :class:`~eodag.plugins.search.base.Search` Configuration for the queryables auto-discovery
344344
discover_queryables: DiscoverQueryables
345345
#: :class:`~eodag.plugins.search.base.Search` The mapping between eodag metadata and the plugin specific metadata
346346
metadata_mapping: dict[str, Union[str, list[str]]]
347347
#: :class:`~eodag.plugins.search.base.Search` :attr:`~eodag.config.PluginConfig.metadata_mapping` got from the given
348-
#: product type
348+
#: collection
349349
metadata_mapping_from_product: str
350350
#: :class:`~eodag.plugins.search.base.Search` A mapping for the metadata of individual assets
351351
assets_mapping: dict[str, dict[str, Any]]
@@ -412,7 +412,7 @@ class PluginConfig(yaml.YAMLObject):
412412
archive_depth: int
413413
#: :class:`~eodag.plugins.download.base.Download` Whether ignore assets and download using ``downloadLink`` or not
414414
ignore_assets: bool
415-
#: :class:`~eodag.plugins.download.base.Download` Product type specific configuration
415+
#: :class:`~eodag.plugins.download.base.Download` Collection specific configuration
416416
products: dict[str, dict[str, Any]]
417417
#: :class:`~eodag.plugins.download.http.HTTPDownload` Whether the product has to be ordered to download it or not
418418
order_enabled: bool

eodag/plugins/manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,15 @@ def build_collection_to_provider_config_map(self) -> None:
132132
"""Build mapping conf between collections and providers"""
133133
self.collection_to_provider_config_map = {}
134134
for provider in list(self.providers.values()):
135-
if not provider.product_types:
135+
if not provider.collections:
136136
logger.info(
137137
"%s: provider has no product configured and will be skipped",
138138
provider,
139139
)
140140
del self.providers[provider.name]
141141
continue
142142

143-
for collection in provider.product_types:
143+
for collection in provider.collections:
144144
collection_providers = (
145145
self.collection_to_provider_config_map.setdefault( # noqa
146146
collection, []

0 commit comments

Comments
 (0)