Skip to content

Commit

Permalink
[UX - SkyServe] user now is able to select a LB policy from a range o…
Browse files Browse the repository at this point in the history
…f options (#4061)

* user can select load balancing policies

* some fixes

* linting

* Fixes according to comments

* Linting

* Linting

* Fixed according to comments

* fix

* removed line from examples

* Reverted changes

* Reverted changes

* Fixed according to comments

* Linting

* Update sky/serve/load_balancer.py

Co-authored-by: Tian Xia <cblmemo@gmail.com>

* [Catalog] Silently ignore TPU price not found. (#4134)

* [Catalog] Silently ignore TPU price not found.

* assert for non tpu v6e

* format

* [docs] Update GPUs used in docs (#4138)

* Change V100 to H100

* updates

* update

* [k8s] Fix GPU labeling for EKS (#4146)

Fix GPU labelling

* [k8s] Handle @ in context name (#4147)

Handle @ in context name

* [Docs] Typo in distributed jobs docs (#4149)

minor typo

* [Performance] Refactor Azure SDK usage (#4139)

* [Performance] Refactor Azure SDK usage

* lazy import and address comments

* address comments

* fixes

* fixes

* nits

* fixes

* Fix OCI import issue (#4178)

* Fix OCI import issue

* Update sky/clouds/oci.py

Co-authored-by: Zhanghao Wu <zhanghao.wu@outlook.com>

* edit comments

---------

Co-authored-by: Zhanghao Wu <zhanghao.wu@outlook.com>

* [k8s] Add retry for apparmor failures (#4176)

* Add retry for apparmor failures

* add comment

* [Docs] Update Managed Jobs page. (#4177)

* [Docs] Update Managed Jobs page.

* Lint

* Updates

* Minor: Jobs docs fix. (#4183)

* [Docs] Update Managed Jobs page.

* Lint

* Updates

* reword

* [UX] remove all uses of deprecated `sky jobs` (#4173)

* [UX] remove all uses of deprecated `sky jobs`

* Apply suggestions from code review

Co-authored-by: Romil Bhardwaj <romil.bhardwaj@gmail.com>

* fix other mentions of "spot jobs"

---------

Co-authored-by: Romil Bhardwaj <romil.bhardwaj@gmail.com>

* [Azure] Support fractional A10 instance types (#3877)

* fix

* change catalog to float gpu num

* support print float point gpu in sky launch. TODO: test if the ray deployment group works for fractional one

* fix unittest

* format

* patch ray resources to ceil value

* support launch from --gpus A10

* only allow strictly match fractional gpu counts

* address comment

* change back condition

* fix

* apply suggestions from code review

* fix

* Update sky/backends/cloud_vm_ray_backend.py

Co-authored-by: Zhanghao Wu <zhanghao.wu@outlook.com>

* format

* fix display of fuzzy candidates

* fix precision issue

* fix num gpu required

* refactor in check_resources_fit_cluster

* change type annotation of acc_count

* enable fuzzy fp acc count

* fix k8s

* Update sky/clouds/service_catalog/common.py

Co-authored-by: Zhanghao Wu <zhanghao.wu@outlook.com>

* fix integer gpus

* format

---------

Co-authored-by: Zhanghao Wu <zhanghao.wu@outlook.com>

* [Jobs] Refactor: Extract task failure state update helper (#4185)

refactor: a unified exception handling utility

* [Core] Remove backward compatibility code for 0.6.0 & 0.7.0 (#4175)

* [Core] Remove backward compatibility code for 0.6.0

* remove backwards compatibility for 0.7.0 release

* Update sky/serve/serve_state.py

Co-authored-by: Romil Bhardwaj <romil.bhardwaj@berkeley.edu>

* remove more

* Revert "remove more"

This reverts commit 34c28e9.

* remove more but not instance tags

---------

Co-authored-by: Christopher Cooper <cooperc@assemblesys.com>
Co-authored-by: Romil Bhardwaj <romil.bhardwaj@berkeley.edu>

* Remove outdated pylint disabling comments (#4196)

Update cloud_vm_ray_backend.py

* [test] update default clouds for smoke tests (#4182)

* [k8s] Show all kubernetes clusters in optimizer table (#4013)

* Show all kubernetes clusters in optimizer table

* format

* Add comment

* [Azure] Allow resource group specifiation for Azure instance provisioning (#3764)

* Allow resource group specifiation for Azure instance provisioning

* Add 'use_external_resource_group' under provider config

* nit

* attached resources deletion

* support deployment removal when terminating

* nit

* delete RoleAssignment when terminating

* update ARM config template

* nit

* nit

* delete role assignment with guid

* update role assignment removal logic

* Separate resource group region and VM, attached resources

* nit

* nit

* nit

* nit

* add error handling for deletion

* format

* deployment naming update

* test

* nit

* update deployment constant names

* update open_ports to wait for the nsg creation corresponding to the VM being provisioned

* format

* nit

* format

* update docstring

* add back deleted snippet

* format

* delete nic with retries

* error handle update

* [dev] restrict pylint to changed files (#4184)

* [dev] restrict pylint to changed files

* fix glob

* avoid use of xargs -d

* Update packer scripts (#4203)

* Update custom image packer script to exclude .sky and include python sys packages

* add comments

* Upgrade Azure SDK version requirement (#4204)

* [Jobs] Add option to specify `max_restarts_on_errors` (#4169)

* Add option to specify `max_retry_on_failure`

* fix recover counts

* fix log streaming

* fix docs

* fix

* fix

* fix

* fix

* fix default value

* Fix spinner

* Add unit test for default strategy

* fix test

* format

* Update docs/source/examples/managed-jobs.rst

Co-authored-by: Zongheng Yang <zongheng.y@gmail.com>

* rename to restarts

* Update docs/source/examples/managed-jobs.rst

Co-authored-by: Zongheng Yang <zongheng.y@gmail.com>

* update docs

* warning instead of error out

* Update docs/source/examples/managed-jobs.rst

Co-authored-by: Romil Bhardwaj <romil.bhardwaj@berkeley.edu>

* rename

* add comment

* fix

* rename

* Update sky/execution.py

Co-authored-by: Romil Bhardwaj <romil.bhardwaj@berkeley.edu>

* Update sky/execution.py

Co-authored-by: Romil Bhardwaj <romil.bhardwaj@berkeley.edu>

* address comments

* format

* commit changes for docs

* Format

---------

Co-authored-by: Zongheng Yang <zongheng.y@gmail.com>
Co-authored-by: Romil Bhardwaj <romil.bhardwaj@berkeley.edu>

* [Core] Fix job race condition. (#4193)

* [Core] Fix job race condition.

* fix

* simplify url

* change to list_jobs

* upd ray comments

* only store jobs in ray_id_set

* [Core] Fix issue with the wrong path of setup logs (#4209)

* fix issue with a getting setup logs

* More conservative

* print error

* comment

* [Jobs] Fix jobs name (#4213)

* fix issue with a getting setup logs

* More conservative

* print error

* comment

* Fix job name

* [Performance] Speed up Azure A10 instance creation (#4205)

* Use date instead of timestamp in skypilot image names

* Speed up Azure A10 VM creation

* disable nouveau and use smaller instance

* address comments

* address comments

* add todo

* [Tests] Fix public bucket tests (#4216)

fix

* [Catalog] Add TPU V6e. (#4218)

* [Catalog] Add TPU V6e.

* swap if else branch

* [test] smoke test fixes for managed jobs (#4217)

* [test] don't wait for old pending jobs controller messages

`sky jobs queue` used to output a temporary "waiting" message while the managed
jobs controller was still being provisioned/starting. Since #3288 this is not
shown, and instead the queued jobs themselves will show PENDING/STARTING.

This also requires some changes to tests to permit the PENDING and STARTING
states for managed jobs.

* fix default aws region

* [test] wait for RECOVERING more quickly

Smoke tests were failing because some managed jobs were fulling recovering back
to the RUNNING state before the smoke test could catch the RECOVERING case (see
e.g. #4192 `test_managed_jobs_cancellation_gcp`). Change tests that manually
terminate a managed job instance, so that they will wait for the managed job to
change away from the RUNNING state, checking every 10s.

* address PR comments

* fix

* Add user toolkits to all sky custom images and fix PyTorch issue on A10 (#4219)

* Add user toolkits to all sky custom images

* address comments

* [Core] Support TPU v6 (#4220)

* init

* fix

* nit

* format

* add readme

* add inference example

* nit

* add multi-host training

* rephrase catalog doc

* Update examples/tpu/v6e/README.md

Co-authored-by: Zhanghao Wu <zhanghao.wu@outlook.com>

---------

Co-authored-by: Zhanghao Wu <zhanghao.wu@outlook.com>

* [Core] Make home address replacement more robust (#4227)

* Make home address replacement more robust

* format

* [UX] sky launch --fast (#4159)

* [UX] skip provisioning stages if cluster is already available

* add new --skip-setup flag and further limit stages to match sky exec

* rename flag to --fast

* add smoke test for sky launch --fast

* changes stages for --fast

* fix --fast help message

* add api test for fast param (outside CLI)

* lint

* explicitly specify stages

* [Docs] Tpu v6 docs (#4221)

* Update TPU v6 docs

* tpu v6 docs

* add TPU v6

* update

* Fix tpu docs

* fix indents

* restructure TPU doc

* Fix

* Fix

* fix

* Fix TPU

* fix docs

* Update docs/source/reference/tpu.rst

Co-authored-by: Tian Xia <cblmemo@gmail.com>

---------

Co-authored-by: Tian Xia <cblmemo@gmail.com>

* [ux] add sky jobs launch --fast (#4231)

* [ux] add sky jobs launch --fast

This flag will make the jobs controller launch use `sky launch --fast`. There
are a few known situations where this can cause misbehavior in the jobs
controller:
- The SkyPilot wheel is outdated (due to changes in the SkyPilot code or a
  version upgrade).
- The user's cloud credentials have changed. In this case the new credentials
  will not be synced, and if there are new clouds available in `sky check`, the
  cloud depedencies may not be correctly installed.

However, this does speed up `jobs launch` _significantly_, so provide it as a
dangerous option. Soon we will add robustness checks to `sky launch --fast` that
will fix the above caveats, and we can remove this flag and just enable the
behavior by default.

* Apply suggestions from code review

Co-authored-by: Romil Bhardwaj <romil.bhardwaj@gmail.com>

* fix lint

---------

Co-authored-by: Romil Bhardwaj <romil.bhardwaj@gmail.com>

* [UX] Show 0.25 on controller queue (#4230)

* Show 0.25 on controller queue

* format

* [Storage] Avoid opt-in regions for S3 (#4239)

* S3 fix + timeout

* S3 fix + timeout

* lint

* Update K8s docker image build and the source artifact registry (#4224)

* Attempt at improving performance of k8s cluster launch

* remove conda env creation

* add multiple regions

* K8s sky launch pulls the new docker images

* Move k8s script

* use us region only

* typo

* Remove --system-site-packages when setup sky cluster (#4168)

* Remove --system-site-packages when setup sky cluster

* add comments

* [AWS/Azure] Avoid error out during image size check (#4244)

* Avoid error out during image size check

* Avoid error for azure

* lint

* [AWS] Disable additional auto update services for ubuntu image with cloud-init (#4252)

* Disable additional auto update services for ubuntu image

* simplify the commands

* [Dashboard] Add a simple status filter. (#4253)

* Disable more potential unattended upgrade sources for AWS (#4246)

* Fix AWS unattended upgrade issue

* more commands

* add retry and disable all unattended

* remove retry

* disable unattended upgrades and add retry in aws default image

* [docs]: OCI key_file path clarrification (#4262)

* [docs]: OCI key_file path clarrification

* Update installation.rst

* [k8s] Parallelize setup for faster multi-node provisioning (#4240)

* parallelize setup

* lint

* Add retries

* lint

* retry for get_remote_home_dir

* optimize privilege check

* parallelize termination

* increase num threads

* comments

* lint

* do not redirect stderr to /dev/null when submitting job (#4247)

* do not redirect stderr to /dev/null when submitting job

Should fix #4199.

* remove grep, add worker_maximum_startup_concurrency override

* [tests] Exclude runpod from smoke tests unless specified (#4238)

Add runpod

* Update comments pointing to Lambda's docs (#4272)

* [Core] Avoid PENDING job to be set to FAILED and speed up job scheduling (#4264)

* fix race condition for setting job status to FAILED during INIT

* Fix

* fix

* format

* Add smoke tests

* revert pending submit

* remove update entirely for the job schedule step

* wait for job 32 to finish

* fix smoke

* move and rename

* Add comment

* minor

* Set minimum port number a Ray worker can listen on to 11002 (#4278)

Set worker minimum port number

* [docs] use k8s instead of kubernetes in the CLI (#4164)

* [docs] use k8s instead of kubernetes in the CLI

* fix docs build script for linux

* Update docs/source/reference/kubernetes/kubernetes-getting-started.rst

Co-authored-by: Romil Bhardwaj <romil.bhardwaj@gmail.com>

---------

Co-authored-by: Romil Bhardwaj <romil.bhardwaj@gmail.com>

* [jobs] autodown managed job clusters (#4267)

* [jobs] autodown managed job clusters

If all goes correctly, the managed job controller should tear down a managed job
cluster once the managed job completes. However, if the controller fails somehow
(e.g. crashes, is terminated, etc), we don't want to leak resources.

As a failsafe, set autodown on the job cluster. This is not foolproof, since the
skylet on the cluster can also crash, but it's likely to catch many cases.

* add comment about autodown duration

* add leading _

* [UX] Improve Formatting of Post Job Creation Logs (#4198)

* Update cloud_vm_ray_backend.py

* Update cloud_vm_ray_backend.py

* format

* Fix `stream_logs` Duplicate Job Handling and TypeError (#4274)

fix: multiple `job_id`

* Update sky/serve/load_balancer.py

Co-authored-by: Tian Xia <cblmemo@gmail.com>

* feat(serve): Improve load balancing policy error message and display

1. Add available policies to schema validation
2. Show available policies in error message when invalid policy is specified
3. Display load balancing policy in service spec repr when explicitly set

* fix(serve): Update load balancing policy schema to match implemented policies

Only 'round_robin' is currently implemented in LoadBalancingPolicy class

* linting

* refactor(serve): Remove policy enum from schema

Move policy validation to code to avoid duplication and make it easier to maintain when adding new policies

* fix

* linting

* Update sky/serve/service_spec.py

Co-authored-by: Tian Xia <cblmemo@gmail.com>

* Fix circular import in schemas.py by moving load_balancing_policies import inside function

* linting

---------

Co-authored-by: Tian Xia <cblmemo@gmail.com>
Co-authored-by: Romil Bhardwaj <romil.bhardwaj@berkeley.edu>
Co-authored-by: Yika <yikaluo@assemblesys.com>
Co-authored-by: Zhanghao Wu <zhanghao.wu@outlook.com>
Co-authored-by: Zongheng Yang <zongheng.y@gmail.com>
Co-authored-by: Christopher Cooper <cooperc@assemblesys.com>
Co-authored-by: Romil Bhardwaj <romil.bhardwaj@gmail.com>
Co-authored-by: Andy Lee <andylizf@outlook.com>
Co-authored-by: landscapepainter <34902420+landscapepainter@users.noreply.github.com>
Co-authored-by: Hysun He <hysunhe@foxmail.com>
Co-authored-by: Cody Brownstein <105375373+cbrownstein-lambda@users.noreply.github.com>
  • Loading branch information
12 people authored Nov 11, 2024
1 parent dddd651 commit 3bfc29e
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 10 deletions.
26 changes: 26 additions & 0 deletions examples/serve/load_balancing_policies_example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# SkyServe YAML to demonstrate multiple load balancing policies.
#
# Usage:
# sky serve up -n load_balancing_policy_test examples/serve/load_balancing_policies_example.yaml
# The endpoint will be printed in the console. You
# could also check the endpoint by running:
# sky serve status --endpoint load_balancing_policy_test

service:
readiness_probe:
path: /health
initial_delay_seconds: 20
replica_policy:
min_replicas: 2
max_replicas: 4
target_qps_per_replica: 1
# Load balancing policy configuration
load_balancing_policy: round_robin # Change this to test different policies...

resources:
ports: 8080
cpus: 2+

workdir: examples/serve/http_server

run: python3 server.py
2 changes: 2 additions & 0 deletions sky/serve/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from sky.serve.core import terminate_replica
from sky.serve.core import up
from sky.serve.core import update
from sky.serve.load_balancing_policies import LB_POLICIES
from sky.serve.serve_state import ReplicaStatus
from sky.serve.serve_state import ServiceStatus
from sky.serve.serve_utils import DEFAULT_UPDATE_MODE
Expand All @@ -35,6 +36,7 @@
'get_endpoint',
'INITIAL_VERSION',
'LB_CONTROLLER_SYNC_INTERVAL_SECONDS',
'LB_POLICIES',
'ReplicaStatus',
'ServiceComponent',
'ServiceStatus',
Expand Down
42 changes: 34 additions & 8 deletions sky/serve/load_balancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import asyncio
import logging
import threading
from typing import Dict, Union
from typing import Dict, Optional, Union

import aiohttp
import fastapi
Expand All @@ -27,18 +27,24 @@ class SkyServeLoadBalancer:
policy.
"""

def __init__(self, controller_url: str, load_balancer_port: int) -> None:
def __init__(self,
controller_url: str,
load_balancer_port: int,
load_balancing_policy_name: Optional[str] = None) -> None:
"""Initialize the load balancer.
Args:
controller_url: The URL of the controller.
load_balancer_port: The port where the load balancer listens to.
load_balancing_policy_name: The name of the load balancing policy
to use. Defaults to None.
"""
self._app = fastapi.FastAPI()
self._controller_url: str = controller_url
self._load_balancer_port: int = load_balancer_port
self._load_balancing_policy: lb_policies.LoadBalancingPolicy = (
lb_policies.RoundRobinPolicy())
# Use the registry to create the load balancing policy
self._load_balancing_policy = lb_policies.LoadBalancingPolicy.make(
load_balancing_policy_name)
self._request_aggregator: serve_utils.RequestsAggregator = (
serve_utils.RequestTimestamp())
# TODO(tian): httpx.Client has a resource limit of 100 max connections
Expand Down Expand Up @@ -223,9 +229,21 @@ async def startup():
uvicorn.run(self._app, host='0.0.0.0', port=self._load_balancer_port)


def run_load_balancer(controller_addr: str, load_balancer_port: int):
load_balancer = SkyServeLoadBalancer(controller_url=controller_addr,
load_balancer_port=load_balancer_port)
def run_load_balancer(controller_addr: str,
load_balancer_port: int,
load_balancing_policy_name: Optional[str] = None) -> None:
""" Run the load balancer.
Args:
controller_addr: The address of the controller.
load_balancer_port: The port where the load balancer listens to.
policy_name: The name of the load balancing policy to use. Defaults to
None.
"""
load_balancer = SkyServeLoadBalancer(
controller_url=controller_addr,
load_balancer_port=load_balancer_port,
load_balancing_policy_name=load_balancing_policy_name)
load_balancer.run()


Expand All @@ -241,5 +259,13 @@ def run_load_balancer(controller_addr: str, load_balancer_port: int):
required=True,
default=8890,
help='The port where the load balancer listens to.')
available_policies = list(lb_policies.LB_POLICIES.keys())
parser.add_argument(
'--load-balancing-policy',
choices=available_policies,
default='round_robin',
help=f'The load balancing policy to use. Available policies: '
f'{", ".join(available_policies)}.')
args = parser.parse_args()
run_load_balancer(args.controller_addr, args.load_balancer_port)
run_load_balancer(args.controller_addr, args.load_balancer_port,
args.load_balancing_policy)
24 changes: 23 additions & 1 deletion sky/serve/load_balancing_policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

logger = sky_logging.init_logger(__name__)

# Define a registry for load balancing policies
LB_POLICIES = {}
DEFAULT_LB_POLICY = None


def _request_repr(request: 'fastapi.Request') -> str:
return ('<Request '
Expand All @@ -25,6 +29,24 @@ class LoadBalancingPolicy:
def __init__(self) -> None:
self.ready_replicas: List[str] = []

def __init_subclass__(cls, name: str, default: bool = False):
LB_POLICIES[name] = cls
if default:
global DEFAULT_LB_POLICY
assert DEFAULT_LB_POLICY is None, (
'Only one policy can be default.')
DEFAULT_LB_POLICY = name

@classmethod
def make(cls, policy_name: Optional[str] = None) -> 'LoadBalancingPolicy':
"""Create a load balancing policy from a name."""
if policy_name is None:
policy_name = DEFAULT_LB_POLICY

if policy_name not in LB_POLICIES:
raise ValueError(f'Unknown load balancing policy: {policy_name}')
return LB_POLICIES[policy_name]()

def set_ready_replicas(self, ready_replicas: List[str]) -> None:
raise NotImplementedError

Expand All @@ -44,7 +66,7 @@ def _select_replica(self, request: 'fastapi.Request') -> Optional[str]:
raise NotImplementedError


class RoundRobinPolicy(LoadBalancingPolicy):
class RoundRobinPolicy(LoadBalancingPolicy, name='round_robin', default=True):
"""Round-robin load balancing policy."""

def __init__(self) -> None:
Expand Down
5 changes: 4 additions & 1 deletion sky/serve/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ def _get_host():
load_balancer_port = common_utils.find_free_port(
constants.LOAD_BALANCER_PORT_START)

# Extract the load balancing policy from the service spec
policy_name = service_spec.load_balancing_policy

# Start the load balancer.
# TODO(tian): Probably we could enable multiple ports specified in
# service spec and we could start multiple load balancers.
Expand All @@ -227,7 +230,7 @@ def _get_host():
target=ux_utils.RedirectOutputForProcess(
load_balancer.run_load_balancer,
load_balancer_log_file).run,
args=(controller_addr, load_balancer_port))
args=(controller_addr, load_balancer_port, policy_name))
load_balancer_process.start()
serve_state.set_service_load_balancer_port(service_name,
load_balancer_port)
Expand Down
19 changes: 19 additions & 0 deletions sky/serve/service_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import yaml

from sky import serve
from sky.serve import constants
from sky.utils import common_utils
from sky.utils import schemas
Expand All @@ -29,6 +30,7 @@ def __init__(
base_ondemand_fallback_replicas: Optional[int] = None,
upscale_delay_seconds: Optional[int] = None,
downscale_delay_seconds: Optional[int] = None,
load_balancing_policy: Optional[str] = None,
) -> None:
if max_replicas is not None and max_replicas < min_replicas:
with ux_utils.print_exception_no_traceback():
Expand All @@ -55,6 +57,13 @@ def __init__(
raise ValueError('readiness_path must start with a slash (/). '
f'Got: {readiness_path}')

# Add the check for unknown load balancing policies
if (load_balancing_policy is not None and
load_balancing_policy not in serve.LB_POLICIES):
with ux_utils.print_exception_no_traceback():
raise ValueError(
f'Unknown load balancing policy: {load_balancing_policy}. '
f'Available policies: {list(serve.LB_POLICIES.keys())}')
self._readiness_path: str = readiness_path
self._initial_delay_seconds: int = initial_delay_seconds
self._readiness_timeout_seconds: int = readiness_timeout_seconds
Expand All @@ -69,6 +78,7 @@ def __init__(
int] = base_ondemand_fallback_replicas
self._upscale_delay_seconds: Optional[int] = upscale_delay_seconds
self._downscale_delay_seconds: Optional[int] = downscale_delay_seconds
self._load_balancing_policy: Optional[str] = load_balancing_policy

self._use_ondemand_fallback: bool = (
self.dynamic_ondemand_fallback is not None and
Expand Down Expand Up @@ -150,6 +160,8 @@ def from_yaml_config(config: Dict[str, Any]) -> 'SkyServiceSpec':
service_config['dynamic_ondemand_fallback'] = policy_section.get(
'dynamic_ondemand_fallback', None)

service_config['load_balancing_policy'] = config.get(
'load_balancing_policy', None)
return SkyServiceSpec(**service_config)

@staticmethod
Expand Down Expand Up @@ -205,6 +217,8 @@ def add_if_not_none(section, key, value, no_empty: bool = False):
self.upscale_delay_seconds)
add_if_not_none('replica_policy', 'downscale_delay_seconds',
self.downscale_delay_seconds)
add_if_not_none('load_balancing_policy', None,
self._load_balancing_policy)
return config

def probe_str(self):
Expand Down Expand Up @@ -256,6 +270,7 @@ def __repr__(self) -> str:
Readiness probe timeout seconds: {self.readiness_timeout_seconds}
Replica autoscaling policy: {self.autoscaling_policy_str()}
Spot Policy: {self.spot_policy_str()}
Load Balancing Policy: {self.load_balancing_policy}
""")

@property
Expand Down Expand Up @@ -310,3 +325,7 @@ def downscale_delay_seconds(self) -> Optional[int]:
@property
def use_ondemand_fallback(self) -> bool:
return self._use_ondemand_fallback

@property
def load_balancing_policy(self) -> Optional[str]:
return self._load_balancing_policy
8 changes: 8 additions & 0 deletions sky/utils/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ def get_storage_schema():

def get_service_schema():
"""Schema for top-level `service:` field (for SkyServe)."""
# To avoid circular imports, only import when needed.
# pylint: disable=import-outside-toplevel
from sky.serve import load_balancing_policies
return {
'$schema': 'https://json-schema.org/draft/2020-12/schema',
'type': 'object',
Expand Down Expand Up @@ -382,6 +385,11 @@ def get_service_schema():
'replicas': {
'type': 'integer',
},
'load_balancing_policy': {
'type': 'string',
'case_insensitive_enum': list(
load_balancing_policies.LB_POLICIES.keys())
},
}
}

Expand Down

0 comments on commit 3bfc29e

Please sign in to comment.