We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2045cfa commit ebdcfd4Copy full SHA for ebdcfd4
sagemaker_ssh_helper/env.py
@@ -1,5 +1,6 @@
1
import json
2
import os
3
+from typing import List
4
5
6
def sm_get_node_rank():
@@ -15,3 +16,15 @@ def sm_get_node_rank():
15
16
rc = json.load(json_file)
17
18
return int(rc["hosts"].index(rc["current_host"]))
19
+
20
21
+def get_caller_script_name(trace_back=1):
22
+ import inspect
23
+ from inspect import FrameInfo
24
+ from pathlib import Path
25
26
+ stack: List[FrameInfo] = inspect.stack()
27
+ if len(stack) < 2:
28
+ raise AssertionError("Cannot fetch stack trace")
29
30
+ return Path(stack[trace_back].filename).name
0 commit comments