Skip to content

Lazily import fs and package_index hook in providers manager #52117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 23, 2025

Conversation

ashb
Copy link
Member

@ashb ashb commented Jun 23, 2025

I discovered this side-effect that once you call ProvidersManager()._clear()
then the fs connection type was no longer registered. This is fixed by
moving the call to _init_airflow_core_hooks into the (already cached in
memory once per instance) initialize_providers_hooks function

This lead me to notice that we were directly importing the standard provider
eagerly at the top level, which we want to avoid in Airflow 3 with the work
torward separation of Core and Task SDK. So I changed it to make use of the
existing "lazy resolve" feature of _hooks_lazy_dict.

And finally, I removed the _hooks_dict attribute which was being created,
but never looked at again.


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

I discovered this side-effect that once you call `ProvidersManager()._clear()`
then the `fs` connection type was no longer registered. This is fixed by
moving the call to `_init_airflow_core_hooks` into the (already cached in
memory once per instance) `initialize_providers_hooks` function

This lead me to notice that we were directly importing the standard provider
eagerly at the top level, which we want to avoid in Airflow 3 with the work
torward separation of Core and Task SDK. So I changed it to make use of the
existing "lazy resolve" feature of `_hooks_lazy_dict`.

And finally, I removed the `_hooks_dict` attribute which was being created,
but never looked at again.
@ashb ashb changed the title Lazily import fs and package_index hook in providers manager. Lazily import fs and package_index hook in providers manager Jun 23, 2025
@ashb ashb requested a review from jedcunningham June 23, 2025 21:16
@ashb ashb merged commit 7d00e45 into main Jun 23, 2025
97 of 98 checks passed
@ashb ashb deleted the providers-manager-lazy-import-fshooks branch June 23, 2025 23:03
@potiuk
Copy link
Member

potiuk commented Jun 24, 2025

Nice! Thanks @ashb !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants