Rob Douglas
01/13/2023, 4:03 PMupstream_task
succeeded. Am I on the right track? I've been poking around for a tutorial or example, but am having trouble finding much in the way of examples of any_successful
@task(trigger=any_successful)
def bar(upstream_tasks):
# get the first upstream_task that succeeded
:gratitude-thank-you: in advance for any insights you might haveNate
01/13/2023, 8:15 PMprefect.tasks.control_flow.filter.FilterTask
may be helpful for this
from prefect import Flow, task
from prefect.tasks.control_flow.filter import FilterTask
only_successful = FilterTask(lambda x: not isinstance(x, Exception)) # this exact type check may not be appropriate for you
@task
def add_42(x):
return x + 42
@task(log_stdout=True)
def log(x):
print(x)
with Flow("any_successful") as flow:
parameters = ["lemur", dict, "capybara", 42]
# if you're not mapping, you would construct a list of relevant tasks that may fail
results = add_42.map(parameters) # results = [TypeError, TypeError, TypeError, 84]
log(only_successful(results)) # prints: [84]
if __name__ == "__main__":
flow.run()
Rob Douglas
01/13/2023, 8:54 PM