I have a PythonOperator task that requires arguments to be passed to the constructor before the python callable is invoked.
PythonOperator(task_id='mytask',
provide_context=True,
python_callable=foo(var="{{ var.json.mydict }}").run,
dag=dag)
I was previously loading the variable with Variable.get('mydict', deserialize_json=True)
, however that is not best practice and was causing a Broken DAG due to runtime.
However I have not had any luck trying to get anything involving the Jinja template to work. I have also tried:
PythonOperator(task_id='mytask',
provide_context=True,
op_kwargs={'var' : "{{ var.json.mydict }}" },
python_callable=foo(**op_kwargs).run,
dag=dag)
But this does not appear to work either. Please tell me what I am doing wrong!