Skip to content

Commit

Permalink
feat: Expose user info to session environment variables (#2043)
Browse files Browse the repository at this point in the history
  • Loading branch information
jopemachine committed Apr 22, 2024
1 parent f08911e commit 4f39048
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions changes/2043.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Expose user info to environment variables
13 changes: 13 additions & 0 deletions src/ai/backend/manager/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1449,7 +1449,20 @@ async def start_session(
Optional[ClusterSSHPortMapping], cluster_ssh_port_mapping
),
)

async with self.db.begin_readonly_session() as db_sess:
uuid, email, username = (
await db_sess.execute(
sa.select([UserRow.uuid, UserRow.email, UserRow.username]).where(
UserRow.uuid == scheduled_session.user_uuid
)
)
).fetchone()

scheduled_session.environ.update({
"BACKENDAI_USER_UUID": str(uuid),
"BACKENDAI_USER_EMAIL": email,
"BACKENDAI_USER_NAME": username,
"BACKENDAI_SESSION_ID": str(scheduled_session.id),
"BACKENDAI_SESSION_NAME": str(scheduled_session.name),
"BACKENDAI_CLUSTER_SIZE": str(scheduled_session.cluster_size),
Expand Down

0 comments on commit 4f39048

Please sign in to comment.