Uploading a Data App with Streamlit | Dadosfera Documentation

Below, you'll find a step-by-step guide on how to use the template provided by our team to deploy Data Apps using Streamlit in the Intelligence Module.

Prerequisites

  • Have a Dadosfera user account
  • Access to the Intelligence Module
  • Have a project created in the Intelligence Module

Preparing the environment in the module for the Data App

In the ENVIRONMENTS tab, select the Python image and name your environment as you prefer.

In the Setup script field, paste the following code:

#!/bin/bash
# Install Python 3.8 and get minimum set of dependencies
mamba create -y -n py38 python=3.8 future
mamba install -y -n py38 ipykernel jupyter_client ipython_genutils pycryptodomex future "pyarrow<8.0.0"
mamba run -n py38 pip install orchest

# Jupyter environment variable that specifies
# a path to search for kernels data files
# See https://jupyter-core.readthedocs.io/en/latest/paths.html
echo "export JUPYTER_PATH=/opt/conda/envs/py38/share/jupyter" >> /home/jovyan/.orchestrc
echo "export PATH='/opt/conda/envs/py38/bin/:$PATH'" >> /home/jovyan/.orchestrc

# Orchest related environment variable that can be set to specify
# the conda environment to use to start Jupyter kernels
echo "export CONDA_ENV=py38" >> /home/jovyan/.orchestrc
mamba run -n py38 pip install pandas snowflake-snowpark-python streamlit plotly

These are the base requirements for a Streamlit-based Data App project. If your project needs any additional resources to run, they should be added to this code.

Next, click the build button so your environment gets built. The button is located in the top-right corner of the interface.

To check whether the build ran successfully, you should see a result similar to this:

Once that's done, the environment is ready to run a Data App with Streamlit.

Uploading the sample project

To download the sample project, just click on your preferred format: .zip or.tar.gz.

Unzip the downloaded file, select the app/ folder, and upload it to the module:

Once that's done, the project is ready to become a service in the module.

Creating a SERVICE for the project under: Data Apps → Edit Data Apps

Add a new Streamlit service under "Add Service":

Select Streamlit and expand the row created with the service name: Streamlit.

Click on the Image field and select the image from the environment you configured earlier:

Configure the service with the following values:

Args: -c 'umask 002 && streamlit run app/Home.py'

Then save your changes:

Once done, just go back to the pipelines page and restart the session, as shown in the bottom-left corner under pipeline sessions (main.ddf):

Accessing the service

In the SERVICES tab, select your Data App:

Done — you'll be redirected to the access link for your Data App, with the components provided in this template:

It's worth noting that changing the service name in its settings directly affects the custom link, so we don't recommend renaming it after the service has already been created and shared with other people or applications.

Note

On the example page, you'll see an error:

This error was intentionally triggered so you can add your own sample.csv file to the project folder and observe how the download button works, as shown below.

Once you have the template in your environment, you can edit the scripts directly through Jupyter according to the project you're building. The whole project was designed with code reuse in mind, so it's split into example components, application components, and pages, and it also includes an entity model to simulate interaction with real data.

If you have any questions or suggestions, please reach out to our team.


Did this page help you?