From c72acfb07a00381ebd1162f77f22d7d8b62c91c9 Mon Sep 17 00:00:00 2001 From: D0rkKnight Date: Thu, 25 Jan 2024 17:26:37 -0800 Subject: [PATCH] Fixed key error with collecting existing gpus --- src/dsmlp/ext/kube.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/dsmlp/ext/kube.py b/src/dsmlp/ext/kube.py index 5231e81..c1cbd08 100644 --- a/src/dsmlp/ext/kube.py +++ b/src/dsmlp/ext/kube.py @@ -35,7 +35,10 @@ def get_gpus_in_namespace(self, name: str) -> int: gpu_count = 0 for pod in pods.items: - gpu_count += int(pod.spec.containers.resources.requests['GPU_LABEL']) + try: + gpu_count += int(pod.spec.containers.resources.requests['GPU_LABEL']) + except KeyError: + pass return gpu_count