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

Commit 4196520

Browse files
authored
Support session UUID prefix queries (#92)
* refs lablup/backend.ai-manager#258 * feat: Show candidate matches for too-many-sessions-matched error * fix: Apply renaming of the template-based session creation API
1 parent 0cc688e commit 4196520

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,17 @@ def format_error(exc: Exception):
105105
yield '{0}: {1} {2}\n'.format(exc.__class__.__name__,
106106
exc.status, exc.reason)
107107
yield '{0[title]}'.format(exc.data)
108-
other_details = exc.data.get('data', None)
109-
if other_details:
110-
yield '\n\u279c Error details: '
111-
yield str(other_details)
108+
if exc.data['type'].endswith('/too-many-sessions-matched'):
109+
matches = exc.data['data'].get('matches', [])
110+
if matches:
111+
yield '\nCandidates (up to 10 recent entries):\n'
112+
for item in matches:
113+
yield '- {0} ({1}, {2})\n'.format(item['id'], item['name'], item['status'])
114+
else:
115+
other_details = exc.data.get('data', None)
116+
if other_details:
117+
yield '\n\u279c Error details: '
118+
yield str(other_details)
112119
agent_details = exc.data.get('agent-details', None)
113120
if agent_details is not None:
114121
yield '\n\u279c This is an agent-side error. '

src/ai/backend/client/func/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ async def create_from_template(cls, template_id: str, *,
321321
if cls.session.config.vfolder_mounts:
322322
mounts.extend(cls.session.config.vfolder_mounts)
323323
prefix = get_naming(cls.session.api_version, 'path')
324-
rqst = Request(cls.session, 'POST', f'/{prefix}/from-template')
324+
rqst = Request(cls.session, 'POST', f'/{prefix}/_/create-from-template')
325325
params = {
326326
'template_id': template_id,
327327
'tag': tag,

0 commit comments

Comments
 (0)