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 | |
nodes = [ | |
"๐ Data Collection", | |
"๐งน Data Cleaning", | |
"๐ง Data Transformation", | |
"๐ Feature Engineering", | |
"โ๏ธ Model Selection", | |
"๐ Model Training", | |
"๐ข Model Deployment", | |
"๐ก Model Serving", | |
"๐ฎ Predictions", | |
"๐ Feedback Collection", | |
"๐ค Feedback Processing", | |
"โ๏ธ Model Updating" | |
] | |
for node in nodes: | |
graph.node(node) | |
# 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): | |
# Randomly select two nodes and add an edge between them | |
node1, node2 = random.sample(nodes, 2) | |
graph.edge(node1, node2) | |
# 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() | |