potiuk commented on a change in pull request #12466:
URL: https://github.com/apache/airflow/pull/12466#discussion_r527277145
##########
File path: airflow/providers_manager.py
##########
@@ -46,42 +45,134 @@ class ProvidersManager:
"""Manages all provider packages."""
def __init__(self):
+ self.__log = logging.getLogger(__name__)
self._provider_directory = {}
try:
from airflow import providers
except ImportError as e:
- log.warning("No providers are present or error when importing
them! :%s", e)
+ self.__log.warning("No providers are present or error when
importing them! :%s", e)
return
- self._validator = _create_validator()
+ self.__connections: Dict[str, Tuple[str, str]] = {}
+ self.__validator = _create_validator()
self.__find_all_providers(providers.__path__)
+ self.__retrieve_connections()
- def __find_all_providers(self, paths: str):
- def onerror(_):
- exception_string = traceback.format_exc()
- log.warning(exception_string)
+ @staticmethod
+ def get_full_class_name(provider_package: str, class_path: str):
+ """
+ Return full class name - if the class starts with ., it adds
package_name in front.
+ :param provider_package: Package name
+ :param class_path: class path (might be relative if starts with .)
+ :return: full class name
+ """
+ if class_path.startswith('.'):
+ return f"{provider_package}{class_path}"
+ return class_path
- for module_info in pkgutil.walk_packages(paths,
prefix="airflow.providers.", onerror=onerror):
- try:
- imported_module = importlib.import_module(module_info.name)
- except Exception as e: # noqa pylint: disable=broad-except
- log.warning("Error when importing %s:%s", module_info.name, e)
- continue
+ def __find_all_providers(self, paths: str) -> None:
+ """
+ Finds all providers installed and stores then in the directory of the
providers.
+ :param paths: Path where to look for providers
+ """
+ import warnings
+
+ old_warn = warnings.warn
+
+ def warn(*args, **kwargs):
+ if "deprecated" not in args[0]:
+ old_warn(*args, **kwargs)
+
+ warnings.warn = warn
Review comment:
Ah nice!
----------------------------------------------------------------
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:
[email protected]