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

When rendering template, unmap task in context #26702

Merged

Conversation

uranusjr
Copy link
Member

@uranusjr uranusjr commented Sep 27, 2022

Currently, when a mapped task is being rendered (and unmapped during the process), the template context continues to reference the mapped task because the context is created before unmapping. This is however not useful, and creates obstacles for use cases needing to reference a task-mapping value (something passed to the expand function).

This patch adds logic to replace context["task"] and context["ti"].task in-place when a mapped task is being unmapped, so they always reference an unmapped task during template rendering. This makes writing a Jinja template for a mapped task more consistent to that for a non-mapped one.

To accommodate this change in reference, some peripheral code is modified so various task variables point to the right things at the right moment. A few tests are also modified to ensure this in-place replacement is done at the right moment.

Fix #24388.

Currently, when a mapped task is being rendered (and unmapped during
the process), the template context continues to reference the mapped
task because the context is created before unmapping. This is however
not useful, and creates obstacles for use cases needing to reference a
task-mapping value (something passed to the expand function).

This patch adds logic to replace context["task"] and context["ti"].task
in-place when a mapped task is being unmapped, so they always reference
an unmapped task during template rendering. This makes writing a Jinja
template for a mapped task more consistent to that for a non-mapped one.

To accommodate this change in reference, some peripheral code is
modified so various task variables point to the right things at the
right moment. A few tests are also modified to ensure this in-place
replacement is done at the right moment.
@uranusjr
Copy link
Member Author

Something’s wrong with yarnpkg… hopefully temporary?

@uranusjr uranusjr force-pushed the aip-42-context-task-reference-unmapped branch from 225b31b to 057d66b Compare September 27, 2022 10:46
@uranusjr uranusjr merged commit 5560a46 into apache:main Sep 27, 2022
@uranusjr uranusjr deleted the aip-42-context-task-reference-unmapped branch September 27, 2022 12:52
@jedcunningham jedcunningham added the type:bug-fix Changelog: Bug Fixes label Sep 27, 2022
jedcunningham pushed a commit that referenced this pull request Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to access operator attrs within Jinja context for mapped tasks
3 participants