MCPcopy Index your code
hub / github.com/huggingface/diffusers / print_tree_deps_of

Function print_tree_deps_of

utils/tests_fetcher.py:660–690  ·  view source on GitHub ↗

Prints the tree of modules depending on a given module. Args: module (`str`): The module that will be the root of the subtree we want. all_edges (`List[Tuple[str, str]]`, *optional*): The list of all edges of the tree. Will be set to `create_reverse_dependency_t

(module, all_edges=None)

Source from the content-addressed store, hash-verified

658
659
660def print_tree_deps_of(module, all_edges=None):
661 """
662 Prints the tree of modules depending on a given module.
663
664 Args:
665 module (`str`): The module that will be the root of the subtree we want.
666 all_edges (`List[Tuple[str, str]]`, *optional*):
667 The list of all edges of the tree. Will be set to `create_reverse_dependency_tree()` if not passed.
668 """
669 if all_edges is None:
670 all_edges = create_reverse_dependency_tree()
671 tree = get_tree_starting_at(module, all_edges)
672
673 # The list of lines is a list of tuples (line_to_be_printed, module)
674 # Keeping the modules lets us know where to insert each new lines in the list.
675 lines = [(tree[0], tree[0])]
676 for index in range(1, len(tree)):
677 edges = tree[index]
678 start_edges = {edge[0] for edge in edges}
679
680 for start in start_edges:
681 end_edges = {edge[1] for edge in edges if edge[0] == start}
682 # We will insert all those edges just after the line showing start.
683 pos = 0
684 while lines[pos][1] != start:
685 pos += 1
686 lines = lines[: pos + 1] + [(" " * (2 * index) + end, end) for end in end_edges] + lines[pos + 1 :]
687
688 for line in lines:
689 # We don't print the refs that where just here to help build lines.
690 print(line[0])
691
692
693def init_test_examples_dependencies() -> Tuple[Dict[str, List[str]], List[str]]:

Callers 1

tests_fetcher.pyFile · 0.85

Calls 2

get_tree_starting_atFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…