Skip to content

Commit

Permalink
fix: Handle user creation failure when model-store does not exists (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
fregataa authored Jul 4, 2024
1 parent dd19d5b commit 4739d81
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions changes/2160.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix user creation error when any model-store does not exists.
11 changes: 8 additions & 3 deletions src/ai/backend/manager/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import enum
import logging
from typing import TYPE_CHECKING, Any, Dict, Iterable, Mapping, Optional, Sequence
from typing import TYPE_CHECKING, Any, Dict, Iterable, Mapping, Optional, Sequence, cast
from uuid import UUID, uuid4

import aiotools
Expand Down Expand Up @@ -662,8 +662,13 @@ async def _post_func(conn: SAConnection, result: Result) -> Row:
model_store_query = sa.select([groups.c.id]).where(
groups.c.type == ProjectType.MODEL_STORE
)
model_store_gid = (await conn.execute(model_store_query)).first()["id"]
gids_to_join = [*group_ids, model_store_gid]
model_store_project = cast(
dict[str, Any] | None, (await conn.execute(model_store_query)).first()
)
if model_store_project is not None:
gids_to_join = [*group_ids, model_store_project["id"]]
else:
gids_to_join = group_ids

# Add user to groups if group_ids parameter is provided.
if gids_to_join:
Expand Down

0 comments on commit 4739d81

Please sign in to comment.