A Streamlit app to make Streamlit apps

[Update 2020-07-16] Updated the gist to fix the subprocess bug (I think) and a typo with the file save. And, if you’re new to Streamlit reading this, you can try it out the quickest by running the following:

streamlit run https://gist.githubusercontent.com/chad-m/65e3f9d91ef23ced5e83c8a814aee7ae/raw/73de429d1ea6e8d93f33dc5fca6002830dffe49d/streamlit_app_maker.py

Hi all, the Github gist below is for a Streamlit app to make Streamlit apps. I built the prototype this weekend, so rumsfeldian bugs are expected.

For example, the code editor saving is wonky after the first save. I need to include session management code to address this, but still familiarizing myself with Streamlit’s codebase. If anyone has a recommended solution to fix the editor, thank you in advance.

The component library code is essentially from the following, excellent app: https://fullstackstation.com/streamlit-components-demo.

7 Likes

For fun I, copied the streamlit app maker into the streamlit app maker into the streamlit app maker…

2 Likes

Haha @Chad_Mitchell I love the meta-ness of this!! Looking forward to trying it out.

2 Likes

this is amazing.

one question: through launching the app as I edit, I notice new processes being spawned up, but cannot bring them down with clearing cache or rerunning. How might I prevent the clutter of jobs? Maybe when hitting “Run App,” it kills the previous process and spawns up at the same port?

[EDIT]: looks like when I shut down the original app, the subprocesses stay up too.

1 Like

awesome work. I have the same question about the “run app” processes.

1 Like

@djdebonis @mathematicalmichael thank you for the feedback! I’m working on a general update given the release of Streamlit components that hopefully will address the editor bug. I’ll work on a fix for the subprocess issue as well, which I suspect is caused by a regex typo.

1 Like

thanks! feel free to ping me when you do. I really like this project as a way to explore the components and quickly put out some skeleton code.

I also noticed that shutting down and restarting streamlit let me pick up in the same state. not sure if that’s a feature or a bug. I could see that being great for local development, not so great for deployment.

1 Like

@djdebonis @mathematicalmichael Updated the gist to fix the process bug (I think) and a typo with the file save.

I wanted to try this awesome app but I get an error

1 Like

Hi @AhmedSalam22 are you using Windows?

If not, i’ll have to look into it further. I can probably add an update to check for os. Thank you for letting me know!

Hey @Chad_Mitchell,

Great minds meet :slight_smile:!

I implemented a similar idea 6 months ago and submitted it to awesome-streamlit, activity on that project has slowed unfortunately, we are all busy :slight_smile:.

Have a look and let me know what you think.

Here is the link: https://gitlab.com/fchesneau/stream.git

3 Likes

Hi @F_C,

Thank you for sharing! I figured, and hoped, I wasn’t the first :slight_smile:

I’m looking forward to checking it out. Now that I’m more familiar with Streamlit (plus components!!!), I’m revamping my approach in general. Still learning up on React, but very much enjoying the extensibility so far.

Cheers

3 Likes

My approach is quite basic and purely python, keeping to the main streamlit functions.
React and so on are over my pay grade :slight_smile: but extending for components is enticing. I hope I find time over the next few weeks to dig into it.

2 Likes

finally got around to sitting down with it for an evening again. It worked swimmingly within docker (which feels a bit like a moving target), but for anyone curious:

Dockerfile

# base image
FROM python:3.7

# streamlit-specific commands
RUN mkdir -p /root/.streamlit
RUN bash -c 'echo -e "\
[general]\n\
email = \"\"\n\
" > /root/.streamlit/credentials.toml'
RUN bash -c 'echo -e "\
[server]\n\
enableCORS = false\n\
enableXsrfProtection = false\n\
" > /root/.streamlit/config.toml'

# exposing default port for streamlit
EXPOSE 8501
EXPOSE 8502

# copy over and install packages
COPY requirements.txt ./requirements.txt
RUN pip3 install -r requirements.txt

# secure container by setting non-root user
WORKDIR /st
RUN useradd appuser && chown -R appuser /st
USER appuser 

# run app
CMD streamlit run

requirements.txt

numpy
streamlit
plotly
matplotlib

streamlit is an extensionless shell script that is executable, and referrs to the streamlit:latest from docker build -t streamlit .

#!/bin/sh
IMAGE_NAME=streamlit:latest
COMMAND=streamlit
docker run --rm --name streamlit -d -p 8502:8502 -p 8501:8501 -v $(pwd):/st -w /st $IMAGE_NAME $COMMAND $@ #--browser.serverAddress 0.0.0.0 --server.enableCORS False

this mounts current folder in the app directory, and lets me have this “app builder” running on my computer at all times, looks like I can even edit the text file and streamlit picks up on the changes.

My only problem encountered was an occasional frustration with (i think the browser) caching. Sometimes I would edit the app, click to another window, and come back only to find my changes missing. This happened a few times (which is why I experimented with opening the temporary application file in a text editor, worked great). Thanks so much for fixing the proxying on new ports issue, that enabled me to keep this whole thing containerized and only expose two ports.

1 Like

Thank you @mathematicalmichael! I’m working on the editor caching issue and some other updates given the new components feature. I’m busy with work projects for the next week or so, and will be pivoting back to this project then.

1 Like