Prefect在Python中的部署,“no-start”选项

huangapple go评论66阅读模式
英文:

Prefect deploy in python "no-start" option

问题

I want to deploy a prefect flow in python. So far I've been using a script like this:

deployment = Deployment.build_from_flow(
    flow=flow_name,
    name="deployment_name", 
    version=1, 
    work_queue_name="queue_name",
    schedule=CronSchedule(cron="0 23 * * *")    
)
deployment.apply()

It works fine, but every time I restart the code it will immediately run the flow. I want it to only run when scheduled. I know if you run prefect from command line there is a "no-start" option, but so far I haven't been able to find how to implement it in Python.

英文:

I want to deploy a prefect flow in python. So far I've been using a script like this:

deployment = Deployment.build_from_flow(
    flow=flow_name,
    name="deployment_name", 
    version=1, 
    work_queue_name="queue_name",
    schedule=CronSchedule(cron="0 23 * * *")    
)
deployment.apply()

It works fine, but every time I restart the code it will immediatly runs the flow. I want it to only run when scheduled. I know if you run prefect from command line there is a "no-start" option, but so far i haven't been able to find how to implement it in Python.

答案1

得分: 0

我在找到解决方案时发现了相同错误。在流程函数所在的脚本中,我实际上是在脚本的末尾调用该函数。出于测试目的而这样做,并忘记去掉它。现在我已经移除它,一切都按预期工作。

英文:

I found the solution in case anyone runs across the same mistake.
In the script where the flow function was, I was actually calling the function at the end of the script. Did it for testing purposes and forgot to take it off. So now that I removed it, everything works as intended.

huangapple
  • 本文由 发表于 2023年4月17日 16:58:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/76033376.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定