Hi, we are experiencing 2 strange things: - flows ...
# prefect-server
t
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
@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
• 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:
Copy code
@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
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
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:
Copy code
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
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
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
I thought maybe you set something else there - all_successful is the default
t
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