The timing could not have been better. As I was searching for ways to deliver interactive content for the 123AI blog, a young startup, streamlit, appeared with a firework of articles, posts, interviews on social media and beyond. Immediately, it became clear that this is the very tool I was missing the whole time. The last missing piece, at least in my mind, to make this blog something special.

What is Streamlit?

Streamlit has very strong backing and was founded by three battle-proven industry veterans: Adrien Treuille (Google X project lead), Thiago Teixeira (Founder of Hangout Chats by Google), and Amanda Kelly (Product owner at Google X). No wonder that there is such a fuzz around the company and the product. If you like it or not, the team and the professional network still matters most. The following statement is, how the company thinks of themselves:

Streamlit is company of tinkerers, engineers, and scientists. We believe that machine learning engineers deserve blazingly fast, fun, and interactive tools. Together, we are building the world’s most beautiful tool for machine learning engineers. Welcome to programming 2.0.

From https://streamlit.io/about/

The product, streamlit, is a Python framework build around a lightweight webserver to turn your code into beautiful, interactive web applications. These apps look and feel more like polished products rather than crude prototypes. Even better, not much code overhead is needed and streamlit will take care of everything. This includes speedup tricks using caching as well as always using your latest code version when you pull it from git. Sounds awesome? Well, it certainly is and I can not emphasize enough on how fast and with how little resources you can build impressive looking web applications. Now, how does it compare to the usual suspects?

Why not Jupyter notebooks?

Jupyter notebooks are also great! In fact, they are so powerful and versatile that we at 123AI.de use them ourselves for educational purposes, for our member services, and for corporate training. They are highly customizable and interactive, have a huge following and come in different shapes. However, they do not serve the same purpose: streamlit is rapid prototyping and delivering applications to a possibly non-technical audience while Jupyter notebooks are still made for programmers and enthusiasts and you could think of it as a pumped up or alternative IDE.

How does 123AI use streamlit?

First off, I started by renting an online vServer at a prepaid hoster (no sponsoring, no affiliate link) for a very low monthly cost. The server should have multiple CPUs and enough memory to support streamlit and possibly JupyterHub. For testing, I started with a 2 CPU and 4GB RAM vServer for a very cost-efficient 5.31 EUR per month. As traffic increases, upgrading to a larger system is a necessity and should be easy up to a certain point.

Having root access, I installed Ubuntu 18.04 with on click on the command console and installed some of the fundamental Linux tools as well as a current version of anaconda. From here, it was really a piece of cake as installing streamlit is nothing more than a pip install streamlit. Starting the service is as easy as installing it. streamlit hello will start the webserver and showing some examples which you can access and manipulate from outside. You might want to start the service within a screen session to make sure it still stays alive even when you log out.

Instead of using the IP address and port directly, I bought a domain and set up a subdomain redirect. For accessing multiple streamlit apps, each of them will live on another port and get another subdomain redirect. Finally, to include and use it on the blog, I use the advance iframe plugin for WordPress. Now, it is possible to launch and show an app with a single line of code in any article.

If you want to know more about the inner workings of streamlit, please check out their API. I highly recommend to check out this introductory article by Co-founder Adrien Treuille. If you want to check out a working example, please have a look at our post on Know your distributions. For our members, all streamlit applications source codes are available as part of the 123ai-content package under streamlit-apps.

Any problems and missing features?

Well, there are a few. Being such a novel product, streamlit is actively developed and far from mature or feature complete. That being said, they really care about their community and I had no server crashes so far. However, since the webserver does not support https out-of-the-box, I had to downgrade the whole blog to http to be able to embed apps in articles. Moreover, for really immersing a streamlit app into the blog, advanced customization is necessary. I.e. fonts and colors need to be adapted, CSS styles need to be supported. For professional use, user management and access control is a must as well as the ability to manage multiple apps using the same server.

What’s the gist

Streamlit is a very interesting new startup that builds powerful tools for rapid prototyping and visualization. It is specially tailored to data science and machine learning problems. Even in its very young, current iteration, it is extraordinarily stable and delivers beautiful, product-like web front ends.

Update March 2020:

The more I use streamlit, the more am I amazed by its simplicity and robustness. However, there are a three more constraints that popped up while coding and really need to be resolved in my view. The good news is that the team is good at communication and taking suggestions from their users serious. They are aware of all of things that bother me and there will be a solution soon.

Most crucial point first: there is no way of having callback functions in a streamlit app right now. Doesn’t matter if you are using Altair, Bokeh, or Plotly. You will not be notified when the user, e.g. selects some data points in their figures.

If you have many interactive widgets such as sliders and drop-downs, the user interface will quickly become cluttered due to the lack of layout flexibility. Right now, each element will consume a whole row which is fine for simple and smaller projects but not for more advanced user interfaces. BTW, streamlit is totally capable for this: it is fast, memory efficient, and stable.

And finally, sometimes it would be good to trigger a refresh or suppress a refresh manually in the code. If you, e.g. change the menu list in the sidebar drop-down it will only be updated once you clicked on one of the old items in the list.

That’s it, these are my main complaints after working so many hours with this framework. There are more, little, things and improvements that would be nice but this is the list that is most severe for me.

If you find this post interesting, please share it and leave a comment below. You can, of course, also support me by donating or becoming a monthly supporter which will come with some more benefits such as exclusive content. If you have any questions, please contact me or leave a comment below.