Skip to content

Commit

Permalink
Canonicalize loadModule commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxColoring committed May 4, 2023
1 parent 8fa9f6e commit 57722e0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions api/src/opentrons/protocol_engine/commands/load_module.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
"""Implementation, request models, and response models for the load module command."""
from __future__ import annotations

from typing import TYPE_CHECKING, Optional, Type
from typing_extensions import Literal

from opentrons_shared_data.robot.dev_types import RobotType
from pydantic import BaseModel, Field

from .command import AbstractCommandImpl, BaseCommand, BaseCommandCreate
Expand Down Expand Up @@ -54,6 +57,17 @@ class LoadModuleParams(BaseModel):
),
)

def canonicalize(self, robot_type: RobotType) -> LoadModuleParams:
return self.copy(
update={
"deckSlot": DeckSlotLocation.construct(
slotName=self.location.slotName.to_equivalent_by_robot_type(
robot_type
)
)
}
)


class LoadModuleResult(BaseModel):
"""The results of loading a module."""
Expand Down Expand Up @@ -130,3 +144,6 @@ class LoadModuleCreate(BaseCommandCreate[LoadModuleParams]):
params: LoadModuleParams

_CommandCls: Type[LoadModule] = LoadModule

def canonicalize(self, robot_type: RobotType) -> LoadModuleCreate:
return self.copy(update={"params": self.params.canonicalize(robot_type)})

0 comments on commit 57722e0

Please sign in to comment.