@@ -1379,12 +1379,14 @@ def exec(cluster: Optional[str], cluster_option: Optional[str],
1379
1379
def _handle_jobs_queue_request (
1380
1380
request_id : str ,
1381
1381
show_all : bool ,
1382
+ show_user : bool ,
1382
1383
limit_num_jobs_to_show : bool = False ,
1383
1384
is_called_by_user : bool = False ) -> Tuple [Optional [int ], str ]:
1384
1385
"""Get the in-progress managed jobs.
1385
1386
1386
1387
Args:
1387
1388
show_all: Show all information of each job (e.g., region, price).
1389
+ show_user: Show the user who submitted the job.
1388
1390
limit_num_jobs_to_show: If True, limit the number of jobs to show to
1389
1391
_NUM_MANAGED_JOBS_TO_SHOW_IN_STATUS, which is mainly used by
1390
1392
`sky status`.
@@ -1452,6 +1454,7 @@ def _handle_jobs_queue_request(
1452
1454
if limit_num_jobs_to_show else None )
1453
1455
msg = managed_jobs .format_job_table (managed_jobs_ ,
1454
1456
show_all = show_all ,
1457
+ show_user = show_user ,
1455
1458
max_jobs = max_jobs_to_show )
1456
1459
return num_in_progress_jobs , msg
1457
1460
@@ -1561,7 +1564,9 @@ def _status_kubernetes(show_all: bool):
1561
1564
click .echo (f'\n { colorama .Fore .CYAN } { colorama .Style .BRIGHT } '
1562
1565
f'Managed jobs'
1563
1566
f'{ colorama .Style .RESET_ALL } ' )
1564
- msg = managed_jobs .format_job_table (all_jobs , show_all = show_all )
1567
+ msg = managed_jobs .format_job_table (all_jobs ,
1568
+ show_all = show_all ,
1569
+ show_user = False )
1565
1570
click .echo (msg )
1566
1571
if any (['sky-serve-controller' in c .cluster_name for c in all_clusters ]):
1567
1572
# TODO: Parse serve controllers and show services separately.
@@ -1779,7 +1784,8 @@ def status(verbose: bool, refresh: bool, ip: bool, endpoints: bool,
1779
1784
show_managed_jobs = show_managed_jobs and not any ([clusters , ip , endpoints ])
1780
1785
if show_managed_jobs :
1781
1786
managed_jobs_queue_request_id = managed_jobs .queue (refresh = False ,
1782
- skip_finished = True )
1787
+ skip_finished = True ,
1788
+ all_users = all_users )
1783
1789
show_endpoints = endpoints or endpoint is not None
1784
1790
show_single_endpoint = endpoint is not None
1785
1791
show_services = show_services and not any ([clusters , ip , endpoints ])
@@ -1859,6 +1865,7 @@ def status(verbose: bool, refresh: bool, ip: bool, endpoints: bool,
1859
1865
num_in_progress_jobs , msg = _handle_jobs_queue_request (
1860
1866
managed_jobs_queue_request_id ,
1861
1867
show_all = False ,
1868
+ show_user = False ,
1862
1869
limit_num_jobs_to_show = not all ,
1863
1870
is_called_by_user = False )
1864
1871
except KeyboardInterrupt :
@@ -2751,7 +2758,7 @@ def start(
2751
2758
def down (
2752
2759
clusters : List [str ],
2753
2760
all : bool , # pylint: disable=redefined-builtin
2754
- all_users : bool , # pylint: disable=redefined-builtin
2761
+ all_users : bool ,
2755
2762
yes : bool ,
2756
2763
purge : bool ,
2757
2764
async_call : bool ,
@@ -2812,7 +2819,9 @@ def _hint_or_raise_for_down_jobs_controller(controller_name: str,
2812
2819
with rich_utils .client_status (
2813
2820
'[bold cyan]Checking for in-progress managed jobs[/]' ):
2814
2821
try :
2815
- request_id = managed_jobs .queue (refresh = False , skip_finished = True )
2822
+ request_id = managed_jobs .queue (refresh = False ,
2823
+ skip_finished = True ,
2824
+ all_users = True )
2816
2825
managed_jobs_ = sdk .stream_and_get (request_id )
2817
2826
except exceptions .ClusterNotUpError as e :
2818
2827
if controller .value .connection_error_hint in str (e ):
@@ -2836,7 +2845,9 @@ def _hint_or_raise_for_down_jobs_controller(controller_name: str,
2836
2845
'jobs (output of `sky jobs queue`) will be lost.' )
2837
2846
click .echo (msg )
2838
2847
if managed_jobs_ :
2839
- job_table = managed_jobs .format_job_table (managed_jobs_ , show_all = False )
2848
+ job_table = managed_jobs .format_job_table (managed_jobs_ ,
2849
+ show_all = False ,
2850
+ show_user = True )
2840
2851
msg = controller .value .decline_down_for_dirty_controller_hint
2841
2852
# Add prefix to each line to align with the bullet point.
2842
2853
msg += '\n ' .join (
@@ -3905,9 +3916,16 @@ def jobs_launch(
3905
3916
is_flag = True ,
3906
3917
required = False ,
3907
3918
help = 'Show only pending/running jobs\' information.' )
3919
+ @click .option ('--all-users' ,
3920
+ '-u' ,
3921
+ default = False ,
3922
+ is_flag = True ,
3923
+ required = False ,
3924
+ help = 'Show jobs from all users.' )
3908
3925
@usage_lib .entrypoint
3909
3926
# pylint: disable=redefined-builtin
3910
- def jobs_queue (verbose : bool , refresh : bool , skip_finished : bool ):
3927
+ def jobs_queue (verbose : bool , refresh : bool , skip_finished : bool ,
3928
+ all_users : bool ):
3911
3929
"""Show statuses of managed jobs.
3912
3930
3913
3931
Each managed jobs can have one of the following statuses:
@@ -3964,9 +3982,10 @@ def jobs_queue(verbose: bool, refresh: bool, skip_finished: bool):
3964
3982
click .secho ('Fetching managed job statuses...' , fg = 'cyan' )
3965
3983
with rich_utils .client_status ('[cyan]Checking managed jobs[/]' ):
3966
3984
managed_jobs_request_id = managed_jobs .queue (
3967
- refresh = refresh , skip_finished = skip_finished )
3985
+ refresh = refresh , skip_finished = skip_finished , all_users = all_users )
3968
3986
_ , msg = _handle_jobs_queue_request (managed_jobs_request_id ,
3969
3987
show_all = verbose ,
3988
+ show_user = all_users ,
3970
3989
is_called_by_user = True )
3971
3990
if not skip_finished :
3972
3991
in_progress_only_hint = ''
@@ -3989,16 +4008,23 @@ def jobs_queue(verbose: bool, refresh: bool, skip_finished: bool):
3989
4008
is_flag = True ,
3990
4009
default = False ,
3991
4010
required = False ,
3992
- help = 'Cancel all managed jobs.' )
4011
+ help = 'Cancel all managed jobs for the current user .' )
3993
4012
@click .option ('--yes' ,
3994
4013
'-y' ,
3995
4014
is_flag = True ,
3996
4015
default = False ,
3997
4016
required = False ,
3998
4017
help = 'Skip confirmation prompt.' )
4018
+ @click .option ('--all-users' ,
4019
+ '-u' ,
4020
+ is_flag = True ,
4021
+ default = False ,
4022
+ required = False ,
4023
+ help = 'Cancel all managed jobs from all users.' )
3999
4024
@usage_lib .entrypoint
4000
4025
# pylint: disable=redefined-builtin
4001
- def jobs_cancel (name : Optional [str ], job_ids : Tuple [int ], all : bool , yes : bool ):
4026
+ def jobs_cancel (name : Optional [str ], job_ids : Tuple [int ], all : bool , yes : bool ,
4027
+ all_users : bool ):
4002
4028
"""Cancel managed jobs.
4003
4029
4004
4030
You can provide either a job name or a list of job IDs to be cancelled.
@@ -4015,25 +4041,33 @@ def jobs_cancel(name: Optional[str], job_ids: Tuple[int], all: bool, yes: bool):
4015
4041
$ sky jobs cancel 1 2 3
4016
4042
"""
4017
4043
job_id_str = ',' .join (map (str , job_ids ))
4018
- if sum ([bool (job_ids ), name is not None , all ]) != 1 :
4019
- argument_str = f'--job-ids { job_id_str } ' if job_ids else ''
4020
- argument_str += f' --name { name } ' if name is not None else ''
4021
- argument_str += ' --all' if all else ''
4044
+ if sum ([bool (job_ids ), name is not None , all , all_users ]) != 1 :
4045
+ arguments = []
4046
+ arguments += [f'--job-ids { job_id_str } ' ] if job_ids else []
4047
+ arguments += [f'--name { name } ' ] if name is not None else []
4048
+ arguments += ['--all' ] if all else []
4049
+ arguments += ['--all-users' ] if all_users else []
4022
4050
raise click .UsageError (
4023
4051
'Can only specify one of JOB_IDS or --name or --all. '
4024
- f'Provided { argument_str !r} .' )
4052
+ f'Provided { " " . join ( arguments ) !r} .' )
4025
4053
4026
4054
if not yes :
4027
4055
job_identity_str = (f'managed jobs with IDs { job_id_str } '
4028
4056
if job_ids else repr (name ))
4029
4057
if all :
4030
4058
job_identity_str = 'all managed jobs'
4059
+ if all_users :
4060
+ job_identity_str = 'all managed jobs FOR ALL USERS'
4031
4061
click .confirm (f'Cancelling { job_identity_str } . Proceed?' ,
4032
4062
default = True ,
4033
4063
abort = True ,
4034
4064
show_default = True )
4035
4065
4036
- sdk .stream_and_get (managed_jobs .cancel (job_ids = job_ids , name = name , all = all ))
4066
+ sdk .stream_and_get (
4067
+ managed_jobs .cancel (job_ids = job_ids ,
4068
+ name = name ,
4069
+ all = all ,
4070
+ all_users = all_users ))
4037
4071
4038
4072
4039
4073
@jobs .command ('logs' , cls = _DocumentedCodeCommand )
0 commit comments