The SlurmClusterExecutor and FluxClusterExecutor behave fundamentally different from the SingleNodeExecutor as explained in the documentation: https://executorlib.readthedocs.io/en/latest/4-developer.html#interface-class-hierarchy
This makes it hard to locally debug their functionality. Still internally executorlib contains the functionality to build a SingleNodeExecutor which behaves similar to the SlurmClusterExecutor and FluxClusterExecutor. This should be explained in the documentation:
importosimporttimefromtypingimportOptional, Callablefromexecutorlib.task_scheduler.file.subprocess_spawnerimportexecute_in_subprocessfromexecutorlib.task_scheduler.file.task_schedulerimportFileTaskSchedulerfromexecutorlib.executor.baseimportBaseExecutorclassLocalFileExecutor(BaseExecutor):
def__init__(
self,
max_workers: Optional[int] =None,
cache_directory: Optional[str] =None,
max_cores: Optional[int] =None,
resource_dict: Optional[dict] =None,
hostname_localhost: Optional[bool] =None,
block_allocation: bool=False,
init_function: Optional[Callable] =None,
disable_dependencies: bool=False,
refresh_rate: float=0.01,
):
default_resource_dict: dict= {
"cores": 1,
"threads_per_core": 1,
"gpus_per_core": 0,
"cwd": None,
"openmpi_oversubscribe": False,
"slurm_cmd_args": [],
}
ifcache_directoryisNone:
default_resource_dict["cache_directory"] ="executorlib_cache"else:
default_resource_dict["cache_directory"] =cache_directoryifresource_dictisNone:
resource_dict= {}
resource_dict.update(
{k: vfork, vindefault_resource_dict.items() ifknotinresource_dict}
)
super().__init__(
executor=FileTaskScheduler(
resource_dict=resource_dict,
pysqa_config_directory=None,
backend=None,
disable_dependencies=disable_dependencies,
execute_function=execute_in_subprocess,
)
)
deffoo(x):
time.sleep(3)
returnx+1withLocalFileExecutor(
cache_directory="not_this_dir",
resource_dict={}
) asexe:
future=exe.submit(
foo, 1, resource_dict={
"cache_directory": "rather_this_dir", "cache_key": "foo",
},
)
print(future.result())
The
SlurmClusterExecutorandFluxClusterExecutorbehave fundamentally different from theSingleNodeExecutoras explained in the documentation: https://executorlib.readthedocs.io/en/latest/4-developer.html#interface-class-hierarchyThis makes it hard to locally debug their functionality. Still internally executorlib contains the functionality to build a
SingleNodeExecutorwhich behaves similar to theSlurmClusterExecutorandFluxClusterExecutor. This should be explained in the documentation: