Skip to content

Commit

Permalink
expose torchx session ID to torchx downstream users.
Browse files Browse the repository at this point in the history
Differential Revision: D63655049

Pull Request resolved: #959
  • Loading branch information
yikaiMeta authored Oct 1, 2024
1 parent 94ac896 commit f5d25f0
Showing 1 changed file with 9 additions and 0 deletions.
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

0 comments on commit f5d25f0

Please sign in to comment.