From f015bbb6bdd92e1f069b41b12b78286cd9de6d57 Mon Sep 17 00:00:00 2001 From: sunchao <1299792067@qq.com> Date: Tue, 5 Aug 2025 09:43:38 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=90=9E=20fix:=20=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E4=B9=8B=E5=90=8E=E9=80=89=E6=8B=A9=E4=B8=8D=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tf_filter_precision_error/index.ts | 19 ++++++++++++++++++- .../app/controllers/match_nodes_controller.py | 4 ++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/graph_controls_board/components/tf_filter_precision_error/index.ts b/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/graph_controls_board/components/tf_filter_precision_error/index.ts index 8ddf63321..280954663 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/graph_controls_board/components/tf_filter_precision_error/index.ts +++ b/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/graph_controls_board/components/tf_filter_precision_error/index.ts @@ -19,7 +19,6 @@ class TfFilterPrecisionError extends PolymerElement { confirm-text="确认" confirm-theme=" primary" opened="{{filterDialogOpened}}" - confirm="[[onFlterDialogConfirm]]" > { }; + @property({ type: Array }) + lastFilterValue: string[] = []; + MAX_RELATIVE_ERR = "0"; MIN_RELATIVE_ERR = "1"; MEAN_RELATIVE_ERR = "2"; @@ -55,12 +57,27 @@ class TfFilterPrecisionError extends PolymerElement { _selectionChanged() { this.set('filterValue', [this.MAX_RELATIVE_ERR, this.MIN_RELATIVE_ERR, this.MEAN_RELATIVE_ERR, this.NORM_RELATIVE_ERR]); } + @observe('filterDialogOpened') + _onFlterDialogOpened = () => { + if (this.filterDialogOpened) { + this.set('lastFilterValue', this.filterValue); + } + + } + override ready(): void { super.ready(); const filterDialog = this.shadowRoot?.querySelector('#filter-dialog') as HTMLElement; filterDialog?.addEventListener('confirm', this.onFlterDialogConfirm) + filterDialog?.addEventListener('cancel', this.onFlterDialogCancel) this.set('filterValue', [this.MAX_RELATIVE_ERR, this.MIN_RELATIVE_ERR, this.MEAN_RELATIVE_ERR, this.NORM_RELATIVE_ERR]); } + + + onFlterDialogCancel = (e: any) => { + this.set('filterValue', this.lastFilterValue); + } + onFlterDialogConfirm = async (e: any) => { if (isEmpty(this.filterValue)) { Notification.show(`错误: 精度误差计算指标为空,请选择指标`, { diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/server/app/controllers/match_nodes_controller.py b/plugins/tensorboard-plugins/tb_graph_ascend/server/app/controllers/match_nodes_controller.py index 904247786..47a28f3a3 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/server/app/controllers/match_nodes_controller.py +++ b/plugins/tensorboard-plugins/tb_graph_ascend/server/app/controllers/match_nodes_controller.py @@ -65,7 +65,7 @@ class MatchNodesController: } result['success'] = result.get('success') or opposite_result.get('success') if not result.get('success'): - result['error'] = f'当前节点:{result.get("error",'')}。对侧节点:{opposite_result.get("error")}' + result['error'] = f'当前节点:{result.get("error","")}。对侧节点:{opposite_result.get("error")}' return result @staticmethod @@ -87,7 +87,7 @@ class MatchNodesController: } result['success'] = result.get('success') or opposite_result.get('success') if not result.get('success'): - result['error'] = f'当前节点:{result.get("error",'')}。对侧节点:{opposite_result.get("error")}' + result['error'] = f'当前节点:{result.get("error","")}。对侧节点:{opposite_result.get("error")}' return result @staticmethod -- Gitee From d3d91da3155e4996806cd116866d559a493d4c53 Mon Sep 17 00:00:00 2001 From: sunchao <1299792067@qq.com> Date: Tue, 5 Aug 2025 15:59:39 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=90=9E=20fix:=20=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=8E=9F=E5=9E=8B=E9=93=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tb_graph_ascend/fe/src/utils/index.ts | 2 +- .../server/app/utils/graph_utils.py | 24 ------------------- 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/utils/index.ts b/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/utils/index.ts index 6358dadc3..d31fdc044 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/utils/index.ts +++ b/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/utils/index.ts @@ -31,7 +31,7 @@ export function fetchPbTxt(filepath: string): Promise { const removePrototypePollution = (obj: any): void => { if (obj && typeof obj === 'object') { for (let key in obj) { - if (key === '__proto__' || key === 'constructor') { + if (key === '__proto__' || key === 'constructor' || key === 'prototype') { delete obj[key]; } else if (typeof obj[key] === 'object') { removePrototypePollution(obj[key]); diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/server/app/utils/graph_utils.py b/plugins/tensorboard-plugins/tb_graph_ascend/server/app/utils/graph_utils.py index 5e77cd88c..74ff3399d 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/server/app/utils/graph_utils.py +++ b/plugins/tensorboard-plugins/tb_graph_ascend/server/app/utils/graph_utils.py @@ -132,7 +132,6 @@ class GraphUtils: try: result = json.loads(json_str) - GraphUtils.remove_prototype_pollution(result) return result except json.JSONDecodeError as e: logger.error(f"JSON decode error: {e}") @@ -141,29 +140,6 @@ class GraphUtils: logger.error(f"Unexpected error: {e}") return default_value - @staticmethod - def remove_prototype_pollution(obj, current_depth=1, max_depth=200): - """ - 递归删除对象中的原型污染字段,如 '__proto__', 'constructor', 'prototype'。 - - :param obj: 要清理的对象 - :param current_depth: 当前递归深度,默认从 1 开始 - :param max_depth: 最大允许递归深度 - """ - if current_depth > max_depth: - logger.warning(f"Reached maximum recursion depth of {max_depth}. Stopping further recursion.") - return - - if isinstance(obj, dict): - for key in list(obj.keys()): - if key in ('__proto__', 'constructor', 'prototype'): - del obj[key] - else: - GraphUtils.remove_prototype_pollution(obj[key], current_depth + 1, max_depth) - elif isinstance(obj, list): - for item in obj: - GraphUtils.remove_prototype_pollution(item, current_depth + 1, max_depth) - @staticmethod def remove_prefix(node_data, prefix): if node_data is None: -- Gitee From 109516cb2b2c54cbc198047f4f7f626cde5c78d6 Mon Sep 17 00:00:00 2001 From: sunchao <1299792067@qq.com> Date: Tue, 5 Aug 2025 16:48:59 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=8C=88=20style:=20clean=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/app/controllers/match_nodes_controller.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/server/app/controllers/match_nodes_controller.py b/plugins/tensorboard-plugins/tb_graph_ascend/server/app/controllers/match_nodes_controller.py index 47a28f3a3..588dcb16e 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/server/app/controllers/match_nodes_controller.py +++ b/plugins/tensorboard-plugins/tb_graph_ascend/server/app/controllers/match_nodes_controller.py @@ -54,10 +54,12 @@ class MatchNodesController: opposite_bench_node_name = MatchNodesController.get_opposite_node_name(bench_node_name) if task == 'md5': result = MatchNodesController.process_md5_task_add(graph_data, npu_node_name, bench_node_name) - opposite_result = MatchNodesController.process_md5_task_add(graph_data, opposite_npu_node_name, opposite_bench_node_name) + opposite_result = MatchNodesController.process_md5_task_add(graph_data, opposite_npu_node_name, + opposite_bench_node_name) elif task == 'summary': result = MatchNodesController.process_summary_task_add(graph_data, npu_node_name, bench_node_name) - opposite_result = MatchNodesController.process_summary_task_add(graph_data, opposite_npu_node_name, opposite_bench_node_name) + opposite_result = MatchNodesController.process_summary_task_add(graph_data, opposite_npu_node_name, + opposite_bench_node_name) else: result = { 'success': False, @@ -76,10 +78,12 @@ class MatchNodesController: opposite_bench_node_name = MatchNodesController.get_opposite_node_name(bench_node_name) if task == 'md5': result = MatchNodesController.process_md5_task_delete(graph_data, npu_node_name, bench_node_name) - opposite_result = MatchNodesController.process_md5_task_delete(graph_data, opposite_npu_node_name, opposite_bench_node_name) + opposite_result = MatchNodesController.process_md5_task_delete(graph_data, opposite_npu_node_name, + opposite_bench_node_name) elif task == 'summary': result = MatchNodesController.process_summary_task_delete(graph_data, npu_node_name, bench_node_name) - opposite_result = MatchNodesController.process_summary_task_delete(graph_data, opposite_npu_node_name, opposite_bench_node_name) + opposite_result = MatchNodesController.process_summary_task_delete(graph_data, opposite_npu_node_name, + opposite_bench_node_name) else: result = { 'success': False, -- Gitee