https://prefect.io logo
Title
k

Kyle McEntush

08/24/2020, 7:30 PM
Two quick questions: within a flow (using the imperative API), how can I view reference tasks? And how can I set a task to be a reference task or not? My code currently consists of using
flow.add_task()
and
task.set_upstream()
. Specifically, I want to make sure that any of my triggers are dependent only the tasks that I think they really are. For example, in my pipeline (image attached), I want the trigger for the next task that will come off of the valid_unit_reducer to be triggered by
any_successful
for the valid_unit_reducer and not by
any_successful
on the invalid_unit_reducer. Maybe this is the default behavior in Prefect, but my current understanding is that triggers are related to all tasks and not just the upstream task immediately before it
k

Kyle Moon-Wright

08/24/2020, 8:03 PM
Hey @Kyle McEntush, Using the imperative API, you can retrieve tasks programmatically from a flow with
flow.get_tasks(name='my task')
, Additionally, triggers are related to upstream tasks, not all tasks in a flow. You can specify the scope of tasks you'd like to trigger upon by listing them out in your
upstream_tasks=[task_1, task_2, task_3]
. Other ways to set up your reference tasks is to use
set_dependencies
,
set_upstream
, or
set_downstream
, which you can read about in the API documentation (though you'll have to scroll down).
k

Kyle McEntush

08/24/2020, 8:51 PM
Got it. Really appreciate all of your help today!
👍 1