Has anyone been able to get Streamlit apps to publish?

taylor.hortontaylor.horton Member Posts: 2
edited October 2019 in Q&A

I have been trying to get a Python Streamlit app to publish as an App, but just get an empty 'Please wait...' screen rather than the app content.

I have a config.toml file and a credentials.toml preconfigured to host on 0.0.0.0 and port 8888 which are moved to ~/.streamlit/ as part of a custom Post Setup script. Those were necessary to get the app sort of working and the logs to stop throwing errors, but there still appears to be issues.

Anyone else been able to get Streamlit (or any other Tornado app) to work and host in Domino?

Best Answers

  • john.joojohn.joo Member, Moderator, Domino Posts: 6 mod
    Accepted Answer

    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!

Answers

  • john.joojohn.joo Member, Moderator, Domino Posts: 6 mod

    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
    
  • taylor.hortontaylor.horton Member Posts: 2

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

  • msterlingmsterling Member Posts: 5

    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?

  • msterlingmsterling Member Posts: 5

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

  • john.stanton-geddesjohn.stanton-geddes Member Posts: 11

    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.

Sign In or Register to comment.