From afd3703e676677a8105f8b0e1c3d9b526cad9b3f Mon Sep 17 00:00:00 2001 From: Edoardo Zoni Date: Fri, 8 May 2026 14:06:22 -0700 Subject: [PATCH 1/2] Simplify code in ModelManager class --- dashboard/model_manager.py | 74 ++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 40 deletions(-) diff --git a/dashboard/model_manager.py b/dashboard/model_manager.py index b7fc08f..6e5a99e 100644 --- a/dashboard/model_manager.py +++ b/dashboard/model_manager.py @@ -27,11 +27,7 @@ MODEL_TYPE_NN_SINGLE = "Neural Network (single)" MODEL_TYPE_NN_ENSEMBLE = "Neural Network (ensemble)" AMSC_LOGO_PATH = LOGO_DIR / "AmSC_300px.png" -AMSC_LOGO_URL = ( - LocalFileManager(LOGO_DIR).url("amsc_logo", AMSC_LOGO_PATH) - if AMSC_LOGO_PATH.is_file() - else None -) +AMSC_LOGO_URL = LocalFileManager(LOGO_DIR).url("amsc_logo", AMSC_LOGO_PATH) MODEL_DOWNLOAD_ACTIVE_EXPR = "model_downloading" AMSC_MLFLOW_LINK_ACTIVE_EXPR = ( f"model_available && model_mlflow_tracking_uri === '{AMSC_MLFLOW_URL}'" @@ -490,7 +486,6 @@ def panel(self): MODEL_TYPE_NN_SINGLE, MODEL_TYPE_NN_ENSEMBLE, ] - model_type_cols = 8 if AMSC_LOGO_URL else 12 with vuetify.VExpansionPanels(v_model=("expand_panel_control_model", 0)): with vuetify.VExpansionPanel( title="Control: Models", @@ -498,60 +493,59 @@ def panel(self): ): with vuetify.VExpansionPanelText(): with vuetify.VRow(align="center"): - with vuetify.VCol(cols=model_type_cols): + with vuetify.VCol(cols=8, classes="d-flex align-center"): vuetify.VSelect( v_model=("model_type_verbose",), label="Model type", items=(model_type_list,), dense=True, + hide_details=True, ) - if AMSC_LOGO_URL: - with vuetify.VCol( - cols=4, - classes="d-flex align-center justify-end", + with vuetify.VCol( + cols=4, + classes="d-flex align-center justify-end", + ): + with html.A( + v_if=(AMSC_MLFLOW_LINK_ACTIVE_EXPR,), + href=(AMSC_MLFLOW_MODEL_URL_EXPR,), + target="_blank", + rel="noopener noreferrer", + title="Open selected model in AmSC MLflow", + style=( + "display: block; width: 100%; " + "max-width: 300px; margin-left: auto; " + "cursor: pointer;" + ), ): - with html.A( - v_if=(AMSC_MLFLOW_LINK_ACTIVE_EXPR,), - href=(AMSC_MLFLOW_MODEL_URL_EXPR,), - target="_blank", - rel="noopener noreferrer", - title="Open selected model in AmSC MLflow", - style=( - "display: block; width: 100%; " - "max-width: 300px; margin-left: auto; " - "cursor: pointer;" - ), - ): - vuetify.VImg( - src=AMSC_LOGO_URL, - alt="AmSC", - max_width=300, - max_height=72, - contain=True, - style="width: 100%;", - ) vuetify.VImg( - v_if=(f"!({AMSC_MLFLOW_LINK_ACTIVE_EXPR})",), src=AMSC_LOGO_URL, alt="AmSC", max_width=300, max_height=72, contain=True, - title=( - "Selected model is not available in AmSC MLflow" - ), - style=( - "width: 100%; max-width: 300px; " - "margin-left: auto;" - ), + style="width: 100%;", ) + vuetify.VImg( + v_if=(f"!({AMSC_MLFLOW_LINK_ACTIVE_EXPR})",), + src=AMSC_LOGO_URL, + alt="AmSC", + max_width=300, + max_height=72, + contain=True, + title=( + "Selected model is not available in AmSC MLflow" + ), + style=( + "width: 100%; max-width: 300px; margin-left: auto;" + ), + ) with vuetify.VRow( v_if=(MODEL_DOWNLOAD_ACTIVE_EXPR,), no_gutters=True, align="center", style="margin-top: -8px; margin-bottom: 8px;", ): - with vuetify.VCol(cols=model_type_cols): + with vuetify.VCol(): with html.Div( classes=( "d-flex align-center text-caption " From 856b140ccb4c1ecb74cc7b690bb8a79048cd7dc2 Mon Sep 17 00:00:00 2001 From: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> Date: Fri, 8 May 2026 15:57:17 -0700 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> --- dashboard/model_manager.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dashboard/model_manager.py b/dashboard/model_manager.py index 6e5a99e..1ad8d98 100644 --- a/dashboard/model_manager.py +++ b/dashboard/model_manager.py @@ -493,13 +493,12 @@ def panel(self): ): with vuetify.VExpansionPanelText(): with vuetify.VRow(align="center"): - with vuetify.VCol(cols=8, classes="d-flex align-center"): + with vuetify.VCol(cols=8): vuetify.VSelect( v_model=("model_type_verbose",), label="Model type", items=(model_type_list,), dense=True, - hide_details=True, ) with vuetify.VCol( cols=4,