Prefect 2.0 | Accessing current flow state Hi! :wa...
# prefect-community
d
Prefect 2.0 | Accessing current flow state Hi! 👋 Possibly simple question which I can’t seem to find an answer for: Can I access the state of the current flow from within that flow? In particular I’d like to check if the flow is retrying, and if so pass an extra argument to my task(s) i.e.
Copy code
@flow
def my_flow():
  if <somehow_get_state_of_this_flow?> == "Retrying":
    do_something()
1
a
when running tasks, you can do:
Copy code
if task.get_state().is_failed():
or rather:
Copy code
if task.get_state().is_retrying():
this assumes that task is submitted to task runner
Copy code
@task
def do_sth():
   ...

@flow
def my_flow():
  if do_sth.submit().get_state().is_retrying():
    do_something()
d
Thanks, but maybe it wasn’t clear, I’m retrying the flow, not a task (added in 2.0b8). All my tasks are using
shell_run_command()
from
prefect_shell
, and I don’t think I can add retries there?
a
for flow there is no way currently, but will be after GA release
🦜 1
d
Okay, thanks! Will hold off until tomorrow then 😁
🙏 1
🙌 1