Prefect Flow 中的任务序列 Python
Tasks sequence in Prefect Flow Python
我目前正在使用 Python 框架 - Prefect (prefect.io)
我写了下面的代码
from prefect import Flow, task
@task
def say_hello():
print('Hello')
@task
def say_how_a_u():
print('How are you?')
@task
def say_bye():
print('Bye Bye')
with Flow('Test') as flow:
say_hello()
say_how_a_u()
say_bye()
flow.run()
事实是所有函数都是并行调用的。如何一个接一个地调用函数并等待前一个函数?你好 -> how_a_u -> 再见
我使用触发器,但它失败了
您可以在 Flow 块中指定上游依赖项。您可以找到另一种语法 here
from prefect import Flow, task
@task
def say_hello():
print('Hello')
@task
def say_how_a_u():
print('How are you?')
@task
def say_bye():
print('Bye Bye')
with Flow('Test') as flow:
a = say_hello()
b = say_how_a_u(upstream_tasks=[a])
c = say_bye(upstream_tasks=[b])
flow.run()
我目前正在使用 Python 框架 - Prefect (prefect.io) 我写了下面的代码
from prefect import Flow, task
@task
def say_hello():
print('Hello')
@task
def say_how_a_u():
print('How are you?')
@task
def say_bye():
print('Bye Bye')
with Flow('Test') as flow:
say_hello()
say_how_a_u()
say_bye()
flow.run()
事实是所有函数都是并行调用的。如何一个接一个地调用函数并等待前一个函数?你好 -> how_a_u -> 再见
我使用触发器,但它失败了
您可以在 Flow 块中指定上游依赖项。您可以找到另一种语法 here
from prefect import Flow, task
@task
def say_hello():
print('Hello')
@task
def say_how_a_u():
print('How are you?')
@task
def say_bye():
print('Bye Bye')
with Flow('Test') as flow:
a = say_hello()
b = say_how_a_u(upstream_tasks=[a])
c = say_bye(upstream_tasks=[b])
flow.run()