bangpypers / meetup-talks

Creative Commons Zero v1.0 Universal
6 stars 2 forks source link

Lightning talk: Deploying a streamlit app as an executable #17

Closed nagendra-y closed 8 months ago

nagendra-y commented 8 months ago

Title of the talk

Deploying a streamlit app as an executable

Description

This brief talk will give a bird's-eye view of the different ways you can deploy a streamlit app as an executable and my personal experience with trying some of them.

I had a built a simple streamlit demo app that uses IndictTrans2 to translate an uploaded document. It was required that the demo be runnable offline. Ideally, by anyone, as a one click desktop executable -- on Linux, Mac and Windows

I explored the following solutions:

  1. Packaging the app into a docker container. This wasn't feasible as it's not always user friendly to install and run docker. Also, the docker image was huge ~12GB
  2. Using nativefier. Can't run offline as we need to upload the app to streamlit share.
  3. Packaging it as an electron app using stlite/pyodide(currently an expiremental project). Did not work for me. The resulting electron app just kept crashing.
  4. Using pyinstaller. Didn't work even after adding relevant hooks. App kept crashing being unable to find metadata/static files. Also, I couldn't do cross compilation on my sole Linux machine (cross compilation support dropped in recent pyinstaller versions). Might have to use their docker images
  5. Found the one method to rule them all and in the executable bind them. This cool starter project https://github.com/Enopios/Enopios uses pyoxidizer to build streamlit into an executable. It also uses poetry for dependency management and a CI workflow to build cross platform releases.

Forked the repo, modified and added dependencies and a few other minor changes to make the build work. Packaged the ct2 model zip separately for the app to load at run time.

Final result: https://github.com/nagendra-y/Enopios

Executables for Linux, Mac and Windows https://github.com/nagendra-y/Enopios/actions/runs/6978427474

Resources

Slides

https://docs.google.com/presentation/d/1C1fSrIyQ1tIdv3vlisf_3hHb_31hpHyWAtkM-EOIXF8/edit?usp=sharing

What format do you have in mind for your talk?

Talk

Table of contents

What domain would you say your talk falls under?

CLI & Tooling

Duration in minutes (including Q&A)

10mins

Prerequisites

No response

Speaker bio

https://twitter.com/nagendra__y https://in.linkedin.com/in/nagendra-y-a976081a3

Full stack dev. Likes python. Looking for opportunities!

The talk/workshop speaker agrees to