-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
Lazy Jinja2 context #20217
Lazy Jinja2 context #20217
Conversation
f594e5e
to
999f2df
Compare
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. |
999f2df
to
17a9ad3
Compare
Don’t merge this yet, there’s another case we need to fix (see comment in linked issue). I’m also thinking I should enable this deprecation-as-error globally in case there are more things we have not catch. |
3a98fd0
to
e4fc2f0
Compare
Alright I’m done. |
Hmm, I'm not seeing a deprecation warning with this: from datetime import datetime
from airflow import DAG
from airflow.operators.bash import BashOperator
with DAG(
dag_id="no-context", schedule_interval=None, start_date=datetime(2021, 12, 10)
) as dag:
BashOperator(task_id="sleep", bash_command="echo 'Hello! {{ execution_date }}'") |
Jinja2 makes the call stack in the context object disappear. Not sure how it does it, but it does. Co-authored-by: Jed Cunningham <[email protected]>
9effcce
to
1f11018
Compare
1f11018
to
b9295c0
Compare
Only one job failing with this, likely a network issue. |
Co-authored-by: Jed Cunningham <[email protected]> (cherry picked from commit 181d60c)
Fix #20213. To work around Jinja2 eagerly resolving context into a new dict, we implement a custom copy interface, and use lower level Jinja2 functions to render templates (because the higher level
Template.render()
simply callsdict(**data)
which is not overridable).Tests are added to ensure that