wooey / Wooey

A Django app that creates automatic web UIs for Python scripts.
http://wooey.readthedocs.org
BSD 3-Clause "New" or "Revised" License
2.12k stars 182 forks source link

User Input while script is executing #332

Closed nalindobhal closed 3 years ago

nalindobhal commented 3 years ago

Hi, we have a script where we have a for loop and inside we have a prompt for user input. So for every iteration user will have to enter a choice. I would like to achieve the same with wooey but couldn't find any resource. Adding code for reference. Please help me to achieve this. Thanks.

for index, row in my_dataframe.iterrows():
    user_answer = input('\nDo you want to continue? (y/n)')
    if user_answer.lower() == 'y':
        do_something()
    else:
        do_something_else()
Chris7 commented 3 years ago

Hi @nalindobhal,

I'm not sure how I would implement this. Scripts run within a python subprocess (using Popen). There are some ways to use subproess.communicate, but I don't know enough about what is provided to the stdout that would give a reliable mechanism to request a user input. Beyond that, it would then have to have a way to pass that information to a remote running worker, which is another challenge.

I'd recommend trying to have ways defined ahead of times to handle potential conflicts for resuming work and picking logic forks.