build_environment: only traverse unique edges (#48301)

Wrap EnvironmentVisitor in CoverEdgesVisitor so only unique edges are enqueued.

Co-authored-by: Harmen Stoppels <harmenstoppels@gmail.com>
This commit is contained in:
Wouter Deconinck 2025-01-03 05:17:26 -06:00 committed by GitHub
parent 0394def68b
commit e374f8fb66
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

View File

@ -923,7 +923,9 @@ def effective_deptypes(
in reverse so that dependents override dependencies, not the other way around."""
topo_sorted_edges = traverse.traverse_topo_edges_generator(
traverse.with_artificial_edges(specs),
visitor=EnvironmentVisitor(*specs, context=context),
visitor=traverse.CoverEdgesVisitor(
EnvironmentVisitor(*specs, context=context), key=traverse.by_dag_hash
),
key=traverse.by_dag_hash,
root=True,
all_edges=True,

View File

@ -381,7 +381,7 @@ def traverse_topo_edges_generator(edges, visitor, key=id, root=True, all_edges=F
Arguments:
edges (list): List of EdgeAndDepth instances
visitor: visitor instance that defines the sub-DAG to traverse
visitor: visitor that produces unique edges defining the (sub)DAG of interest.
key: function that takes a spec and outputs a key for uniqueness test.
root (bool): Yield the root nodes themselves
all_edges (bool): When ``False`` only one in-edge per node is returned, when