https://prefect.io logo
Title
t

Thomas Opsomer

12/20/2021, 2:45 PM
Hi, we are experiencing 2 strange things: • flows with 'manual validation' are stuck after being approved, the states stay orange in "Resume" • restart of failed flows doesn't work: after click on the restart button, the wheel keeps spinning and the flow never restart Any ideas on how to overcome these issues ?
a

Anna Geller

12/20/2021, 3:02 PM
@Thomas Opsomer regarding Resume: can you share how you defined the manual approval in your flow? Can you try again and send a Screenshot? For both issues: did you specify a Result on your task decorator? Restarts are only possible when results are configured
t

Thomas Opsomer

12/20/2021, 3:14 PM
• resume: basically we have introduced "waiting" tasks in between other tasks to allow us to have "waiting" steps in our flows. The code for these waiting task is:
@task(
    name="common.wait",
    task_run_name="wait-after-{previous_task_name}",
    trigger=manual_only_after_all_successful,
    state_handlers=[wait_task_slack_handler],
    skip_on_upstream_skip=False,
)
def wait_for_human_task(previous_task_name: str = None):
    """ """
    pass
• result: no there is no Result type specified on the task decorator. But it used to work in the past. How long has it been mandatory to use results to enable restarts ?
a

Anna Geller

12/20/2021, 3:19 PM
is “manual_only_after_all_successful” your custom trigger? we only have manual_only. Could you try using the “manual_only” trigger and see whether this works?
for Results, it depends whether your tasks return anything. If they don’t, then restart can probably work without results. But it’s definitely recommended to always explicitly configure Results if you want to leverage the restart functionality
t

Thomas Opsomer

12/20/2021, 3:31 PM
the "manual_only_after_all_successful" is just a fix to ensure the flow is failed even if there is a waiting task in it. Because I noticed that my flows with a failed task and a downstream manual task where not in a Failed state. It's a mix between all_successful and manual like this:
def manual_only_after_all_successful(
    upstream_states: Dict["core.Edge", "state.State"]
) -> bool:
    """ """
    if not all(s.is_successful() for s in _get_all_states_as_set(upstream_states)):
        raise signals.TRIGGERFAIL(
            'Trigger was "all_successful" but some of the upstream tasks failed.'
        )

    if prefect.context.get("resume"):
        return True

    raise signals.PAUSE('Trigger function is "manual_only"')
Hum ok, some tasks have returns, not that we use it, but more as a coding habit. I'll add results to all my task and see how it goes.
a

Anna Geller

12/20/2021, 3:37 PM
I don’t think that you need this fix as long as you allow the failure to be propagated downstream - the default “all_successful” trigger takes care of that. I would recommend using the default “manual_only” trigger because it was tested to work with the pause for approval pattern - some links on it you can check to be sure: • https://docs.prefect.io/core/idioms/pause-for-approval.htmlhttps://medium.com/the-prefect-blog/needs-approval-184f2512a3cf
t

Thomas Opsomer

12/20/2021, 3:43 PM
Thanks for resources, I'll try again with the default manual_only 🙂 When you say "as long as you allow the failure to be propagated downstream", isn't it the default behaviour ? Or should I add something somewhere ?
a

Anna Geller

12/20/2021, 3:44 PM
I thought maybe you set something else there - all_successful is the default
t

Thomas Opsomer

12/20/2021, 4:01 PM
Alright, I'll experiment with your suggestions and get back to you ! Funny thing, while we were discussing, the flows that were stuck in resume state just got resumed and are now running!
🙌 1