@@ -41,7 +41,51 @@ def test_executor(self):
4141 fs1 = exe .submit (mpi_funct , 1 )
4242 self .assertFalse (fs1 .done ())
4343 self .assertEqual (fs1 .result (), [(1 , 2 , 0 ), (1 , 2 , 1 )])
44+ self .assertEqual (len (os .listdir ("executorlib_cache" )), 4 )
4445 self .assertTrue (fs1 .done ())
4546
47+ def test_executor_existing_files (self ):
48+ with FluxClusterExecutor (
49+ resource_dict = {"cores" : 2 , "cwd" : "executorlib_cache" },
50+ block_allocation = False ,
51+ cache_directory = "executorlib_cache" ,
52+ ) as exe :
53+ cloudpickle_register (ind = 1 )
54+ fs1 = exe .submit (mpi_funct , 1 )
55+ self .assertFalse (fs1 .done ())
56+ self .assertEqual (fs1 .result (), [(1 , 2 , 0 ), (1 , 2 , 1 )])
57+ self .assertTrue (fs1 .done ())
58+ self .assertEqual (len (os .listdir ("executorlib_cache" )), 4 )
59+
60+ with FluxClusterExecutor (
61+ resource_dict = {"cores" : 2 , "cwd" : "executorlib_cache" },
62+ block_allocation = False ,
63+ cache_directory = "executorlib_cache" ,
64+ ) as exe :
65+ cloudpickle_register (ind = 1 )
66+ fs1 = exe .submit (mpi_funct , 1 )
67+ self .assertFalse (fs1 .done ())
68+ self .assertEqual (fs1 .result (), [(1 , 2 , 0 ), (1 , 2 , 1 )])
69+ self .assertTrue (fs1 .done ())
70+ self .assertEqual (len (os .listdir ("executorlib_cache" )), 4 )
71+ for file_name in os .listdir ("executorlib_cache" ):
72+ file_path = os .path .join ("executorlib_cache" , file_name )
73+ os .remove (file_path )
74+ if ".h5" in file_path :
75+ with open (file_path , "w" ) as f :
76+ f .write ("test" )
77+
78+ with FluxClusterExecutor (
79+ resource_dict = {"cores" : 2 , "cwd" : "executorlib_cache" },
80+ block_allocation = False ,
81+ cache_directory = "executorlib_cache" ,
82+ ) as exe :
83+ cloudpickle_register (ind = 1 )
84+ fs1 = exe .submit (mpi_funct , 1 )
85+ self .assertFalse (fs1 .done ())
86+ self .assertEqual (fs1 .result (), [(1 , 2 , 0 ), (1 , 2 , 1 )])
87+ self .assertTrue (fs1 .done ())
88+ self .assertEqual (len (os .listdir ("executorlib_cache" )), 4 )
89+
4690 def tearDown (self ):
4791 shutil .rmtree ("executorlib_cache" , ignore_errors = True )
0 commit comments