feat(asset): move download_link property to an asset #2029#2091
feat(asset): move download_link property to an asset #2029#2091pdavid-cssopra wants to merge 1 commit intodevelopfrom
Conversation
86d88b2 to
5c91ba2
Compare
Test Results 2 files - 2 2 suites - 2 35s ⏱️ - 2m 38s For more details on these failures, see this check. Results for commit 1a81d2b. ± Comparison against base commit 798a34a. ♻️ This comment has been updated with latest results. |
Code Coverage (Ubuntu)DetailsDiff against developResults for commit: 1a81d2b Minimum allowed coverage is ♻️ This comment has been updated with latest results |
5c91ba2 to
6061929
Compare
+ update/complete asset mapping behaviour + update provider configuration + update specific providers + centralize/deduplicate source
6061929 to
1a81d2b
Compare
| self, collection: Optional[str] = None | ||
| ) -> dict[str, Union[str, list[str]]]: | ||
| """Get the plugin metadata mapping configuration (collection specific if exists) | ||
| :param collection: the desired collection |
There was a problem hiding this comment.
| :param collection: the desired collection | |
| :param collection: the desired collection |
| """ | ||
| metadata_mapping = getattr(self.config, "metadata_mapping", {}) | ||
| if isinstance(collection, str): | ||
| # Special overfload for collection config |
There was a problem hiding this comment.
| # Special overfload for collection config | |
| # Special overload for collection config |
| watchdog -= 1 | ||
| # Check if collection has a specific configuration | ||
| collection_config = self.config.products.get(target_collection, {}) | ||
| # Overload imported asset mapping configuration by current one |
There was a problem hiding this comment.
| # Overload imported asset mapping configuration by current one | |
| # Overload imported metadata mapping configuration by current one |
| collection_metadata_mapping = buffer | ||
| # This collection configuration can refer to another collection configuration | ||
| target_collection = collection_config.get( | ||
| "metadata_mapping_from_product", None |
There was a problem hiding this comment.
| "metadata_mapping_from_product", None | |
| "metadata_mapping_from_product" |
| :returns: The collection metadata assets-mapping | ||
| """ | ||
| metadata_mapping = getattr(self.config, "metadata_mapping", {}) | ||
| if isinstance(collection, str): |
There was a problem hiding this comment.
| if isinstance(collection, str): | |
| if collection is not None: |
avoids having to wonder if collection supports different types and if it needs to be handled
| assets_mapping = getattr(self.config, "assets_mapping", {}) | ||
| if isinstance(collection, str): | ||
| # Special overfload for collection config | ||
| # "metadata_mapping_from_product" overloaded by "current" |
There was a problem hiding this comment.
as metadata_mapping and assets_mapping are already distinct config entries, i'd use a new assets_mapping_from_product here
| ) -> dict[str, Union[str, list[str]]]: | ||
| """Get the plugin metadata mapping configuration (collection specific if exists) | ||
| :param collection: the desired collection | ||
| :returns: The collection metadata assets-mapping |
There was a problem hiding this comment.
| :returns: The collection metadata assets-mapping | |
| :returns: The collection specific metadata-mapping |
| ) | ||
| metadata_mapping.update(collection_metadata_mapping) | ||
| if watchdog == 0: | ||
| logger.warning("get_assets_mapping watchdog triggered") |
There was a problem hiding this comment.
| logger.warning("get_assets_mapping watchdog triggered") | |
| logger.warning("get_metadata_mapping watchdog triggered") |
| return queryables | ||
|
|
||
| def get_assets_from_mapping(self, provider_item: dict[str, Any]) -> dict[str, Any]: | ||
| def get_assets_from_mapping( |
There was a problem hiding this comment.
name is confusing with get_assets_mapping, please rename to build_assets_from_mapping or similar
| properties[field_name] = collection_properties[field_name] | ||
|
|
||
| # Gather asset mapping | ||
| assets_mapping = self.get_assets_mapping(collection) |
There was a problem hiding this comment.
do not rewrite a new metadata-mapping parser, use existing mechanisms:
assets_mapping = self.get_assets_mapping(collection)
assets = AssetsDict(product)
if not assets_mapping:
return assets
for key, mapping in assets_mapping.items():
asset_querypaths = mtd_cfg_as_conversion_and_querypath(mapping)
assets |= {key: properties_from_json(provider_item, asset_querypaths)}You will need to update roles in providers.yml:
from
roles:
- 'archive'
- 'data'to
roles: '["archive", "data"]'
From #1929
Task
move
eodag:download_linkproperty to an asset when it is downloadable (do not keep it has a fake-value and when product download was performed from other assets). If the download_link is not required, remove it and do not add it to assets.download_linkas keyarchive, dataas rolesWhen downloading a whole product:
archivein rolesarchivein roles, download all assetsNote:
hrefororder_linkWork on