将参数化的完美流程与随参数变化的计划相结合

2024-04-16 19:21:35 发布

您现在位置:Python中文网/ 问答频道 /正文

我希望能够重用相同的参数化Prefect流,但是Schedule因输入而异。例如:

from prefect import task, Flow, Task, Parameter
from prefect.schedules import CronSchedule

diurnal   = ['rooster', 'dog']
nocturnal = ['owl', 'hampster']

# Schedules
diurnal_schedule   = CronSchedule("50 7 * * mon,wed")
nocturnal_schedule = CronSchedule("15 12 * * tue,thu")

# Flow is common to both types, though with different schedules.
with Flow(name="wakuptime") as this_flow:
    animals         = Parameter("animals")
    wakeup(animals)

this_flow.run(parameters = dict(animals = diurnal)) on diurnal_schedule
this_flow.run(parameters = dict(animals = nocturnal)) on nocturnal_schedule

有什么建议吗?你知道吗


Tags: runfromimportparameterwiththisflowschedule