You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add support for get_current_context in Task SDK #45234
fromairflow.providers.standard.operators.pythonimportget_current_context@task(# Causes variables that end with `.sql` to be read and templates# within to be rendered.templates_exts=[".sql"], )deftemplate_test(sql, test_var, data_interval_end):
context=get_current_context()
# Will print...# select * from test_data# where 1=1# and run_id = 'scheduled__2024-10-09T00:00:00+00:00'# and something_else = 'param_from_task'print(f"sql: {sql}")
# Will print `scheduled__2024-10-09T00:00:00+00:00`print(f"test_var: {test_var}")
# Will print `2024-10-10 00:00:00+00:00`.# Note how we didn't pass this value when calling the task. Instead# it was passed by the decorator from the contextprint(f"data_interval_end: {data_interval_end}")
# Will print...# run_id: scheduled__2024-10-09T00:00:00+00:00; params.other_param: from_dagtemplate_str="run_id: {{ run_id }}; params.other_param: {{ params.other_param }}"rendered_template=context["task"].render_template(
template_str,
context,
)
print(f"rendered template: {rendered_template}")
# Will print the full context dictprint(f"context: {context}")
Hey @okirialbert , thanks for your interest in getting this one but since we are in time crunch for Airflow 3.0 and since I am already on it, I will pick this up for now
Activity
okirialbert commentedon Dec 30, 2024
Hi @kaxil, I'd like to work on this.
kaxil commentedon Jan 8, 2025
Hey @okirialbert , thanks for your interest in getting this one but since we are in time crunch for Airflow 3.0 and since I am already on it, I will pick this up for now
[-]Add support for `ti.get_current_context` in Task SDK[/-][+]Add support for `get_current_context` in Task SDK[/+]AIP-72: Add support for `get_current_context` in Task SDK
AIP-72: Add support for `get_current_context` in Task SDK
AIP-72: Add support for `get_current_context` in Task SDK
AIP-72: Add support for `get_current_context` in Task SDK
AIP-72: Add support for `get_current_context` in Task SDK
AIP-72: Add support for `get_current_context` in Task SDK
1 remaining item
AIP-72: Add support for `get_current_context` in Task SDK (apache#45486)
AIP-72: Add support for `get_current_context` in Task SDK (apache#45486)
AIP-72: Add support for `get_current_context` in Task SDK (apache#45486)
AIP-72: Add support for `get_current_context` in Task SDK (apache#45486)
AIP-72: Add support for `get_current_context` in Task SDK (#45486)
AIP-72: Add support for `get_current_context` in Task SDK (#45486)
AIP-72: Add support for `get_current_context` in Task SDK (#45486)
AIP-72: Add support for `get_current_context` in Task SDK (#45486)
AIP-72: Add support for `get_current_context` in Task SDK (#45486)
AIP-72: Add support for `get_current_context` in Task SDK (#45486)
AIP-72: Add support for `get_current_context` in Task SDK (#45486)