Skip to content

Commit

Permalink
Add plotting through plotly
Browse files Browse the repository at this point in the history
  • Loading branch information
berland committed Sep 26, 2024
1 parent 8fd0806 commit 1cd3639
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion res/dash_gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import dash_bootstrap_components as dbc
import dash_table
import pandas as pd
import plotly.express as px
import websocket
from communication.experiments import fetch_experiments_data
from dash import dcc, html
Expand Down Expand Up @@ -65,6 +66,7 @@
width=12,
)
),
dcc.Graph(id="memory-profile"),
dbc.Row(
dbc.Col(
html.Div(
Expand Down Expand Up @@ -119,7 +121,6 @@ def event_to_row(event: dict, experiment_id):
def update_table(n_clicks, n_intervals):
global dataframe_rows
data = fetch_experiments_data()
print(pd.DataFrame(dataframe_rows))
if data:
# Convert to DataFrame and return as dict records
df = pd.DataFrame(data)
Expand Down Expand Up @@ -162,6 +163,22 @@ def start_websocket(experiment_id):
ws.run_forever()


@app.callback(
Output("memory-profile", "figure"),
Input("interval-component", "n_intervals"),
)
def update_graph(value):
global dataframe_rows
global FM_STATES
global old_id
FM_STATES = pd.DataFrame(dataframe_rows)
print(FM_STATES)
dff = FM_STATES[FM_STATES.experiment_id == old_id].reset_index()
print(value)
print(dff)
return px.line(dff, x="index", y="current_memory_usage")


# Callback to handle the selected experiment and start WebSocket connection
@app.callback(
Output("websocket-events", "children"),
Expand Down

0 comments on commit 1cd3639

Please sign in to comment.