Skip to content

Commit

Permalink
Rename CurrentCommand -> CommandPointer.
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxColoring committed May 20, 2024
1 parent 9ae503d commit ed298ab
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions api/src/opentrons/protocol_engine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
CommandType,
CommandIntent,
)
from .state import State, StateView, StateSummary, CommandSlice, CurrentCommand, Config
from .state import State, StateView, StateSummary, CommandSlice, CommandPointer, Config
from .plugins import AbstractPlugin

from .types import (
Expand Down Expand Up @@ -85,7 +85,7 @@
"State",
"StateView",
"CommandSlice",
"CurrentCommand",
"CommandPointer",
# public value interfaces and models
"LabwareOffset",
"LabwareOffsetCreate",
Expand Down
4 changes: 2 additions & 2 deletions api/src/opentrons/protocol_engine/state/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
CommandState,
CommandView,
CommandSlice,
CurrentCommand,
CommandPointer,
)
from .command_history import CommandEntry
from .labware import LabwareState, LabwareView
Expand Down Expand Up @@ -39,7 +39,7 @@
"CommandState",
"CommandView",
"CommandSlice",
"CurrentCommand",
"CommandPointer",
"CommandEntry",
# labware state and values
"LabwareState",
Expand Down
10 changes: 5 additions & 5 deletions api/src/opentrons/protocol_engine/state/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ class CommandSlice:


@dataclass(frozen=True)
class CurrentCommand:
"""The "current" command's ID and index in the overall commands list."""
class CommandPointer:
"""Brief info about a command and where to find it."""

command_id: str
command_key: str
Expand Down Expand Up @@ -593,15 +593,15 @@ def get_queue_ids(self) -> OrderedSet[str]:
"""Get the IDs of all queued protocol commands, in FIFO order."""
return self._state.command_history.get_queue_ids()

