Skip to content

Commit 61d9160

Browse files
committed
apply review
1 parent 16162b2 commit 61d9160

File tree

3 files changed

+9
-20
lines changed

3 files changed

+9
-20
lines changed

src/aiida/engine/processes/process.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,6 @@ def kill(self, msg_text: str | None = None, force_kill: bool = False) -> Union[b
339339
"""
340340
self.node.logger.info(f'Request to kill Process<{self.node.pk}>')
341341

342-
# PR_COMMENT Because we need to overwrite the logic of the cancelation of the self._killing task of the
343-
# scheduler job, we need to copy this logic of the parent class in plumpy, we need to adapt the
344-
# cancelation of the last sent killing action to also resend the kill/cancelation of the scheduler
345-
# job as we stop this canelation by canceling the last killing action
346342
if self.killed():
347343
# Already killed
348344
return True
@@ -356,11 +352,9 @@ def kill(self, msg_text: str | None = None, force_kill: bool = False) -> Union[b
356352
if self._killing:
357353
self._killing.cancel()
358354

359-
# PR_COMMENT: We cannot reuse _killing because of type issues, it is a CancellableAction.
360-
# We can wrap a task around a CancellableAction but the CancellableAction catches silently any
361-
# error whilel here we need to know if the cancelation of the scheduler job failed.
362355
if self._cancelling_scheduler_job:
363356
self._cancelling_scheduler_job.cancel()
357+
self.node.logger.report('Found active scheduler job cancelation that will be rescheduled.')
364358

365359
from .calcjobs.tasks import task_kill_job
366360

@@ -369,7 +363,7 @@ def kill(self, msg_text: str | None = None, force_kill: bool = False) -> Union[b
369363
try:
370364
self.loop.run_until_complete(self._cancelling_scheduler_job)
371365
except Exception as exc:
372-
self.node.logger.error(f'While cancelling job error was raised: {exc!s}')
366+
self.node.logger.error(f'While cancelling the scheduler job an error was raised: {exc!s}')
373367
return False
374368

375369
result = super().kill(msg_text, force_kill)
@@ -410,8 +404,6 @@ def done(done_future: plumpy.futures.Future):
410404

411405
return result
412406

413-
# PR_COMMENT This is a copy of the function in engine/processes/calcjobs/tasks.py
414-
# and will merged to one place in PR #6868
415407
async def _launch_task(self, coro, *args, **kwargs):
416408
"""Launch a coroutine as a task, making sure to make it interruptable."""
417409
import functools

src/aiida/engine/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ async def exponential_backoff_retry(
193193
:param ignore_exceptions: exceptions to ignore, i.e. when caught do nothing and simply re-raise
194194
:return: result if the ``coro`` call completes within ``max_attempts`` retries without raising
195195
"""
196-
197196
if logger is None:
198197
logger = LOGGER
199198

tests/cmdline/commands/test_process.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from aiida.engine import Process, ProcessState
2727
from aiida.engine.processes import control as process_control
2828
from aiida.engine.utils import exponential_backoff_retry
29-
from aiida.orm import CalcJobNode, Group, WorkChainNode, WorkflowNode, WorkFunctionNode
29+
from aiida.orm import CalcJobNode, Group, Int, WorkChainNode, WorkflowNode, WorkFunctionNode
3030
from tests.utils.processes import WaitProcess
3131

3232
FuncArgs = tuple[t.Any, ...]
@@ -152,7 +152,6 @@ def test_process_kill_failing_transport(
152152
A failure in opening a transport connection results in the EBM to be fired blocking a regular kill command.
153153
The force kill command will ignore the EBM and kill the process in any case."""
154154
from aiida.cmdline.utils.common import get_process_function_report
155-
from aiida.orm import Int
156155

157156
code = aiida_code_installed(default_calc_job_plugin='core.arithmetic.add', filepath_executable='/bin/bash')
158157

@@ -193,7 +192,6 @@ def test_process_kill_failing_transport_failed_kill(
193192
"""
194193

195194
from aiida.cmdline.utils.common import get_process_function_report
196-
from aiida.orm import Int
197195

198196
code = aiida_code_installed(default_calc_job_plugin='core.arithmetic.add', filepath_executable='/bin/bash')
199197

@@ -235,8 +233,6 @@ def test_process_kill_failing_ebm_transport(
235233
It should be possible to kill it normally. A process that failed upload (e.g. in scenarios that transport is working
236234
again) and is then killed
237235
"""
238-
from aiida.orm import Int
239-
240236
code = aiida_code_installed(default_calc_job_plugin='core.arithmetic.add', filepath_executable='/bin/bash')
241237

242238
def make_a_builder(sleep_seconds=0):
@@ -275,7 +271,7 @@ def test_process_kill_failing_ebm_kill(
275271
Killing a process tries to gracefully cancel the job on the remote node. If there are connection problems it retries
276272
it in using the EBM. If this fails another kill command can be send to restart the cancelation of the job scheduler.
277273
"""
278-
from aiida.orm import Int
274+
from aiida.cmdline.utils.common import get_process_function_report
279275

280276
code = aiida_code_installed(default_calc_job_plugin='core.arithmetic.add', filepath_executable='/bin/bash')
281277

@@ -306,7 +302,11 @@ def make_a_builder(sleep_seconds=0):
306302
# kill should restart EBM and be not successful in EBM
307303
# this tests if the old task is cancelled and restarted successfully
308304
run_cli_command(cmd_process.process_kill, [str(node.pk), '--wait'])
309-
await_condition(lambda: not node.is_killed, timeout=kill_timeout)
305+
await_condition(
306+
lambda: 'Found active scheduler job cancelation that will be rescheduled.'
307+
in get_process_function_report(node),
308+
timeout=kill_timeout,
309+
)
310310

311311
# force kill should skip EBM and successfully kill the process
312312
run_cli_command(cmd_process.process_kill, [str(node.pk), '-F', '--wait'])
@@ -826,8 +826,6 @@ def test_process_kill(submit_and_await, run_cli_command, aiida_code_installed):
826826
assert result.exit_code == ExitCode.USAGE_ERROR
827827
assert len(result.output_lines) > 0
828828

829-
from aiida.orm import Int
830-
831829
code = aiida_code_installed(default_calc_job_plugin='core.arithmetic.add', filepath_executable='/bin/bash')
832830
builder = code.get_builder()
833831
builder.x = Int(2)

0 commit comments

Comments
 (0)