Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update hub streamlit #67

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ services:
- ./hub_monitoring/grafana/provisioning:/etc/grafana/provisioning
profiles: [hub]

hub_streamlit:
container_name: hub_streamlit
build:
context: hub_streamlit
dockerfile: Dockerfile
ports:
- 8500:8500
environment:
GCP_BUCKET_NAME: tf-vio-bucket
GOOGLE_APPLICATION_CREDENTIALS: /hub_streamlit/config/secrets/credentials.json
volumes:
- ./hub_streamlit/config:/hub_streamlit/config
profiles: [hub]

hub_monitoring_db:
container_name: hub_monitoring_db
image: postgres:15.1
Expand Down
26 changes: 26 additions & 0 deletions hub_streamlit/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM python:3.9-slim

# let print debug messages log on the console
ENV PYTHONUNBUFFERED=1
ENV PYTHONIOENCODING=UTF-8

WORKDIR /hub_streamlit

RUN apt-get update && apt-get install -y \
build-essential \
curl \
software-properties-common \
git \
&& rm -rf /var/lib/apt/lists/*

COPY requirements.txt .

RUN pip install -r requirements.txt

COPY src ./hub_streamlit

EXPOSE 8501

HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health

ENTRYPOINT ["streamlit", "run", "hub_streamlit/app.py", "--server.port", "8500"]
2 changes: 1 addition & 1 deletion hub_streamlit/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ env:

.PHONY: run ## Run the streamlit app
run:
streamlit run src/app.py --server.port 8502
streamlit run src/app.py --server.port 8500
12 changes: 7 additions & 5 deletions hub_streamlit/src/app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import streamlit as st
from google.cloud.storage import Client

from data_extraction import extract_items
from data_extraction import extract_edges
from models.edge_data_manager import EdgeDataManager
from streamlit_component.edge_section import EdgeSection
from streamlit_component.html_objects import vio_hub_title_object


def main():
Expand All @@ -16,13 +15,16 @@ def main():
st.session_state.active_edges = []
st.session_state.gcp_client = Client()

st.session_state.edge_data = extract_items(st.session_state.gcp_client)
st.session_state.edge_data = extract_edges(st.session_state.gcp_client)

sidebar(st.session_state.edge_data)


def sidebar(edge_data: EdgeDataManager):
vio_hub_title_object()
st.sidebar.markdown(
"<h1 style='font-size: 2em; text-align: left;'><b>VIO Hub</b></h1>",
unsafe_allow_html=True,
)
st.sidebar.title("Configuration")

# Select edge and use case
Expand All @@ -33,7 +35,7 @@ def sidebar(edge_data: EdgeDataManager):

# Refresh data
if st.sidebar.button("↻"):
st.session_state.edge_data = extract_items(st.session_state.gcp_client)
st.session_state.edge_data = extract_edges(st.session_state.gcp_client)

# Computes the page display
removing_edges = [
Expand Down
2 changes: 1 addition & 1 deletion hub_streamlit/src/data_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


@st.cache_data(ttl=30)
def extract_items(_gcp_client: Client) -> EdgeDataManager:
def extract_edges(_gcp_client: Client) -> EdgeDataManager:
# Get the bucket
bucket = _gcp_client.bucket(BUCKET_NAME)
blobs = bucket.list_blobs()
Expand Down
8 changes: 0 additions & 8 deletions hub_streamlit/src/streamlit_component/html_objects.py

This file was deleted.