Flujo de aire: cómo pasar la variable xcom a la función Python
Necesito hacer referencia a una variable que es devuelta por unBashOperator
. Puede que esté haciendo esto mal, así que por favor perdóname. En mitask_archive_s3_file
, Necesito obtener el nombre de archivo deget_s3_file
. La tarea simplemente imprime{{ ti.xcom_pull(task_ids=submit_file_to_spark) }}
como una cadena en lugar del valor.
Si uso elbash_command
, el valor se imprime correctamente.
get_s3_file = PythonOperator(
task_id='get_s3_file',
python_callable=obj.func_get_s3_file,
trigger_rule=TriggerRule.ALL_SUCCESS,
dag=dag)
submit_file_to_spark = BashOperator(
task_id='submit_file_to_spark',
bash_command="echo 'hello world'",
trigger_rule="all_done",
xcom_push=True,
dag=dag)
task_archive_s3_file = PythonOperator(
task_id='archive_s3_file',
# bash_command="echo {{ ti.xcom_pull(task_ids='submit_file_to_spark') }}",
python_callable=obj.func_archive_s3_file,
params={'s3_path_filename': "{{ ti.xcom_pull(task_ids=submit_file_to_spark) }}" },
dag=dag)
get_s3_file >> submit_file_to_spark >> task_archive_s3_file