MCPcopy Create free account
hub / github.com/AgentOps-AI/agentops / get_imported_libraries

Function get_imported_libraries

agentops/helpers/system.py:13–50  ·  view source on GitHub ↗

Get the top-level imported libraries in the current script. Returns: list: List of imported libraries

()

Source from the content-addressed store, hash-verified

11
12
13def get_imported_libraries():
14 """
15 Get the top-level imported libraries in the current script.
16
17 Returns:
18 list: List of imported libraries
19 """
20 user_libs = []
21
22 builtin_modules = {
23 "builtins",
24 "sys",
25 "os",
26 "_thread",
27 "abc",
28 "io",
29 "re",
30 "types",
31 "collections",
32 "enum",
33 "math",
34 "datetime",
35 "time",
36 "warnings",
37 }
38
39 try:
40 main_module = sys.modules.get("__main__")
41 if main_module and hasattr(main_module, "__dict__"):
42 for name, obj in main_module.__dict__.items():
43 if isinstance(obj, type(sys)) and hasattr(obj, "__name__"):
44 mod_name = obj.__name__.split(".")[0]
45 if mod_name and not mod_name.startswith("_") and mod_name not in builtin_modules:
46 user_libs.append(mod_name)
47 except Exception as e:
48 logger.debug(f"Error getting imports: {e}")
49
50 return user_libs
51
52
53def get_sdk_details():

Callers 1

Calls 1

getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…