mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 17:55:21 +03:00
Formatting
This commit is contained in:
parent
eb25935dd2
commit
61cac3c2f9
@ -5,7 +5,6 @@ from frigate.util import get_amd_gpu_stats, get_nvidia_gpu_stats
|
|||||||
|
|
||||||
|
|
||||||
class TestGpuStats(unittest.TestCase):
|
class TestGpuStats(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.nvidia_results = "name, utilization.gpu [%], memory.used [MiB], memory.total [MiB]\nNVIDIA GeForce RTX 3050, 42 %, 5036 MiB, 8192 MiB\n"
|
self.nvidia_results = "name, utilization.gpu [%], memory.used [MiB], memory.total [MiB]\nNVIDIA GeForce RTX 3050, 42 %, 5036 MiB, 8192 MiB\n"
|
||||||
self.amd_results = "Unknown Radeon card. <= R500 won't work, new cards might.\nDumping to -, line limit 1.\n1664070990.607556: bus 10, gpu 4.17%, ee 0.00%, vgt 0.00%, ta 0.00%, tc 0.00%, sx 0.00%, sh 0.00%, spi 0.83%, smx 0.00%, cr 0.00%, sc 0.00%, pa 0.00%, db 0.00%, cb 0.00%, vram 60.37% 294.04mb, gtt 0.33% 52.21mb, mclk 100.00% 1.800ghz, sclk 26.65% 0.533ghz\n"
|
self.amd_results = "Unknown Radeon card. <= R500 won't work, new cards might.\nDumping to -, line limit 1.\n1664070990.607556: bus 10, gpu 4.17%, ee 0.00%, vgt 0.00%, ta 0.00%, tc 0.00%, sx 0.00%, sh 0.00%, spi 0.83%, smx 0.00%, cr 0.00%, sc 0.00%, pa 0.00%, db 0.00%, cb 0.00%, vram 60.37% 294.04mb, gtt 0.33% 52.21mb, mclk 100.00% 1.800ghz, sclk 26.65% 0.533ghz\n"
|
||||||
@ -17,7 +16,7 @@ class TestGpuStats(unittest.TestCase):
|
|||||||
process.stdout = self.amd_results
|
process.stdout = self.amd_results
|
||||||
sp.return_value = process
|
sp.return_value = process
|
||||||
amd_stats = get_amd_gpu_stats()
|
amd_stats = get_amd_gpu_stats()
|
||||||
assert amd_stats == {'gpu_usage': '4.17 %', 'memory_usage': '60.37 %'}
|
assert amd_stats == {"gpu_usage": "4.17 %", "memory_usage": "60.37 %"}
|
||||||
|
|
||||||
@patch("subprocess.run")
|
@patch("subprocess.run")
|
||||||
def test_amd_gpu_stats(self, sp):
|
def test_amd_gpu_stats(self, sp):
|
||||||
@ -26,4 +25,8 @@ class TestGpuStats(unittest.TestCase):
|
|||||||
process.stdout = self.nvidia_results
|
process.stdout = self.nvidia_results
|
||||||
sp.return_value = process
|
sp.return_value = process
|
||||||
nvidia_stats = get_nvidia_gpu_stats()
|
nvidia_stats = get_nvidia_gpu_stats()
|
||||||
assert nvidia_stats == {'name': 'NVIDIA GeForce RTX 3050', 'gpu_usage': '42 %', 'memory_usage': '61.5 %'}
|
assert nvidia_stats == {
|
||||||
|
"name": "NVIDIA GeForce RTX 3050",
|
||||||
|
"gpu_usage": "42 %",
|
||||||
|
"memory_usage": "61.5 %",
|
||||||
|
}
|
||||||
|
|||||||
@ -802,7 +802,9 @@ def get_amd_gpu_stats() -> dict[str, str]:
|
|||||||
if "gpu" in hw:
|
if "gpu" in hw:
|
||||||
results["gpu_usage"] = f"{hw.strip().split(' ')[1].replace('%', '')} %"
|
results["gpu_usage"] = f"{hw.strip().split(' ')[1].replace('%', '')} %"
|
||||||
elif "vram" in hw:
|
elif "vram" in hw:
|
||||||
results["memory_usage"] = f"{hw.strip().split(' ')[1].replace('%', '')} %"
|
results[
|
||||||
|
"memory_usage"
|
||||||
|
] = f"{hw.strip().split(' ')[1].replace('%', '')} %"
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
@ -855,7 +857,7 @@ def get_nvidia_gpu_stats() -> dict[str, str]:
|
|||||||
memory_percent = f"{round(float(usages[2].replace(' MiB', '').strip()) / float(usages[3].replace(' MiB', '').strip()) * 100, 1)} %"
|
memory_percent = f"{round(float(usages[2].replace(' MiB', '').strip()) / float(usages[3].replace(' MiB', '').strip()) * 100, 1)} %"
|
||||||
results: dict[str, str] = {
|
results: dict[str, str] = {
|
||||||
"name": usages[0],
|
"name": usages[0],
|
||||||
"gpu_usage": usages[1],
|
"gpu_usage": usages[1].strip(),
|
||||||
"memory_usage": memory_percent,
|
"memory_usage": memory_percent,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,2 +1,2 @@
|
|||||||
export const ENV = import.meta.env.MODE;
|
export const ENV = import.meta.env.MODE;
|
||||||
export const API_HOST = ENV === 'production' ? '' : 'http://localhost:5000/';
|
export const API_HOST = ENV === 'production' ? '' : 'http://192.168.50.106:5000/';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user