1010from .algo import partition
1111from .static_scheduler_utils import group_items_by_parallel_steps
1212from mpi4py import MPI
13+ import numpy as np
1314
1415def mark_skip (item , ntasks ):
1516 n_proc_test = get_n_proc_for_test (item )
@@ -103,18 +104,22 @@ def submit_items(items_to_run, SCHEDULER_IP_ADDRESS, port, main_invoke_params, n
103104
104105 script = " & \\ \n " .join (cmds ) + '\n '
105106 Path ('.pytest_parallel' ).mkdir (exist_ok = True )
106- script_path = f'.pytest_parallel/pytest_static_sched_{ i_step } .sh'
107+ script_path = f'.pytest_parallel/pytest_static_sched_{ i_step + 1 } .sh'
107108 with open (script_path ,'w' ) as f :
108109 f .write (script )
109110
110111 current_permissions = stat .S_IMODE (os .lstat (script_path ).st_mode )
111112 os .chmod (script_path , current_permissions | stat .S_IXUSR )
112113
113114 p = subprocess .Popen ([script_path ], shell = True , stdout = subprocess .PIPE )
114- print (f'\n Launching tests (step { i_step } /{ n_step } )...' )
115+ print (f'\n Launching tests (step { i_step + 1 } /{ n_step } )...' )
115116 return p
116117
117118def receive_items (items , session , socket , n_item_to_recv ):
119+ # > Precondition: Items must keep their original order to pick up the right item at the reception
120+ original_indices = np .array ([item .original_index for item in items ])
121+ assert (original_indices == np .arange (len (items ))).all ()
122+
118123 while n_item_to_recv > 0 :
119124 conn , addr = socket .accept ()
120125 with conn :
@@ -123,13 +128,13 @@ def receive_items(items, session, socket, n_item_to_recv):
123128 test_idx = test_info ['test_idx' ]
124129 if test_info ['fatal_error' ] is not None :
125130 assert 0 , f'{ test_info ["fatal_error" ]} '
126- item = items [test_idx ]
131+ item = items [test_idx ] # works because of precondition
127132 item .sub_comm = None
128133 item .info = test_info
129134
130135 # "run" the test (i.e. trigger PyTest pipeline but do not really run the code)
131136 nextitem = None # not known at this point
132- run_item_test (items [ test_idx ] , nextitem , session )
137+ run_item_test (item , nextitem , session )
133138 n_item_to_recv -= 1
134139
135140class ShellStaticScheduler :
0 commit comments