Execute loop iterations until controller or terminate node stops it.
(self,input:dict[str,object])
| 354 | return edge |
| 355 | @masf_hook(Node.Hook.FORWARD) |
| 356 | def _forward(self,input:dict[str,object]) -> dict[str,object]: |
| 357 | """Execute loop iterations until controller or terminate node stops it.""" |
| 358 | self.reset_gate() |
| 359 | self._controller.outsource_input = input |
| 360 | self._controller.execute(self._attributes_store) |
| 361 | if self._controller.terminated: |
| 362 | return self._controller.output.copy() |
| 363 | iteration_count = 0 |
| 364 | max_loop_iterations = 1000 |
| 365 | while self._gate == Gate.OPEN: |
| 366 | iteration_count += 1 |
| 367 | if iteration_count > max_loop_iterations: |
| 368 | logging.warning(f"Loop {self.name} exceeded max iterations ({max_loop_iterations})") |
| 369 | break |
| 370 | executed_any = False |
| 371 | for node in self._nodes.values(): |
| 372 | if node.is_ready: |
| 373 | node.execute(self._attributes_store) |
| 374 | executed_any = True |
| 375 | break |
| 376 | if self._controller.is_ready: |
| 377 | self._controller.execute(self._attributes_store) |
| 378 | executed_any = True |
| 379 | if self._controller.terminated: |
| 380 | return self._controller.output.copy() |
| 381 | if self._terminate_node.is_ready: |
| 382 | self._terminate_node.execute(self._attributes_store) |
| 383 | return self._terminate_node.output |
| 384 | if not executed_any: |
| 385 | return self._controller.output.copy() if self._controller.output else {} |
| 386 | return self._controller.output.copy() if self._controller.output else {} |
| 387 | def reset(self): |
| 388 | super().reset() |
| 389 | self._controller.reset() |
no test coverage detected