Daniel
07/12/2024, 7:49 PMMarvin
07/12/2024, 7:49 PMjson
{
"type": "compound",
"require": "all",
"within": 3600,
"triggers": [
{
"type": "event",
"posture": "Reactive",
"expect": ["prefect.block.remote-file-system.write_path.called"],
"match_related": {
"prefect.resource.name": "previous-flow-name",
"prefect.resource.role": "flow"
}
}
]
}
Step 2: Use Dependencies in Your Flow
For more complex scenarios, you may want to specify dependencies explicitly within your flows. This can be done by using wait_for
in your flow and task definitions. Here’s a simple example:
python
from prefect import flow, task, run_deployment
@task
def first_flow_task():
# Some operations
pass
@flow
def first_flow():
first_flow_task()
@task
def second_flow_task():
# Some operations
pass
@flow
def second_flow():
second_flow_task()
@flow
def parent_flow():
first_run = run_deployment(name="first_flow")
second_run = run_deployment(name="second_flow", wait_for=[first_run])
if __name__ == "__main__":
parent_flow()
In this structure, the second_flow
will only start after first_flow
completes. Further reading can be found in the Prefect Upstream Dependencies guide.
For additional context and examples, you may check the following relevant pull requests and issues:
- Automations Guide PR: link
- Tutorial section docs: link
These resources should help you set up your desired workflow for triggering flows based on the completion of other flows.Nate
07/12/2024, 7:50 PMNate
07/12/2024, 7:52 PMrun_deployment
in an on_completion
hook with timeout=0
to avoid blocking / waiting for that
my preferred way is to configure a trigger on the downstream deployment that will expect
a prefect.flow-run.Completed
event from the upstream deployment, then its no code changesDaniel
07/12/2024, 7:53 PMDaniel
07/12/2024, 7:55 PMNate
07/12/2024, 7:56 PMI need to trigger 3 different deployments for a day with 3 different sets of data and then once that day is complete I need to trigger the next day with the next 3 days of datahmm im not sure I totally understand. I would say it depends on where you're getting the data you want to pass to downstream deployments and whether or not you can write code to run in the hook that would retrieve it
Daniel
07/12/2024, 7:58 PMDaniel
07/12/2024, 7:58 PM