本文整理匯總了Python中airflow.operators.bash_operator.BashOperator.set_downstream方法的典型用法代碼示例。如果您正苦於以下問題:Python BashOperator.set_downstream方法的具體用法?Python BashOperator.set_downstream怎麽用?Python BashOperator.set_downstream使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類airflow.operators.bash_operator.BashOperator
的用法示例。
在下文中一共展示了BashOperator.set_downstream方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: DAG
# 需要導入模塊: from airflow.operators.bash_operator import BashOperator [as 別名]
# 或者: from airflow.operators.bash_operator.BashOperator import set_downstream [as 別名]
args = {
'owner': 'airflow',
'start_date': airflow.utils.dates.days_ago(2)
}
dag = DAG(
dag_id='test_example_bash_operator', default_args=args,
schedule_interval='0 0 * * *',
dagrun_timeout=timedelta(minutes=60))
cmd = 'ls -l'
run_this_last = DummyOperator(task_id='run_this_last', dag=dag)
run_this = BashOperator(
task_id='run_after_loop', bash_command='echo 1', dag=dag)
run_this.set_downstream(run_this_last)
for i in range(3):
i = str(i)
task = BashOperator(
task_id='runme_'+i,
bash_command='echo "{{ task_instance_key_str }}" && sleep 1',
dag=dag)
task.set_downstream(run_this)
task = BashOperator(
task_id='also_run_this',
bash_command='echo "run_id={{ run_id }} | dag_run={{ dag_run }}"',
dag=dag)
task.set_downstream(run_this_last)
示例2: BashOperator
# 需要導入模塊: from airflow.operators.bash_operator import BashOperator [as 別名]
# 或者: from airflow.operators.bash_operator.BashOperator import set_downstream [as 別名]
task_id='y1',
bash_command='sleep 1 && echo [y1 start]',
dag=dag)
y2_task = BashOperator(
task_id='y2',
bash_command='sleep 2 && echo [y2 start]',
dag=dag)
segmentation_task = BashOperator(
task_id='segmentation',
bash_command='sleep 1 && echo [segmentation start]',
dag=dag)
merge_task.set_upstream(xlsx_to_csv_task)
cleansing_task.set_upstream(merge_task)
x1_task.set_upstream(cleansing_task)
x2_task.set_upstream(cleansing_task)
x3_task.set_upstream(cleansing_task)
y1_task.set_upstream(cleansing_task)
y2_task.set_upstream(cleansing_task)
x1_task.set_downstream(segmentation_task)
x2_task.set_downstream(segmentation_task)
x3_task.set_downstream(segmentation_task)
y1_task.set_downstream(segmentation_task)
y2_task.set_downstream(segmentation_task)