MCPcopy
hub / github.com/NVIDIA/TensorRT-LLM / get_current_location

Function get_current_location

tensorrt_llm/llmapi/utils.py:69–103  ·  view source on GitHub ↗

Get the current execution location in format 'module.class.function'. Args: skip_frames: Number of stack frames to skip (default 2 to skip this function and its caller) Returns: String in format 'module.class.function' or 'module.function' if not in a class

(skip_frames: int = 2)

Source from the content-addressed store, hash-verified

67
68
69def get_current_location(skip_frames: int = 2) -> str:
70 """
71 Get the current execution location in format 'module.class.function'.
72
73 Args:
74 skip_frames: Number of stack frames to skip (default 2 to skip this function and its caller)
75
76 Returns:
77 String in format 'module.class.function' or 'module.function' if not in a class
78 """
79 stack = inspect.stack()
80 if len(stack) <= skip_frames:
81 return "unknown"
82
83 frame = stack[skip_frames]
84 module_name = frame.frame.f_globals.get('__name__', 'unknown')
85 function_name = frame.function
86
87 # Try to determine if we're in a class method
88 class_name = None
89 if 'self' in frame.frame.f_locals:
90 # This is likely an instance method
91 obj = frame.frame.f_locals['self']
92 class_name = obj.__class__.__name__
93 elif 'cls' in frame.frame.f_locals:
94 # This might be a class method
95 cls = frame.frame.f_locals['cls']
96 if inspect.isclass(cls):
97 class_name = cls.__name__
98
99 # Build the location string
100 if class_name:
101 return f"{module_name}.{class_name}.{function_name}"
102 else:
103 return f"{module_name}.{function_name}"
104
105
106def logger_debug(message,

Callers 1

logger_debugFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected