@@ -35,7 +35,7 @@ def create_executor(
3535 backend : str = "local" ,
3636 max_cores : Optional [int ] = None ,
3737 cache_directory : Optional [str ] = None ,
38- resource_dict : dict = {} ,
38+ resource_dict : Optional [ dict ] = None ,
3939 flux_executor = None ,
4040 flux_executor_pmi_mode : Optional [str ] = None ,
4141 flux_executor_nesting : bool = False ,
@@ -83,6 +83,8 @@ def create_executor(
8383 of the individual function.
8484 init_function (None): optional function to preset arguments for functions which are submitted later
8585 """
86+ if resource_dict is None :
87+ resource_dict = {}
8688 if flux_executor is not None and backend != "flux_allocation" :
8789 backend = "flux_allocation"
8890 if backend == "flux_allocation" :
@@ -149,7 +151,7 @@ def create_flux_allocation_executor(
149151 max_workers : Optional [int ] = None ,
150152 max_cores : Optional [int ] = None ,
151153 cache_directory : Optional [str ] = None ,
152- resource_dict : dict = {} ,
154+ resource_dict : Optional [ dict ] = None ,
153155 flux_executor = None ,
154156 flux_executor_pmi_mode : Optional [str ] = None ,
155157 flux_executor_nesting : bool = False ,
@@ -160,16 +162,18 @@ def create_flux_allocation_executor(
160162) -> Union [InteractiveStepExecutor , InteractiveExecutor ]:
161163 check_init_function (block_allocation = block_allocation , init_function = init_function )
162164 check_pmi (backend = "flux_allocation" , pmi = flux_executor_pmi_mode )
165+ if resource_dict is None :
166+ resource_dict = {}
163167 cores_per_worker = resource_dict .get ("cores" , 1 )
164168 resource_dict ["cache_directory" ] = cache_directory
165169 resource_dict ["hostname_localhost" ] = hostname_localhost
166170 check_oversubscribe (oversubscribe = resource_dict .get ("openmpi_oversubscribe" , False ))
167171 check_command_line_argument_lst (
168172 command_line_argument_lst = resource_dict .get ("slurm_cmd_args" , [])
169173 )
170- if "openmpi_oversubscribe" in resource_dict . keys () :
174+ if "openmpi_oversubscribe" in resource_dict :
171175 del resource_dict ["openmpi_oversubscribe" ]
172- if "slurm_cmd_args" in resource_dict . keys () :
176+ if "slurm_cmd_args" in resource_dict :
173177 del resource_dict ["slurm_cmd_args" ]
174178 resource_dict ["flux_executor" ] = flux_executor
175179 resource_dict ["flux_executor_pmi_mode" ] = flux_executor_pmi_mode
@@ -206,12 +210,14 @@ def create_slurm_allocation_executor(
206210 max_workers : Optional [int ] = None ,
207211 max_cores : Optional [int ] = None ,
208212 cache_directory : Optional [str ] = None ,
209- resource_dict : dict = {} ,
213+ resource_dict : Optional [ dict ] = None ,
210214 hostname_localhost : Optional [bool ] = None ,
211215 block_allocation : bool = False ,
212216 init_function : Optional [Callable ] = None ,
213217) -> Union [InteractiveStepExecutor , InteractiveExecutor ]:
214218 check_init_function (block_allocation = block_allocation , init_function = init_function )
219+ if resource_dict is None :
220+ resource_dict = {}
215221 cores_per_worker = resource_dict .get ("cores" , 1 )
216222 resource_dict ["cache_directory" ] = cache_directory
217223 resource_dict ["hostname_localhost" ] = hostname_localhost
@@ -246,12 +252,14 @@ def create_local_executor(
246252 max_workers : Optional [int ] = None ,
247253 max_cores : Optional [int ] = None ,
248254 cache_directory : Optional [str ] = None ,
249- resource_dict : dict = {} ,
255+ resource_dict : Optional [ dict ] = None ,
250256 hostname_localhost : Optional [bool ] = None ,
251257 block_allocation : bool = False ,
252258 init_function : Optional [Callable ] = None ,
253259) -> Union [InteractiveStepExecutor , InteractiveExecutor ]:
254260 check_init_function (block_allocation = block_allocation , init_function = init_function )
261+ if resource_dict is None :
262+ resource_dict = {}
255263 cores_per_worker = resource_dict .get ("cores" , 1 )
256264 resource_dict ["cache_directory" ] = cache_directory
257265 resource_dict ["hostname_localhost" ] = hostname_localhost
@@ -260,11 +268,11 @@ def create_local_executor(
260268 check_command_line_argument_lst (
261269 command_line_argument_lst = resource_dict .get ("slurm_cmd_args" , [])
262270 )
263- if "threads_per_core" in resource_dict . keys () :
271+ if "threads_per_core" in resource_dict :
264272 del resource_dict ["threads_per_core" ]
265- if "gpus_per_core" in resource_dict . keys () :
273+ if "gpus_per_core" in resource_dict :
266274 del resource_dict ["gpus_per_core" ]
267- if "slurm_cmd_args" in resource_dict . keys () :
275+ if "slurm_cmd_args" in resource_dict :
268276 del resource_dict ["slurm_cmd_args" ]
269277 if block_allocation :
270278 resource_dict ["init_function" ] = init_function
0 commit comments