From b9928fe1ac7291e2f0ccf211d1523377d5488f93 Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Tue, 27 May 2025 07:00:04 +0200 Subject: [PATCH 1/3] Define ExecutorBase in base module This is helpful for identifying if a software package received an executor from executorlib. ```python from executorlib import SingleNodeExecutor from executorlib import BaseExecutor exe = SingleNodeExecutor() print(isinstance(exe, ExecutorBase)) ``` --- executorlib/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/executorlib/__init__.py b/executorlib/__init__.py index 616fdc65..bf174c1a 100644 --- a/executorlib/__init__.py +++ b/executorlib/__init__.py @@ -1,3 +1,4 @@ +from executorlib.executor.base import ExecutorBase from executorlib.executor.flux import ( FluxClusterExecutor, FluxJobExecutor, @@ -13,6 +14,7 @@ __all__: list[str] = [ "get_cache_data", + "ExecutorBase", "FluxJobExecutor", "FluxClusterExecutor", "SingleNodeExecutor", From e9e59c6f9155c7b2e514eb3a4d3dc0069a651266 Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Tue, 27 May 2025 07:08:09 +0200 Subject: [PATCH 2/3] clarify that ExecutorBase is an abstract class --- executorlib/executor/base.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/executorlib/executor/base.py b/executorlib/executor/base.py index 78a410a4..e4dc3686 100644 --- a/executorlib/executor/base.py +++ b/executorlib/executor/base.py @@ -1,4 +1,5 @@ import queue +from abc import ABC from concurrent.futures import ( Executor as FutureExecutor, ) @@ -10,7 +11,7 @@ from executorlib.task_scheduler.base import TaskSchedulerBase -class ExecutorBase(FutureExecutor): +class ExecutorBase(FutureExecutor, ABC): """ Interface class for the executor. From df1dbd2c5ad3686c76a4ffadeb57288fb40e9a2e Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Tue, 27 May 2025 07:24:51 +0200 Subject: [PATCH 3/3] Rename ExecutorBase to BaseExecutor --- executorlib/__init__.py | 4 ++-- executorlib/executor/base.py | 2 +- executorlib/executor/flux.py | 6 +++--- executorlib/executor/single.py | 4 ++-- executorlib/executor/slurm.py | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/executorlib/__init__.py b/executorlib/__init__.py index bf174c1a..e43a8d80 100644 --- a/executorlib/__init__.py +++ b/executorlib/__init__.py @@ -1,4 +1,4 @@ -from executorlib.executor.base import ExecutorBase +from executorlib.executor.base import BaseExecutor from executorlib.executor.flux import ( FluxClusterExecutor, FluxJobExecutor, @@ -14,7 +14,7 @@ __all__: list[str] = [ "get_cache_data", - "ExecutorBase", + "BaseExecutor", "FluxJobExecutor", "FluxClusterExecutor", "SingleNodeExecutor", diff --git a/executorlib/executor/base.py b/executorlib/executor/base.py index e4dc3686..74c6ce84 100644 --- a/executorlib/executor/base.py +++ b/executorlib/executor/base.py @@ -11,7 +11,7 @@ from executorlib.task_scheduler.base import TaskSchedulerBase -class ExecutorBase(FutureExecutor, ABC): +class BaseExecutor(FutureExecutor, ABC): """ Interface class for the executor. diff --git a/executorlib/executor/flux.py b/executorlib/executor/flux.py index 21f51719..aaff34b7 100644 --- a/executorlib/executor/flux.py +++ b/executorlib/executor/flux.py @@ -1,6 +1,6 @@ from typing import Callable, Optional, Union -from executorlib.executor.base import ExecutorBase +from executorlib.executor.base import BaseExecutor from executorlib.standalone.inputcheck import ( check_command_line_argument_lst, check_init_function, @@ -17,7 +17,7 @@ from executorlib.task_scheduler.interactive.onetoone import OneProcessTaskScheduler -class FluxJobExecutor(ExecutorBase): +class FluxJobExecutor(BaseExecutor): """ The executorlib.Executor leverages either the message passing interface (MPI), the SLURM workload manager or preferable the flux framework for distributing python functions within a given resource allocation. In contrast to @@ -202,7 +202,7 @@ def __init__( ) -class FluxClusterExecutor(ExecutorBase): +class FluxClusterExecutor(BaseExecutor): """ The executorlib.Executor leverages either the message passing interface (MPI), the SLURM workload manager or preferable the flux framework for distributing python functions within a given resource allocation. In contrast to diff --git a/executorlib/executor/single.py b/executorlib/executor/single.py index f4af810e..3081f412 100644 --- a/executorlib/executor/single.py +++ b/executorlib/executor/single.py @@ -1,6 +1,6 @@ from typing import Callable, Optional, Union -from executorlib.executor.base import ExecutorBase +from executorlib.executor.base import BaseExecutor from executorlib.standalone.inputcheck import ( check_command_line_argument_lst, check_gpus_per_worker, @@ -17,7 +17,7 @@ from executorlib.task_scheduler.interactive.onetoone import OneProcessTaskScheduler -class SingleNodeExecutor(ExecutorBase): +class SingleNodeExecutor(BaseExecutor): """ The executorlib.Executor leverages either the message passing interface (MPI), the SLURM workload manager or preferable the flux framework for distributing python functions within a given resource allocation. In contrast to diff --git a/executorlib/executor/slurm.py b/executorlib/executor/slurm.py index fe604386..b0cc5a46 100644 --- a/executorlib/executor/slurm.py +++ b/executorlib/executor/slurm.py @@ -1,6 +1,6 @@ from typing import Callable, Optional, Union -from executorlib.executor.base import ExecutorBase +from executorlib.executor.base import BaseExecutor from executorlib.standalone.inputcheck import ( check_init_function, check_plot_dependency_graph, @@ -18,7 +18,7 @@ ) -class SlurmClusterExecutor(ExecutorBase): +class SlurmClusterExecutor(BaseExecutor): """ The executorlib.Executor leverages either the message passing interface (MPI), the SLURM workload manager or preferable the flux framework for distributing python functions within a given resource allocation. In contrast to @@ -194,7 +194,7 @@ def __init__( ) -class SlurmJobExecutor(ExecutorBase): +class SlurmJobExecutor(BaseExecutor): """ The executorlib.Executor leverages either the message passing interface (MPI), the SLURM workload manager or preferable the flux framework for distributing python functions within a given resource allocation. In contrast to