From c3f09951b0821c80e9496ab89fbb813da084f08c Mon Sep 17 00:00:00 2001 From: Jusong Yu Date: Sat, 18 Jan 2025 03:59:05 +0100 Subject: [PATCH] debug logger when state change --- src/plumpy/base/state_machine.py | 1 - src/plumpy/processes.py | 4 ++-- tests/test_processes.py | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/plumpy/base/state_machine.py b/src/plumpy/base/state_machine.py index 1eae4789..814c1491 100644 --- a/src/plumpy/base/state_machine.py +++ b/src/plumpy/base/state_machine.py @@ -312,7 +312,6 @@ def transition_to(self, new_state: State | None, **kwargs: Any) -> None: The arguments are passed to the state class to create state instance. (process arg does not need to pass since it will always call with 'self' as process) """ - print(f'try: {self._state} -> {new_state}') assert not self._transitioning, 'Cannot call transition_to when already transitioning state' if new_state is None: diff --git a/src/plumpy/processes.py b/src/plumpy/processes.py index 611004ff..9c14fa86 100644 --- a/src/plumpy/processes.py +++ b/src/plumpy/processes.py @@ -748,7 +748,7 @@ def on_entered(self, from_state: Optional[state_machine.State]) -> None: elif state_label == process_states.ProcessState.KILLED: call_with_super_check(self.on_killed) - if self._coordinator and isinstance(self.state, enum.Enum): + if self._coordinator and isinstance(self.state_label, enum.Enum): from_label = cast(enum.Enum, from_state.LABEL).value if from_state is not None else None subject = f'state_changed.{from_label}.{self.state_label.value}' self.logger.info('Process<%s>: Broadcasting state change: %s', self.pid, subject) @@ -1342,7 +1342,6 @@ async def step(self) -> None: self._stepping = True next_state = None try: - # XXX: debug log when need to step to next state next_state = await self._run_task(self._state.execute) except process_states.Interruption as exception: # If the interruption was caused by a call to a Process method then there should @@ -1368,6 +1367,7 @@ async def step(self) -> None: self._interrupt_action.run(next_state) else: # Everything nominal so transition to the next state + self.logger.debug(f'Process<{self.pid}>: transfer from {self._state.LABEL} to {next_state.LABEL}') self.transition_to(next_state) finally: diff --git a/tests/test_processes.py b/tests/test_processes.py index 61d73054..91d98e40 100644 --- a/tests/test_processes.py +++ b/tests/test_processes.py @@ -331,7 +331,7 @@ def test_kill(self): proc.kill(msg_text=msg_text) self.assertTrue(proc.killed()) self.assertEqual(proc.killed_msg()[MESSAGE_TEXT_KEY], msg_text) - self.assertEqual(proc.state, ProcessState.KILLED) + self.assertEqual(proc.state_label, ProcessState.KILLED) def test_wait_continue(self): proc = utils.WaitForSignalProcess()