-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor integration dashboard display for TA1 (#7)
* Start on graph creation * Render graph * Render to near parity * Render text correctly * Render scenario names on feature tables * Render as boxes * Round tables * Update README usage * Remove TODOs * Update screenshot
- Loading branch information
Showing
11 changed files
with
461 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
from pyvis.network import Network | ||
import networkx as nx | ||
import pandas as pd | ||
import streamlit as st | ||
import streamlit.components.v1 as components | ||
|
||
from dashboard.formatting import custom_title | ||
|
||
|
||
def render_scenario_viewer(scenarios): | ||
st.write(f"### Scenario Viewer") | ||
scenario_name = st.selectbox("Select a pipeline:", list(scenarios.keys())) | ||
scenario = scenarios[scenario_name] | ||
|
||
graph = nx.DiGraph() | ||
steps = scenario["steps"] | ||
total_time = 0 | ||
for step_name, step_details in steps.items(): | ||
total_time += step_details["time"] | ||
status_color = 'green' if step_details['success'] else 'red' | ||
graph.add_node(step_name, color=status_color) | ||
shape = scenario["shape"] | ||
for link in shape: | ||
graph.add_edge(link["from"], link["to"]) | ||
nx.set_node_attributes(graph, "box", "shape") | ||
pipeline = Network(notebook=False, directed=True) | ||
pipeline.from_nx(graph) | ||
pipeline.options = { | ||
'layout': { | ||
'hierarchical': { | ||
'enabled': True, | ||
'direction': 'LR', | ||
'sortMethod': 'directed' | ||
}, | ||
}, | ||
} | ||
display = pipeline.generate_html() | ||
|
||
|
||
st.write(f"### {scenario_name}") | ||
st.text(scenario["description"]) | ||
st.metric("Total Time", round(total_time,2)) | ||
components.html(display, height=800, width=800) | ||
|
||
|
||
def render_section_scenario_status(scenarios): | ||
st.write(f"### Scenario Status") | ||
status_data = { | ||
"Scenario": list(scenarios.keys()), | ||
"Success": [scenario["success"] for scenario in scenarios.values()], | ||
"Total Time": [ | ||
round(sum([step["time"] for step in scenario["steps"].values()]),2) | ||
for scenario in scenarios.values() | ||
] | ||
} | ||
df = pd.DataFrame(status_data) | ||
df.replace({False: "❌", True: "✅"}, inplace=True) | ||
st.dataframe(df, hide_index=True) | ||
|
||
|
||
def get_feature_table(scenarios, feature): | ||
results = {} | ||
step_names = set() | ||
for scenario_name, scenario in scenarios.items(): | ||
for step_name, step in scenario["steps"].items(): | ||
step_names.add(step_name) | ||
results[(scenario_name, step_name)] = step[feature] | ||
df = pd.DataFrame(index=list(scenarios.keys()), columns=list(step_names)) | ||
for (scenario_name, step_name), result in results.items(): | ||
df.at[scenario_name, step_name] = result | ||
return df | ||
|
||
def render_section_integration_status(scenarios): | ||
st.write(f"### Integration Status") | ||
df = get_feature_table(scenarios, "success") | ||
df.replace({False: "❌", True: "✅", None: ""}, inplace=True) | ||
st.dataframe(df) | ||
|
||
def render_section_time(scenarios): | ||
st.write(f"### Execution Time") | ||
df = get_feature_table(scenarios, "time") | ||
df = df.applymap(lambda t: round(t,2), ) # `df.round(2)` is ineffective | ||
st.dataframe(df) | ||
|
||
|
||
def render_section_accuracy(scenarios): | ||
st.write(f"### Accuracy") | ||
df = get_feature_table(scenarios, "accuracy") | ||
st.dataframe(df) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.