Skip to content

Commit 3536c9b

Browse files
EZoniRemiLehe
andauthored
Simplify code in ModelManager class (#442)
Co-authored-by: Remi Lehe <remi.lehe@normalesup.org>
1 parent 880db00 commit 3536c9b

1 file changed

Lines changed: 33 additions & 42 deletions

File tree

dashboard/model_manager.py

Lines changed: 33 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@
2727
MODEL_TYPE_NN_SINGLE = "Neural Network (single)"
2828
MODEL_TYPE_NN_ENSEMBLE = "Neural Network (ensemble)"
2929
AMSC_LOGO_PATH = LOGO_DIR / "AmSC_300px.png"
30-
AMSC_LOGO_URL = (
31-
LocalFileManager(LOGO_DIR).url("amsc_logo", AMSC_LOGO_PATH)
32-
if AMSC_LOGO_PATH.is_file()
33-
else None
34-
)
30+
AMSC_LOGO_URL = LocalFileManager(LOGO_DIR).url("amsc_logo", AMSC_LOGO_PATH)
3531
MODEL_DOWNLOAD_ACTIVE_EXPR = "model_downloading"
3632
AMSC_MLFLOW_LINK_ACTIVE_EXPR = (
3733
f"model_available && model_mlflow_tracking_uri === '{AMSC_MLFLOW_URL}'"
@@ -490,71 +486,66 @@ def panel(self):
490486
MODEL_TYPE_NN_SINGLE,
491487
MODEL_TYPE_NN_ENSEMBLE,
492488
]
493-
model_type_cols = 8 if AMSC_LOGO_URL else 12
494489
with vuetify.VExpansionPanels(v_model=("expand_panel_control_model", 0)):
495490
with vuetify.VExpansionPanel(
496491
title="Control: Models",
497492
style="font-size: 20px; font-weight: 500;",
498493
):
499494
with vuetify.VExpansionPanelText():
500495
with vuetify.VRow(align="center"):
501-
with vuetify.VCol(
502-
cols=model_type_cols, classes="d-flex align-center"
503-
):
496+
with vuetify.VCol(cols=8, classes="d-flex align-center"):
504497
vuetify.VSelect(
505498
v_model=("model_type_verbose",),
506499
label="Model type",
507500
items=(model_type_list,),
508501
dense=True,
509502
hide_details=True,
510503
)
511-
if AMSC_LOGO_URL:
512-
with vuetify.VCol(
513-
cols=4,
514-
classes="d-flex align-center",
504+
with vuetify.VCol(
505+
cols=4,
506+
classes="d-flex align-center",
507+
):
508+
with html.A(
509+
v_if=(AMSC_MLFLOW_LINK_ACTIVE_EXPR,),
510+
href=(AMSC_MLFLOW_MODEL_URL_EXPR,),
511+
target="_blank",
512+
rel="noopener noreferrer",
513+
title="Open selected model in AmSC MLflow",
514+
style=(
515+
"display: block; width: 100%; "
516+
"max-width: 300px; margin-left: auto; "
517+
"cursor: pointer;"
518+
),
515519
):
516-
with html.A(
517-
v_if=(AMSC_MLFLOW_LINK_ACTIVE_EXPR,),
518-
href=(AMSC_MLFLOW_MODEL_URL_EXPR,),
519-
target="_blank",
520-
rel="noopener noreferrer",
521-
title="Open selected model in AmSC MLflow",
522-
style=(
523-
"display: block; width: 100%; "
524-
"max-width: 300px; margin-left: auto; "
525-
"cursor: pointer;"
526-
),
527-
):
528-
vuetify.VImg(
529-
src=AMSC_LOGO_URL,
530-
alt="AmSC",
531-
max_width=300,
532-
max_height=72,
533-
contain=True,
534-
style="width: 100%;",
535-
)
536520
vuetify.VImg(
537-
v_if=(f"!({AMSC_MLFLOW_LINK_ACTIVE_EXPR})",),
538521
src=AMSC_LOGO_URL,
539522
alt="AmSC",
540523
max_width=300,
541524
max_height=72,
542525
contain=True,
543-
title=(
544-
"Selected model is not available in AmSC MLflow"
545-
),
546-
style=(
547-
"width: 100%; max-width: 300px; "
548-
"margin-left: auto;"
549-
),
526+
style="width: 100%;",
550527
)
528+
vuetify.VImg(
529+
v_if=(f"!({AMSC_MLFLOW_LINK_ACTIVE_EXPR})",),
530+
src=AMSC_LOGO_URL,
531+
alt="AmSC",
532+
max_width=300,
533+
max_height=72,
534+
contain=True,
535+
title=(
536+
"Selected model is not available in AmSC MLflow"
537+
),
538+
style=(
539+
"width: 100%; max-width: 300px; margin-left: auto;"
540+
),
541+
)
551542
with vuetify.VRow(
552543
v_if=(MODEL_DOWNLOAD_ACTIVE_EXPR,),
553544
no_gutters=True,
554545
align="center",
555546
style="margin-top: -8px; margin-bottom: 8px;",
556547
):
557-
with vuetify.VCol(cols=model_type_cols):
548+
with vuetify.VCol():
558549
with html.Div(
559550
classes=(
560551
"d-flex align-center text-caption "

0 commit comments

Comments
 (0)