88
99try :
1010 from executorlib .task_scheduler .file .spawner_subprocess import (
11- execute_in_subprocess ,
12- terminate_subprocess ,
11+ subprocess_execute ,
12+ subprocess_terminate ,
1313 )
1414 from executorlib .task_scheduler .file .task_scheduler import FileTaskScheduler , create_file_executor
1515 from executorlib .task_scheduler .file .shared import execute_tasks_h5 , _convert_args_and_kwargs
@@ -36,21 +36,21 @@ def get_error(a):
3636)
3737class TestCacheExecutorSerial (unittest .TestCase ):
3838 def test_submit_with_positional_and_keyword_args (self ):
39- with FileTaskScheduler (execute_function = execute_in_subprocess ) as exe :
39+ with FileTaskScheduler (execute_function = subprocess_execute ) as exe :
4040 fs1 = exe .submit (my_funct , 1 , b = 2 )
4141 self .assertFalse (fs1 .done ())
4242 self .assertEqual (fs1 .result (), 3 )
4343 self .assertTrue (fs1 .done ())
4444
4545 def test_submit_with_custom_cache_key (self ):
46- with FileTaskScheduler (execute_function = execute_in_subprocess ) as exe :
46+ with FileTaskScheduler (execute_function = subprocess_execute ) as exe :
4747 fs1 = exe .submit (my_funct , 1 , b = 2 , resource_dict = {"cache_key" : "a/b/c" })
4848 self .assertFalse (fs1 .done ())
4949 self .assertEqual (fs1 .result (), 3 )
5050 self .assertTrue (fs1 .done ())
5151
5252 def test_submit_dependency_with_keyword_arg_future (self ):
53- with FileTaskScheduler (execute_function = execute_in_subprocess ) as exe :
53+ with FileTaskScheduler (execute_function = subprocess_execute ) as exe :
5454 fs1 = exe .submit (my_funct , 1 , b = 2 )
5555 fs2 = exe .submit (my_funct , 1 , b = fs1 )
5656 self .assertFalse (fs2 .done ())
@@ -70,23 +70,23 @@ def test_create_file_executor_error(self):
7070 def test_submit_dependency_raises_when_dependencies_disabled (self ):
7171 with self .assertRaises (ValueError ):
7272 with FileTaskScheduler (
73- execute_function = execute_in_subprocess , disable_dependencies = True
73+ execute_function = subprocess_execute , disable_dependencies = True
7474 ) as exe :
7575 fs = exe .submit (my_funct , 1 , b = exe .submit (my_funct , 1 , b = 2 ))
7676 fs .result ()
7777
7878 def test_executor_working_directory (self ):
7979 cwd = os .path .join (os .path .dirname (__file__ ), ".." , ".." , ".." , "static" )
8080 with FileTaskScheduler (
81- executor_kwargs = {"cwd" : cwd }, execute_function = execute_in_subprocess
81+ executor_kwargs = {"cwd" : cwd }, execute_function = subprocess_execute
8282 ) as exe :
8383 fs1 = exe .submit (list_files_in_working_directory )
8484 self .assertEqual (fs1 .result (), os .listdir (cwd ))
8585
8686 def test_executor_error (self ):
8787 cwd = os .path .join (os .path .dirname (__file__ ), ".." , ".." , ".." , "static" )
8888 with FileTaskScheduler (
89- executor_kwargs = {"cwd" : cwd }, execute_function = execute_in_subprocess
89+ executor_kwargs = {"cwd" : cwd }, execute_function = subprocess_execute
9090 ) as exe :
9191 fs1 = exe .submit (get_error , a = 1 )
9292 with self .assertRaises (ValueError ):
@@ -97,7 +97,7 @@ def test_executor_error_file(self):
9797 cwd = os .path .join (os .path .dirname (__file__ ), ".." , ".." , ".." , "static" )
9898 with FileTaskScheduler (
9999 executor_kwargs = {"cwd" : cwd , "error_log_file" : "error.out" },
100- execute_function = execute_in_subprocess
100+ execute_function = subprocess_execute
101101 ) as exe :
102102 fs1 = exe .submit (get_error , a = 1 )
103103 with self .assertRaises (ValueError ):
@@ -125,9 +125,9 @@ def test_executor_function(self):
125125 target = execute_tasks_h5 ,
126126 kwargs = {
127127 "future_queue" : q ,
128- "execute_function" : execute_in_subprocess ,
128+ "execute_function" : subprocess_execute ,
129129 "executor_kwargs" : {"cores" : 1 , "cwd" : None , "cache_directory" : cache_dir },
130- "terminate_function" : terminate_subprocess ,
130+ "terminate_function" : subprocess_terminate ,
131131 },
132132 )
133133 process .start ()
@@ -165,9 +165,9 @@ def test_executor_function_dependence_kwargs(self):
165165 target = execute_tasks_h5 ,
166166 kwargs = {
167167 "future_queue" : q ,
168- "execute_function" : execute_in_subprocess ,
168+ "execute_function" : subprocess_execute ,
169169 "executor_kwargs" : {"cores" : 1 , "cwd" : None , "cache_directory" : cache_dir },
170- "terminate_function" : terminate_subprocess ,
170+ "terminate_function" : subprocess_terminate ,
171171 },
172172 )
173173 process .start ()
@@ -205,9 +205,9 @@ def test_executor_function_dependence_args(self):
205205 target = execute_tasks_h5 ,
206206 kwargs = {
207207 "future_queue" : q ,
208- "execute_function" : execute_in_subprocess ,
208+ "execute_function" : subprocess_execute ,
209209 "executor_kwargs" : {"cores" : 1 , "cache_directory" : cache_dir },
210- "terminate_function" : terminate_subprocess ,
210+ "terminate_function" : subprocess_terminate ,
211211 },
212212 )
213213 process .start ()
@@ -218,27 +218,27 @@ def test_executor_function_dependence_args(self):
218218 process .join ()
219219
220220 def test_execute_in_subprocess (self ):
221- process = execute_in_subprocess (
221+ process = subprocess_execute (
222222 command = ["sleep" , "5" ],
223223 file_name = "test.h5" ,
224224 data_dict = {"fn" : sleep , "args" : (5 ,)},
225225 )
226- self .assertIsNone (terminate_subprocess (task = process ))
226+ self .assertIsNone (subprocess_terminate (task = process ))
227227
228228 def test_execute_in_subprocess_errors (self ):
229229 file_name = os .path .abspath (os .path .join (os .path .dirname (__file__ ), "executorlib_cache" , "test.h5" ))
230230 os .makedirs (os .path .dirname (file_name ), exist_ok = True )
231231 with open (file_name , "w" ) as f :
232232 f .write ("test" )
233233 with self .assertRaises (ValueError ):
234- execute_in_subprocess (
234+ subprocess_execute (
235235 file_name = file_name ,
236236 data_dict = {},
237237 command = [],
238238 config_directory = "test" ,
239239 )
240240 with self .assertRaises (ValueError ):
241- execute_in_subprocess (
241+ subprocess_execute (
242242 file_name = file_name ,
243243 data_dict = {},
244244 command = [],
0 commit comments