44from executorlib .standalone .inputcheck import (
55 check_command_line_argument_lst ,
66 check_init_function ,
7+ check_log_obj_size ,
78 check_oversubscribe ,
89 check_plot_dependency_graph ,
910 check_pmi ,
1011 check_refresh_rate ,
12+ check_terminate_tasks_on_shutdown ,
1113 validate_number_of_cores ,
1214)
1315from executorlib .task_scheduler .interactive .blockallocation import (
@@ -62,6 +64,7 @@ class FluxJobExecutor(BaseExecutor):
6264 debugging purposes and to get an overview of the specified dependencies.
6365 plot_dependency_graph_filename (str): Name of the file to store the plotted graph in.
6466 log_obj_size (bool): Enable debug mode which reports the size of the communicated objects.
67+ terminate_tasks_on_shutdown (bool): Shutdown all tasks when the Executor is shutdown, this is the default.
6568
6669 Examples:
6770 ```
@@ -102,6 +105,7 @@ def __init__(
102105 plot_dependency_graph : bool = False ,
103106 plot_dependency_graph_filename : Optional [str ] = None ,
104107 log_obj_size : bool = False ,
108+ terminate_tasks_on_shutdown : bool = True ,
105109 ):
106110 """
107111 The executorlib.FluxJobExecutor leverages either the message passing interface (MPI), the SLURM workload manager
@@ -147,6 +151,7 @@ def __init__(
147151 debugging purposes and to get an overview of the specified dependencies.
148152 plot_dependency_graph_filename (str): Name of the file to store the plotted graph in.
149153 log_obj_size (bool): Enable debug mode which reports the size of the communicated objects.
154+ terminate_tasks_on_shutdown (bool): Shutdown all tasks when the Executor is shutdown, this is the default.
150155
151156 """
152157 default_resource_dict : dict = {
@@ -162,6 +167,9 @@ def __init__(
162167 resource_dict .update (
163168 {k : v for k , v in default_resource_dict .items () if k not in resource_dict }
164169 )
170+ check_terminate_tasks_on_shutdown (
171+ terminate_tasks_on_shutdown = terminate_tasks_on_shutdown
172+ )
165173 if not disable_dependencies :
166174 super ().__init__ (
167175 executor = DependencyTaskScheduler (
@@ -246,6 +254,8 @@ class FluxClusterExecutor(BaseExecutor):
246254 plot_dependency_graph (bool): Plot the dependencies of multiple future objects without executing them. For
247255 debugging purposes and to get an overview of the specified dependencies.
248256 plot_dependency_graph_filename (str): Name of the file to store the plotted graph in.
257+ log_obj_size (bool): Enable debug mode which reports the size of the communicated objects.
258+ terminate_tasks_on_shutdown (bool): Shutdown all tasks when the Executor is shutdown, this is the default.
249259
250260 Examples:
251261 ```
@@ -282,6 +292,8 @@ def __init__(
282292 refresh_rate : float = 0.01 ,
283293 plot_dependency_graph : bool = False ,
284294 plot_dependency_graph_filename : Optional [str ] = None ,
295+ log_obj_size : bool = False ,
296+ terminate_tasks_on_shutdown : bool = True ,
285297 ):
286298 """
287299 The executorlib.FluxClusterExecutor leverages either the message passing interface (MPI), the SLURM workload
@@ -323,6 +335,8 @@ def __init__(
323335 plot_dependency_graph (bool): Plot the dependencies of multiple future objects without executing them. For
324336 debugging purposes and to get an overview of the specified dependencies.
325337 plot_dependency_graph_filename (str): Name of the file to store the plotted graph in.
338+ log_obj_size (bool): Enable debug mode which reports the size of the communicated objects.
339+ terminate_tasks_on_shutdown (bool): Shutdown all tasks when the Executor is shutdown, this is the default.
326340
327341 """
328342 default_resource_dict : dict = {
@@ -338,12 +352,20 @@ def __init__(
338352 resource_dict .update (
339353 {k : v for k , v in default_resource_dict .items () if k not in resource_dict }
340354 )
355+ check_log_obj_size (log_obj_size = log_obj_size )
341356 if not plot_dependency_graph :
342357 import pysqa # noqa
343358
344359 from executorlib .task_scheduler .file .task_scheduler import (
345360 create_file_executor ,
346361 )
362+ if terminate_tasks_on_shutdown :
363+ from executorlib .task_scheduler .file .queue_spawner import (
364+ terminate_with_pysqa ,
365+ )
366+ terminate_function = terminate_with_pysqa
367+ else :
368+ terminate_function = None
347369
348370 super ().__init__ (
349371 executor = create_file_executor (
@@ -361,6 +383,7 @@ def __init__(
361383 block_allocation = block_allocation ,
362384 init_function = init_function ,
363385 disable_dependencies = disable_dependencies ,
386+ terminate_function = terminate_function ,
364387 )
365388 )
366389 else :
0 commit comments