简体   繁体   English

Prefect 如何等待外部依赖

[英]Prefect how to wait for external dependency

I have a prefect flow that I want to run if and when a specific file appears.我有一个完美的流程,我想在出现特定文件时运行它。 With something like Luigi you would create an ExternalTask that outputs that file and then impose a dependence on it.使用 Luigi 之类的东西,您可以创建一个 ExternalTask​​ 来输出该文件,然后对其施加依赖。 What is the standard pattern for this in Prefect? Prefect 中的标准模式是什么?

There are a few options depending on your use case:根据您的用例,有几个选项:

  • create a waiting task: in this case, you can write a root task for your flow that waits for the external dependency / condition to be met, and then returns.创建一个等待任务:在这种情况下,您可以为您的流编写一个根任务,等待外部依赖/条件得到满足,然后返回。 As long as the other tasks depend on this one, they won't run until this task completes.只要其他任务依赖于这个任务,它们就不会运行,直到此任务完成。
  • use the GraphQL API: both Prefect Server and Cloud have a fully featured GraphQL API for performing many common actions with flows and runs.使用 GraphQL API:Prefect Server 和 Cloud 都有一个功能齐全的 GraphQL API,用于通过流和运行执行许多常见操作。 In this case, you can call create_flow_run whenever your external condition is met (possibly with Parameter values describing the condition) to create an ad-hoc run of your flow.在这种情况下,您可以在满足外部条件(可能使用描述条件的Parameter值)时调用create_flow_run来创建流的临时运行。 For more discussion of this pattern, check out this stackoverflow question有关此模式的更多讨论,请查看此 stackoverflow 问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM