Repository navigation
Conversation
Add get_templated_list to utils.helper
Fix operator list as templated field issue
Fix operators' list as templated field issue
Fix operators' list as templated field issue
|
I don't think this sort of special case handling should be needed after #4292 (which is in master but not released, will make it in to 1.10.3). Maybe all the change we need to do here is add more fields to be templated in these operators. |
|
@ashb Thank you for looking at my PR. I looked at the commit you mentioned above. It looks like the issue it's fixed is not for the issue I've raised. If I pass a Jinja template to a templated field, the type of the content would be string. In that case, it will render the actual value using Jinja template as string. For example: Inside pull_task, the type of templates_list is string instead of list. My fix is specifcally for passing Jinja templated list to a templated field. And the rendered value should be converted from string to list. |
|
Ah okay, similar but not the same issue. In the specific case of PythonOperator you can do this: def push_value(**kwargs):
kwargs['ti'].xcom_push(key='push_key', value=[1, 2, 3])
def do_nothing(ti, **kwargs):
mylist = ti.xcom_pull(key='push_key')
print(repr(mylist))
return
push_task = PythonOperator(
task_id='push_task',
provider_context=True,
dag=dag,
python_callable=push_value,
)
pull_task = PythonOperator(
task_id='pull_task',
provide_context=True,
dag=dag,
python_callable=do_nothing,
)
push_task >> pull_task(I know that only works for python operator, and not a general solution.) I think https://issues.apache.org/jira/browse/AIRFLOW-3362 is the way to fix this more generally - that one: works with types other than list, and doesn't need each operator to handle it specifically. |
|
@ashb Oh awesome! I will have a look at the new Jinja2 library. Cheers! |
Operator list as templated field
This is a global fix for #4770
Make sure you have checked all steps below.
Jira
Description
Tests
Commits
Documentation
Code Quality
flake8