12
12
13
13
class SingleCollectScheduling :
14
14
"""Implement scheduling with a single test collection phase.
15
-
15
+
16
16
This differs from LoadScheduling by:
17
17
1. Only collecting tests on the first node
18
18
2. Skipping collection on other nodes
19
19
3. Not checking for collection equality
20
-
20
+
21
21
This can significantly improve startup time by avoiding redundant collection
22
22
and collection verification across multiple worker processes.
23
23
"""
@@ -72,7 +72,7 @@ def add_node(self, node: WorkerController) -> None:
72
72
"""Add a new node to the scheduler."""
73
73
assert node not in self .node2pending
74
74
self .node2pending [node ] = []
75
-
75
+
76
76
# Remember the first node as our collector
77
77
if self .first_node is None :
78
78
self .first_node = node
@@ -92,10 +92,10 @@ def add_node_collection(
92
92
self .log (f"Ignoring collection from node { node .gateway .id } " )
93
93
94
94
def mark_test_complete (
95
- self , node : WorkerController , item_index : int , duration : float = 0
95
+ self , node : WorkerController , item_index : int | str , duration : float = 0
96
96
) -> None :
97
97
"""Mark test item as completed by node."""
98
- self .node2pending [node ].remove (item_index )
98
+ self .node2pending [node ].remove (int ( item_index ) if isinstance ( item_index , str ) else item_index )
99
99
self .check_schedule (node , duration = duration )
100
100
101
101
def mark_test_pending (self , item : str ) -> None :
@@ -145,11 +145,11 @@ def check_schedule(self, node: WorkerController, duration: float = 0) -> None:
145
145
def remove_node (self , node : WorkerController ) -> str | None :
146
146
"""Remove a node from the scheduler."""
147
147
pending = self .node2pending .pop (node )
148
-
148
+
149
149
# If this is the first node (collector), reset it
150
150
if node == self .first_node :
151
151
self .first_node = None
152
-
152
+
153
153
if not pending :
154
154
return None
155
155
0 commit comments