我正在查看示例代码这里。
有两个“operation”函数:
有两个“operation”函数:
def my_sleeping_function(random_base):
"""This is a function that will run within the DAG execution"""
time.sleep(random_base)
并且:
def print_context(ds, **kwargs):
pprint(kwargs)
print(ds)
return 'Whatever you return gets printed in the logs'
对于每次运行my_sleeping_function
,我们都会运行print_context
吗?
我不明白的是顺序。 这是图和树...执行顺序不同:
先发生什么?之后又会发生什么?为什么?
我认为根据这个:
for i in range(5):
task = PythonOperator(
task_id='sleep_for_' + str(i),
python_callable=my_sleeping_function,
op_kwargs={'random_base': float(i) / 10},
dag=dag)
task.set_upstream(run_this)
run_this执行,然后task执行,但循环让我感到困惑。