From 0ff43877d2ebc723c1fb708e74514c4f9ac8c067 Mon Sep 17 00:00:00 2001 From: nkwangleiGIT Date: Tue, 12 Nov 2024 23:27:20 +0800 Subject: [PATCH] fix format and lint --- sky/cli.py | 5 +++-- sky/clouds/service_catalog/kubernetes_catalog.py | 3 ++- sky/provision/kubernetes/utils.py | 15 ++++++++++----- sky/utils/common_utils.py | 5 +++-- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/sky/cli.py b/sky/cli.py index de600de977d..f38e7bdf041 100644 --- a/sky/cli.py +++ b/sky/cli.py @@ -3161,8 +3161,9 @@ def _get_kubernetes_node_info_table(context: Optional[str]): node_info_dict = kubernetes_utils.get_kubernetes_node_info(context) for node_name, node_info in node_info_dict.items(): - available = node_info.free[common_utils.get_gpu_resource_name()] if node_info.free[ - common_utils.get_gpu_resource_name()] != -1 else no_permissions_str + available = node_info.free[common_utils.get_gpu_resource_name( + )] if node_info.free[common_utils.get_gpu_resource_name( + )] != -1 else no_permissions_str node_table.add_row([ node_name, node_info.gpu_type, node_info.total[common_utils.get_gpu_resource_name()], available diff --git a/sky/clouds/service_catalog/kubernetes_catalog.py b/sky/clouds/service_catalog/kubernetes_catalog.py index 42289389895..2b57c6e5b20 100644 --- a/sky/clouds/service_catalog/kubernetes_catalog.py +++ b/sky/clouds/service_catalog/kubernetes_catalog.py @@ -147,7 +147,8 @@ def list_accelerators_realtime( continue accelerator_count = int( - node.status.allocatable.get(common_utils.get_gpu_resource_name(), 0)) + node.status.allocatable.get( + common_utils.get_gpu_resource_name(), 0)) # Generate the GPU quantities for the accelerators if accelerator_name and accelerator_count > 0: diff --git a/sky/provision/kubernetes/utils.py b/sky/provision/kubernetes/utils.py index ba5a1a31ca2..2c7395373f8 100644 --- a/sky/provision/kubernetes/utils.py +++ b/sky/provision/kubernetes/utils.py @@ -1833,8 +1833,9 @@ def get_kubernetes_node_info( else: accelerator_name = None - accelerator_count = int(node.status.allocatable.get( - common_utils.get_gpu_resource_name(), 0)) + accelerator_count = int( + node.status.allocatable.get(common_utils.get_gpu_resource_name(), + 0)) if pods is None: accelerators_available = -1 @@ -1856,9 +1857,13 @@ def get_kubernetes_node_info( node_info_dict[node.metadata.name] = KubernetesNodeInfo( name=node.metadata.name, gpu_type=accelerator_name, - total={common_utils.get_gpu_resource_name(): int(accelerator_count)}, - free={common_utils.get_gpu_resource_name(): int(accelerators_available)}) - + total={ + common_utils.get_gpu_resource_name(): int(accelerator_count) + }, + free={ + common_utils.get_gpu_resource_name(): + int(accelerators_available) + }) return node_info_dict diff --git a/sky/utils/common_utils.py b/sky/utils/common_utils.py index 712a3e70663..d0e10e48646 100644 --- a/sky/utils/common_utils.py +++ b/sky/utils/common_utils.py @@ -698,7 +698,8 @@ def truncate_long_string(s: str, max_length: int = 35) -> str: prefix += s[len(prefix):max_length] return prefix + '...' -def get_gpu_resource_name(name="nvidia.com/gpu"): + +def get_gpu_resource_name(name: str = 'nvidia.com/gpu'): """ Get the GPU resource name. @@ -713,7 +714,7 @@ def get_gpu_resource_name(name="nvidia.com/gpu"): """ # retrieve GPU resource name from environment variable, # can be nvidia.com/gpu-h100 if it's customized by the device plugin - custom_name = os.getenv("CUSTOM_GPU_RESOURCE_NAME") + custom_name = os.getenv('CUSTOM_GPU_RESOURCE_NAME') # If the environment variable is not defined, return the default name if custom_name is None: