18 from typing
import Type, Optional, List
20 from .metric
import Metric, MetricType
21 from .predefined_metrics
import *
24 def getClassForMetric(name: str) -> Optional[Type[Metric]]:
25 if name ==
"disk_read":
28 if name ==
"disk_write":
29 return MetricDiskWrite
31 if name ==
"cpu_usage":
34 if name ==
"ram_usage":
37 if name ==
"swap_usage":
38 return MetricSwapUsage
40 if name ==
"gpu_usage":
43 if name ==
"gpu_memory_usage":
44 return MetricGPUMemoryUsage
46 if name ==
"gpu_temperature":
47 return MetricGPUTemperature
49 if name ==
"upload_speed":
50 return MetricUploadSpeed
52 if name ==
"download_speed":
53 return MetricDownloadSpeed
64 xRange: Optional[List[float]] =
None,
65 yRange: Optional[List[float]] =
None
68 metric = getClassForMetric(name)
70 raise ValueError(f
"[Coretex] Failed to create {name} metric")
72 return metric.create(name, xLabel, xType, yLabel, yType, xRange, yRange)