Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose torchx session ID to torchx downstream users. #959

Merged
merged 1 commit into from
Oct 1, 2024
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
9 changes: 9 additions & 0 deletions torchx/util/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,19 @@ def get_session_id_or_create_new() -> str:
"""
Returns the current session ID, or creates a new one if none exists.
The session ID remains the same as long as it is in the same process.
Please DO NOT use this function out of torchx codebase.
"""
global CURRENT_SESSION_ID
if CURRENT_SESSION_ID:
return CURRENT_SESSION_ID
session_id = str(uuid.uuid4())
CURRENT_SESSION_ID = session_id
return session_id


def get_torchx_session_id() -> Optional[str]:
"""
Returns the torchx session ID.
Please use this function to get the session ID out of torchx codebase.
"""
return CURRENT_SESSION_ID
Loading