Skip to content

Commit

Permalink
tests progress not done!
Browse files Browse the repository at this point in the history
  • Loading branch information
TamarZanzouri committed May 2, 2024
1 parent c47ea33 commit 8716bd4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
22 changes: 9 additions & 13 deletions api/src/opentrons/protocol_runner/protocol_runner.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Protocol run control and management."""
import asyncio
from dataclasses import dataclass
from typing import List, NamedTuple, Optional, Union

from abc import ABC, abstractmethod
Expand Down Expand Up @@ -40,10 +39,7 @@
LegacyLoadInfo,
)
from ..ordered_set import OrderedSet
from ..protocol_engine.actions import QueueCommandAction
from ..protocol_engine.commands import hash_protocol_command_params
from ..protocol_engine.errors import ProtocolCommandFailedError
from ..protocol_engine.resources import model_utils
from ..protocol_engine.types import (
PostRunHardwareState,
DeckConfigurationType,
Expand Down Expand Up @@ -72,21 +68,21 @@ class AbstractRunner(ABC):
you will need a new Runner to do another run.
"""

_queued_protocol_commands: OrderedSet[CommandCreate]
_queued_protocol_commands: List[CommandCreate]
"""The IDs of queued commands, in FIFO order"""

_queued_setup_commands: OrderedSet[CommandCreate]
_queued_setup_commands: List[CommandCreate]
"""The IDs of queued setup commands, in FIFO order"""

_queued_fixit_commands: OrderedSet[CommandCreate]
_queued_fixit_commands: List[CommandCreate]
"""The IDs of queued fixit commands, in FIFO order"""

def __init__(self, protocol_engine: ProtocolEngine) -> None:
self._protocol_engine = protocol_engine
self._broker = LegacyBroker()
self._queued_protocol_commands = OrderedSet()
self._queued_setup_commands = OrderedSet()
self._queued_fixit_commands = OrderedSet()
self._queued_protocol_commands = []
self._queued_setup_commands = []
self._queued_fixit_commands = []

# 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.
Expand Down Expand Up @@ -394,7 +390,7 @@ def set_command_queued(self, command: CommandCreate) -> None:

def _add_to_queue(self, command: CommandCreate) -> None:
"""Add new ID to the queued."""
self._queued_protocol_commands.add(command)
self._queued_protocol_commands.append(command)


class LiveRunner(AbstractRunner):
Expand Down Expand Up @@ -446,11 +442,11 @@ def set_command_queued(self, command: CommandCreate) -> None:

def _add_to_setup_queue(self, command: CommandCreate) -> None:
"""Add a new ID to the queued setup."""
self._queued_setup_commands.add(command)
self._queued_setup_commands.append(command)

def _add_to_fixit_queue(self, command: CommandCreate) -> None:
"""Add a new ID to the queued fixit."""
self._queued_fixit_commands.add(command)
self._queued_fixit_commands.append(command)


AnyRunner = Union[PythonAndLegacyRunner, JsonRunner, LiveRunner]
Expand Down
10 changes: 8 additions & 2 deletions api/tests/opentrons/protocol_runner/test_run_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ def mock_hardware_api(decoy: Decoy) -> HardwareAPI:
return decoy.mock(cls=HardwareAPI)


@pytest.fixture
def config() -> JsonProtocolConfig:
"""Get an API version to apply to the interface."""
return JsonProtocolConfig(schema_version=7)

@pytest.fixture
@pytest.mark.parametrize(
"config",
Expand Down Expand Up @@ -79,11 +84,11 @@ def subject(
pe_commands.CommandIntent.FIXIT,
),
(
lazy_fixture("mock_json_runner"),
lazy_fixture("mock_protocol_json_runner"),
pe_commands.CommandIntent.PROTOCOL,
),
(
lazy_fixture("mock_python_runner"),
lazy_fixture("mock_protocol_python_runner"),
pe_commands.CommandIntent.PROTOCOL,
),
],
Expand All @@ -96,6 +101,7 @@ def test_add_command(
) -> None:
"""Should verify calls to set_command_queued."""
command_to_queue = pe_commands.HomeCreate.construct(
intent=command_intent,
params=pe_commands.HomeParams.construct()
)
subject.add_command(command_to_queue)
Expand Down

0 comments on commit 8716bd4

Please sign in to comment.