-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create session id and use it in table 'Pytorch Elastic Tsm Log' (#953)
Summary: Pull Request resolved: #953 Please read the doc to understand why we create the session id: https://docs.google.com/document/d/1WJBrqSHrNIc9J1W_1PMIQPu11y2fV_hU36aeiBTgN90/edit Differential Revision: D62087199
- Loading branch information
1 parent
66733b7
commit 47833f9
Showing
5 changed files
with
86 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
# pyre-strict | ||
|
||
import uuid | ||
from typing import Optional | ||
|
||
_CURRENT_SESSION_ID: Optional[str] = None | ||
|
||
|
||
def get_session_id_or_create_new() -> str: | ||
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_session_id() -> Optional[str]: | ||
return _CURRENT_SESSION_ID |