From 68d586f4a1501b4cb0d7c524ad6348f7fa33f307 Mon Sep 17 00:00:00 2001 From: wtingkai <330445001@qq.com> Date: Wed, 20 Aug 2025 11:44:48 +0800 Subject: [PATCH] =?UTF-8?q?feat(OmniAdvisor):=20=E5=9C=A8Django=20Admin?= =?UTF-8?q?=E4=B8=AD=E5=B0=86Runtime=E5=AD=97=E6=AE=B5=E4=BF=9D=E7=95=993?= =?UTF-8?q?=E4=BD=8D=E6=9C=89=E6=95=88=E6=95=B0=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../omniadvisor/service/spark_service/spark_executor.py | 2 +- .../omniadvisor/service/spark_service/spark_fetcher.py | 3 +-- omniadvisor/src/server/app/admin.py | 8 ++++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/omniadvisor/src/omniadvisor/service/spark_service/spark_executor.py b/omniadvisor/src/omniadvisor/service/spark_service/spark_executor.py index dfcfe386b..62de86f11 100644 --- a/omniadvisor/src/omniadvisor/service/spark_service/spark_executor.py +++ b/omniadvisor/src/omniadvisor/service/spark_service/spark_executor.py @@ -93,7 +93,7 @@ class SparkExecutor: match_objs = re.findall(pattern, spark_output, re.MULTILINE) if match_objs: time_taken_list = [float(obj) for obj in match_objs] - total_time_taken = round(sum(time_taken_list), OA_CONF.decimal_digits) + total_time_taken = sum(time_taken_list) global_logger.debug(f'Total time taken is {total_time_taken} seconds') else: global_logger.info('This spark task do not have Time taken message.') diff --git a/omniadvisor/src/omniadvisor/service/spark_service/spark_fetcher.py b/omniadvisor/src/omniadvisor/service/spark_service/spark_fetcher.py index 4c84fc8ff..329fb3581 100755 --- a/omniadvisor/src/omniadvisor/service/spark_service/spark_fetcher.py +++ b/omniadvisor/src/omniadvisor/service/spark_service/spark_fetcher.py @@ -4,7 +4,6 @@ from typing import Any import requests from dateutil import parser -from common.constant import OA_CONF from omniadvisor.utils.logger import global_logger @@ -124,4 +123,4 @@ class SparkFetcher: # 计算时间差 time_diff = max(timestamp_list) - min(timestamp_list) global_logger.debug(f"Total time diff calculate by jobs is {time_diff} seconds") - return round(time_diff, OA_CONF.decimal_digits) + return time_diff diff --git a/omniadvisor/src/server/app/admin.py b/omniadvisor/src/server/app/admin.py index af7a6f450..191e9e955 100644 --- a/omniadvisor/src/server/app/admin.py +++ b/omniadvisor/src/server/app/admin.py @@ -21,11 +21,15 @@ class TuningRecordAdmin(admin.ModelAdmin): @admin.register(DatabaseExamRecord) class ExamRecordAdmin(admin.ModelAdmin): - list_display = ('id', 'load', 'tuning_record', 'start_time', 'end_time', 'status', 'runtime', 'application_id', 'trace') + list_display = ('id', 'load', 'tuning_record', 'start_time', 'end_time', 'status', 'runtime_f', 'application_id', 'trace') list_filter = () # 增加对Load的显示 def load(self, model): return model.tuning_record.load load.short_description = 'Load' - load.admin_order_field = 'load' + + # 对Runtime的浮点数保留3位有效数字 + def runtime_f(self, model): + return round(model.runtime, 3) + runtime_f.short_description = 'Runtime' -- Gitee