Developer guide
Live task

Streamlit live task

The Streamlit live task is a special type of task that lets you create a Streamlit dashboard app connected to your lab's data.

Streamlit is a popular Python package for rapidly building data apps. You can find more information and examples on the Streamlit website: https://streamlit.io/.


When you develop a streamlit live task you can provide as many inputs as needed. The inputs must be File and Folder.

When you write the code of a streamlit env live task , there are 1 important variable available in your code context :

  • source_paths : type List[string]
    • list of string containing the path of files and folders defined as inputs. The list size and order match the inputs defined in the task.


    The Streamlit live task has only one output, which is a StreamlitResource. Opening this resource will allow you to access the Streamlit app. In this resource, you also have access to all the input File and Folder used in the Streamlit app.

    Develop the streamlit live task

    When you're deploying a Streamlit app in Constellab, the system takes care of deployment, security, and app cleanup, so you don't need to worry about those aspects.

    You can develop and test your Streamlit app directly in the Codelab environment. Write your Streamlit app within a folder. Once it's ready, run the Streamlit app using port 8501 with the following command: streamlit run [PATH_TO_FILE] --server.port 8501. You should see the message: "You can now view your Streamlit app in your browser."

    To test your app, open the URL: https//dashboard-dev.[LAB].constellab.app. Basically, you need to take the URL of your Codelab, replace "codelab" with "streamlit-dev," and remove everything after "/". This will open the Streamlit app, allowing you to test it.

    Once your app is ready, you can test it within a Streamlit live task and connect it with your data. Replace your input variables with the source_paths variable and remove the st.set_page_config statement. The app should work as tested in the Codelab.


    Connecting / Connection lost / Connection timed out

    If you encounter connection issues such as "Connecting/Connection lost/Connection timed out" when opening the Streamlit app, please close the resource or view and then reopen it. This should resolve the issue and allow you to use the app again.