def get_current(self) -> Optional[CurrentCommand]:
def get_current(self) -> Optional[CommandPointer]:
"""Return the "current" command, if any.
The "current" command is the command that is currently executing,
or the most recent command to have completed.
"""
running_command = self._state.command_history.get_running_command()
if running_command:
return CurrentCommand(
return CommandPointer(
command_id=running_command.command.id,
command_key=running_command.command.key,
created_at=running_command.command.createdAt,
Expand All @@ -610,7 +610,7 @@ def get_current(self) -> Optional[CurrentCommand]:

most_recently_finalized_command = self.get_most_recently_finalized_command()
if most_recently_finalized_command:
return CurrentCommand(
return CommandPointer(
command_id=most_recently_finalized_command.command.id,
command_key=most_recently_finalized_command.command.key,
created_at=most_recently_finalized_command.command.createdAt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
CommandState,
CommandView,
CommandSlice,
CurrentCommand,
CommandPointer,
RunResult,
QueueStatus,
)
Expand Down Expand Up @@ -846,7 +846,7 @@ def test_get_current() -> None:
queued_command_ids=[],
commands=[command],
)
assert subject.get_current() == CurrentCommand(
assert subject.get_current() == CommandPointer(
index=0,
command_id="command-id",
command_key="command-key",
Expand All @@ -866,7 +866,7 @@ def test_get_current() -> None:
subject = get_command_view(commands=[command_1, command_2])
subject.state.command_history._set_terminal_command_id(command_1.id)

assert subject.get_current() == CurrentCommand(
assert subject.get_current() == CommandPointer(
index=1,
command_id="command-id-2",
command_key="key-2",
Expand All @@ -886,7 +886,7 @@ def test_get_current() -> None:
subject = get_command_view(commands=[command_1, command_2])
subject.state.command_history._set_terminal_command_id(command_1.id)

assert subject.get_current() == CurrentCommand(
assert subject.get_current() == CommandPointer(
index=1,
command_id="command-id-2",
command_key="key-2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
LabwareOffsetCreate,
StateSummary,
CommandSlice,
CurrentCommand,
CommandPointer,
Command,
)

Expand Down Expand Up @@ -183,7 +183,7 @@ def get_commands_slice(
)
return the_slice

def get_current_command(self, run_id: str) -> Optional[CurrentCommand]:
def get_current_command(self, run_id: str) -> Optional[CommandPointer]:
"""Get the "current" command, if any.
See `ProtocolEngine.state_view.commands.get_current()` for the definition
Expand Down
4 changes: 2 additions & 2 deletions robot-server/robot_server/runs/run_data_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
LabwareOffsetCreate,
StateSummary,
CommandSlice,
CurrentCommand,
CommandPointer,
Command,
)
from opentrons.protocol_engine.types import RunTimeParamValuesType
Expand Down Expand Up @@ -373,7 +373,7 @@ def get_commands_slice(
run_id=run_id, cursor=cursor, length=length
)

def get_current_command(self, run_id: str) -> Optional[CurrentCommand]:
def get_current_command(self, run_id: str) -> Optional[CommandPointer]:
"""Get the "current" command, if any.
See `ProtocolEngine.state_view.commands.get_current()` for the definition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from dataclasses import dataclass
from typing import Callable, Optional

from opentrons.protocol_engine import CurrentCommand, StateSummary, EngineStatus
from opentrons.protocol_engine import CommandPointer, StateSummary, EngineStatus

from server_utils.fastapi_utils.app_state import (
AppState,
Expand All @@ -20,15 +20,15 @@ class RunHooks:
"""Generated during a protocol run. Utilized by RunsPublisher."""

run_id: str
get_current_command: Callable[[str], Optional[CurrentCommand]]
get_current_command: Callable[[str], Optional[CommandPointer]]
get_state_summary: Callable[[str], Optional[StateSummary]]


@dataclass
class EngineStateSlice:
"""Protocol Engine state relevant to RunsPublisher."""

current_command: Optional[CurrentCommand] = None
current_command: Optional[CommandPointer] = None
state_summary_status: Optional[EngineStatus] = None


Expand All @@ -54,7 +54,7 @@ def __init__(
async def initialize(
self,
run_id: str,
get_current_command: Callable[[str], Optional[CurrentCommand]],
get_current_command: Callable[[str], Optional[CommandPointer]],
get_state_summary: Callable[[str], Optional[StateSummary]],
) -> None:
"""Initialize RunsPublisher with necessary information derived from the current run.
Expand Down
4 changes: 2 additions & 2 deletions robot-server/tests/commands/test_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from opentrons.protocol_engine import (
ProtocolEngine,
CommandSlice,
CurrentCommand,
CommandPointer,
commands as pe_commands,
)
from opentrons.protocol_engine.errors import CommandDoesNotExistError
Expand Down Expand Up @@ -147,7 +147,7 @@ async def test_get_commands_list(
)

decoy.when(protocol_engine.state_view.commands.get_current()).then_return(
CurrentCommand(
CommandPointer(
command_id="abc123",
command_key="command-key-1",
created_at=datetime(year=2021, month=1, day=1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from opentrons.protocol_engine import (
CommandSlice,
CurrentCommand,
CommandPointer,
ProtocolEngine,
commands as pe_commands,
errors as pe_errors,
Expand Down Expand Up @@ -199,7 +199,7 @@ async def test_get_run_commands(
decoy.when(
mock_maintenance_run_data_manager.get_current_command("run-id")
).then_return(
CurrentCommand(
CommandPointer(
command_id="current-command-id",
command_key="current-command-key",
created_at=datetime(year=2024, month=4, day=4),
Expand Down
4 changes: 2 additions & 2 deletions robot-server/tests/runs/router/test_commands_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from opentrons.protocol_engine import (
CommandSlice,
CurrentCommand,
CommandPointer,
ProtocolEngine,
CommandNote,
commands as pe_commands,
Expand Down Expand Up @@ -321,7 +321,7 @@ async def test_get_run_commands(
)

decoy.when(mock_run_data_manager.get_current_command("run-id")).then_return(
CurrentCommand(
CommandPointer(
command_id="current-command-id",
command_key="current-command-key",
created_at=datetime(year=2024, month=4, day=4),
Expand Down
4 changes: 2 additions & 2 deletions robot-server/tests/runs/test_run_data_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
commands,
types as pe_types,
CommandSlice,
CurrentCommand,
CommandPointer,
ErrorOccurrence,
LoadedLabware,
LoadedPipette,
Expand Down Expand Up @@ -847,7 +847,7 @@ def test_get_current_command(
run_command: commands.Command,
) -> None:
"""Should get current command from engine store."""
expected_current = CurrentCommand(
expected_current = CommandPointer(
command_id=run_command.id,
command_key=run_command.key,
created_at=run_command.createdAt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
from unittest.mock import MagicMock, AsyncMock

from robot_server.service.notifications import RunsPublisher, Topics
from opentrons.protocol_engine import CurrentCommand, EngineStatus, StateSummary
from opentrons.protocol_engine import CommandPointer, EngineStatus, StateSummary


def mock_curent_command(command_id: str) -> CurrentCommand:
"""Create a mock CurrentCommand."""
return CurrentCommand(
def mock_curent_command(command_id: str) -> CommandPointer:
"""Create a mock CommandPointer."""
return CommandPointer(
command_id=command_id,
command_key="1",
index=0,
Expand Down

0 comments on commit ed298ab

Please sign in to comment.