From 6f9d04e2a2b4aae8cb12df1ef7274035f1dff8df Mon Sep 17 00:00:00 2001 From: Praneeth Bedapudi Date: Thu, 20 Jul 2023 16:18:58 +0530 Subject: [PATCH] minor changes Signed-off-by: Praneeth Bedapudi --- smartdash/smartdash/dash.py | 37 +++++++++++++++---------- smartdash/smartdash/smartdash_server.py | 4 +++ 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/smartdash/smartdash/dash.py b/smartdash/smartdash/dash.py index 98c3eb8..4a1d200 100644 --- a/smartdash/smartdash/dash.py +++ b/smartdash/smartdash/dash.py @@ -137,24 +137,32 @@ def main(): graphs.append(stage_time_line) if data_by_uid: - # Pie chart showing number of failed, success, and in-process uids - metrics_pie = px.pie( - values=[ - sum([1 for uid, data in data_by_uid.items() if data["success"]]), - sum([1 for uid, data in data_by_uid.items() if data["in_process"]]), - sum([1 for uid, data in data_by_uid.items() if data["failed"]]), - sum( - [1 for uid, data in data_by_uid.items() if data["long_running"]] - ), - ], - names=["Success", "In Process", "Failed", "Long running"], - title="Uids by Status", - ) + metrics_df = pd.DataFrame({ + "status": ["Success" if data["success"] + else "In Process" if data["in_process"] + else "Failed" if data["failed"] + else "Long running" + for uid, data in data_by_uid.items()], + }) + + metrics_pie = px.pie(metrics_df, + names='status', + title="Uids by Status", + color='status', + color_discrete_map={ + "Success": "green", + "In Process": "yellow", + "Failed": "red", + "Long running": "lightcoral" + }) + + metrics_pie.update_traces(textposition='inside', textinfo='percent+label') + graphs.append(metrics_pie) cols = st.columns(2, gap="small") for i, graph in enumerate(graphs): - cols[i % 2].write(graph) + cols[i % 2].plotly_chart(graph) with st.expander("Show/hide logs"): logs_data = [] @@ -196,6 +204,7 @@ def main(): st.dataframe(logs_df) except Exception as e: + print(e) st.warning( "No Apps uploaded logs yet. Please upload logs using the smartlogger CLI." ) diff --git a/smartdash/smartdash/smartdash_server.py b/smartdash/smartdash/smartdash_server.py index 6a38d04..6a84dcf 100644 --- a/smartdash/smartdash/smartdash_server.py +++ b/smartdash/smartdash/smartdash_server.py @@ -115,6 +115,10 @@ def on_get(self, req, resp): "logs": [], "ml_inputs_outputs": [], "stage_wise_times": {}, + "success": None, + "failed": None, + "in_process": None, + "long_running": False, } data_by_id[log["u_id"]]["ml_inputs_outputs"].append(ml_inputs_outputs)