From f865e7fed152bcfc81f0f250dfc1ac1b6a9f729d Mon Sep 17 00:00:00 2001 From: lakshith Date: Sat, 7 Sep 2024 17:44:34 +0530 Subject: [PATCH 1/3] fix magic metric repeat bug on ui --- app/ui/src/cache/cache.ts | 2 +- app/ui/src/views/run_view.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/ui/src/cache/cache.ts b/app/ui/src/cache/cache.ts index 6247a80aa..ebd7d75af 100644 --- a/app/ui/src/cache/cache.ts +++ b/app/ui/src/cache/cache.ts @@ -93,7 +93,7 @@ export abstract class CacheObject { abstract load(...args: any[]): Promise async get(isRefresh = false, ...args: any[]): Promise { - if (this.data == null || (isRefresh && isForceReloadTimeout(this.lastUpdated)) || isReloadTimeout(this.lastUpdated)) { + if (this.data == null || isRefresh || (isForceReloadTimeout(this.lastUpdated)) || isReloadTimeout(this.lastUpdated)) { this.data = await this.load() this.lastUpdated = (new Date()).getTime() } diff --git a/app/ui/src/views/run_view.ts b/app/ui/src/views/run_view.ts index dd6209e44..b28548bd6 100644 --- a/app/ui/src/views/run_view.ts +++ b/app/ui/src/views/run_view.ts @@ -310,6 +310,8 @@ class RunView extends ScreenView { } private renderCards() { + this.cardContainer.innerHTML = '' + this.cards = [] $(this.cardContainer, $ => { if (this.customMetrics != null && this.run != null) { this.customMetrics.getMetrics().map((metric, i) => { From 1ad761b0e3973d3ff54dcd672913127df9c7d07b Mon Sep 17 00:00:00 2001 From: lakshith Date: Sat, 7 Sep 2024 21:22:46 +0530 Subject: [PATCH 2/3] only ignore past runs of the entire chart prefernces match --- .../analyses/experiments/custom_metrics.py | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/app/server/labml_app/analyses/experiments/custom_metrics.py b/app/server/labml_app/analyses/experiments/custom_metrics.py index 6f97ff6ac..006f5def2 100644 --- a/app/server/labml_app/analyses/experiments/custom_metrics.py +++ b/app/server/labml_app/analyses/experiments/custom_metrics.py @@ -182,18 +182,21 @@ async def delete_custom_metric(request: Request, run_uuid: str) -> Any: @Analysis.route('GET', 'custom_metrics/{run_uuid}/magic') async def create_magic_metric(request: Request, run_uuid: str) -> Any: - list_key = CustomMetricsListIndex.get(run_uuid) - - run_cm = list_key.load() - current_run = run.get(run_uuid) if current_run is None: return {'is_success': False, 'message': 'Run not found'} + + run_cm = CustomMetricsListIndex.get(run_uuid).load() + current_run = current_run.get_summary() analysis_data = MetricsAnalysis.get_or_create(run_uuid).get_tracking() - indicators = [track_item['name'] for track_item in analysis_data] - indicators = sorted(indicators) + run_indicators = sorted([track_item['name'] for track_item in analysis_data]) + + current_metrics = run_cm.get_data() + current_selected_indicators = [] + for x in current_metrics: + current_selected_indicators.append(x['preferences']['series_preferences']) u = user.get_by_session_token('local') # todo @@ -205,12 +208,6 @@ async def create_magic_metric(request: Request, run_uuid: str) -> Any: runs = [x for s, x in sorted(zip(similarity, runs), key=lambda pair: pair[0], reverse=True)] runs = runs[:20] - current_metrics = run_cm.get_data() - current_indicators = [] - for x in current_metrics: - current_indicators += x['preferences']['series_preferences'] - current_indicators = set(current_indicators) - indicator_counts = {} for r in runs: list_key = CustomMetricsListIndex.get(r['run_uuid']) @@ -225,8 +222,8 @@ async def create_magic_metric(request: Request, run_uuid: str) -> Any: if len(preferences['series_preferences']) == 0: continue has_current_indicators = False - for indicator in current_indicators: - if indicator in preferences['series_preferences']: + for indicator_list in current_selected_indicators: + if indicator_list == preferences['series_preferences']: has_current_indicators = True break if has_current_indicators: @@ -247,7 +244,7 @@ async def create_magic_metric(request: Request, run_uuid: str) -> Any: for key in sorted_keys: ind = key.split('|') overlap = False - for i in indicators: + for i in run_indicators: if i in ind: overlap = True break @@ -263,7 +260,7 @@ async def create_magic_metric(request: Request, run_uuid: str) -> Any: new_metric_data = selected_metric.get_data() new_metric_data['preferences']['series_preferences'] = \ - [x for x in new_metric_data['preferences']['series_preferences'] if x in indicators] + [x for x in new_metric_data['preferences']['series_preferences'] if x in run_indicators] run_cm.create_custom_metric(new_metric_data) From 5c5596e578e3f72423da1d7c1e35a73d4ca0a9a8 Mon Sep 17 00:00:00 2001 From: lakshith Date: Sat, 7 Sep 2024 21:29:25 +0530 Subject: [PATCH 3/3] error response update --- app/server/labml_app/analyses/experiments/custom_metrics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/server/labml_app/analyses/experiments/custom_metrics.py b/app/server/labml_app/analyses/experiments/custom_metrics.py index 006f5def2..29cbc61a3 100644 --- a/app/server/labml_app/analyses/experiments/custom_metrics.py +++ b/app/server/labml_app/analyses/experiments/custom_metrics.py @@ -235,7 +235,7 @@ async def create_magic_metric(request: Request, run_uuid: str) -> Any: indicator_counts[preference_map_key].append((m.key, m_data['created_time'])) if len(indicator_counts) == 0: - return {'is_success': False, 'message': "Couldn't find any related past run."} + return {'is_success': False, 'message': "Couldn't find any new related chart."} sorted_keys = sorted(indicator_counts.keys(), key=lambda x: len(indicator_counts[x]), reverse=True)