potiuk commented on a change in pull request #12472: URL: https://github.com/apache/airflow/pull/12472#discussion_r533841635
########## File path: airflow/providers_manager.py ########## @@ -224,6 +226,43 @@ def _add_hook(self, hook_class_name, provider_package) -> None: self._hooks_dict[conn_type] = (hook_class_name, connection_id_attribute_name) + def _discover_extra_links(self) -> None: + """Retrieves all extra links defined in the providers""" + for provider_package, (_, provider) in self._provider_dict.items(): + if provider.get("extra-links"): + for extra_link in provider["extra-links"]: + self.__add_extra_link(extra_link, provider_package) + + def __add_extra_link(self, extra_link_class_name, provider_package) -> None: + """ + Adds extra link class name to the list of classes + :param extra_link_class_name: name of the class to add + :param provider_package: provider package adding the link + :return: + """ + if provider_package.startswith("apache-airflow"): + provider_path = provider_package[len("apache-") :].replace("-", ".") + if not extra_link_class_name.startswith(provider_path): + log.warning( + "Sanity check failed when importing '%s' from '%s' package. It should start with '%s'", + extra_link_class_name, + provider_package, + provider_path, + ) + return + try: + module, class_name = extra_link_class_name.rsplit('.', maxsplit=1) + getattr(importlib.import_module(module), class_name) Review comment: Surely, I wanted to get more of a sanity check and "early" warning in the logs of Airflow. The way it is done right now is that the class will be anyhow imported in the "deserialize_operator" method, which I think is 'good enough" so I am happy to remove it. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org