Implementation:Apache Airflow ProvidersManager Validation
| Knowledge Sources | |
|---|---|
| Domains | Testing, Plugin_System |
| Last Updated | 2026-02-08 00:00 GMT |
Overview
Concrete tool for validating provider packages and discovering registered components provided by the ProvidersManager singleton.
Description
The ProvidersManager is a singleton that discovers all installed provider packages by scanning the apache_airflow_provider entry point. It validates provider metadata against the schema, imports all declared components, and caches the results. The discover_all_providers_from_packages function handles the actual scanning logic.
Usage
ProvidersManager is initialized automatically by the Airflow runtime. Use it in tests to validate that providers are correctly installed and configured.
Code Reference
Source Location
- Repository: Apache Airflow
- File: airflow-core/src/airflow/providers_manager.py
- Lines: L368-1361
Signature
class ProvidersManager(LoggingMixin):
"""Manages all provider distributions. Singleton class."""
resource_version = "0"
_initialized: bool = False
_instance: ProvidersManager | None = None
def __new__(cls) -> ProvidersManager:
"""Ensure singleton."""
...
def __init__(self) -> None:
"""Initialize or return cached instance."""
...
# Key properties:
# providers: dict[str, ProviderInfo]
# hooks: dict[str, HookClassProvider]
# connection_form_widgets: dict
# trigger_info_set: set[TriggerInfo]
Discovery function:
def discover_all_providers_from_packages(
provider_dict: dict[str, ProviderInfo],
provider_schema_validator,
) -> None:
"""Scan installed packages for apache_airflow_provider entry points."""
...
Import
from airflow.providers_manager import ProvidersManager
from airflow_shared.providers_discovery.providers_discovery import discover_all_providers_from_packages
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| Installed packages | Entry points | Yes | Packages with apache_airflow_provider entry point |
| provider_schema_validator | Validator | Yes | JSON Schema validator for provider.yaml |
Outputs
| Name | Type | Description |
|---|---|---|
| provider_dict | dict[str, ProviderInfo] | Validated provider metadata |
| hooks | dict[str, HookClassProvider] | Registered hook classes by connection type |
| connection_form_widgets | dict | Custom UI widgets for connection forms |
| trigger_info_set | set[TriggerInfo] | Registered trigger classes |
Usage Examples
Validate Providers in Tests
from airflow.providers_manager import ProvidersManager
def test_provider_loaded():
pm = ProvidersManager()
assert "apache-airflow-providers-example" in pm.providers
def test_hooks_registered():
pm = ProvidersManager()
assert "example" in pm.hooks