-
Notifications
You must be signed in to change notification settings - Fork 16.4k
feat: Adjust common.compat HookLevelLineage collector for new add_extra method #58057
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
Conversation
7d7c23a to
2d9d30f
Compare
mobuchowski
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's definitely not beautiful... but can't think of better way of making this work on older versions.
Could not agree more, and I think it can bring a lot of value for older Airflow versions. |
ashb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the polyfill approach is one we should use - my first thought is to instead make it a no op only older versions
|
I considered that approach as well, but ultimately decided to go with the polyfill implementation. The code isn’t very complex in the end, and since it’s only executed once for a singleton collector instance, the overhead is minimal. I understand that maintaining it could be more challenging compared to a no-op, and that ideally, users should upgrade Airflow to benefit from the latest features. However, in my view, the value this solution provides outweighs the effort required to implement and maintain it. That said, if this is a hard no or a blocker for you, I’m happy to adjust the code and switch to a no-op. But if you think there’s room to proceed with the polyfill approach, I’d be glad to make any changes needed to align it better. |
|
@ashb How do you feel about the above? Can we proceed with the polyfill approach? |
potiuk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Waiting for @ashb
|
Looking now. |
ashb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay with polyfill, but we need to make it duck-typed, not version based (see comment)
providers/common/compat/src/airflow/providers/common/compat/lineage/hook.py
Outdated
Show resolved
Hide resolved
providers/common/compat/src/airflow/providers/common/compat/lineage/hook.py
Outdated
Show resolved
Hide resolved
2d9d30f to
bd3987f
Compare
Extends the current common.compat compatibility layer with support for the new Hook Lineage `add_extra` method, ensuring full backward compatibility and consistent hook-level lineage behavior across all Airflow 2.11+ versions.
bd3987f to
a178d16
Compare
…#58057) Extends the current common.compat compatibility layer with support for the new Hook Lineage `add_extra` method, ensuring full backward compatibility and consistent hook-level lineage behavior across all Airflow 2.11+ versions.
…#58057) Extends the current common.compat compatibility layer with support for the new Hook Lineage `add_extra` method, ensuring full backward compatibility and consistent hook-level lineage behavior across all Airflow 2.11+ versions.
TLDR;
Follow-up to #57620 - this PR extends the common.compat provider to support the new Hook Lineage
add_extramethod, ensuring full backward compatibility and consistent hook-level lineage behavior across all Airflow 2.10+ versions.Problem
The
add_extramethod for hook lineage collection was introduced in Airflow 3.2 (#57620). However, providers currently support Airflow 2.10+ and may call the newadd_extramethod when running on Airflow versions earlier than 3.2. We previously encountered a similar issue during the transition fromDatasettoAsset, where the hook lineage collector methods changed fromadd_input_datasettoadd_input_asset. To handle that, we added a compatibility layer in the common.compat provider that manages these naming differences. All other providers were then updated to import the hook lineage collector from common.compat instead of core Airflow, call was changed to the new_assetmethods and the newer compat provider was made a dependency for those providers.Without such a compatibility layer, hooks using incompatible code (for example, calling a method that does not exist) would fail on older Airflow versions. This would cause inconsistent behavior and prevent provider hooks from emitting rich lineage metadata. Therefore, I propose applying the same solution here, extending the current compatibility approach.
Solution
This PR enhances the existing compatibility layer in the common.compat provider to ensure that the hook lineage collector returned from it consistently supports the
add_extramethod across all supported Airflow versions. For Airflow versions that do not natively includeadd_extra, the compatibility layer provides a full implementation of the method, maintaining consistent lineage quality. This is feasible because the hook lineage collector is already operational and collecting lineage data in Airflow 2.10+, so only a small extension was needed to add this capability.This PR extends current compatibility layer in the
common.compatprovider to ensure that hook lineage collector returned by common.compat provider is equipped withadd_extramethod and behaves consistently across all supported Airflow versions. It implements the fulladd_extrafunctionality for Airflow versions that don't have it natively to keep consistency in lineage quality. (It's possible because the hook lineage collector is already up and running and is already gathering lineage as the whole structure in airflow core is already there for AF2.10+, so it was just about extending it a bit.)With this update, provider hooks can safely use:
on any Airflow 2.10+ version, and the behavior will remain identical - provided they depend on the latest common.compat provider version (which should be updated when introducing this call, as per usual practice).
Comprehensive test coverage has been added, covering both standard and edge cases across all Airflow versions included in compatibility testing, ensuring the functionality performs as intended.
This solution allows hook implementations to call
add_extrawithout version-specific logic, delivering a consistent lineage experience for users regardless of the Airflow version in use.Example Usage
^ 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.rstor{issue_number}.significant.rst, in airflow-core/newsfragments.