Skip to content

Commit

Permalink
Allow setting torchx session id from cmd (#967) (#967)
Browse files Browse the repository at this point in the history
Summary:

This will be used by e2e test to locate the test runs and retrieve metrics for comparison.

Differential Revision: D64678003
  • Loading branch information
hstonec authored Oct 21, 2024
1 parent af5acd6 commit b6b9450
Showing 1 changed file with 7 additions and 0 deletions.
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

0 comments on commit b6b9450

Please sign in to comment.