potiuk commented on a change in pull request #17625:
URL: https://github.com/apache/airflow/pull/17625#discussion_r689795995
##########
File path: airflow/providers_manager.py
##########
@@ -61,6 +62,36 @@ def
_create_customized_form_field_behaviours_schema_validator():
return validator
+def _sanity_check(provider_package: str, class_name: str) -> bool:
+ """
+ Performs sanity check on provider classes.
+ For apache-airflow providers - it checks if it starts with appropriate
package. For all providers
+ it tries to import the provider - checking that there are no exceptions
during importing.
+ """
+ if provider_package.startswith("apache-airflow"):
+ provider_path = provider_package[len("apache-") :].replace("-", ".")
+ if not class_name.startswith(provider_path):
+ log.warning(
+ "Sanity check failed when importing '%s' from '%s' package. It
should start with '%s'",
+ class_name,
+ provider_package,
+ provider_path,
+ )
+ return False
+ try:
+ module, class_name = class_name.rsplit('.', maxsplit=1)
+ getattr(importlib.import_module(module), class_name)
Review comment:
Ah . I did not even know we had it . Sure :)
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]