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

Commit

Permalink
fix: desync of "info" command alias to "admin session" (#162)
Browse files Browse the repository at this point in the history
* setup: Update mypy and type annotation pkgs
  • Loading branch information
achimnol committed Jun 13, 2021
1 parent b0df6da commit 7bb98cf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions changes/162.fix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix desynchronized parameters of the `info` command alias of the `admin session` command
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@
'flake8>=3.8.4',
]
typecheck_requires = [
'mypy>=0.812',
'mypy>=0.901',
'types-click',
'types-python-dateutil',
'types-tabulate',
]
dev_requires: List[str] = [
# 'pytest-sugar>=0.9.1',
Expand Down
10 changes: 5 additions & 5 deletions src/ai/backend/client/cli/admin/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ def format_dependencies(dependencies: Sequence[Mapping[str, Any]], indent='') ->


@admin.command()
@click.argument('id_or_name', metavar='ID_OR_NAME')
def session(id_or_name):
@click.argument('session_id', metavar='SESSID')
def session(session_id):
'''
Show detailed information for a running compute session.
'''
Expand Down Expand Up @@ -257,7 +257,7 @@ def session(id_or_name):
q = 'query($name: String!) {' \
' compute_session(sess_id: $name) { $fields }' \
'}'
v = {'name': id_or_name}
v = {'name': session_id}
else:
# In API v5 or later, we can query any compute session both in the history
# and currently running using its UUID.
Expand Down Expand Up @@ -289,11 +289,11 @@ def session(id_or_name):
' }' \
'}'
try:
uuid.UUID(id_or_name)
uuid.UUID(session_id)
except ValueError:
print_fail("In API v5 or later, the session ID must be given in the UUID format.")
sys.exit(1)
v = {'id': id_or_name}
v = {'id': session_id}
q = q.replace('$fields', ' '.join(item[1] for item in fields))
try:
resp = session_.Admin.query(q, v)
Expand Down
6 changes: 2 additions & 4 deletions src/ai/backend/client/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -1177,11 +1177,9 @@ def restart(session_names):


@main.command()
@click.argument('session_name', metavar='NAME')
@click.option('-o', '--owner', '--owner-access-key', 'owner_access_key', metavar='ACCESS_KEY',
help='Specify the owner of the target session explicitly.')
@click.argument('session_id', metavar='SESSID')
@click.pass_context
def info(ctx, session_name, owner_access_key):
def info(ctx, session_id):
"""
Show detailed information for a running compute session.
This is an alias of the "admin session <sess_id>" command.
Expand Down

0 comments on commit 7bb98cf

Please sign in to comment.