Skip to content

Commit 4e2cfdc

Browse files
Michaelvllactions-userkevinmingtarja
authored
Release 0.10.5 (#7869)
* Release 0.10.5 * Cherry pick d0e0748 to 0.10.5 (#7870) [Requests] Fix list_accelerators JSON encoding (#7865) * [Requests] Fix list_accelerators JSON encoding * improve test --------- Co-authored-by: GitHub Action <[email protected]> Co-authored-by: Kevin Mingtarja <[email protected]>
1 parent d8d9217 commit 4e2cfdc

File tree

3 files changed

+44
-8
lines changed

3 files changed

+44
-8
lines changed

sky/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def _get_git_commit():
3737

3838

3939
__commit__ = _get_git_commit()
40-
__version__ = '0.10.4'
40+
__version__ = '0.10.5'
4141
__root_dir__ = directory_utils.get_sky_dir()
4242

4343

sky/server/requests/serializers/encoders.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
import typing
99
from typing import Any, Dict, List, Optional, Tuple, Union
1010

11+
from sky import models
12+
from sky.catalog import common
1113
from sky.schemas.api import responses
1214
from sky.server import constants as server_constants
1315
from sky.utils import serialize_utils
1416

1517
if typing.TYPE_CHECKING:
1618
from sky import backends
1719
from sky import clouds
18-
from sky import models
1920
from sky.provision.kubernetes import utils as kubernetes_utils
2021

2122
handlers: Dict[str, Any] = {}
@@ -254,11 +255,27 @@ def encode_realtime_gpu_availability(
254255
List[Any]]]) -> List[Tuple[str, List[List[Any]]]]:
255256
# Convert RealtimeGpuAvailability namedtuples to lists
256257
# for JSON serialization.
257-
result = []
258+
encoded = []
258259
for context, gpu_list in return_value:
259-
gpu_availability_list = []
260+
converted_gpu_list = []
260261
for gpu in gpu_list:
261-
gpu_list_item = [gpu.gpu, gpu.counts, gpu.capacity, gpu.available]
262-
gpu_availability_list.append(gpu_list_item)
263-
result.append((context, gpu_availability_list))
264-
return result
262+
assert isinstance(gpu, models.RealtimeGpuAvailability), (
263+
f'Expected RealtimeGpuAvailability, got {type(gpu)}')
264+
converted_gpu_list.append(list(gpu))
265+
encoded.append((context, converted_gpu_list))
266+
return encoded
267+
268+
269+
@register_encoder('list_accelerators')
270+
def encode_list_accelerators(
271+
return_value: Dict[str, List[Any]]) -> Dict[str, Any]:
272+
encoded: Dict[str, Any] = {}
273+
for accelerator_name, instances in return_value.items():
274+
# Convert InstanceTypeInfo namedtuples to lists for JSON serialization.
275+
converted_instances: List[Any] = []
276+
for instance in instances:
277+
assert isinstance(instance, common.InstanceTypeInfo), (
278+
f'Expected InstanceTypeInfo, got {type(instance)}')
279+
converted_instances.append(list(instance))
280+
encoded[accelerator_name] = converted_instances
281+
return encoded

tests/smoke_tests/test_basic.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,25 @@ def test_kubernetes_show_gpus(generic_cloud: str):
10841084
smoke_tests_utils.run_one_test(test)
10851085

10861086

1087+
@pytest.mark.no_kubernetes
1088+
def test_show_gpus(generic_cloud: str):
1089+
# Check that output contains GPU table headers and common GPU types
1090+
check_cmd = ('echo "$s" && '
1091+
'echo "$s" | grep "COMMON_GPU" && '
1092+
'echo "$s" | grep "AVAILABLE_QUANTITIES" && '
1093+
'echo "$s" | grep -E "A100|H100|H200|L4|T4|B200"')
1094+
test = smoke_tests_utils.Test(
1095+
'show_gpus',
1096+
[
1097+
(f's=$(SKYPILOT_DEBUG=0 sky show-gpus --infra {generic_cloud}) && '
1098+
f'{check_cmd}'),
1099+
(f's=$(SKYPILOT_DEBUG=0 sky show-gpus --infra {generic_cloud} --all) && '
1100+
f'{check_cmd}'),
1101+
],
1102+
)
1103+
smoke_tests_utils.run_one_test(test)
1104+
1105+
10871106
@pytest.mark.no_seeweb # Seeweb fails to provision resources
10881107
def test_launch_and_exec_async(generic_cloud: str):
10891108
"""Test if the launch and exec commands work correctly with --async."""

0 commit comments

Comments
 (0)