Let me first say that I like Streamlit. If you don’t have a large or difficult dataset to work with, it’s pretty easy to make a good looking dashboard pretty quickly. It is so much faster to create something good looking than Plotly Dash. That said, here are some areas I’ve found to be challenging.
1. The 403 error.
I found early on I was getting an inconsistent 403 error. When that happened refreshing sometimes worked. It looked like an issue Streamlit had before. That is, it ran fine locally but had problems with any sort of cloud deployments. But I didn’t (and still don’t) know what it was and, in the end, I chalked it up to someone doing site maintainence since I had only just noticed the problem during the early AM and it seems to have resolved itself.
2. Local enviornments do not always match web.
This was so frustrating. I’d like to say I have some thoughts on how to resolve this. I don’t. I just ground on until I got it work.
3. The entire app reruns with any change.
This is double edged sword. On the good side, it makes deveopment a bit easier. Make a change, see the effect. The downside is there is a lag when you update as everything has to rerun. It appears it doesn’t maintain it maintain state. And you can see this if you close a tab. Everything starts again new. My sense is this because Streamlit employs a functional programming model to simplify the development of dashboards. I didn’t want to grapple with how to manage states, so I just avoided it.
4. Adding an external CSS.
If you look on StackOverflow or Google for how to summon a stylesheet into Streamlit, you typically get an answer that says the incantation is like this:
# Read the CSS file
with open("styles.css") as f:
css = f.read()
# Add CSS to the app
st.markdown(f'<style>{css}</style>', unsafe_allow_html=True)
That simply would not work. According to Streamlit, you need to have the css either in the same folder as the app (which I had) or in a subfolder.
End the end what did it for me was using the os
module to take out any ambiguity
css_path = os.path.join(os.path.dirname(__file__), "styles.css")
with open(css_path, "r") as css_file:
st.markdown(f"<style>{css_file.read()}</style>", unsafe_allow_html=True)
I know this sounds like a lot complaints. I think of it as being aware of it’s limitations. Everything has a limtation or tradeoff. Matplotlib is remarkably powerful But out of the box it’s ugly and you have style everything yourself so plots look like the metaphorical quilivent of 90’s webpages because most people don’t have the combination of skill and tasteful design.
So, Streamlit is fun. But when you get past it’s presets, development time doesn’t scale linearly, it’s more like