pumpwood_streamlit

Pumpwood Streamlit Package.

This package helps to build Streamlit dashboard with authentication integrated with Pumpwood Auth authentication.

Example of use in aplications:

Creation of the app.py called by streamlit:

import os
from dashboard import Dashboard
from pumpwood_communication.microservices import PumpWoodMicroService

##########################################################################
# Read env variables to be used on local test of the dashboard.          #
# Passing a logged microservice to dashboard will disable authentication #
# !!! DO NOT USE AUTHENTICATED MICROSERVICE IN PRODUCTION DASHBOARDS !!! #
MICROSERVICE_URL = os.getenv('MICROSERVICE_URL')
MICROSERVICE_DASHBOARD_USERNAME = os.getenv('MICROSERVICE_DASHBOARD_USERNAME')
MICROSERVICE_DASHBOARD_PASSWORD = os.getenv('MICROSERVICE_DASHBOARD_PASSWORD')

microservice = None
if MICROSERVICE_DASHBOARD_USERNAME is not None:
    microservice = PumpWoodMicroService(
        name="dashboard-microservice",
        server_url=MICROSERVICE_URL,
        username=MICROSERVICE_DASHBOARD_USERNAME,
        password=MICROSERVICE_DASHBOARD_PASSWORD,)
    microservice.login()

dash_obj = Dashboard(microservice=microservice)
dash_obj.run()

Creation of the dashboard:

import os
import streamlit as st
import pandas as pd
import altair as alt
import plotly.express as px
from pumpwood_streamlit.dashboard import PumpwoodStreamlitDashboard


class Dashboard(PumpwoodStreamlitDashboard):
    def set_page_config(self):
        #######################
        # Page configuration
        st.set_page_config(
            page_title="US Population Dashboard",
            page_icon="🏂",
            layout="wide",
            initial_sidebar_state="expanded")

    def main_view(self):
        alt.themes.enable("dark")

        #######################
        # Load data
        st.title('O dash mudou!')
 1"""
 2# Pumpwood Streamlit Package.
 3
 4This package helps to build Streamlit dashboard with authentication
 5integrated with Pumpwood Auth authentication.
 6
 7## Example of use in aplications:
 8Creation of the app.py called by streamlit:
 9```python
10import os
11from dashboard import Dashboard
12from pumpwood_communication.microservices import PumpWoodMicroService
13
14##########################################################################
15# Read env variables to be used on local test of the dashboard.          #
16# Passing a logged microservice to dashboard will disable authentication #
17# !!! DO NOT USE AUTHENTICATED MICROSERVICE IN PRODUCTION DASHBOARDS !!! #
18MICROSERVICE_URL = os.getenv('MICROSERVICE_URL')
19MICROSERVICE_DASHBOARD_USERNAME = os.getenv('MICROSERVICE_DASHBOARD_USERNAME')
20MICROSERVICE_DASHBOARD_PASSWORD = os.getenv('MICROSERVICE_DASHBOARD_PASSWORD')
21
22microservice = None
23if MICROSERVICE_DASHBOARD_USERNAME is not None:
24    microservice = PumpWoodMicroService(
25        name="dashboard-microservice",
26        server_url=MICROSERVICE_URL,
27        username=MICROSERVICE_DASHBOARD_USERNAME,
28        password=MICROSERVICE_DASHBOARD_PASSWORD,)
29    microservice.login()
30
31dash_obj = Dashboard(microservice=microservice)
32dash_obj.run()
33```
34
35Creation of the dashboard:
36```python
37import os
38import streamlit as st
39import pandas as pd
40import altair as alt
41import plotly.express as px
42from pumpwood_streamlit.dashboard import PumpwoodStreamlitDashboard
43
44
45class Dashboard(PumpwoodStreamlitDashboard):
46    def set_page_config(self):
47        #######################
48        # Page configuration
49        st.set_page_config(
50            page_title="US Population Dashboard",
51            page_icon="🏂",
52            layout="wide",
53            initial_sidebar_state="expanded")
54
55    def main_view(self):
56        alt.themes.enable("dark")
57
58        #######################
59        # Load data
60        st.title('O dash mudou!')
61```
62"""