Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions torchx/util/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@

# pyre-strict

import os
import uuid
from typing import Optional

TORCHX_INTERNAL_SESSION_ID = "TORCHX_INTERNAL_SESSION_ID"

CURRENT_SESSION_ID: Optional[str] = None


Expand All @@ -22,6 +25,10 @@ def get_session_id_or_create_new() -> str:
global CURRENT_SESSION_ID
if CURRENT_SESSION_ID:
return CURRENT_SESSION_ID
env_session_id = os.getenv(TORCHX_INTERNAL_SESSION_ID)
if env_session_id:
CURRENT_SESSION_ID = env_session_id
return CURRENT_SESSION_ID
session_id = str(uuid.uuid4())
CURRENT_SESSION_ID = session_id
return session_id
Expand Down
Loading