Skip to content

Remove old lineage stuff - #45260

Merged
Lee-W merged 4 commits into
apache:mainfrom
jason810496:remove-old-lineage-stuff
Jan 25, 2025
Merged

Remove old lineage stuff#45260
Lee-W merged 4 commits into
apache:mainfrom
jason810496:remove-old-lineage-stuff

Conversation

@jason810496

Copy link
Copy Markdown
Member

closes: #44983


^ 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 newsfragments.

@jason810496

Copy link
Copy Markdown
MemberAuthor

When attempting to remove the lineage logic from the core module, I noticed that it causes failures in tests related to OpenLineage listener capturing hook-level lineage (#41482).

For example, removing apply_lineage and prepare_lineage from BaseOperator:

@prepare_lineage
defpre_execute(self, context: Any):
"""Execute right before self.execute() is called."""
ifself._pre_execute_hookisNone:
return
ExecutionCallableRunner(
self._pre_execute_hook,
context_get_outlet_events(context),
logger=self.log,
).run(context)
defexecute(self, context: Context) ->Any:
"""
Derive when creating an operator.
Context is the same dictionary used as when rendering jinja templates.
Refer to get_template_context for more context.
"""
raiseNotImplementedError()
@apply_lineage
defpost_execute(self, context: Any, result: Any=None):
"""
Execute right after self.execute() is called.
It is passed the execution context and any results returned by the operator.
"""
ifself._post_execute_hookisNone:
return
ExecutionCallableRunner(
self._post_execute_hook,
context_get_outlet_events(context),
logger=self.log,
).run(context, result)

Results in the following test failure:

FAILED providers/tests/openlineage/extractors/test_manager.py::test_extractor_manager_gets_data_from_pythonoperator - assert 0 == 1
+ where 0 = len([])
+ where [] = HookLineage(inputs=[], outputs=[]).outputs

deftest_extractor_manager_gets_data_from_pythonoperator(session, dag_maker, hook_lineage_collector):

It seems OpenLineage is still coupled with the lineage module and might need to be moved to compact.lineage for now (or to the OpenLineage module in a future PR ).

After some experimentation, implementing an on_load callback in the OpenLineageProviderPlugin to monkey-patch the core module at runtime prevents the OpenLineage test failures, even with the lineage module removed from the core.

Based on https://airflow.apache.org/docs/apache-airflow/stable/authoring-and-scheduling/plugins.html#interface

I’m not sure if this is a suitable long-term solution for maintaining OpenLineage compatibility while cleaning up the lineage module ?

cc @Lee-W@uranusjr

@jason810496
jason810496force-pushed the remove-old-lineage-stuff branch from 7975d5a to 727a6c1CompareDecember 28, 2024 13:39
@Lee-W
Lee-W self-requested a review December 29, 2024 23:53
@jason810496
jason810496force-pushed the remove-old-lineage-stuff branch from 727a6c1 to 2ec66f0CompareJanuary 1, 2025 16:20
@jason810496

jason810496 commented Jan 2, 2025

Copy link
Copy Markdown
MemberAuthor

The CI failure is caused by a flaky K8s test (#45145) and a breaking change in the compatibility tests for providers 2.9.3 and 2.10.4 .

Should we fix the tests to pass the compatibility checks, or is it acceptable to ignore the compatibility tests since all tests for 3.0 have passed ?

@jason810496
jason810496 marked this pull request as ready for review January 2, 2025 06:01
@jason810496jason810496 changed the title [WIP] Remove old lineage stuffRemove old lineage stuffJan 2, 2025
@Lee-W

Lee-W commented Jan 2, 2025

Copy link
Copy Markdown
Member

The CI failure is caused by a flaky K8s test (#45145) and a breaking change in the compatibility tests for providers 2.3.9 and 2.3.10.

Should we fix the tests to pass the compatibility checks, or is it acceptable to ignore the compatibility tests since all tests for 3.0 have passed ?

2.9.3 or 2.3.9. If it's 2.9.3, then we'll need to fix it as providers will still support airflow 2 for some time

@jason810496

Copy link
Copy Markdown
MemberAuthor

2.9.3 or 2.3.9. If it's 2.9.3, then we'll need to fix it as providers will still support airflow 2 for some time

Sorry for the typo, I mean 2.9.3 and 2.10.4 . Thanks for reply, if then I will fix the test.

@jason810496
jason810496 marked this pull request as draft January 2, 2025 06:40
@uranusjr

Copy link
Copy Markdown
Member

We should not remove the entire lineage mechanism. The issue is only meant to remove the old lineage constructs in airflow.lineage.entities. The rest of the mechanism integrates modern Airflow assets with OpenLineage, and they should be kept.

@mobuchowski

Copy link
Copy Markdown
Contributor

Just as TP said. Removing airflow/lineage/hook.py is wrong

@potiuk
potiukforce-pushed the remove-old-lineage-stuff branch from 2ec66f0 to 7274e30CompareJanuary 2, 2025 12:34
@potiuk

Copy link
Copy Markdown
Member

@jason810496 I rebased it -> we found and issue with @jscheffl with the new caching scheme - fixed in #45347 that would run "main" version of the tests.

@jason810496
jason810496force-pushed the remove-old-lineage-stuff branch from 7274e30 to b32fd1aCompareJanuary 3, 2025 11:40
@jason810496jason810496 reopened this Jan 3, 2025
@jason810496
jason810496 marked this pull request as ready for review January 4, 2025 06:28
@jason810496

Copy link
Copy Markdown
MemberAuthor

Fixed: I only moved airflow.lineage.entities to airflow.providers.common.compat.lineage.entities.
The CI failure is unrelated, as no relevant frontend tests failed.

One small question: Does this PR need to be backported to 2.10 ?

@jason810496
jason810496force-pushed the remove-old-lineage-stuff branch from 2cb6d39 to f527be9CompareJanuary 8, 2025 02:58
@Lee-W

Copy link
Copy Markdown
Member

Hi @jason810496, I just found the PR we discussed yesterday. #44720 I think this one would be useful for this PR.

Comment threadproviders/src/airflow/providers/common/compat/__init__.py Outdated
@jason810496
jason810496force-pushed the remove-old-lineage-stuff branch from f527be9 to 4367e2aCompareJanuary 14, 2025 04:09
@uranusjr

Copy link
Copy Markdown
Member

One small question: Does this PR need to be backported to 2.10?

No since you only moved the classes. The providers are always released from main, and it’s OK for those classes to be available in two places in 2.10.

@jason810496
jason810496force-pushed the remove-old-lineage-stuff branch 2 times, most recently from fcb5625 to 9545aa1CompareJanuary 23, 2025 13:13
@jason810496
jason810496force-pushed the remove-old-lineage-stuff branch from 9545aa1 to 7158e1eCompareJanuary 24, 2025 16:50
@Lee-W
Lee-W merged commit a3294cc into apache:mainJan 25, 2025
@utkarsharma2utkarsharma2 added the changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) label Jan 27, 2025
gpathak128 pushed a commit to gpathak128/airflow that referenced this pull request Jan 29, 2025
* Move airflow.lineage.entities to compact provider
* Fix providers and corresponding test import path
* Fix core test import path
* Fix import path in related docs
got686-yandex pushed a commit to got686-yandex/airflow that referenced this pull request Jan 30, 2025
* Move airflow.lineage.entities to compact provider
* Fix providers and corresponding test import path
* Fix core test import path
* Fix import path in related docs
niklasr22 pushed a commit to niklasr22/airflow that referenced this pull request Feb 8, 2025
* Move airflow.lineage.entities to compact provider
* Fix providers and corresponding test import path
* Fix core test import path
* Fix import path in related docs
ambika-garg pushed a commit to ambika-garg/airflow that referenced this pull request Feb 17, 2025
* Move airflow.lineage.entities to compact provider
* Fix providers and corresponding test import path
* Fix core test import path
* Fix import path in related docs
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:dev-toolsarea:lineagechangelog:skipChanges that should be skipped from the changelog (CI, tests, etc..)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove old lineage stuff

6 participants

@jason810496@Lee-W@uranusjr@mobuchowski@potiuk@utkarsharma2