Invoker Utils
Helpers for locating LM invokers inside metric object graphs.
iter_invokers(obj, seen=None, depth=0)
Yield each BaseLMInvoker (not BaseDMInvoker) reachable from obj, once.
Descends into list/tuple/set/dict values, the root's attributes, and attributes of gllm*
objects. Does not descend into an invoker, into objects already seen, or past
_MAX_INVOKER_SEARCH_DEPTH levels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object (or container) to search. |
required |
seen
|
set[int] | None
|
Ids of objects already visited, mutated in place as the walk proceeds. Defaults to a new set. |
None
|
depth
|
int
|
Current recursion depth. Defaults to 0. |
0
|
Yields:
| Name | Type | Description |
|---|---|---|
BaseLMInvoker |
BaseLMInvoker
|
Each uniquely reachable invoker instance. |