Skip to content

Commit b6b9450

Browse files
authored
Allow setting torchx session id from cmd (#967) (#967)
Summary: This will be used by e2e test to locate the test runs and retrieve metrics for comparison. Differential Revision: D64678003
1 parent af5acd6 commit b6b9450

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

torchx/util/session.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77

88
# pyre-strict
99

10+
import os
1011
import uuid
1112
from typing import Optional
1213

14+
TORCHX_INTERNAL_SESSION_ID = "TORCHX_INTERNAL_SESSION_ID"
15+
1316
CURRENT_SESSION_ID: Optional[str] = None
1417

1518

@@ -22,6 +25,10 @@ def get_session_id_or_create_new() -> str:
2225
global CURRENT_SESSION_ID
2326
if CURRENT_SESSION_ID:
2427
return CURRENT_SESSION_ID
28+
env_session_id = os.getenv(TORCHX_INTERNAL_SESSION_ID)
29+
if env_session_id:
30+
CURRENT_SESSION_ID = env_session_id
31+
return CURRENT_SESSION_ID
2532
session_id = str(uuid.uuid4())
2633
CURRENT_SESSION_ID = session_id
2734
return session_id

0 commit comments

Comments
 (0)