-
Notifications
You must be signed in to change notification settings - Fork 61
/
metric.py
99 lines (84 loc) 路 2.38 KB
/
metric.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#
# Copyright (c) 2019, Neptune Labs Sp. z o.o.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
class Metric(object):
def __init__(
self,
name,
description,
resource_type,
unit,
min_value,
max_value,
gauges,
internal_id=None,
):
self.__internal_id = internal_id
self.__name = name
self.__description = description
self.__resource_type = resource_type
self.__unit = unit
self.__min_value = min_value
self.__max_value = max_value
self.__gauges = gauges
@property
def internal_id(self):
return self.__internal_id
@internal_id.setter
def internal_id(self, value):
self.__internal_id = value
@property
def name(self):
return self.__name
@property
def description(self):
return self.__description
@property
def resource_type(self):
return self.__resource_type
@property
def unit(self):
return self.__unit
@property
def min_value(self):
return self.__min_value
@property
def max_value(self):
return self.__max_value
@property
def gauges(self):
return self.__gauges
def __repr__(self):
return (
"Metric(internal_id={}, name={}, description={}, resource_type={}, unit={}, min_value={}, "
"max_value={}, gauges={})"
).format(
self.internal_id,
self.name,
self.description,
self.resource_type,
self.unit,
self.min_value,
self.max_value,
self.gauges,
)
def __eq__(self, other):
return self.__class__ == other.__class__ and repr(self) == repr(other)
class MetricResourceType(object):
CPU = "CPU"
RAM = "MEMORY"
GPU = "GPU"
GPU_RAM = "GPU_MEMORY"
OTHER = "OTHER"