In this example I'd say it shouldn't be templated, as you can do it via

@task
def get_templated_echo(ds):
    return f'echo "The date is {ds}"'

(This is nothing particular to XcomArg either, just the way Xcom had always 
worked.)

I don't think we can change the current/default behaviour without it likely 
being a breaking change to someone's workflow.

If there's enough desire and a good enough use case we can add a way to make it 
something you can turn on via one way or another.

-ash 



On 29 August 2022 07:46:01 BST, Tzu-ping Chung <[email protected]> 
wrote:
>Context: https://github.com/apache/airflow/issues/26016 
><https://github.com/apache/airflow/issues/26016>
>
>Currently if a value is passed to a downstream via XComArg, e.g.
>
>@task
>def get_templated_echo():
>    return 'echo "The date is {{ ds }}"'
>
>BashOperator(task_id="echo_task", bash_command=get_templated_echo())
>
>Then this value does not go through Jinja2 templating, i.e. the BashOperator 
>above would print The date is {{ ds }} instead of The date is 2022-08-29. The 
>question here is, is this a conscious design decision, and is there reasoning 
>behind it? Personally I can see arguments from both sides, but some context 
>would be very appreciated.
>
>And, if there wasn’t an explicit decision, should template-rendering an 
>XComArg be supported?
>
>TP

Reply via email to