Formatting

This commit is contained in:
Nick Mowen 2022-09-24 19:33:35 -06:00
parent beb8229e4d
commit 447df28746

View File

@ -783,13 +783,7 @@ def ffprobe_stream(path: str) -> sp.CompletedProcess:
def get_amd_gpu_stats() -> dict[str, str]: def get_amd_gpu_stats() -> dict[str, str]:
"""Get stats using radeontop.""" """Get stats using radeontop."""
radeontop_command = [ radeontop_command = ["radeontop", "-d", "-", "-l", "1"]
"radeontop",
"-d",
"-",
"-l",
"1"
]
p = sp.run( p = sp.run(
radeontop_command, radeontop_command,
@ -812,18 +806,10 @@ def get_amd_gpu_stats() -> dict[str, str]:
return results return results
def get_intel_gpu_stats() -> dict[str, str]: def get_intel_gpu_stats() -> dict[str, str]:
"""Get stats using intel_gpu_top.""" """Get stats using intel_gpu_top."""
radeontop_command = [ radeontop_command = ["timeout", "1s", "intel_gpu_top", "-J", "-o", "-", "-s", "1"]
"timeout",
"1s",
"intel_gpu_top",
"-J",
"-o",
"-",
"-s",
"1"
]
p = sp.run( p = sp.run(
radeontop_command, radeontop_command,
@ -852,7 +838,7 @@ def get_nvidia_gpu_stats() -> dict[str, str]:
nvidia_smi_command = [ nvidia_smi_command = [
"nvidia-smi", "nvidia-smi",
"--query-gpu=gpu_name,utilization.gpu,memory.used,memory.total", "--query-gpu=gpu_name,utilization.gpu,memory.used,memory.total",
"--format=csv" "--format=csv",
] ]
p = sp.run( p = sp.run(
@ -866,11 +852,11 @@ def get_nvidia_gpu_stats() -> dict[str, str]:
return None return None
else: else:
usages = p.stdout.split("\n")[1].strip() usages = p.stdout.split("\n")[1].strip()
memory_percent = f"{round(float(usages[2].replace(' MiB', '')) / float(usages[3].replace(' MiB', '')) * 100, 1)}" %" memory_percent = f"{round(float(usages[2].replace(' MiB', '')) / float(usages[3].replace(' MiB', '')) * 100, 1)} %"
results: dict[str, str] = { results: dict[str, str] = {
"name": usages[0], "name": usages[0],
"gpu_usage": usages[1], "gpu_usage": usages[1],
"memory_usage": memory_percent "memory_usage": memory_percent,
} }
return results return results