Commit 725e067c authored by akhuziy's avatar akhuziy
Browse files

fixed some formatting issues

parent 9b16785f
......@@ -14,9 +14,9 @@ def printd(*args, **kargs):
def rcmattr(func):
'''Function decorator. Checks and sets arguments'''
def wrapper(*args, **kwargs):
printd(" - evaluation of the attribute {:s} - ".format(func.__name__))
printd("-- evaluation of the attribute {:s} --".format(func.__name__))
res = func(*args, **kwargs)
printd(" - finished the attribute {:s} ({}) - ".format(func.__name__, res))
printd(" attribute {:s} = {}".format(func.__name__, res))
return res
wrapper.decorator = rcmattr
......@@ -158,9 +158,9 @@ class Attributes:
node_res = res.index("NORM")
elif node_proc_ratio > 80 and node.alloc_cu > 8:
node_res = res.index("NORM")
printd("{}: {} / ({} / {}) = {}({})".format(node.name,
node.proc.cpu_usage, node.alloc_cu,
printd("{}: {} / ({} / {}) = {}({})".format(node.name,
node.proc.cpu_usage, node.alloc_cu,
thr_cnt, node_proc_ratio, node_res))
min_res = min(node_res, min_res)
......@@ -216,3 +216,98 @@ class Attributes:
swap_used = True
return swap_used
@rcmattr
def gpu_job(self):
is_gpu = False
for node in self._aggr.nodes:
if node.gpus:
is_gpu = True
return is_gpu
@rcmattr
def gpu_usage_max(self):
res = ["ZERO", "LOW", "NORM", "HIGH"]
max_res = res.index("ZERO")
for node in self._aggr.nodes:
if not node.gpus: continue
for gpu in node.gpus:
gpu_usage = gpu.usage_max
if gpu_usage > 90:
gpu_res = res.index("HIGH")
elif gpu_usage > 50:
gpu_res = res.index("NORM")
elif gpu_usage > 0.5:
gpu_res = res.index("LOW")
else:
gpu_res = res.index("ZERO")
max_res = max(gpu_res, max_res)
return res[max_res]
@rcmattr
def gpu_usage_min(self):
res = ["ZERO", "LOW", "NORM", "HIGH"]
min_res = res.index("HIGH")
gpu_was_used = False
for node in self._aggr.nodes:
if not node.gpus: continue
gpu_was_used = True
for gpu in node.gpus:
gpu_usage = gpu.usage_max
if gpu_usage > 90:
gpu_res = res.index("HIGH")
elif gpu_usage > 50:
gpu_res = res.index("NORM")
elif gpu_usage > 0.5:
gpu_res = res.index("LOW")
else:
gpu_res = res.index("ZERO")
min_res = min(gpu_res, min_res)
if not gpu_was_used:
min_res = res.index("ZERO")
return res[min_res]
@rcmattr
def gpus_amount(self):
ngpus = 0
for node in self._aggr.nodes:
if node.gpus:
ngpus += len(node.gpus)
res = "ERR"
if ngpus == 1:
res = "ONE"
elif ngpus > 1:
res = "MULT"
return res
@rcmattr
def gpus_overcrowded_exist(self):
has_overcrowded = False
for node in self._aggr.nodes:
if not node.gpus: continue
for gpu in node.gpus:
if helpers.gpu_has_overcrowded_interval(gpu) is True:
has_overcrowded = True
break
if has_overcrowded:
break
return has_overcrowded
......@@ -26,13 +26,19 @@ def print_rule(rule):
print("attribute name | value(s)")
print("--- | ---")
for attr_name, attr_value in rule["attrs"].items():
attrs = ""
if isinstance(attr_value, list):
attrs = ", ".join(attr_value)
else:
attrs = attr_value
print("[{an}]({al}) | `{av}`".format(
an = attr_name,
al = format_attr_link(attr_name),
av = attr_value,
av = attrs,
))
print("")
def main():
print_header()
for arule in RULES:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment