Skip to content
This repository was archived by the owner on Sep 22, 2023. It is now read-only.

Commit b0df6da

Browse files
authored
feat: Add support for SCHEDULED status (#161)
1 parent b324992 commit b0df6da

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

changes/161.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add support for the `SCHEDULED` status in `ps` (including `admin sessions`), `run`, and `start` commands

src/ai/backend/client/cli/admin/sessions.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def transform_fields(item: SessionItem, *, in_row: bool = True) -> SessionItem:
6969
@admin.command()
7070
@click.option('-s', '--status', default=None,
7171
type=click.Choice([
72-
'PENDING',
72+
'PENDING', 'SCHEDULED',
7373
'PREPARING', 'BUILDING', 'RUNNING', 'RESTARTING',
7474
'RESIZING', 'SUSPENDED', 'TERMINATING',
7575
'TERMINATED', 'ERROR', 'CANCELLED',
@@ -142,7 +142,8 @@ def sessions(status, access_key, name_only, dead, running, detail, plain, format
142142

143143
no_match_name = None
144144
if status is None:
145-
status = 'PENDING,PREPARING,PULLING,RUNNING,RESTARTING,TERMINATING,RESIZING,SUSPENDED,ERROR'
145+
status = ('PENDING,SCHEDULED,PREPARING,PULLING,RUNNING,RESTARTING,TERMINATING,'
146+
'RESIZING,SUSPENDED,ERROR')
146147
no_match_name = 'active'
147148
if running:
148149
status = 'PREPARING,PULLING,RUNNING'
@@ -151,7 +152,8 @@ def sessions(status, access_key, name_only, dead, running, detail, plain, format
151152
status = 'CANCELLED,TERMINATED'
152153
no_match_name = 'dead'
153154
if status == 'ALL':
154-
status = ('PENDING,PREPARING,PULLING,RUNNING,RESTARTING,TERMINATING,RESIZING,SUSPENDED,ERROR,'
155+
status = ('PENDING,SCHEDULED,PREPARING,PULLING,RUNNING,RESTARTING,TERMINATING,'
156+
'RESIZING,SUSPENDED,ERROR,'
155157
'CANCELLED,TERMINATED')
156158
no_match_name = 'in any status'
157159
if no_match_name is None:

src/ai/backend/client/cli/ps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
@main.command()
88
@click.option('-s', '--status', default=None,
99
type=click.Choice([
10-
'PENDING',
10+
'PENDING', 'SCHEDULED',
1111
'PREPARING', 'BUILDING', 'RUNNING', 'RESTARTING',
1212
'RESIZING', 'SUSPENDED', 'TERMINATING',
1313
'TERMINATED', 'ERROR', 'CANCELLED',

src/ai/backend/client/cli/run.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,10 @@ def _run_legacy(session, idx, name, envs,
505505
print_info('Session ID {0} is enqueued for scheduling.'
506506
.format(name))
507507
return
508+
elif compute_session.status == 'SCHEDULED':
509+
print_info('Session ID {0} is scheduled and about to be started.'
510+
.format(name))
511+
return
508512
elif compute_session.status == 'RUNNING':
509513
if compute_session.created:
510514
vprint_done(
@@ -602,6 +606,10 @@ async def _run(session, idx, name, envs,
602606
print_info('Session ID {0} is enqueued for scheduling.'
603607
.format(name))
604608
return
609+
elif compute_session.status == 'SCHEDULED':
610+
print_info('Session ID {0} is scheduled and about to be started.'
611+
.format(name))
612+
return
605613
elif compute_session.status == 'RUNNING':
606614
if compute_session.created:
607615
vprint_done(
@@ -888,6 +896,10 @@ def start(image, name, owner, # base args
888896
if compute_session.status == 'PENDING':
889897
print_info('Session ID {0} is enqueued for scheduling.'
890898
.format(compute_session.id))
899+
elif compute_session.status == 'SCHEDULED':
900+
print_info('Session ID {0} is scheduled and about to be started.'
901+
.format(compute_session.id))
902+
return
891903
elif compute_session.status == 'RUNNING':
892904
if compute_session.created:
893905
print_info('Session ID {0} is created and ready.'
@@ -1055,6 +1067,10 @@ def start_template(
10551067
if compute_session.status == 'PENDING':
10561068
print_info('Session ID {0} is enqueued for scheduling.'
10571069
.format(name))
1070+
elif compute_session.status == 'SCHEDULED':
1071+
print_info('Session ID {0} is scheduled and about to be started.'
1072+
.format(name))
1073+
return
10581074
elif compute_session.status == 'RUNNING':
10591075
if compute_session.created:
10601076
print_info('Session ID {0} is created and ready.'

0 commit comments

Comments
 (0)