Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing SkyServe #2458

Merged
merged 242 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
242 commits
Select commit Hold shift + click to select a range
9a645a4
init
infwinston Jul 13, 2023
4bb4420
format
infwinston Jul 13, 2023
d52c2b9
format
infwinston Jul 13, 2023
208bdf4
reademe
infwinston Jul 14, 2023
1fa6401
update
infwinston Jul 14, 2023
c56ae22
[SkyServe] add http server example (#2260)
cblmemo Jul 18, 2023
f28ebbb
[SkyServe] `sky serve` CLI prototype (#2276)
cblmemo Jul 26, 2023
8fa4323
[SkyServe] Refactoring, Introducing multiprocess for provisioning and…
cblmemo Aug 4, 2023
05da33f
[SkyServe] Use SSH for Authentication, new replica status, `sky serve…
cblmemo Aug 13, 2023
c32e18d
merge to master
cblmemo Aug 13, 2023
d6bd068
[SkyServe] Final changes for v0 release (#2396)
cblmemo Aug 15, 2023
cd2b44c
Merge remote-tracking branch 'origin/master' into serve
cblmemo Aug 15, 2023
7968de9
fix serve example (#2406)
infwinston Aug 15, 2023
23e7529
surface debug msg (#2407)
infwinston Aug 15, 2023
57b3347
[SkyServe] Fix port failover (#2408)
cblmemo Aug 16, 2023
0a1a7de
[SkyServe] Introducing smoke test and fix bugs (#2411)
cblmemo Aug 18, 2023
f7f33e9
[SkyServe] Add cancel and gorilla example (#2417)
cblmemo Aug 20, 2023
8216e71
[SkyServe] Fix interrupt process group and format (#2449)
cblmemo Aug 24, 2023
1c9e23f
Merge remote-tracking branch 'origin/master' into serve-dev
cblmemo Aug 24, 2023
d8aaf65
add authentication init
cblmemo Aug 24, 2023
ede0cad
typo fix & remove prehook
cblmemo Aug 24, 2023
4ace061
fix --no-follow in replica log and disable cancel log when skyserve down
cblmemo Aug 24, 2023
14ddf2f
set controller task resources for when controller failed to provision…
cblmemo Aug 25, 2023
8ce9c18
finish llm & interrupt test
cblmemo Aug 25, 2023
6fae8ac
early check cluster name is valid
cblmemo Aug 25, 2023
21c07cc
add hint message for tailing replica job status
cblmemo Aug 25, 2023
377789b
make dict thread safe
cblmemo Aug 25, 2023
b2f2388
upd doc
cblmemo Aug 25, 2023
7bfeec9
rename redirector to lb
cblmemo Aug 26, 2023
2d58994
Merge remote-tracking branch 'origin/master' into serve-dev
cblmemo Aug 26, 2023
082c88b
rename sky serve controller prefix
cblmemo Aug 26, 2023
a4c8fc2
restore example
cblmemo Aug 26, 2023
63b2601
upd smoke test
cblmemo Aug 26, 2023
14621d3
use asyncio
cblmemo Aug 27, 2023
55d3503
change core with underlying function to avoid usage collection on status
cblmemo Aug 27, 2023
c9d2e28
reatore comma
cblmemo Aug 27, 2023
d236eec
add comment
cblmemo Aug 27, 2023
e3e698c
adopt comments in #2473
cblmemo Aug 28, 2023
b288ba0
Apply suggestions from code review
cblmemo Aug 31, 2023
7fccb8f
Apply suggestions from code review
cblmemo Aug 31, 2023
58a1122
fix example
infwinston Sep 4, 2023
7aef306
Fix serve probe (#2513)
infwinston Sep 5, 2023
d05b42f
[SkyServe] Add option to auto restart (#2518)
cblmemo Sep 6, 2023
5200fbd
[SkyServe] Fix auto restart (#2521)
cblmemo Sep 6, 2023
45e43c3
[SkyServe] Using Multi-service controller (#2489)
cblmemo Sep 9, 2023
fdd6332
Update sky/cli.py
cblmemo Sep 10, 2023
a93d9fa
Update sky/serve/examples/stable_diffusion_service.yaml
cblmemo Sep 10, 2023
87b2079
style for example
cblmemo Sep 10, 2023
3dc4dac
format & add comments & rephrase
cblmemo Sep 10, 2023
f585294
Merge remote-tracking branch 'origin/master' into serve-dev
cblmemo Sep 10, 2023
9850d40
move serve_down to core and refactor
cblmemo Sep 10, 2023
2fb615d
Update sky/execution.py
cblmemo Sep 10, 2023
aa4cda0
apply suggestions from code review
cblmemo Sep 10, 2023
3db51ca
move examples
cblmemo Sep 10, 2023
788c497
Update sky/cli.py
cblmemo Sep 10, 2023
9bb4334
use _make_task_or_dag_from_entrypoint_with_overrides & minor
cblmemo Sep 10, 2023
bdef682
make sky serve status accept multiple service names
cblmemo Sep 10, 2023
96419ae
minor
cblmemo Sep 10, 2023
d0a3fb8
minor
cblmemo Sep 10, 2023
1eefc54
upd docstring
cblmemo Sep 10, 2023
457c7a2
fix
cblmemo Sep 10, 2023
9a2d27e
better programmatic api
cblmemo Sep 11, 2023
f4bdbdb
ux
cblmemo Sep 12, 2023
78d7342
use flag to control logging
cblmemo Sep 13, 2023
baf62f9
combine reserved prefix & name
cblmemo Sep 14, 2023
4c52014
fix
cblmemo Sep 14, 2023
755114f
expand user
cblmemo Sep 14, 2023
b547b19
better UX for auto restart
cblmemo Sep 14, 2023
f465e32
fix consecutive timeout threshold
cblmemo Sep 15, 2023
c773d70
minor
cblmemo Sep 15, 2023
4eb1d44
nnit
cblmemo Sep 16, 2023
d83f9a2
temp remove
cblmemo Sep 18, 2023
ac3244b
Merge remote-tracking branch 'origin/master' into serve-dev
cblmemo Sep 18, 2023
dd261d5
add back
cblmemo Sep 18, 2023
6f6d8e7
only open ports used
cblmemo Sep 18, 2023
4037e7e
remove redundant task yaml for load balancer
cblmemo Sep 19, 2023
0578487
move task ports handling to python API
cblmemo Sep 20, 2023
a100433
fix controller generation bug
cblmemo Sep 26, 2023
8f49ff9
UX nits
cblmemo Sep 26, 2023
4dd0e8e
nit
cblmemo Sep 26, 2023
20dcd1b
Fix sky serve down --purge when storage cleanup failed
cblmemo Sep 27, 2023
672840c
ux
cblmemo Sep 27, 2023
a8bec0d
reuse service handle
cblmemo Sep 28, 2023
7bb01f6
revert
cblmemo Sep 28, 2023
9de419b
Merge remote-tracking branch 'origin/master' into serve-dev
cblmemo Sep 28, 2023
fbd2873
add todo
cblmemo Sep 28, 2023
fbde4aa
[SkyServe] Add Ray Serve example (#2621)
iojw Sep 28, 2023
fa4981a
restore job id type
cblmemo Oct 3, 2023
f36cb42
Merge remote-tracking branch 'origin/master' into serve-dev
cblmemo Oct 3, 2023
5704d05
Apply suggestions from code review
cblmemo Oct 3, 2023
e47e005
lint
cblmemo Oct 3, 2023
3e81e8b
Merge remote-tracking branch 'origin/master' into serve-dev
cblmemo Oct 3, 2023
a86523c
move service section to the top
cblmemo Oct 3, 2023
27a29b4
add docstr
cblmemo Oct 3, 2023
ecc0640
make controller port not optinal
cblmemo Oct 3, 2023
9bf337b
remove cpu demand for gpu workloads
cblmemo Oct 3, 2023
b8ce4c4
make ReservedClusterGroup.get_group accept none arg
cblmemo Oct 3, 2023
01bea22
nit
cblmemo Oct 3, 2023
d27dab8
remove yaml_only and task_only in _make_task_or_dag_from_entrypoint_w…
cblmemo Oct 3, 2023
c00fcdf
cli nits
cblmemo Oct 3, 2023
2b43b83
remove get_glob_service_names
cblmemo Oct 3, 2023
65b9bb2
fix pop CPU
cblmemo Oct 4, 2023
28f613d
remove CPU demand for job when presented in CLI
cblmemo Oct 4, 2023
2b38cc6
Merge remote-tracking branch 'origin/master' into serve-dev
cblmemo Oct 5, 2023
e973442
remove cancel and use os.kill now
cblmemo Oct 5, 2023
1b31110
add db on controller VM, remove job id and use skylet to refresh serv…
cblmemo Oct 5, 2023
8799e09
minor
cblmemo Oct 5, 2023
849ba81
merge controllers with normal clusters
cblmemo Oct 5, 2023
e8160c7
Merge remote-tracking branch 'origin/master' into serve-dev
cblmemo Oct 5, 2023
4fa8aa0
deprecate controller port adn refresh in infra provider
cblmemo Oct 6, 2023
e0392c7
Apply suggestions from code review
cblmemo Oct 10, 2023
b9b0a78
use enum in serve logs + minor
cblmemo Oct 10, 2023
a4683bd
Merge remote-tracking branch 'origin/master' into serve-dev
cblmemo Oct 10, 2023
82d01ea
remove stop hint
cblmemo Oct 10, 2023
e2aa2a2
env vars & monir
cblmemo Oct 10, 2023
ef24cda
use cluster regex and remove service regex
cblmemo Oct 10, 2023
4870e73
remove pylint hint & rename app_port -> replica_port
cblmemo Oct 10, 2023
f1406cf
change constants used in _maybe_translate_local_file_mounts_and_sync_up
cblmemo Oct 10, 2023
686ebd9
add --endpoint and ux
cblmemo Oct 11, 2023
9ee2cf0
new termination of controller & lb; minor suggestions
cblmemo Oct 11, 2023
ec3877a
move statuses to serve_state, minors
cblmemo Oct 11, 2023
e97381e
minor
cblmemo Oct 11, 2023
e55958d
speedup terminate
cblmemo Oct 11, 2023
a952249
replica db mypy & pylint passed
cblmemo Oct 12, 2023
688bb20
fix
cblmemo Oct 12, 2023
09fd88e
fix scale down & cleanup failed replica
cblmemo Oct 12, 2023
f13e3ef
minor
cblmemo Oct 12, 2023
aeca540
move controller resources to config.yaml
cblmemo Oct 12, 2023
3155453
fix smoke test
cblmemo Oct 13, 2023
2afdfc3
refactor request information report
cblmemo Oct 13, 2023
1fd1db5
architecture: autoscaler no longer talk with infra provider again
cblmemo Oct 13, 2023
42e1f4a
fix auto restart
cblmemo Oct 13, 2023
3f81cdb
sync down logs and then streaming
cblmemo Oct 13, 2023
692d844
terminate log streaming when service is downed
cblmemo Oct 13, 2023
8d4f64d
refactor autoscaler & argument pass in controller
cblmemo Oct 13, 2023
673c747
move several var from local db
cblmemo Oct 13, 2023
003c655
use a control process to handle signal and terminate service
cblmemo Oct 15, 2023
8d15ef0
move port selection to the controller VM
cblmemo Oct 16, 2023
5668049
minor
cblmemo Oct 16, 2023
2984996
refactor dataabse
cblmemo Oct 16, 2023
cf721a2
comments, docs and function reorder for infra providers
cblmemo Oct 16, 2023
dfcc373
change launch/terminate replica to python API
cblmemo Oct 16, 2023
1fa207f
fix pass task in multiprocessing
cblmemo Oct 16, 2023
e2365e7
minor & fix smoke test
cblmemo Oct 16, 2023
1e7936d
rename infra_provider to replica_manager
cblmemo Oct 16, 2023
1aba238
ux
cblmemo Oct 16, 2023
6d646a6
not count as failure if UP for more than initial_delay_seconds
cblmemo Oct 17, 2023
32aa294
default auto restart to true
cblmemo Oct 18, 2023
fa4fdfa
add todo
cblmemo Oct 18, 2023
297f837
Merge remote-tracking branch 'origin/master' into serve-dev
cblmemo Oct 18, 2023
756a669
upd test for auto_restart
cblmemo Oct 18, 2023
ea992a0
Use only one controller and remove local database. TODO: change to SE…
cblmemo Oct 21, 2023
6d590b4
minor
cblmemo Oct 21, 2023
8961e59
Apply suggestions from code review
cblmemo Oct 21, 2023
3320919
apply suggestion from code review
cblmemo Oct 21, 2023
05a9f83
mske sky status showing service as well
cblmemo Oct 22, 2023
e2d103d
fix
cblmemo Oct 22, 2023
0ab0dec
replica manager ux; use sky logger for uvicorn
cblmemo Oct 22, 2023
4ee5676
UX, refactoring
cblmemo Oct 23, 2023
ce82675
rephrase hint after sky serve up
cblmemo Oct 23, 2023
a9e706a
Merge remote-tracking branch 'origin/master' into serve-dev
cblmemo Oct 23, 2023
ce283f1
Update sky/execution.py
cblmemo Oct 23, 2023
05aec69
comments
cblmemo Oct 23, 2023
bd835d4
add service name check before sky serve up
cblmemo Oct 23, 2023
e17d789
rename reserved cluster to controller
cblmemo Oct 24, 2023
743cabd
Merge remote-tracking branch 'origin/master' into serve-dev
cblmemo Oct 24, 2023
5e07d5b
Merge remote-tracking branch 'origin/master' into serve-dev
cblmemo Oct 24, 2023
cbfa389
upd schema
cblmemo Oct 24, 2023
3bd6c8c
change to async function for fastapi
cblmemo Oct 27, 2023
f97bd5b
add multiple ports TODO
cblmemo Nov 1, 2023
8773d0c
fix outdated example
cblmemo Nov 2, 2023
2008590
[SkyServe] Serving with Spot (#2749)
MaoZiming Nov 2, 2023
ad40472
fix sky status pool wait
cblmemo Nov 3, 2023
b5557bb
fix sync down logs failed
cblmemo Nov 3, 2023
8414ea7
upd examples
cblmemo Nov 4, 2023
f6c3d70
add gorilla notebook
cblmemo Nov 4, 2023
d036560
add todo for customizable setup commands
cblmemo Nov 5, 2023
8327a2e
add launch log to streaming
cblmemo Nov 7, 2023
6f3f809
move comment position
cblmemo Nov 7, 2023
f52ebb0
catch error and print log
cblmemo Nov 7, 2023
8377b8a
align output
cblmemo Nov 7, 2023
114e751
ux
cblmemo Nov 7, 2023
30b36ba
fix storage cleanup failure
cblmemo Nov 7, 2023
74c83af
fix extra newline
cblmemo Nov 8, 2023
d18badb
comments
cblmemo Nov 8, 2023
c4b8b24
Apply suggestions from code review
cblmemo Nov 8, 2023
e241aff
rename
cblmemo Nov 8, 2023
6ba5c9f
Update sky/core.py
cblmemo Nov 8, 2023
8ffe0be
apply suggestion from code review
cblmemo Nov 8, 2023
bb0542c
apply suggestion from code review
cblmemo Nov 9, 2023
330b893
format
cblmemo Nov 9, 2023
2aa266b
move controller related functions/classes to controller_utils
cblmemo Nov 9, 2023
a521615
apply suggestion from code review
cblmemo Nov 9, 2023
191d2ff
Update sky/exceptions.py
cblmemo Nov 9, 2023
61774bc
Update sky/serve/replica_managers.py
cblmemo Nov 9, 2023
e38fc17
import
cblmemo Nov 9, 2023
01bbac7
Update sky/serve/autoscalers.py
cblmemo Nov 9, 2023
9a198b0
move max #sky.launch to replica manager and limit total # across serv…
cblmemo Nov 9, 2023
4ae8996
refactor autoscaler
cblmemo Nov 9, 2023
84a4120
pass json dict rather than pickle
cblmemo Nov 9, 2023
b6ef448
apply suggestion from code review
cblmemo Nov 9, 2023
d598ed4
Apply suggestions from code review
cblmemo Nov 9, 2023
5170225
apply suggestion from code review
cblmemo Nov 10, 2023
8cea486
bug fix & apply suggestion from code review
cblmemo Nov 10, 2023
8711f45
apply suggestions
cblmemo Nov 10, 2023
6181497
comments
cblmemo Nov 10, 2023
2c0f3c8
move port to resources
cblmemo Nov 10, 2023
f2b4c29
add cancel test
cblmemo Nov 10, 2023
b68a1fd
fix controller resources cloud not specified
cblmemo Nov 10, 2023
81a88d2
ux
cblmemo Nov 10, 2023
3ba4f99
ux for down
cblmemo Nov 10, 2023
f68242c
add smoke retry teardown
cblmemo Nov 10, 2023
c7183c7
Merge remote-tracking branch 'origin/master' into serve-dev
cblmemo Nov 10, 2023
122de45
resolve conflict
cblmemo Nov 10, 2023
33bd321
add endpoint, move check for name conflict to _execute
cblmemo Nov 10, 2023
4ff9975
apply suggestion from code review
cblmemo Nov 11, 2023
7cff543
fix jinja2 var
cblmemo Nov 11, 2023
aff8250
rename reserved cluster, move controller_utils function back
cblmemo Nov 11, 2023
869eb75
stream logs
cblmemo Nov 11, 2023
9e5c69e
fix not showing controller
cblmemo Nov 11, 2023
d14b5cf
move controllers back to controller_utils
cblmemo Nov 12, 2023
e0049bf
fix wrong controller resources when controller is exist
cblmemo Nov 12, 2023
f2eaabc
use return value to indicate success
cblmemo Nov 12, 2023
86f6d5f
default controller resources & better error handling
cblmemo Nov 12, 2023
9b812d2
stress test passed
cblmemo Nov 12, 2023
78ac155
nits
cblmemo Nov 13, 2023
d3ed24a
Merge remote-tracking branch 'origin/master' into serve-dev
cblmemo Nov 13, 2023
7a25afa
fix examples
cblmemo Nov 13, 2023
0a2d4bd
Merge remote-tracking branch 'origin/master' into serve-dev
cblmemo Nov 14, 2023
8352aff
refactor: moving some funcs in execution.py to controller_utils
cblmemo Nov 14, 2023
0c8b734
smoke test passed
cblmemo Nov 14, 2023
9c67cd0
remove --target & minor
cblmemo Nov 14, 2023
fa20443
teardown failed services with --purge flag
cblmemo Nov 14, 2023
7793833
move core api to sky/serve/api.py
cblmemo Nov 14, 2023
e87042a
resolve controller_utils circular import
cblmemo Nov 14, 2023
a276a8f
fix spot config
cblmemo Nov 14, 2023
6889119
minor ux
cblmemo Nov 14, 2023
85a1bb0
add todo for default argument for sky serve logs
cblmemo Nov 15, 2023
bcc05ba
resolve circular import.
cblmemo Nov 15, 2023
e3f1f33
fix all circular import
cblmemo Nov 15, 2023
e91b60e
minor
cblmemo Nov 15, 2023
a60be5a
apply suggestion from code review
cblmemo Nov 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions sky/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def get_git_commit():
from sky.core import download_logs
from sky.core import job_status
from sky.core import queue
from sky.core import serve_down
from sky.core import spot_cancel
from sky.core import spot_queue
from sky.core import spot_status
Expand All @@ -65,7 +64,6 @@ def get_git_commit():
from sky.data import StoreType
from sky.execution import exec # pylint: disable=redefined-builtin
from sky.execution import launch
from sky.execution import serve_up
from sky.execution import spot_launch
from sky.optimizer import Optimizer
from sky.optimizer import OptimizeTarget
Expand Down Expand Up @@ -116,7 +114,6 @@ def get_git_commit():
'launch',
'exec',
'spot_launch',
'serve_up',
# core APIs
'status',
'start',
Expand All @@ -137,6 +134,4 @@ def get_git_commit():
# core APIs Storage Management
'storage_ls',
'storage_delete',
# core APIs Serve Management
'serve_down',
]
2 changes: 1 addition & 1 deletion sky/backends/cloud_vm_ray_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -4917,7 +4917,7 @@ def _execute_task_n_nodes(self, handle: CloudVmRayResourceHandle,
env_vars=task.envs,
task_name=task.name,
job_run_id=job_run_id,
ray_resources_dict=resources_dict,
ray_resources_dict=backend_utils.get_task_demands_dict(task),
log_dir=log_dir,
gang_scheduling_id=i,
use_sudo=use_sudo,
Expand Down
80 changes: 29 additions & 51 deletions sky/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1692,7 +1692,7 @@ def _get_services(service_names: Optional[List[str]],
if not service_names:
# Change empty list to None
service_names = None
service_records = core.serve_status(service_names)
service_records = sky.serve.status(service_names)
cblmemo marked this conversation as resolved.
Show resolved Hide resolved
num_services = len(service_records)
except exceptions.ClusterNotUpError as e:
controller_status = e.cluster_status
Expand Down Expand Up @@ -1721,9 +1721,9 @@ def _get_services(service_names: Optional[List[str]],
f'{service_num} service{plural} found. Please specify '
'an existing service to show its endpoint. Usage: '
'sky serve status --endpoint <service-name>')
msg = status_utils.get_endpoint(service_records[0])
msg = serve_lib.get_endpoint(service_records[0])
else:
msg = status_utils.format_service_table(service_records, show_all)
msg = serve_lib.format_service_table(service_records, show_all)
service_not_found_msg = ''
if service_names is not None:
for service_name in service_names:
Expand Down Expand Up @@ -2863,7 +2863,7 @@ def _hint_or_raise_for_down_sky_serve_controller(controller_name: str):
with rich_utils.safe_status(
'[bold cyan]Checking for running services[/]'):
try:
services = core.serve_status()
services = sky.serve.status()
except exceptions.ClusterNotUpError:
cluster_status = backend_utils.refresh_cluster_status_handle(
controller_name)
Expand Down Expand Up @@ -4243,7 +4243,6 @@ def serve_up(

sky serve up service.yaml
"""
# TODO(tian): Update the example after we move the ports to resources.
if service_name is None:
service_name = serve_lib.generate_service_name()

Expand Down Expand Up @@ -4283,7 +4282,7 @@ def serve_up(
if prompt is not None:
click.confirm(prompt, default=True, abort=True, show_default=True)

sky.serve_up(task, service_name)
sky.serve.up(task, service_name)


@serve.command('status', cls=_DocumentedCodeCommand)
Expand Down Expand Up @@ -4410,14 +4409,19 @@ def serve_status(all: bool, endpoint: bool, service_names: List[str]):
default=False,
is_flag=True,
help='Tear down all services.')
@click.option('--purge',
'-p',
default=False,
is_flag=True,
help='Tear down services in failed status.')
@click.option('--yes',
'-y',
is_flag=True,
default=False,
required=False,
help='Skip confirmation prompt.')
# pylint: disable=redefined-builtin
def serve_down(service_names: List[str], all: bool, yes: bool):
def serve_down(service_names: List[str], all: bool, purge: bool, yes: bool):
"""Teardown service(s).

SERVICE_NAMES is the name of the service (or glob pattern) to tear down. If
Expand All @@ -4441,7 +4445,9 @@ def serve_down(service_names: List[str], all: bool, yes: bool):
\b
# Tear down all existing services.
sky serve down -a

\b
# Forcefully tear down a service in failed status.
sky serve down failed-service --purge
"""
if sum([len(service_names) > 0, all]) != 1:
argument_str = f'SERVICE_NAMES={",".join(service_names)}' if len(
Expand All @@ -4468,7 +4474,7 @@ def serve_down(service_names: List[str], all: bool, yes: bool):
abort=True,
show_default=True)

sky.serve_down(service_names=service_names, all=all)
sky.serve.down(service_names=service_names, all=all, purge=purge)


@serve.command('logs', cls=_DocumentedCodeCommand)
Expand All @@ -4488,22 +4494,17 @@ def serve_down(service_names: List[str], all: bool, yes: bool):
default=False,
required=False,
help='Show the load balancer logs of this service.')
@click.option('--target',
default=None,
type=click.Choice(['controller', 'load-balancer', 'replica'],
case_sensitive=False),
required=False,
help='Target to stream logs.')
@click.argument('service_name', required=True, type=str)
@click.argument('replica_id', required=False, type=int)
@usage_lib.entrypoint
# TODO(tian): Add default argument for this CLI if none of the flags are
# specified.
def serve_logs(
service_name: str,
follow: bool,
controller: bool,
load_balancer: bool,
replica_id: Optional[int],
target: Optional[str],
):
"""Tail the log of a service.

Expand All @@ -4512,58 +4513,35 @@ def serve_logs(
.. code-block:: bash

# Tail the controller logs of a service
sky serve logs --controller [SERVICE_ID]
sky serve logs --controller [SERVICE_NAME]
\b
# Print the load balancer logs so far and exit
sky serve logs --load-balancer --no-follow [SERVICE_ID]
sky serve logs --load-balancer --no-follow [SERVICE_NAME]
\b
# Tail the logs of replica 1
sky serve logs [SERVICE_ID] 1
\b
# Specify target to stream logs by `--target` is also supported
sky serve logs --target controller [SERVICE_ID]
sky serve logs --target load-balancer [SERVICE_ID]
sky serve logs --target replica [SERVICE_ID] 1
\b
# If both --target and --controller/--load-balancer are specified,
# --controller/--load-balancer takes precedence.
# Tail the controller logs of a service:
sky serve logs --controller --target load-balancer [SERVICE_ID]
sky serve logs [SERVICE_NAME] 1
"""
have_replica_id = replica_id is not None
num_flags = (controller + load_balancer + have_replica_id)
if num_flags > 1:
raise click.UsageError('At most one of --controller, --load-balancer, '
'[REPLICA_ID] can be specified.')
if num_flags == 0 and target is None:
raise click.UsageError(
'One of --controller, --load-balancer, [REPLICA_ID] or --target '
'must be specified.')
if num_flags == 0:
raise click.UsageError('One of --controller, --load-balancer, '
'[REPLICA_ID] must be specified.')
if controller:
if target is not None:
click.secho(f'Overriding --target={target} with --controller.',
fg='yellow')
target_component = serve_lib.ServiceComponent.CONTROLLER
elif load_balancer:
if target is not None:
click.secho(f'Overriding --target={target} with --load-balancer.',
fg='yellow')
target_component = serve_lib.ServiceComponent.LOAD_BALANCER
elif target is not None:
# Change load-balancer to load_balancer to match the enum.
target = target.replace('-', '_')
target_component = serve_lib.ServiceComponent(target)
if (target_component == serve_lib.ServiceComponent.REPLICA and
not have_replica_id):
raise click.UsageError(
'REPLICA_ID must be specified when using --target replica.')
else:
# Already checked that num_flags == 1.
assert replica_id is not None
target_component = serve_lib.ServiceComponent.REPLICA
try:
core.serve_tail_logs(service_name,
target=target_component,
replica_id=replica_id,
follow=follow)
sky.serve.tail_logs(service_name,
target=target_component,
replica_id=replica_id,
follow=follow)
except exceptions.ClusterNotUpError:
# Hint messages already printed by the call above.
sys.exit(1)
Expand Down
Loading