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

Commit

Permalink
feat: Add support for SCHEDULED status (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
achimnol committed May 5, 2021
1 parent b324992 commit b0df6da
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions changes/161.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for the `SCHEDULED` status in `ps` (including `admin sessions`), `run`, and `start` commands
8 changes: 5 additions & 3 deletions src/ai/backend/client/cli/admin/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def transform_fields(item: SessionItem, *, in_row: bool = True) -> SessionItem:
@admin.command()
@click.option('-s', '--status', default=None,
type=click.Choice([
'PENDING',
'PENDING', 'SCHEDULED',
'PREPARING', 'BUILDING', 'RUNNING', 'RESTARTING',
'RESIZING', 'SUSPENDED', 'TERMINATING',
'TERMINATED', 'ERROR', 'CANCELLED',
Expand Down Expand Up @@ -142,7 +142,8 @@ def sessions(status, access_key, name_only, dead, running, detail, plain, format

no_match_name = None
if status is None:
status = 'PENDING,PREPARING,PULLING,RUNNING,RESTARTING,TERMINATING,RESIZING,SUSPENDED,ERROR'
status = ('PENDING,SCHEDULED,PREPARING,PULLING,RUNNING,RESTARTING,TERMINATING,'
'RESIZING,SUSPENDED,ERROR')
no_match_name = 'active'
if running:
status = 'PREPARING,PULLING,RUNNING'
Expand All @@ -151,7 +152,8 @@ def sessions(status, access_key, name_only, dead, running, detail, plain, format
status = 'CANCELLED,TERMINATED'
no_match_name = 'dead'
if status == 'ALL':
status = ('PENDING,PREPARING,PULLING,RUNNING,RESTARTING,TERMINATING,RESIZING,SUSPENDED,ERROR,'
status = ('PENDING,SCHEDULED,PREPARING,PULLING,RUNNING,RESTARTING,TERMINATING,'
'RESIZING,SUSPENDED,ERROR,'
'CANCELLED,TERMINATED')
no_match_name = 'in any status'
if no_match_name is None:
Expand Down
2 changes: 1 addition & 1 deletion src/ai/backend/client/cli/ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@main.command()
@click.option('-s', '--status', default=None,
type=click.Choice([
'PENDING',
'PENDING', 'SCHEDULED',
'PREPARING', 'BUILDING', 'RUNNING', 'RESTARTING',
'RESIZING', 'SUSPENDED', 'TERMINATING',
'TERMINATED', 'ERROR', 'CANCELLED',
Expand Down
16 changes: 16 additions & 0 deletions src/ai/backend/client/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,10 @@ def _run_legacy(session, idx, name, envs,
print_info('Session ID {0} is enqueued for scheduling.'
.format(name))
return
elif compute_session.status == 'SCHEDULED':
print_info('Session ID {0} is scheduled and about to be started.'
.format(name))
return
elif compute_session.status == 'RUNNING':
if compute_session.created:
vprint_done(
Expand Down Expand Up @@ -602,6 +606,10 @@ async def _run(session, idx, name, envs,
print_info('Session ID {0} is enqueued for scheduling.'
.format(name))
return
elif compute_session.status == 'SCHEDULED':
print_info('Session ID {0} is scheduled and about to be started.'
.format(name))
return
elif compute_session.status == 'RUNNING':
if compute_session.created:
vprint_done(
Expand Down Expand Up @@ -888,6 +896,10 @@ def start(image, name, owner, # base args
if compute_session.status == 'PENDING':
print_info('Session ID {0} is enqueued for scheduling.'
.format(compute_session.id))
elif compute_session.status == 'SCHEDULED':
print_info('Session ID {0} is scheduled and about to be started.'
.format(compute_session.id))
return
elif compute_session.status == 'RUNNING':
if compute_session.created:
print_info('Session ID {0} is created and ready.'
Expand Down Expand Up @@ -1055,6 +1067,10 @@ def start_template(
if compute_session.status == 'PENDING':
print_info('Session ID {0} is enqueued for scheduling.'
.format(name))
elif compute_session.status == 'SCHEDULED':
print_info('Session ID {0} is scheduled and about to be started.'
.format(name))
return
elif compute_session.status == 'RUNNING':
if compute_session.created:
print_info('Session ID {0} is created and ready.'
Expand Down

0 comments on commit b0df6da

Please sign in to comment.