Sacha
Sachaโ€ข3d ago

recursive loop in windmill.dev

I need to create a loop that start and run against a list that depends on the output of each loop. I can't find a way to do it? ๐Ÿš€ ๐Ÿ”ฅ ๐Ÿ˜‡
11 Replies
rubenf
rubenfโ€ข3d ago
Hi, I'm not sure to understand but you can nest loop
Sacha
SachaOPโ€ข3d ago
I run a python script (script A) that get all urls from a webpage. the result of this script is a list of urls that need to run script A again until a certain limit or depth is triggered it is a dynamic loop where each time you run the loop you update the iteration list hope it makes sense
rubenf
rubenfโ€ข3d ago
You just need a while loop and a for loop and to store the array of items in flow user state and return the number of items left in each while loop end
Sacha
SachaOPโ€ข3d ago
while len(items_left) > 0: for item in item_left: update list of item left return updated_item_left as flow user state thanks I think I got it, I ll try that Thanks for your time
Sacha
SachaOPโ€ข3d ago
Hi @rubenf , Not sure how I can retrieve the list of item from
urls = wmill.get_flow_user_state("urls") and to iterate in the loop iterator?
No description
Sacha
SachaOPโ€ข3d ago
flow_input as super easy to use but what i can't use flow user state?
No description
Sacha
SachaOPโ€ข3d ago
i guess i need to create python code previously that return urls = wmill.get_flow_user_state("urls") I was hoping that we could call the flow_user_state directly in the iterator like with flow_input
Sacha
SachaOPโ€ข2d ago
please let me know if i can help to do it since windmill is open-source not sure how linear interact with github, since I did not see the issue
rubenf
rubenfโ€ข2d ago
it's internal so you can't see it
rubenf
rubenfโ€ข2d ago
if you want to contribute on it, you would have to modify this: https://github.com/windmill-labs/windmill/blob/main/backend/windmill-worker/src/js_eval.rs and use deno_core ops functions
GitHub
windmill/backend/windmill-worker/src/js_eval.rs at main ยท windmill-...
Open-source developer platform to power your entire infra and turn scripts into webhooks, workflows and UIs. Fastest workflow engine (13x vs Airflow). Open-source alternative to Retool and Temporal...