Spaces:
Build error
Build error
import streamlit as st | |
from graphviz import Digraph | |
import time | |
import random | |
# Define the emoji to use for the swim lanes | |
SWIM_LANES = { | |
"Data Pipelines": "๐", | |
"Build and Train Models": "๐งช", | |
"Deploy and Predict": "๐" | |
} | |
# Define the graph structure | |
graph = Digraph() | |
graph.attr(rankdir="TB") # Top to Bottom or LR Left to Right | |
graph.attr(fontsize="20") | |
graph.attr(compound="true") | |
graph.attr(nodesep="0.5") | |
# Define the nodes | |
graph.node("๐ Data Collection") | |
graph.node("๐งน Data Cleaning") | |
graph.node("๐ง Data Transformation") | |
graph.node("๐ Feature Engineering") | |
graph.node("โ๏ธ Model Selection") | |
graph.node("๐ Model Training") | |
graph.node("๐ข Model Deployment") | |
graph.node("๐ก Model Serving") | |
graph.node("๐ฎ Predictions") | |
graph.node("๐ Feedback Collection") | |
graph.node("๐ค Feedback Processing") | |
graph.node("โ๏ธ Model Updating") | |
# Add the edges | |
graph.edge("๐ Data Collection", "๐งน Data Cleaning") | |
graph.edge("๐งน Data Cleaning", "๐ง Data Transformation") | |
graph.edge("๐ง Data Transformation", "๐ Feature Engineering") | |
graph.edge("๐ Feature Engineering", "โ๏ธ Model Selection") | |
graph.edge("โ๏ธ Model Selection", "๐ Model Training") | |
graph.edge("๐ Model Training", "๐ข Model Deployment") | |
graph.edge("๐ข Model Deployment", "๐ก Model Serving") | |
graph.edge("๐ก Model Serving", "๐ฎ Predictions") | |
graph.edge("๐ฎ Predictions", "๐ Feedback Collection") | |
graph.edge("๐ Feedback Collection", "๐ค Feedback Processing") | |
graph.edge("๐ค Feedback Processing", "โ๏ธ Model Updating") | |
graph.edge("โ๏ธ Model Updating", "๐ Model Training") | |
# Add the swim lanes | |
with graph.subgraph(name="cluster_0") as c: | |
c.attr(rank="1") | |
c.attr(label=SWIM_LANES["Data Pipelines"]) | |
c.edge("๐ Data Collection", "๐งน Data Cleaning", style="invis") | |
c.edge("๐งน Data Cleaning", "๐ง Data Transformation", style="invis") | |
with graph.subgraph(name="cluster_1") as c: | |
c.attr(rank="2") | |
c.attr(label=SWIM_LANES["Build and Train Models"]) | |
c.edge("๐ Feature Engineering", "โ๏ธ Model Selection", style="invis") | |
c.edge("โ๏ธ Model Selection", "๐ Model Training", style="invis") | |
with graph.subgraph(name="cluster_2") as c: | |
c.attr(rank="3") | |
c.attr(label=SWIM_LANES["Deploy and Predict"]) | |
c.edge("๐ข Model Deployment", "๐ก Model Serving", style="invis") | |
c.edge("๐ก Model Serving", "๐ฎ Predictions", style="invis") | |
with graph.subgraph(name="cluster_3") as c: | |
c.attr(rank="4") | |
c.attr(label="Reinforcement Learning Human Feedback") | |
c.edge("๐ฎ Predictions", "๐ Feedback Collection", style="invis") | |
c.edge("๐ Feedback Collection", "๐ค Feedback Processing", style="invis") | |
c.edge("๐ค Feedback Processing", "โ๏ธ Model Updating", style="invis") | |
def render_graph(): | |
st.graphviz_chart(graph.source) | |
def update_graph(): | |
for i in range(10): | |
# Update the graph with new inputs randomly | |
graph.node("๐ Data Collection", label=f"๐ Data Collection\nData {random.randint(0,100)}") | |
graph.node("๐งน Data Cleaning", label=f"๐งน Data Cleaning\nCleaned Data {random.randint(0,100)}") | |
graph.node("๐ง Data Transformation", label=f"๐ง Data Transformation\nTransformed Data {random.randint(0,100)}") | |
graph.node("๐ Feature Engineering", label=f"๐ Feature Engineering\nFeatures {random.randint(0,100)}") | |
graph.node("โ๏ธ Model Selection", label=f"โ๏ธ Model Selection\nSelected Model {random.randint(0,100)}") | |
graph.node("๐ Model Training", label=f"๐ Model Training\nTrained Model {random.randint(0,100)}") | |
graph.node("๐ข Model Deployment", label=f"๐ข Model Deployment\nDeployed Model {random.randint(0,100)}") | |
graph.node("๐ก Model Serving", label=f"๐ก Model Serving\nServed Model {random.randint(0,100)}") | |
graph.node("๐ฎ Predictions", label=f"๐ฎ Predictions\nPredicted Results {random.randint(0,100)}") | |
graph.node("๐ Feedback Collection", label=f"๐ Feedback Collection\nFeedback {random.randint(0,100)}") | |
graph.node("๐ค Feedback Processing", label=f"๐ค Feedback Processing\nProcessed Feedback {random.randint(0,100)}") | |
graph.node("โ๏ธ Model Updating", label=f"โ๏ธ Model Updating\nUpdated Model {random.randint(0,100)}") | |
# Render the updated graph | |
render_graph() | |
# Wait for 1 second | |
time.sleep(1) | |
# Render the initial graph | |
render_graph() | |
# Update the graph every second for 60 seconds | |
update_graph() |