btw, I’ve seen this a while that I have to restart...
# ask-community
t
btw, I’ve seen this a while that I have to restart the flow twice to make it really restarted. The first time click just logged a line but nothing in effect until the second time click. Is this a known issue?
a
Hi @Tony Yun, thanks for reporting that. I was able to reproduce the issue and indeed, something seems weird. Here is an example flow I used. First setting a key in KV Store:
Copy code
from prefect.backend import set_key_value
key_value_uuid = set_key_value(key="fail_or_not", value="fail")
Then failing the flow based on the value from KV store:
Copy code
from prefect import task, Flow
from prefect.backend import get_key_value

@task(log_stdout=True)
def fail_if_key_say_so():
    value = get_key_value(key="fail_or_not")
    if value == "fail":
        raise ValueError("Failing the task...")
    print("Success!")

with Flow("fail_based_on_key") as flow:
    fail_if_key_say_so()
Changing the value should result in success upon restart:
Copy code
from prefect.backend import set_key_value
key_value_uuid = set_key_value(key="fail_or_not", value="not")
But similarly to you, I had to click twice for the restart to take effect. There is a caveat though. This happens ONLY when the original flow is triggered through “Quick Run” in the UI. When I trigger the flow run from CLI or when the flow runs on schedule, the Restart button in the UI triggers a restart immediately.
🙏 1
👍 1
k
@Marvin open “Restarting Quick Run from Failed state doesn’t always restart the FlowRun” in UI