Skip to content
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

Update ExternalTaskSensorLink to handle templated external_dag_id #21192

Merged

Conversation

josh-fell
Copy link
Contributor

Closes: #21183


^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code change, 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 UPDATING.md.

@boring-cyborg boring-cyborg bot added the area:core-operators Operators, Sensors and hooks within Core Airflow label Jan 28, 2022
@josh-fell josh-fell force-pushed the template-field-op-link-externaltasksensor branch from e9473fd to 6fafc4d Compare January 29, 2022 02:32
Comment on lines 43 to 44
ti = TaskInstance(task=operator, execution_date=dttm)
operator.render_template_fields({"ti": ti})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, we should try to discourage creating ad-hoc TaskInstance objects since it is much too brittle now that it has a foreign key to DagRun. Not sure what’s a good alternative though. @ashb Maybe this is a good time to (finally) start working on a new interface for this?

Also instead of just {"ti": ti} we should likely use ti.get_template_context().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah OK. Took a look at the other operator links too and all but one creates an ad hoc TaskInstance, but honestly those probably could just use XCom.get_one().

I'll update to use ti.get_template_context() in the meantime and test.

@josh-fell josh-fell force-pushed the template-field-op-link-externaltasksensor branch from 6fafc4d to 7a87b0d Compare February 1, 2022 03:13
@github-actions github-actions bot added the full tests needed We need to run full set of tests for this PR to merge label Feb 1, 2022
@github-actions
Copy link

github-actions bot commented Feb 1, 2022

The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.

@josh-fell josh-fell force-pushed the template-field-op-link-externaltasksensor branch from 7a87b0d to d7e83d7 Compare February 6, 2022 03:46
@potiuk potiuk closed this Feb 6, 2022
@potiuk potiuk reopened this Feb 6, 2022
@potiuk
Copy link
Member

potiuk commented Feb 6, 2022

Just an intermittend docker-compose test failure (which we should take a look soon BTW).

@potiuk potiuk merged commit 8da7af2 into apache:main Feb 6, 2022
@josh-fell josh-fell deleted the template-field-op-link-externaltasksensor branch February 7, 2022 15:02
@jedcunningham jedcunningham added the type:bug-fix Changelog: Bug Fixes label Mar 1, 2022
@jedcunningham jedcunningham added this to the Airflow 2.2.5 milestone Mar 22, 2022
ephraimbuddy pushed a commit that referenced this pull request Mar 23, 2022
ephraimbuddy pushed a commit that referenced this pull request Mar 24, 2022
ephraimbuddy pushed a commit that referenced this pull request Mar 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:core-operators Operators, Sensors and hooks within Core Airflow full tests needed We need to run full set of tests for this PR to merge type:bug-fix Changelog: Bug Fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Webserver "External DAG" button on ExternalTaskSensor not working when dag_id is templated
5 participants