|
36 | 36 | from packaging.utils import canonicalize_name |
37 | 37 |
|
38 | 38 | from airflow.exceptions import AirflowOptionalProviderFeatureException |
39 | | -from airflow.providers.standard.hooks.filesystem import FSHook |
40 | | -from airflow.providers.standard.hooks.package_index import PackageIndexHook |
41 | 39 | from airflow.typing_compat import ParamSpec |
42 | 40 | from airflow.utils.entry_points import entry_points_with_dist |
43 | 41 | from airflow.utils.log.logging_mixin import LoggingMixin |
@@ -395,8 +393,6 @@ def __init__(self): |
395 | 393 | self._initialized_cache: dict[str, bool] = {} |
396 | 394 | # Keeps dict of providers keyed by module name |
397 | 395 | self._provider_dict: dict[str, ProviderInfo] = {} |
398 | | - # Keeps dict of hooks keyed by connection type |
399 | | - self._hooks_dict: dict[str, HookInfo] = {} |
400 | 396 | self._fs_set: set[str] = set() |
401 | 397 | self._asset_uri_handlers: dict[str, Callable[[SplitResult], SplitResult]] = {} |
402 | 398 | self._asset_factories: dict[str, Callable[..., Asset]] = {} |
@@ -443,19 +439,17 @@ def _init_airflow_core_hooks(self): |
443 | 439 | connection_type=None, |
444 | 440 | connection_testable=False, |
445 | 441 | ) |
446 | | - for cls in [FSHook, PackageIndexHook]: |
447 | | - package_name = cls.__module__ |
448 | | - hook_class_name = f"{cls.__module__}.{cls.__name__}" |
449 | | - hook_info = self._import_hook( |
| 442 | + for conn_type, class_name in ( |
| 443 | + ("fs", "airflow.providers.standard.hooks.filesystem.FSHook"), |
| 444 | + ("package_index", "airflow.providers.standard.hooks.package_index.PackageIndexHook"), |
| 445 | + ): |
| 446 | + self._hooks_lazy_dict[conn_type] = functools.partial( |
| 447 | + self._import_hook, |
450 | 448 | connection_type=None, |
451 | | - provider_info=None, |
452 | | - hook_class_name=hook_class_name, |
453 | | - package_name=package_name, |
454 | | - ) |
455 | | - self._hook_provider_dict[hook_info.connection_type] = HookClassProvider( |
456 | | - hook_class_name=hook_class_name, package_name=package_name |
| 449 | + package_name="apache-airflow-providers-standard", |
| 450 | + hook_class_name=class_name, |
| 451 | + provider_info=None, # type: ignore[argument] |
457 | 452 | ) |
458 | | - self._hooks_lazy_dict[hook_info.connection_type] = hook_info |
459 | 453 |
|
460 | 454 | @provider_info_cache("list") |
461 | 455 | def initialize_providers_list(self): |
@@ -487,6 +481,7 @@ def _verify_all_providers_all_compatible(self): |
487 | 481 | @provider_info_cache("hooks") |
488 | 482 | def initialize_providers_hooks(self): |
489 | 483 | """Lazy initialization of providers hooks.""" |
| 484 | + self._init_airflow_core_hooks() |
490 | 485 | self.initialize_providers_list() |
491 | 486 | self._discover_hooks() |
492 | 487 | self._hook_provider_dict = dict(sorted(self._hook_provider_dict.items())) |
@@ -1275,7 +1270,6 @@ def already_initialized_provider_configs(self) -> list[tuple[str, dict[str, Any] |
1275 | 1270 | def _cleanup(self): |
1276 | 1271 | self._initialized_cache.clear() |
1277 | 1272 | self._provider_dict.clear() |
1278 | | - self._hooks_dict.clear() |
1279 | 1273 | self._fs_set.clear() |
1280 | 1274 | self._taskflow_decorators.clear() |
1281 | 1275 | self._hook_provider_dict.clear() |
|
0 commit comments