Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/executorlib/executor/single.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from time import sleep
from typing import Callable, Optional, Union

from executorlib.executor.base import BaseExecutor
Expand Down Expand Up @@ -188,6 +189,7 @@ def __init__(
log_obj_size=log_obj_size,
)
)
_executor_self_test(exe=self._task_scheduler)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, find the file and check its size
find . -name "single.py" -path "*/executor/*" | head -5

Repository: pyiron/executorlib

Length of output: 98


🏁 Script executed:

# Examine the file around line 192 and the TestClusterExecutor area
sed -n '185,300p' src/executorlib/executor/single.py

Repository: pyiron/executorlib

Length of output: 8212


🏁 Script executed:

# Continue reading to see TestClusterExecutor.__init__ implementation body
sed -n '289,370p' src/executorlib/executor/single.py

Repository: pyiron/executorlib

Length of output: 4316


🏁 Script executed:

# Search for _executor_self_test definition
rg -n "def _executor_self_test" src/executorlib/

Repository: pyiron/executorlib

Length of output: 130


🏁 Script executed:

# View the _executor_self_test function
sed -n '453,500p' src/executorlib/executor/single.py

Repository: pyiron/executorlib

Length of output: 474


🏁 Script executed:

# Check the structure of both __init__ methods to see if they both expose _task_scheduler
sed -n '100,200p' src/executorlib/executor/single.py

Repository: pyiron/executorlib

Length of output: 6781


Add self-test validation to TestClusterExecutor for consistency.

TestClusterExecutor initialization lacks the _executor_self_test() call present in SingleNodeExecutor, despite both having similar executor setup patterns. Consider adding _executor_self_test(exe=self._task_scheduler) after the super().__init__() call to validate executor initialization and catch connection issues early, consistent with SingleNodeExecutor's approach.

🤖 Prompt for AI Agents
In src/executorlib/executor/single.py around line 192, TestClusterExecutor's
initializer is missing the self-test call used in SingleNodeExecutor; add a call
to _executor_self_test(exe=self._task_scheduler) immediately after the
super().__init__(...) return so the TaskScheduler/connection is validated during
initialization, mirroring SingleNodeExecutor and allowing early failure
detection.



class TestClusterExecutor(BaseExecutor):
Expand Down Expand Up @@ -446,3 +448,20 @@ def create_single_node_executor(
executor_kwargs=resource_dict,
spawner=MpiExecSpawner,
)


def _executor_self_test(exe):
f = exe.submit(sum, [1, 1])
counter = 0
while not f.done() and counter < 10:
sleep(0.1)
counter += 1
if not f.done():
exe.shutdown(wait=False, cancel_futures=False)
raise TimeoutError(
'Plase try "hostname_localhost=True" in the initialization of the SingleNodeExecutor(hostname_localhost=True).'
)
else:
exe._future_hash_dict = {}
exe._task_hash_dict = {}
return True
Loading