From 5ca06a6225ecc12d3510839250a7605d91b37551 Mon Sep 17 00:00:00 2001 From: Shreyash Iyengar Date: Fri, 11 Aug 2023 13:42:59 -0700 Subject: [PATCH 1/2] add instructions for aggregate_file script + constants for hardware metircs column names --- src/autogluon_dashboard/app.py | 14 ++++++-------- src/autogluon_dashboard/constants/df_constants.py | 2 ++ src/autogluon_dashboard/utils/aggregate_file.py | 13 +++++++++++++ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/autogluon_dashboard/app.py b/src/autogluon_dashboard/app.py index 610c328..6262204 100644 --- a/src/autogluon_dashboard/app.py +++ b/src/autogluon_dashboard/app.py @@ -1,5 +1,3 @@ -import os - import panel as pn from autogluon_dashboard.constants.app_layout_constants import ( @@ -28,6 +26,7 @@ FRAMEWORK, LOSS_RESCALED, RANK, + STATISTIC_VALUE, TIME_INFER_S, WINRATE, ) @@ -45,7 +44,6 @@ HW_METRICS_WIDGET_NAME, METRICS_PLOT_TITLE, PER_DATASET_DOWNLOAD_TITLE, - RANK1_TITLE, RANK_LABEL, TOP5_PERFORMERS_TITLE, YAXIS_LABEL, @@ -236,8 +234,8 @@ hware_metrics_idf, "hvplot", col_name=yaxis_widget4, - x_axis="framework", - y_axis="statistic_value", + x_axis=FRAMEWORK, + y_axis=STATISTIC_VALUE, ylabel=yaxis_widget4, by="mode", ) @@ -247,10 +245,10 @@ hware_metrics_idf, "hvplot", col_name=yaxis_widget4, - x_axis="framework", - y_axis="statistic_value", + x_axis=FRAMEWORK, + y_axis=STATISTIC_VALUE, ylabel=yaxis_widget4, - by="dataset", + by=DATASET, ) create_panel_object( panel_objs, diff --git a/src/autogluon_dashboard/constants/df_constants.py b/src/autogluon_dashboard/constants/df_constants.py index 114d446..b693773 100644 --- a/src/autogluon_dashboard/constants/df_constants.py +++ b/src/autogluon_dashboard/constants/df_constants.py @@ -26,3 +26,5 @@ UTC = "utc" DATETIME = "datetime" + +STATISTIC_VALUE = "statistic_value" diff --git a/src/autogluon_dashboard/utils/aggregate_file.py b/src/autogluon_dashboard/utils/aggregate_file.py index 00db554..65bde4c 100644 --- a/src/autogluon_dashboard/utils/aggregate_file.py +++ b/src/autogluon_dashboard/utils/aggregate_file.py @@ -3,6 +3,19 @@ import re from collections import namedtuple +""" +The Aggregate File Script +---------------------------- +One issue with panel is that it does not allow relative imports. +The website generated by panel runs in a pyodide web-environment, where it installs the necessary python packages only from the official python index (PyPI). +Therefore, to circumvent this, we created a script to aggregate all the files within the project directory into one big file to convert the web app into WebAssembly (HTML and JavaScript). + +NOTE: The order of crawling in the aggregate script is very important! +If the app imports module A before module B, then it is imperative that the script crawls through the folder corresponding to module A first. +Therefore, pay attention to how the dependency of the subdirectories is affected by any changes you make to app.py. +The order of crawling can be found and modified in the "__main__" body of this file. +""" + def get_import_tuples(path: str): """Extracts import statements from a Python file by leveraging the ast parser library. From 2c543d7e28a47509de9e8b9d2ed04e4afa12cf3b Mon Sep 17 00:00:00 2001 From: Shreyash Iyengar Date: Fri, 11 Aug 2023 13:44:18 -0700 Subject: [PATCH 2/2] use constants for hardware metircs column names --- src/autogluon_dashboard/plotting/hardware_metrics.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/autogluon_dashboard/plotting/hardware_metrics.py b/src/autogluon_dashboard/plotting/hardware_metrics.py index 55615f4..361b64f 100644 --- a/src/autogluon_dashboard/plotting/hardware_metrics.py +++ b/src/autogluon_dashboard/plotting/hardware_metrics.py @@ -4,6 +4,8 @@ import pandas import panel as pn +from autogluon_dashboard.constants.df_constants import FRAMEWORK, METRIC + from .plot import Plot @@ -90,7 +92,7 @@ def __init__( def _preprocess(self, df, col_name_for_metrics, group_by, **kwargs) -> pandas.DataFrame: df = df[:] - df = df.groupby(["framework", "metric", group_by]).mean(numeric_only=True).reset_index() + df = df.groupby([FRAMEWORK, METRIC, group_by]).mean(numeric_only=True).reset_index() df.statistic_value = df.statistic_value.apply(lambda x: round(float(x), 2)) df = df[df.metric.isin([col_name_for_metrics])] return df