Skip to content

Commit

Permalink
remove unused types.
Browse files Browse the repository at this point in the history
  • Loading branch information
amit lissack committed Jan 4, 2021
1 parent 9fd2c9b commit 75efde6
Showing 1 changed file with 26 additions and 30 deletions.
56 changes: 26 additions & 30 deletions robot-server/robot_server/service/session/models/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@


class LoadLabwareRequestData(BaseModel):
"""Data field in an equipment.loadLabware command request."""

location: int = Field(
...,
description="Deck slot", ge=1, lt=12)
Expand All @@ -39,19 +41,25 @@ class LoadLabwareRequestData(BaseModel):


class LoadLabwareResponseData(BaseModel):
"""Result field in an equipment.loadLabware command response."""

labwareId: IdentifierType
definition: LabwareDefinition
calibration: OffsetVector


class LoadInstrumentRequestData(BaseModel):
"""Data field in an equipment.loadInstrument command request."""

instrumentName: PipetteName = Field(
...,
description="The name of the instrument model")
mount: Mount


class LoadInstrumentResponseData(BaseModel):
"""Result field in an equipment.loadInstrument command response."""

instrumentId: IdentifierType


Expand Down Expand Up @@ -88,25 +96,8 @@ class SetHasCalibrationBlockRequestData(BaseModel):
description="whether or not there is a calibration block present")


CommandDataType = typing.Union[
SetHasCalibrationBlockRequestData,
JogPosition,
LiquidRequestData,
PipetteRequestDataBase,
LoadLabwareRequestData,
LoadInstrumentRequestData,
EmptyModel
]

# A Union of all command result types
CommandResultType = typing.Union[
LoadLabwareResponseData,
LoadInstrumentResponseData,
]


class CommandStatus(str, Enum):
"""The command status"""
"""The command status."""
executed = "executed"
queued = "queued"
failed = "failed"
Expand All @@ -121,7 +112,7 @@ class SessionCommandRequest(
GenericModel,
typing.Generic[CommandT, RequestDataT, ResponseDataT]
):
"""A session command"""
"""A session command request."""
command: CommandT = Field(
...,
description="The command description")
Expand All @@ -139,6 +130,7 @@ def make_response(
completed_at: typing.Optional[datetime],
result: typing.Optional[ResponseDataT]
) -> 'SessionCommandResponse[CommandT, RequestDataT, ResponseDataT]':
"""Create a SessionCommandResponse object."""
return SessionCommandResponse(
command=self.command,
data=self.data,
Expand All @@ -155,7 +147,7 @@ class SessionCommandResponse(
GenericModel,
typing.Generic[CommandT, RequestDataT, ResponseDataT]
):
"""A session command response"""
"""A session command response."""
command: CommandT
data: RequestDataT
status: CommandStatus
Expand All @@ -165,7 +157,6 @@ class SessionCommandResponse(
result: typing.Optional[ResponseDataT] = None


# The command definitions requiring no data and result types.
CommandsEmptyData = Literal[
ProtocolCommand.start_run,
ProtocolCommand.start_simulate,
Expand All @@ -190,21 +181,22 @@ class SessionCommandResponse(
CheckCalibrationCommand.return_tip,
CheckCalibrationCommand.transition
]
"""The command definitions requiring no data and result types."""


class SimpleCommandRequest(
SessionCommandRequest[CommandsEmptyData,
EmptyModel,
EmptyModel]):
"""A command containing no data and result type"""
pass
SimpleCommandRequest = SessionCommandRequest[
CommandsEmptyData,
EmptyModel,
EmptyModel]
"""A command request containing no data and result type."""


SimpleCommandResponse = SessionCommandResponse[
CommandsEmptyData,
EmptyModel,
EmptyModel
]
"""Response to :class:`~SimpleCommandRequest`"""


LoadLabwareRequest = SessionCommandRequest[
Expand Down Expand Up @@ -289,8 +281,7 @@ class SimpleCommandRequest(


SetHasCalibrationBlockResponse = SessionCommandResponse[
Literal[
CalibrationCommand.set_has_calibration_block],
Literal[CalibrationCommand.set_has_calibration_block],
SetHasCalibrationBlockRequestData,
EmptyModel]

Expand All @@ -304,6 +295,7 @@ class SimpleCommandRequest(
JogRequest,
SetHasCalibrationBlockRequest,
]
"""Union of all request types"""

ResponseTypes = typing.Union[
SimpleCommandResponse,
Expand All @@ -314,11 +306,15 @@ class SimpleCommandRequest(
JogResponse,
SetHasCalibrationBlockResponse,
]
"""Union of all response types"""


# Session command requests/responses
CommandRequest = RequestModel[
RequestTypes
]
"""The command request model."""

CommandResponse = ResponseModel[
ResponseTypes
]
"""The command response model."""

0 comments on commit 75efde6

Please sign in to comment.