【发布时间】:2018-02-13 23:55:29
【问题描述】:
我需要引用BashOperator 返回的变量。在我的task_archive_s3_file 中,我需要从get_s3_file 获取文件名。该任务只是将{{ ti.xcom_pull(task_ids=submit_file_to_spark) }} 打印为字符串而不是值。
如果我使用bash_command,值会正确打印。
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
【问题讨论】:
标签: airflow