Streamlit in Electron
See original GitHub issueIs there a future for electron deployment of streamlit?
streamlit electron app.py
Streamlits target demographic (seemingly the Data Science / ML / AI community) often has apps which consume a lot of resources. RAM for loading data used by the app can be quite a bit- pair this with st.cache
and in a few hours/days time your streamlit app needs to be killed / controlled / scaled. That is fine (and good for AWS’ profit), but why not be able to distribute the app across its users so they can run it on their machine (and use their resources). This is easy enough if your streamlit users are capable of running streamlit run ..
in their terminal. However, who are the users of these apps? Oftentimes they will be other engineers / programmers sure - but I think a substantial chunk of the user-base of streamlit apps is a non-technical audience. We send links to streamlit apps to management / non-technical members of the organization constantly I would much rather send them an S3
link to download an electron app and not worry about scaling up the AWS instance(s) hosting it. Sure, they have to have python and some dependencies - but those are relatively easy to control by IT and can often involve little user work. Furthermore, we could maybe have a future where the streamlit build electon
command could bundle dependencies? I am not sure - but it seems possible.
Streamlit seems well-positioned for this to be possible. It is trivial to “fake it”. Just do something like this to get an MVP.
import streamlit as lit # you guys really dropped the ball on this not being the suggested import
# idk - maybe it is too z00mer.
def main():
lit.sidebar.title("Electron")
lit.sidebar.info("The Electron Slide...")
lit.sidebar.slider('How "nativive"?', 0, 100, 50)
lit.title("Streamlit in `Electron`")
if __name__ == "__main__":
main()
Run it,
streamlit run app.py
Take the starter electron app from here. and change literally 1 line (:16)
mainWindow.loadURL('http://localhost:8501/') // or wherever you served
And…
I am just opening this issue to see if you guys (and the community) think this has any legs. I am not sure of the specifics. For example,
streamlit (electron|run_electron) app.py # for local testing and development
streamlit build -t electron app.py <name> # for building and bundling dependencies
# to a downloadable launcher?
...
Could there be electron-specific component implementations (so sidebar could be a native window), or tab support, keyboard shortcuts, etc? Could session state be saved to disk and loaded on app start to preserve state? Or maybe this is all a terrible idea… (also if there is another discussion of this already somewhere else (I couldn’t find one) lmk and this can just be closed)
Community voting on feature requests enables the Streamlit team to understand which features are most important to our users.
If you’d like the Streamlit team to prioritize this feature request, please use the 👍 (thumbs up emoji) reaction in response to the initial post.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:17
- Comments:32 (15 by maintainers)
Top GitHub Comments
Hi @DylanModesitt,
I completely agree, this is a wide open field of opportunity. In fact, just a few nights ago I was fiddling with just this. Your post encouraged me to bundle it up into a neat little easy to use prototype.
See https://github.com/pymedphys/pymedphys/tree/master/streamlit-bundle.
Essentially, within a library that I manage I have just added a little command line tool that does some parts of what you describe. Run it within a directory that contains both an
app.py
and arequirements.txt
and it will create for you an installation exe that has an embedded Python installation bundled within it.You require an installation of
yarn
, my library toolpymedphys
(https://github.com/pymedphys/pymedphys), and if you’re building this Windows exe on a Linux machine you’ll also needwine
installed. See https://github.com/pymedphys/pymedphys/tree/master/streamlit-bundle for more info.Have this little utility carry with it all the warnings of a rough and ready prototype.
My App’s user isn’t developer so they can not install python enviroment on computer. I want to find out a way which can build an .exe file. So that I can send this file to my user, and they can run my app with just one-cilck.
I don’t care which the app use browner or not. If the file size can be smaller, that will be a perfect way to use Streamlit.
(My first language isn’t English, so if you found some error in my comment, please tell me and improve my standard of English.)
Best wishes, yezi.