Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(api): Delete dead private_result supporting code #16621

Merged
merged 3 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions api/src/opentrons/protocol_engine/actions/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
Command,
CommandCreate,
CommandDefinedErrorData,
CommandPrivateResult,
)
from ..error_recovery_policy import ErrorRecoveryPolicy, ErrorRecoveryType
from ..notes.notes import CommandNote
Expand Down Expand Up @@ -146,10 +145,6 @@ class SucceedCommandAction:
command: Command
"""The command in its new succeeded state."""

# todo(mm, 2024-08-26): Remove when no state stores use this anymore.
# https://opentrons.atlassian.net/browse/EXEC-639
private_result: CommandPrivateResult

state_update: StateUpdate = dataclasses.field(
# todo(mm, 2024-08-26): This has a default only to make it easier to transition
# old tests while https://opentrons.atlassian.net/browse/EXEC-639 is in
Expand Down
1 change: 0 additions & 1 deletion api/src/opentrons/protocol_engine/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
CommandCreate,
CommandResult,
CommandType,
CommandPrivateResult,
CommandDefinedErrorData,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ class CloseLidResult(BaseModel):
"""Result data from closing the lid on an aborbance reading."""


class CloseLidImpl(
AbstractCommandImpl[CloseLidParams, SuccessData[CloseLidResult, None]]
):
class CloseLidImpl(AbstractCommandImpl[CloseLidParams, SuccessData[CloseLidResult]]):
"""Execution implementation of closing the lid on an Absorbance Reader."""

def __init__(
Expand All @@ -53,9 +51,7 @@ def __init__(
self._equipment = equipment
self._labware_movement = labware_movement

async def execute(
self, params: CloseLidParams
) -> SuccessData[CloseLidResult, None]:
async def execute(self, params: CloseLidParams) -> SuccessData[CloseLidResult]:
"""Execute the close lid command."""
mod_substate = self._state_view.modules.get_absorbance_reader_substate(
module_id=params.moduleId
Expand Down Expand Up @@ -142,7 +138,6 @@ async def execute(

return SuccessData(
public=CloseLidResult(),
private=None,
state_update=state_update,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class InitializeResult(BaseModel):


class InitializeImpl(
AbstractCommandImpl[InitializeParams, SuccessData[InitializeResult, None]]
AbstractCommandImpl[InitializeParams, SuccessData[InitializeResult]]
):
"""Execution implementation of initializing an Absorbance Reader."""

Expand All @@ -50,9 +50,7 @@ def __init__(
self._state_view = state_view
self._equipment = equipment

async def execute(
self, params: InitializeParams
) -> SuccessData[InitializeResult, None]:
async def execute(self, params: InitializeParams) -> SuccessData[InitializeResult]:
"""Initiate a single absorbance measurement."""
abs_reader_substate = self._state_view.modules.get_absorbance_reader_substate(
module_id=params.moduleId
Expand Down Expand Up @@ -105,7 +103,6 @@ async def execute(

return SuccessData(
public=InitializeResult(),
private=None,
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class OpenLidResult(BaseModel):
"""Result data from opening the lid on an aborbance reading."""


class OpenLidImpl(AbstractCommandImpl[OpenLidParams, SuccessData[OpenLidResult, None]]):
class OpenLidImpl(AbstractCommandImpl[OpenLidParams, SuccessData[OpenLidResult]]):
"""Execution implementation of opening the lid on an Absorbance Reader."""

def __init__(
Expand All @@ -52,7 +52,7 @@ def __init__(
self._equipment = equipment
self._labware_movement = labware_movement

async def execute(self, params: OpenLidParams) -> SuccessData[OpenLidResult, None]:
async def execute(self, params: OpenLidParams) -> SuccessData[OpenLidResult]:
"""Move the absorbance reader lid from the module to the lid dock."""
mod_substate = self._state_view.modules.get_absorbance_reader_substate(
module_id=params.moduleId
Expand Down Expand Up @@ -137,7 +137,6 @@ async def execute(self, params: OpenLidParams) -> SuccessData[OpenLidResult, Non

return SuccessData(
public=OpenLidResult(),
private=None,
state_update=state_update,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ReadAbsorbanceResult(BaseModel):


class ReadAbsorbanceImpl(
AbstractCommandImpl[ReadAbsorbanceParams, SuccessData[ReadAbsorbanceResult, None]]
AbstractCommandImpl[ReadAbsorbanceParams, SuccessData[ReadAbsorbanceResult]]
):
"""Execution implementation of an Absorbance Reader measurement."""

Expand All @@ -65,7 +65,7 @@ def __init__(

async def execute( # noqa: C901
self, params: ReadAbsorbanceParams
) -> SuccessData[ReadAbsorbanceResult, None]:
) -> SuccessData[ReadAbsorbanceResult]:
"""Initiate an absorbance measurement."""
abs_reader_substate = self._state_view.modules.get_absorbance_reader_substate(
module_id=params.moduleId
Expand Down Expand Up @@ -168,12 +168,10 @@ async def execute( # noqa: C901
public=ReadAbsorbanceResult(
data=asbsorbance_result, fileIds=file_ids
),
private=None,
)

return SuccessData(
public=ReadAbsorbanceResult(data=asbsorbance_result, fileIds=file_ids),
private=None,
)


Expand Down
3 changes: 1 addition & 2 deletions api/src/opentrons/protocol_engine/commands/aspirate.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class AspirateResult(BaseLiquidHandlingResult, DestinationPositionResult):


_ExecuteReturn = Union[
SuccessData[AspirateResult, None],
SuccessData[AspirateResult],
DefinedErrorData[OverpressureError],
]

Expand Down Expand Up @@ -167,7 +167,6 @@ async def execute(self, params: AspirateParams) -> _ExecuteReturn:
volume=volume_aspirated,
position=deck_point,
),
private=None,
state_update=state_update,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class AspirateInPlaceResult(BaseLiquidHandlingResult):


_ExecuteReturn = Union[
SuccessData[AspirateInPlaceResult, None],
SuccessData[AspirateInPlaceResult],
DefinedErrorData[OverpressureError],
]

Expand Down Expand Up @@ -150,7 +150,6 @@ async def execute(self, params: AspirateInPlaceParams) -> _ExecuteReturn:
)
return SuccessData(
public=AspirateInPlaceResult(volume=volume),
private=None,
state_update=state_update,
)

Expand Down
3 changes: 1 addition & 2 deletions api/src/opentrons/protocol_engine/commands/blow_out.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class BlowOutResult(DestinationPositionResult):


_ExecuteReturn = Union[
SuccessData[BlowOutResult, None],
SuccessData[BlowOutResult],
DefinedErrorData[OverpressureError],
]

Expand Down Expand Up @@ -116,7 +116,6 @@ async def execute(self, params: BlowOutParams) -> _ExecuteReturn:
else:
return SuccessData(
public=BlowOutResult(position=deck_point),
private=None,
state_update=state_update,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class BlowOutInPlaceResult(BaseModel):


_ExecuteReturn = Union[
SuccessData[BlowOutInPlaceResult, None],
SuccessData[BlowOutInPlaceResult],
DefinedErrorData[OverpressureError],
]

Expand Down Expand Up @@ -99,7 +99,9 @@ async def execute(self, params: BlowOutInPlaceParams) -> _ExecuteReturn:
),
)
else:
return SuccessData(public=BlowOutInPlaceResult(), private=None)
return SuccessData(
public=BlowOutInPlaceResult(),
)


class BlowOutInPlace(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ class CalibrateGripperResult(BaseModel):


class CalibrateGripperImplementation(
AbstractCommandImpl[
CalibrateGripperParams, SuccessData[CalibrateGripperResult, None]
]
AbstractCommandImpl[CalibrateGripperParams, SuccessData[CalibrateGripperResult]]
):
"""The implementation of a `calibrateGripper` command."""

Expand All @@ -87,7 +85,7 @@ def __init__(

async def execute(
self, params: CalibrateGripperParams
) -> SuccessData[CalibrateGripperResult, None]:
) -> SuccessData[CalibrateGripperResult]:
"""Execute a `calibrateGripper` command.

1. Move from the current location to the calibration area on the deck.
Expand Down Expand Up @@ -126,7 +124,6 @@ async def execute(
),
savedCalibration=calibration_data,
),
private=None,
)

@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class CalibrateModuleResult(BaseModel):


class CalibrateModuleImplementation(
AbstractCommandImpl[CalibrateModuleParams, SuccessData[CalibrateModuleResult, None]]
AbstractCommandImpl[CalibrateModuleParams, SuccessData[CalibrateModuleResult]]
):
"""CalibrateModule command implementation."""

Expand All @@ -64,7 +64,7 @@ def __init__(

async def execute(
self, params: CalibrateModuleParams
) -> SuccessData[CalibrateModuleResult, None]:
) -> SuccessData[CalibrateModuleResult]:
"""Execute calibrate-module command."""
ot3_api = ensure_ot3_hardware(
self._hardware_api,
Expand All @@ -91,7 +91,6 @@ async def execute(
),
location=slot,
),
private=None,
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ class CalibratePipetteResult(BaseModel):


class CalibratePipetteImplementation(
AbstractCommandImpl[
CalibratePipetteParams, SuccessData[CalibratePipetteResult, None]
]
AbstractCommandImpl[CalibratePipetteParams, SuccessData[CalibratePipetteResult]]
):
"""CalibratePipette command implementation."""

Expand All @@ -49,7 +47,7 @@ def __init__(

async def execute(
self, params: CalibratePipetteParams
) -> SuccessData[CalibratePipetteResult, None]:
) -> SuccessData[CalibratePipetteResult]:
"""Execute calibrate-pipette command."""
# TODO (tz, 20-9-22): Add a better solution to determine if a command can be executed on an OT-3/OT-2
ot3_api = ensure_ot3_hardware(
Expand All @@ -72,7 +70,6 @@ async def execute(
x=pipette_offset.x, y=pipette_offset.y, z=pipette_offset.z
)
),
private=None,
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class MoveToMaintenancePositionResult(BaseModel):
class MoveToMaintenancePositionImplementation(
AbstractCommandImpl[
MoveToMaintenancePositionParams,
SuccessData[MoveToMaintenancePositionResult, None],
SuccessData[MoveToMaintenancePositionResult],
]
):
"""Calibration set up position command implementation."""
Expand All @@ -73,7 +73,7 @@ def __init__(

async def execute(
self, params: MoveToMaintenancePositionParams
) -> SuccessData[MoveToMaintenancePositionResult, None]:
) -> SuccessData[MoveToMaintenancePositionResult]:
"""Move the requested mount to a maintenance deck slot."""
ot3_api = ensure_ot3_hardware(
self._hardware_api,
Expand Down Expand Up @@ -118,7 +118,9 @@ async def execute(
)
await ot3_api.disengage_axes([Axis.Z_R])

return SuccessData(public=MoveToMaintenancePositionResult(), private=None)
return SuccessData(
public=MoveToMaintenancePositionResult(),
)


class MoveToMaintenancePosition(
Expand Down
14 changes: 2 additions & 12 deletions api/src/opentrons/protocol_engine/commands/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
_ResultT_co = TypeVar("_ResultT_co", bound=BaseModel, covariant=True)
_ErrorT = TypeVar("_ErrorT", bound=ErrorOccurrence)
_ErrorT_co = TypeVar("_ErrorT_co", bound=ErrorOccurrence, covariant=True)
_PrivateResultT_co = TypeVar("_PrivateResultT_co", covariant=True)


class CommandStatus(str, Enum):
Expand Down Expand Up @@ -108,19 +107,12 @@ class BaseCommandCreate(


@dataclasses.dataclass(frozen=True)
class SuccessData(Generic[_ResultT_co, _PrivateResultT_co]):
class SuccessData(Generic[_ResultT_co]):
"""Data from the successful completion of a command."""

public: _ResultT_co
"""Public result data. Exposed over HTTP and stored in databases."""

private: _PrivateResultT_co
"""Additional result data, only given to `opentrons.protocol_engine` internals.

Deprecated:
Use `state_update` instead.
"""

state_update: StateUpdate = dataclasses.field(
# todo(mm, 2024-08-22): Remove the default once all command implementations
# use this, to make it harder to forget in new command implementations.
Expand Down Expand Up @@ -239,8 +231,6 @@ class BaseCommand(
# Our _ImplementationCls must return public result data that can fit
# in our `result` field:
_ResultT,
# But we don't care (here) what kind of private result data it returns:
object,
],
DefinedErrorData[
# Our _ImplementationCls must return public error data that can fit
Expand All @@ -255,7 +245,7 @@ class BaseCommand(
_ExecuteReturnT_co = TypeVar(
"_ExecuteReturnT_co",
bound=Union[
SuccessData[BaseModel, object],
SuccessData[BaseModel],
DefinedErrorData[ErrorOccurrence],
],
covariant=True,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Union types of concrete command definitions."""

from collections.abc import Collection
from typing import Annotated, Literal, Type, Union, get_type_hints
from typing import Annotated, Type, Union, get_type_hints

from pydantic import Field

Expand Down Expand Up @@ -699,9 +699,6 @@
unsafe.UnsafeUngripLabwareResult,
]

# todo(mm, 2024-10-28): This has been obsoleted by StateUpdate. Delete this.
# https://opentrons.atlassian.net/browse/EXEC-639
CommandPrivateResult = Literal[None]

# All `DefinedErrorData`s that implementations will actually return in practice.
CommandDefinedErrorData = Union[
Expand Down
Loading
Loading