-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Split out and handle 'params' in mapped operator #26100
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
5824f87 to
7b2115b
Compare
uranusjr
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.
Some notes explaining the implementation, hopefully this is easier to review with them.
airflow/models/mappedoperator.py
Outdated
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.
To be able to expand a task against params, we need to be able to “merge” default DAG- and task-level params with the user-mapped params. So params is split out of other partial kwargs and treated specially. Partial kwargs should never contain the "params" key.
airflow/models/baseoperator.py
Outdated
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.
So we don’t set the default params in partial_kwargs…
airflow/models/baseoperator.py
Outdated
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.
… but pass them to this separate attribute.
airflow/decorators/base.py
Outdated
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.
And this line is deleted since it’s now no-op.
airflow/models/mappedoperator.py
Outdated
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.
Actual merging happens here. The merged params is put last so it overrides the incomplete mapped_kwargs["params"].
airflow/models/baseoperator.py
Outdated
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.
This does not change any behaviour, I only did it so the behaviour is easier to explain…
airflow/models/taskinstance.py
Outdated
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.
… here. Previously it’s difficult to follow when rendered_task is None and when it’s not; now it’s simple—a mapped operator (MappedOperator subclases) performs unmapping and returns the unmapped task, while a non-mapped operator (BaseOperator subclasses) return None because no unmapping is needed.
7b2115b to
50c6989
Compare
50c6989 to
d05e7c2
Compare
|
|
It turns out we need to update the template context a bit after unmapping. This also fixes a bug that context["task"] pointed to the mapped task but context["ti"].task is the unmapped task. They now both point to the unmapped one.
d05e7c2 to
e9b5861
Compare
Allow using
paramsin expanding kwargs. Fix #24014.Syntax unlocked: