how do I get and set custom flow states
@Ask Inkeep how do I get and set custom flow states
4 Replies
Thanks for tagging me @rubenf. I'll look through relevant sources and get back to you shortly.
-----------------------------
While I generate an answer, here are some sources that might be helpful:
* Within Windmill: Not recommended
* Architecture and Data Exchange
* Resources and Resource Types
* set flow user state POST /w/{workspace}/jobs/flow/user_states/{id}/{key}
-----------------------------
Answer
To get and set custom flow states in Windmill, you can use the
setFlowUserState
and getFlowUserState
functions. These functions allow you to store and retrieve data across steps in a flow. Here's how you can use them:
1. Setting a custom flow state:
You can use the setFlowUserState
function to set a value for a given key. (1)
2. Getting a custom flow state:
You can use the getFlowUserState
function to retrieve a value for a given key. The custom flow states are stored in the flow state itself and have the same lifetime as the flow job. It's important to note that custom flow states are a powerful feature when passing data as output/input is not feasible, and using getResource/setResource
might clutter the workspace or create an inconvenient user experience. These functions are supported in both TypeScript and Python. (2) Here's an example in Python:
(1)
Remember that to use these functions, you need to import the
wmill
client library. For TypeScript, you would use import * as wmill from "windmill-client@1.297.0"
, and for Python, you would include #extra_requirements: #wmill==1.297.0
at the top of your script. (3) (1)
Custom flow states allow you to set and retrieve values from any step of a flow, and they will be available globally within the flow. This feature was introduced in Windmill version v1.296.0. (2)Feel free to tag @Ask Inkeep with additional questions.
good bot