From 5d5cba2d78d376a2abc1af6de8eff4a242ab60d7 Mon Sep 17 00:00:00 2001 From: MaoZiming Date: Thu, 4 Jan 2024 14:21:33 -0500 Subject: [PATCH] fix print and dictionary issue --- sky/cli.py | 2 ++ sky/serve/core.py | 14 +++++--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/sky/cli.py b/sky/cli.py index ac5ebd9dfec..6958a3bab95 100644 --- a/sky/cli.py +++ b/sky/cli.py @@ -4329,6 +4329,8 @@ def serve_up( if resource.use_spot is not None and not resource.use_spot: logger.info(f'{resource} use_spot will be override to True, ' 'because spot placer is enabled.') + break + if task.service.spot_placer is None: use_spot = False for resource in list(task.resources): diff --git a/sky/serve/core.py b/sky/serve/core.py index 677a5395da2..abeac05bd6f 100644 --- a/sky/serve/core.py +++ b/sky/serve/core.py @@ -62,18 +62,14 @@ def up( with ux_utils.print_exception_no_traceback(): raise RuntimeError('Service section not found.') - if task.service.spot_placer is not None: - for resource in list(task.resources): - if resource.use_spot is not None and not resource.use_spot: - logger.info(f'{resource} use_spot will be override to True, ' - 'because spot placer is enabled.') - for requested_resources in task.resources: first_resource_dict = list(task.resources)[0].__dict__ requested_resources_dict = requested_resources.__dict__ - for key in ['region', 'zone', 'cloud']: - first_resource_dict.pop(key) - requested_resources_dict.pop(key) + for key in ['_region', '_zone', '_cloud']: + if key in first_resource_dict: + first_resource_dict.pop(key) + if key in requested_resources_dict: + requested_resources_dict.pop(key) if first_resource_dict != requested_resources_dict: raise ValueError( 'Require multiple resources to have the same fields '