Simple Streamlit App within a workspace

Follow

Comments

6 comments

  • Jaclyn Patterson

    We haven't been able to get Streamlit working as an app. There seems to be a polling call to the /healthz endpoint. Because the Domino App uses reverse proxy, ie the Streamlit app would be served at domino.company.com (or whatever your Domino address is), the health check will fail and Streamlit will not load. There is an open issue in Streamlit for this here: https://github.com/streamlit/streamlit/issues/225

    As a workaround, you can instead use Streamlit as a Workspace while taking advantage of the Datasets Scratch Spaces feature. You will need to configure and start 2 workspaces. The first workspace will be using whatever IDE/Workspace that you like using.

    1. For this example, we'll keep it Jupyter. You most likely won't have to do anything for this, but if you don't see Jupyter as a workspace, enter the following in Pluggable Workspace Tools in your Compute Environment:
    jupyter:
     title: "Jupyter (Python, R, Julia)"
      iconUrl: "https://raw.github.com/dominodatalab/workspace-configs/develop/workspace-logos/Jupyter.svg?sanitize=true"
     start: [ "/var/opt/workspaces/jupyter/start" ]
     httpProxy:
      port: 8888
      rewrite: false
      internalPath: "/{{#if pathToOpen}}tree/{{pathToOpen}}{{/if}}"
     supportedFileExtensions: [ ".ipynb" ] 
    
    1. Start the Jupyter workspace session.
    2. Create your app.py file in `/domino/datasets/$DOMINO_STARTING_USERNAME/$DOMINO_PROJECT_NAME/scratch/app.py`.
    3. Configure the Streamlit workspace in your environment under Pluggable Workspace Tools:
    streamlit:
       title: "streamlit"
       start: [ "echo -e \"\n\" | streamlit run /domino/datasets/$DOMINO_STARTING_USERNAME/$DOMINO_PROJECT_NAME/scratch/app.py" ]
       httpProxy:
        port: 8501
    
    1. Start your Streamlit workspace session.
    2. To edit your app, edit the code in your Jupyter/lab session and reload the Streamlit app.


    Hopefully, with the merge of the pull request by Thiago, Streamlit will able to support reverse proxied applications natively soon!

    Submitted by: john.joo

    0
    Comment actions Permalink
  • Jaclyn Patterson

    Here are some other configs that were used to make Streamlit work. I put this in my pre-run script, but there are a number of ways to do this:

    mkdir ~/.streamlit && \
      echo "[browser]" > ~/.streamlit/config.toml && \
      echo "serverAddress = \"0.0.0.0\"" >> ~/.streamlit/config.toml && \
      echo "serverPort = 8501" >> ~/.streamlit/config.toml && \
      echo "gatherUsageStats = true" >> ~/.streamlit/config.toml && \
      echo "[server]" >> ~/.streamlit/config.toml && \
      echo "port = 8501" >> ~/.streamlit/config.toml && \
      echo "enableCORS = false" >> ~/.streamlit/config.toml
      echo "runOnSave = true" >> ~/.streamlit/config.toml
    

    Submitted by: john.joo

    0
    Comment actions Permalink
  • Jaclyn Patterson

    Awesome. Thanks John. I'll give that a shot and I guess we'll wait for the updates to support reverse proxied applications.

    Submitted by: taylor.horton

    0
    Comment actions Permalink
  • Jaclyn Patterson

    It looks like the issue referenced above aws resolved. Does that just allow for the two workspace trick to work or does that make it possible to run streamlit as an app?

    Submitted by: msterling

    0
    Comment actions Permalink
  • Jaclyn Patterson

    Thanks @anthony.lee I'll give that a shot.

    Submitted by: msterling

    0
    Comment actions Permalink
  • Jaclyn Patterson

    Thanks @john.joo and @anthony.lee -- we tested this and were able to get streamlit to work in Domino! It is a bit odd as I have to refresh the app a few times before it functions after starting it.

    Submitted by: john.stanton-geddes

    0
    Comment actions Permalink

Please sign in to leave a comment.