https://prefect.io logo
#prefect-server
Title
# prefect-server
v

Vaibhav Ariyur

12/02/2021, 8:10 PM
is it possible to pass parameters to the callable called by the
on_failure
param of a flow? Should the function called by
on_failure
be able to read your flow's results?
k

Kevin Kho

12/02/2021, 8:12 PM
If your state handler is defined like:
Copy code
def st_handler(task, old_state, new_state):
    ...
You can try doing
new_state.result
to get the result. What kind of parameters are you trying to pass?
v

Vaibhav Ariyur

12/02/2021, 8:14 PM
my on_failure handler is defined as
def *clean_on_failure*(flow: *Flow*, state: *State*)
and I am trying to pass the directory to remove
I tried accessing using state.result
k

Kevin Kho

12/02/2021, 8:16 PM
Ah on the Flow level the results are not kept because they can be too big. For
flow.run()
you will see them but when running with a backend (Server or Cloud), they are not stored.
v

Vaibhav Ariyur

12/02/2021, 8:20 PM
so is there anyway to pass additional \*args/\**kwargs on the flow level?
^sorry if this is confusing to read lol, escaped the asterisk to stop bolding
k

Kevin Kho

12/02/2021, 8:27 PM
Maybe you can persist it in the KV Store ?
v

Vaibhav Ariyur

12/02/2021, 8:28 PM
KV store won't work in server, right?
k

Kevin Kho

12/02/2021, 8:35 PM
Oh that’s true it’s Cloud only. What kind of args and kwargs are you passing?
If it’s parameters, you can use
prefect.context.parameters
v

Vaibhav Ariyur

12/02/2021, 8:37 PM
directory_to_clean=f"/output/{uuid}"
it is a parameter based value yes
k

Kevin Kho

12/02/2021, 8:38 PM
Copy code
def st_handler(flow, old_state, new_state):
    myparam = prefect.context.parameters.get("myparam")
something like this
v

Vaibhav Ariyur

12/02/2021, 8:43 PM
oh that works
thanks!
k

Kevin Kho

12/02/2021, 8:45 PM
Nice!
2 Views