Skip to content

Commit

Permalink
fixed return type from classmethod
Browse files Browse the repository at this point in the history
  • Loading branch information
TamarZanzouri committed May 8, 2024
1 parent 840e83f commit 7fb9f21
Showing 1 changed file with 40 additions and 40 deletions.
80 changes: 40 additions & 40 deletions api/src/opentrons/protocol_runner/run_orchestrator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass
from typing import Optional, Union, NamedTuple
from __future__ import annotations
from typing import Optional, Union

from . import protocol_runner
from ..hardware_control import HardwareControlAPI
Expand Down Expand Up @@ -37,43 +37,6 @@ def __init__(
self._setup_runner = setup_runner
self._fixit_runner = fixit_runner

def add_command(
self, request: CommandCreate, failed_command_id: Optional[str] = None
) -> Command:
"""Add a command to the queue.
Arguments:
request: The command type and payload data used to construct
the command in state.
failed_command_id: the failed command id this command is trying to fix.
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.
"""
if failed_command_id and request.intent != CommandIntent.FIXIT:
raise CommandNotAllowedError(
"failed command id should be supplied with a FIXIT command."
)

# pass the failed_command_id somewhere
if request.intent == CommandIntent.SETUP:
self._setup_runner.set_command_queued(request)
elif request.intent == CommandIntent.FIXIT:
self._fixit_runner.set_command_queued(request)
elif (
request.intent == CommandIntent.PROTOCOL
and self._json_or_python_runner is not None
):
self._json_or_python_runner.set_command_queued(request)

@classmethod
def build_orchestrator(
cls,
Expand All @@ -84,7 +47,7 @@ def build_orchestrator(
] = None,
post_run_hardware_state: PostRunHardwareState = PostRunHardwareState.HOME_AND_STAY_ENGAGED,
drop_tips_after_run: bool = True,
) -> RunOrchestrator:
) -> "RunOrchestrator":
setup_runner = protocol_runner.create_protocol_runner(
protocol_engine=protocol_engine,
hardware_api=hardware_api,
Expand Down Expand Up @@ -113,3 +76,40 @@ def build_orchestrator(
hardware_api=hardware_api,
protocol_engine=protocol_engine,
)

def add_command(
self, request: CommandCreate, failed_command_id: Optional[str] = None
) -> Command:
"""Add a command to the queue.
Arguments:
request: The command type and payload data used to construct
the command in state.
failed_command_id: the failed command id this command is trying to fix.
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.
"""
if failed_command_id and request.intent != CommandIntent.FIXIT:
raise CommandNotAllowedError(
"failed command id should be supplied with a FIXIT command."
)

# pass the failed_command_id somewhere
if request.intent == CommandIntent.SETUP:
self._setup_runner.set_command_queued(request)
elif request.intent == CommandIntent.FIXIT:
self._fixit_runner.set_command_queued(request)
elif (
request.intent == CommandIntent.PROTOCOL
and self._json_or_python_runner is not None
):
self._json_or_python_runner.set_command_queued(request)

0 comments on commit 7fb9f21

Please sign in to comment.