|
@@ -4,13 +4,15 @@
|
|
|
@time: 2024/11/1
|
|
|
@desc: 指标监控配置
|
|
|
"""
|
|
|
+import json
|
|
|
+import os
|
|
|
from typing import List, Dict
|
|
|
|
|
|
from entitys import MetricConfigEntity
|
|
|
from metrics import f_get_metric_clazz_dict, MetricBase
|
|
|
|
|
|
|
|
|
-class ModelMonitorConfigEntity():
|
|
|
+class MonitorMetricConfigEntity():
|
|
|
|
|
|
def __init__(self, metric_config_list: List[MetricConfigEntity], template_path: str):
|
|
|
self._template_path = template_path
|
|
@@ -32,14 +34,32 @@ class ModelMonitorConfigEntity():
|
|
|
metric_code = metric_config.metric_code
|
|
|
# 指标函数不存在
|
|
|
if metric_func_name not in self._metric_clazz_dict.keys():
|
|
|
+ # TODO
|
|
|
pass
|
|
|
# 指标code不唯一
|
|
|
if metric_code in metric_dict.keys():
|
|
|
+ # TODO
|
|
|
pass
|
|
|
metric_clazz = self._metric_clazz_dict[metric_func_name]
|
|
|
metric_dict[metric_code] = metric_clazz(*metric_config.args, **metric_config.kwargs)
|
|
|
return metric_dict
|
|
|
|
|
|
+ @staticmethod
|
|
|
+ def from_config(config_path: str):
|
|
|
+ """
|
|
|
+ 从配置文件生成实体类
|
|
|
+ """
|
|
|
+ if os.path.exists(config_path):
|
|
|
+ with open(config_path, mode="r", encoding="utf-8") as f:
|
|
|
+ j = json.loads(f.read())
|
|
|
+ else:
|
|
|
+ # TODO
|
|
|
+ pass
|
|
|
+ metric_config_list = j.get("metric_config_list", [])
|
|
|
+ metric_config_list = [MetricConfigEntity(**i) for i in metric_config_list]
|
|
|
+ j["metric_config_list"] = metric_config_list
|
|
|
+ return MonitorMetricConfigEntity(**j)
|
|
|
+
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
pass
|