Using streamlit to run 2 separate codes simultaneously which can be changed using dropdown widget

Hi Guys, I want to run to separate sessions with different options which can be changed using different items in a dropdown list

Even if there are any runs happening in one option i need to work on other list which is independently. Any leads will be appreciated.

Thanks in advance @Streamliters

Could you elaborate your idea? @Subin_George_Malana

Like in the photo we can use 2 different independent session simultaneously. Even if Session1 is running something we can switch to Session2 and do other tasks.

Hey @Subin_George_Malana . According to my understanding streamlit page run from top to bottom for every widget response. It means if we select any option from drop-down list means it will run the whole application from top to bottom. So, if i choose the session1 in drop-down, you can perform some work. But you can’t provide any functionality to session2 without its get selected.

Hi @Guna_Sekhar_Venkata, thanks for the update. I wanted to use it like, whenever we want to change the session we can change the option from the dropdown. it should be like 1 Streamlit and 2 separate independent sessions. I hope this makes sense

Yes by selecting which session you can control it from drop-down list.

Happy Streamlit-ing :balloon:

Hi @Guna_Sekhar_Venkata, Is there any ways to do this?
I have seen people are talking about multiple logins but nobody is talking about same user but multiple sessions. can you give me some pointers on the same?

@Subin_George_Malana i don’t have that much deep knowledge about that. It’s better you can drop this question in community cloud category

For multiple sessions you open the application in multiple browser tabs/windows.

Hi @Goyo, Can we do the same in different tab widget?

No, because each session is tied to a websocket connection between a browser tab and the application. There is no builtin way of changing that programmatically.

That is, in case you are really talking about streamlit sessions. If you mean some bespoke concept of “session” or just what the title says (“run 2 separate codes”), then the answer may be different. But you would need to be more specific.

Sure, i want to use Paramiko to connect 2 nodes at the same time and do independent operations at the same time.

It doesn’t look like you need separate sessions for that. What challenges are you facing?

But how can we run separate actions in different nodes parallel?

I am nor sure exactly what you mean by actions and nodes here. You can achieve concurrency by the usual means: asincio, threading and multiprocessing.

it is basically i need to run some Py files in each nodes and get the stdout from each separately in different tabs. like a one stop point to run different codes from a single portal

A session begins when we send the command:
streamlit run
And open the browser on the given url.

To create a new or second session, just open another tab or window with the given url.

You can use session state to manage what you want inside a single session. If task 1 processes web scraping and task 2 is doing some regression analysis you can do so. Just manage the variables in the session states so that the app may run without issues even if there are possible code reruns. Talking about reruns, there is an upcoming awesome feature of partial rerun. Rerun can be isolated in a function.

Hi @ferdy, Thanks for responding.
What i want here is using Paramiko i want to connect to 2 different nodes and run some commands and display stdout on some widget in Streamlit. I want to run them independently in different time based on button in each tab. it should work like a Master and Slave type where Streamlit will be Master and those other systems will be slaves.

If you try this with a script, it mostly like work with streamlit.

Have you tried testing it? What issues you have encountered.

My question is once we start running something in one session, how can we do any other tasks in other session unless we wait until the 1st session tasks. The reason i am saying this is i will be printing the stdout to some widget in streamlit