From 9cfaf4cce2d356afbbe22a669118231783cf4fe3 Mon Sep 17 00:00:00 2001 From: tamarzanzouri Date: Wed, 1 May 2024 16:23:15 -0400 Subject: [PATCH] removed list of commands from runners --- .../protocol_runner/protocol_runner.py | 58 +------------------ .../protocol_runner/run_orchestrator.py | 30 +++------- 2 files changed, 8 insertions(+), 80 deletions(-) diff --git a/api/src/opentrons/protocol_runner/protocol_runner.py b/api/src/opentrons/protocol_runner/protocol_runner.py index eb7fec6af78..921414c9691 100644 --- a/api/src/opentrons/protocol_runner/protocol_runner.py +++ b/api/src/opentrons/protocol_runner/protocol_runner.py @@ -83,12 +83,6 @@ class AbstractRunner(ABC): you will need a new Runner to do another run. """ - _all_command_ids: List[str] - """All command IDs, in insertion order.""" - - _commands_by_id: Dict[str, CommandEntry] - """All command resources, in insertion order, mapped by their unique IDs.""" - _queued_command_ids: OrderedSet[str] """The IDs of queued commands, in FIFO order""" @@ -101,11 +95,9 @@ class AbstractRunner(ABC): def __init__(self, protocol_engine: ProtocolEngine) -> None: self._protocol_engine = protocol_engine self._broker = LegacyBroker() - self._all_command_ids = [] self._queued_command_ids = OrderedSet() self._queued_setup_command_ids = OrderedSet() self._queued_fixit_command_ids = OrderedSet() - self._commands_by_id = OrderedDict() # TODO(mm, 2023-10-03): `LegacyBroker` is specific to Python protocols and JSON protocols ≤v5. # We'll need to extend this in order to report progress from newer JSON protocols. @@ -431,54 +423,6 @@ async def run( # noqa: D102 commands = self._protocol_engine.state_view.commands.get_all() return RunResult(commands=commands, state_summary=run_data, parameters=[]) - # todo(tamar): should this be async? - def _prepare_add_command_to_queue(self, request: CommandCreate) -> Command: - """Add a command to the queue. - - Arguments: - request: The command type and payload data used to construct - the command in state. - - Returns: - The full, newly queued command. - - Raises: - SetupCommandNotAllowed: the request specified a setup command, - but the engine was not idle or paused. - RunStoppedError: the run has been stopped, so no new commands - may be added. - CommandNotAllowedError: the request specified a failed command id - with a non fixit command. - """ - # request = slot_standardization.standardize_command( - # request, self.state_view.config.robot_type - # ) - - command_id = model_utils.generate_id() - if request.intent in ( - CommandIntent.SETUP, - CommandIntent.FIXIT, - ): - request_hash = None - else: - request_hash = hash_protocol_command_params( - create=request, - last_hash=self._protocol_engine.state_view.commands.get_latest_protocol_command_hash(), - ) - - command_created_at = model_utils.get_timestamp() - - queue_command = self.validate_action_allowed( - request=request, - request_hash=request_hash, - command_id=command_id, - created_at=command_created_at, - ) - - # self._create_command_queue(queue_command) - - return queue_command - # todo(tamar): change to QueueCommand, should this be async def _create_and_add_command_queue( self, queue_command: QueueCommandAction @@ -511,7 +455,7 @@ def _create_and_add_command_queue( async def _add_command_and_execute(self) -> None: for command in self._queued_commands: - command_queue = self._prepare_add_command_to_queue(command) + command_queue = self._create_and_add_command_queue(command) self._create_and_add_command_queue(command_queue) # TODO(Tamar): should_add_execute_command change to only wait_for_command? # should the whole command state move over? get_next_t0_execute diff --git a/api/src/opentrons/protocol_runner/run_orchestrator.py b/api/src/opentrons/protocol_runner/run_orchestrator.py index 716172d58de..ecdfc3f91c9 100644 --- a/api/src/opentrons/protocol_runner/run_orchestrator.py +++ b/api/src/opentrons/protocol_runner/run_orchestrator.py @@ -2,7 +2,13 @@ from .protocol_runner import create_protocol_runner, AnyRunner from ..hardware_control import HardwareControlAPI -from ..protocol_engine import ProtocolEngine, Command, CommandCreate, CommandIntent, slot_standardization +from ..protocol_engine import ( + ProtocolEngine, + Command, + CommandCreate, + CommandIntent, + slot_standardization, +) from ..protocol_engine.commands import hash_command_params from ..protocol_engine.errors import CommandNotAllowedError from ..protocol_engine.types import PostRunHardwareState @@ -73,28 +79,6 @@ def add_command( "failed command id should be supplied with a FIXIT command." ) - request = slot_standardization.standardize_command( - request, self.state_view.config.robot_type - ) - # create a method create_command_id in PE - command_id = self._protocol_engine._model_utils.generate_id() - if request.intent in ( - CommandIntent.SETUP, - CommandIntent.FIXIT, - ): - request_hash = None - else: - request_hash = hash_command_params.hash_protocol_command_params( - create=request, - last_hash=self._state_store.commands.get_latest_protocol_command_hash(), - ) - - command_created_at = self._protocol_engine._model_utils.get_timestamp() - - command_to_queue = CommandQueue( - - ) - # pass the failed_command_id somewhere if request.intent == CommandIntent.SETUP: self._setup_runner.set_command_queued(request)