Skip to content

Comments

Fix false warning about usage outside of ti for extended operators#47552

Closed
insomnes wants to merge 1 commit intoapache:mainfrom
insomnes:fix-extended-operator-warning
Closed

Fix false warning about usage outside of ti for extended operators#47552
insomnes wants to merge 1 commit intoapache:mainfrom
insomnes:fix-extended-operator-warning

Conversation

@insomnes
Copy link
Contributor

@insomnes insomnes commented Mar 10, 2025

Current ExecutorSafeguard emits a false warning about extended operators' usage outside of the task instance.

In #42849 the fix was introduced, but it's tests are flawed and depend on the testing order and values in ExecutorSafeguard leaking between tests.

An isolated call of pytest -sv tests/models/test_baseoperatormeta.py::TestExecutorSafeguard::test_executor_when_extended_classic_operator_called_from_dag shows tests fail while pytest -sv tests/models/test_baseoperatormeta.py is green.

Changes:

  • adapt to wrapped execute methods calling orders for extended operator classes by propagating sentinel via base classes keys to callers
  • emit warning only once per class chain
  • clean ExecutorSafeguard state between tests
  • expand tests

closes: #47511
related: #45498


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

@insomnes insomnes requested a review from uranusjr as a code owner March 10, 2025 00:26
@eladkal
Copy link
Contributor

eladkal commented Mar 10, 2025

We already have PR for this #47523

@uranusjr
Copy link
Member

I’m going with the other PR since that one alreay has multiple approvals.

@uranusjr uranusjr closed this Mar 10, 2025
@insomnes
Copy link
Contributor Author

Sorry, I've missed that one during search. Thank you.

@insomnes insomnes deleted the fix-extended-operator-warning branch April 18, 2025 16:46
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.

BranchPythonOperator.execute cannot be called outside TaskInstance!

3 participants