Stephen Lloyd
05/26/2022, 2:31 PMsend_tasks
will be a list of the responses and I could iterate over it in a subsequent task, but I’m hoping there is a more efficient method. Can I force a task to fail if the api indicates a failed call? If i do, is there a way to count those?
@task
def make_post(creds, task):
...
response = requests.request('POST', ...)
return response
with Flow(stuff, stuff):
send_tasks = make_post.map(creds=unmapped(creds), task=data)
Kevin Kho
05/26/2022, 2:35 PMraise FAIL
inside it where FAIL
is the Prefect signal.
And then you can have a reduce task
@task
def reduce(x: List):
total = len(x)
fail = len[1 for _ in x if isinstance(_, BaseException)]
success = total - fail
because the FAIL is an Exception so you can look for it like that.