-
Notifications
You must be signed in to change notification settings - Fork 51
feat(plugins): allow multiple download or auth plugins for a single provider #1704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
feat(plugins): allow multiple download or auth plugins for a single provider #1704
Conversation
…t adaptations and fixes
…daptions and fixes
Code Coverage (Ubuntu)Diff against developResults for commit: 3d76b87 Minimum allowed coverage is ♻️ This comment has been updated with latest results |
Code Coverage (Windows)Diff against developResults for commit: 3d76b87 Minimum allowed coverage is ♻️ This comment has been updated with latest results |
e266451 to
3d76b87
Compare
| :param auth_conf: Authentication plugin configuration | ||
| :returns: True if credentials are set, else False | ||
| """ | ||
| return any( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move credentials_in_auth to PluginConfig.has_credentials ?
| """Authenticate""" | ||
| raise NotImplementedError | ||
|
|
||
| def get_required_credentials(self) -> dict[str, str]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| def get_required_credentials(self) -> dict[str, str]: | |
| def get_credentials(self) -> dict[str, str]: |
| """checks if only a subset of the credentials is required for the plugin object | ||
| and returns this subset; returns all credentials if not required credentials are given | ||
| :returns: dict of credentials |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| """checks if only a subset of the credentials is required for the plugin object | |
| and returns this subset; returns all credentials if not required credentials are given | |
| :returns: dict of credentials | |
| """Get plugin configuration credentials. | |
| Checks if only a subset of the credentials is required for the plugin object | |
| and returns this subset. | |
| Returns all credentials if no required credentials are given. | |
| :returns: dict of credentials |
| matching_conf: Optional[PluginConfig], | ||
| ) -> bool: | ||
| """ | ||
| checks if the given plugin config is matching the matching config or url |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| checks if the given plugin config is matching the matching config or url | |
| Checks if the given plugin config is matching the matching config or url | |
| logger = logging.getLogger("eodag.plugins.manager") | ||
|
|
||
|
|
||
| def _is_plugin_matching( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to PluginConfig.is_matching ?
| }, | ||
| download: dict[str, Any] = {"type": "HTTPDownload", "auth_error_code": 401}, | ||
| download: list[dict[str, Any]] = [], | ||
| **kwargs: dict[str, Any], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please replace **kwargs with auth: Optional[list[dict[str, Any]]] = None and api: Optional[dict[str, Any]] = None
| logger.info( | ||
| "%s: provider needing auth for search has been pruned because " | ||
| "no credentials could be found", | ||
| provider, | ||
| ) | ||
| self._pruned_providers_config[ | ||
| provider | ||
| ] = self.providers_config.pop(provider) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| logger.info( | |
| "%s: provider needing auth for search has been pruned because " | |
| "no credentials could be found", | |
| provider, | |
| ) | |
| self._pruned_providers_config[ | |
| provider | |
| ] = self.providers_config.pop(provider) | |
| self._pruned_providers_config[ | |
| provider | |
| ] = self.providers_config.pop(provider) | |
| logger.info( | |
| "%s: provider needing auth for search has been pruned because " | |
| "no credentials could be found", | |
| provider, | |
| ) |
| kwargs["auth"] = auth | ||
| else: | ||
| logger.debug( | ||
| f"No authentication plugin for {provider} for product types discovery found" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| f"No authentication plugin for {provider} for product types discovery found" | |
| "No authentication plugin for %s for product types discovery found", provider |
| def get_auth( | ||
| self, | ||
| provider: str, | ||
| required_for: str, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| required_for: str, | |
| required_for: Literal["search", "download"], |
| returns the url used to find the download and auth plugin for a product | ||
| (currently there is only one matching_url per product, where per asset | ||
| downloaders are implmented, this will change) | ||
| :param eo_product: product for with the matching url shall be found |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| returns the url used to find the download and auth plugin for a product | |
| (currently there is only one matching_url per product, where per asset | |
| downloaders are implmented, this will change) | |
| :param eo_product: product for with the matching url shall be found | |
| returns the url used to find the download and auth plugin for a product | |
| (currently there is only one matching_url per product, where per asset | |
| downloaders are implmented, this will change) | |
| TODO: adapt method to asset once downloadLink is handled through an asset | |
| :param eo_product: product for with the matching url shall be found |
Instead of a single download or authentication plugin, now a list of plugins is defined for each provider:
search_authanddownload_authhave been removed, both are now given in a list and the parameterrequired_for(list[str]) is used to define if an authentication plugin is used for search, download or both. This also replaces the attributeneed_authof the search plugin. The parameterrequired_credentialsis used to define which credentials are used for which plugin in case of multiple plugins. If it is not given, it is assumed that all available credentials fromeodag.ymlare required.matching_urlandmatching_confhave been replaced by a dictionarymatch. The parameterhrefin the dictionary corresponds tomatching_url, the remaining parameters tomatching_conf.