Skip to content

Commit

Permalink
storing the model uuid as client side state
Browse files Browse the repository at this point in the history
  • Loading branch information
brifordwylie committed Apr 1, 2024
1 parent 9dc10ed commit 8c5c884
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/sageworks/web_components/model_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def __init__(self):
self.prefix_id = ""
self.model = None
super().__init__()
self.metrics_just_updated = False

def create_component(self, component_id: str) -> html.Div:
"""Create a Markdown Component without any data.
Expand All @@ -35,6 +34,7 @@ def create_component(self, component_id: str) -> html.Div:
html.H3(children="Inference Metrics"),
dcc.Dropdown(id=f"{self.prefix_id}-dropdown", className="dropdown"),
dcc.Markdown(id=f"{self.prefix_id}-metrics"),
dcc.Store(id=f"{self.prefix_id}-model-uuid"), # Store the model uuid
],
)
return container
Expand All @@ -47,6 +47,7 @@ def register_callbacks(self, model_table):
Output(f"{self.prefix_id}-dropdown", "options"),
Output(f"{self.prefix_id}-dropdown", "value"),
Output(f"{self.prefix_id}-metrics", "children", allow_duplicate=True),
Output(f"{self.prefix_id}-model-uuid", "data"),
],
Input(model_table, "derived_viewport_selected_row_ids"),
State(model_table, "data"),
Expand All @@ -71,20 +72,19 @@ def update_model(selected_rows, table_data):

# Update the metrics for the default inference run
metrics = self.inference_metrics(default_run)
self.metrics_just_updated = True

# Return the updated components
return header, summary, inference_runs, default_run, metrics
return header, summary, inference_runs, default_run, metrics, model_uuid

@callback(
Output(f"{self.prefix_id}-metrics", "children", allow_duplicate=True),
Input(f"{self.prefix_id}-dropdown", "value"),
State(f"{self.prefix_id}-model-uuid", "data"),
prevent_initial_call=True,
)
def update_inference_run(inference_run):
def update_inference_run(inference_run, model_uuid):
# Check for no inference run
if not inference_run or self.metrics_just_updated:
self.metrics_just_updated = False
if not inference_run or (self.model.uuid != model_uuid):
return no_update

# Update the model metrics
Expand Down

0 comments on commit 8c5c884

Please sign in to comment.