Skip to content

Commit

Permalink
fix: Fill vfolder user and group field (#1837)
Browse files Browse the repository at this point in the history
Co-authored-by: Kyujin Cho <[email protected]>
  • Loading branch information
fregataa and kyujin-cho authored Jan 12, 2024
1 parent 7668404 commit 1f4c652
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions changes/1837.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix `vfolder_list` GQL query not returning `user_email` and `groups_name` field
10 changes: 8 additions & 2 deletions src/ai/backend/manager/models/vfolder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1123,15 +1123,21 @@ def from_row(cls, ctx: GraphQueryContext, row: Row | VFolderRow) -> Optional[Vir
if row is None:
return None

def _get_field(name: str) -> Any:
try:
return row[name]
except sa.exc.NoSuchColumnError:
return None

return cls(
id=row["id"],
host=row["host"],
quota_scope_id=row["quota_scope_id"],
name=row["name"],
user=row["user"],
user_email=row["users_email"] if "users_email" in row else None,
user_email=_get_field("users_email"),
group=row["group"],
group_name=row["groups_name"] if "groups_name" in row else None,
group_name=_get_field("groups_name"),
creator=row["creator"],
unmanaged_path=row["unmanaged_path"],
usage_mode=row["usage_mode"],
Expand Down

0 comments on commit 1f4c652

Please sign in to comment.