StreamPy app : Streamlit based python interactive console (supporting streamlit commands)

Hi!

Quite new here. Discovered streamlit a few weeks ago, but I think the app I’m currently working on could be interesting to some of you.

It’s called StreamPy, a streamlit-based python interactive interpreter allowing to run streamlit commands and pop widgets interactively in the console’s queue. I added a basic text editor to work on longer scripts for convenience.

You can find the repo here or you can try the app here.

Still a work in progress (likely not bug-proof). Any feedback/contribution welcome with gratitude!

Cheers!

7 Likes

Hello @B4PT0R, thanks very much for sharing your new project! :raised_hands:

I actually spotted it on Twitter last week, and I’ve already shared it internally! :slight_smile:

It’s very cool, do let us know if you need any help to progress on it!

Best,
Charly

1 Like

Hello Charly!

Thanks for the reply. Very happy to hear that you find it cool and that it has attracted a bit of attention amongst the Streamlit devs! :slight_smile:

The current implementation is still pretty naive, and I have much more in mind for this app.

Yet, I’m convinced the streamlit_deferrer module on which it is based has some potential.

I will surely ask for help if I encounter any technical difficulty. For now, coding this app is a great way to get to know the Streamlit API better.

Feel free, you or anyone at Streamlit, to give feedback, suggest improvements or contribute directly to the project. It would be an honor!

Cheers!

Baptiste

1 Like

Oh btw,

Let me know if giving users the possibility to run arbitrary python code from within the webapp may cause security problems. I mean it’s no big deal if a silly user destroys the app itself but I don’t mean to introduce vulnerability on your servers. My first guess was that the app’s execution environment is sandboxed in a virtual machine so I was not really worried…

Just fixed st.echo. It now works seamlessly in StreamPy !

I also added the possibility to import : matplotlib ; numpy ; pandas ; graphviz ; altair ; plotly ; bokeh ; pydeck ; scipy ; sympy ; vega-datasets

This way you should be able to test most streamlit features in the console.

Let me know if there are some beloved modules/components that you’d like to have access to, I’ll add them.

Cheers!

Just found a way to remove threads entirely from the app without loosing any feature. Greatly simplifies and increases robustness of the code while avoiding thread-related session_state issues.

Just added the possibility to hide / show past input cells in the console’s queue.
Also implemented automatic key attribution so that calling twice a widget with same arguments without specifying a key results in two distinct keys/widgets created.
Streamlit’s native automatic key management somewhat produced weird results in some cases when using the deferrer.

Somewhat managed to handle sdtin redirection to an input dialog. Only working on local mode obviously.
Allows using built-in python input command, and more generaly handle all python functions requiring keyboard input.

I guess what is needed to make it work in the web app is a custom widget component for inputting text in a blocking way (stopping the streamlit’s script execution until the inputted text is returned). I hope it’s feasible within the constraints of streamlit runtime though… That would be neat !

Proud to announce that stdin redirection now works both in local mode or in the webapp. Created a custom input component for the purpose. It uses firebase to establish a direct communication between the streamlit “backend” and the js frontend (in a websocket fashion) in such a way that python may access the data returned by the widget instantly, without having to rerun the whole script.

You may therefore use the classic python ‘input’ command in the console :
txt=input(“Enter text here:”) #renders an input widget, python waits for its output
print(txt) # access the content returned by the widget immediately and print it.

Cheers!

1 Like

Next step, implement proper user login via firebase, use it to save user files in cloud storage so that they persist accross various sessions (In the current implementation, accounts and user files are lost whenever the app goes to sleep).

If you think of any other feature I should add to make the most of this app, feel free to share your thoughts here !

I was also thinking about changing the name of the app, “Streampy” already exists as a python library… Any ideas ?

Thanks for the updates, @B4PT0R! :raised_hands:

So many improvements since the last time I used it! I’ve shared your library internally as well.

By the way, are you on Twitter? Happy to give it a bit more visibility from here too, if you like?

You can find me at https://twitter.com/DataChaz

Best,
Charly

1 Like

Hello @Charly_Wargnier !

Thanks for your kind message.

Yes, I’ve been working quite a bit on it lately, as much as my job schedule allows…

I indeed am on twitter (https://twitter.com/B4PT0R), though almost invisible there. I created my account only very recently and didn’t post much.

I gratefully accept your proposal to give Streampy a bit more visibility. The app definitely needs some user testing/feedback at this point, notably to set the direction and priority for the next improvements.

I’ll implement proper login and cloud storage via firebase in the next few days, so by the end of the week it should be ready to receive a bit more visits. I also need to make sure my secrets are protected enough to avoid silly users to use the python console to grab them. I realized last week that they just had to run:

import streamlit
st.write(streamlit.secrets)

in the console to get them… which was way too easy ! :sweat_smile:
Found a workaround to that unwanted situation by overriding streamlit module directly in sys.modules with a mocking class so that it bans access to the ‘secrets’ attributes after init.

So yeah, by the week end, it should be good to go viral… :sunglasses:

Thanks for your support.

Have a nice evening

Baptiste

1 Like

Improved security by restricting access to some modules, improved user log in and implemented cloud file storage so that you may access your files/scripts across sessions.

Cheers!

If you like the app and are willing to help it have a bit more visibility, feel free to follow me on twitter and/or share this tweet:

Many thanks !

Baptiste

Improved styling, changed the input cell and editor to a (neat!) streamlit-code-editor widget.

Cheers!

Hello @B4PT0R,
Sounds like a great project, though I haven’t been able to access your hosted project from the link posted within the original post.
Thanks!

Hello @abd_kmm ,

Yeah, the old project has been shut down. I’ve worked a lot on it in the meanwhile to integrate GPT4 in the mix and I’m quite close now to release a new iteration more publicly. It’s called Pandora now. You can check it out here. The app also exists as a local client, feel free to check the repo for more info.

Minor things still need to be done to improve user experience, but it’s functional as is.

Requires an OpenAI API key to enjoy voice interaction an AI assistance, but can still be used as a mere python console (allowing to run live streamlit commands!) without.

You would be my first real user, so any feedback would be much appreciated !

Cheers from France!

Baptiste

1 Like

Great application @B4PT0R . I’m facing the error in the time of signup page.

@Guna_Sekhar_Venkata

Oops, my bad. It’s been corrected, should be ok now.

Thank you for the bug report. Feel free to report any other you find, I’ll adress it as soon as possible.

Cheers

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.