Skip to content

Commit

Permalink
defer_build=True in api.
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxColoring committed Dec 17, 2024
1 parent b64c446 commit 12034e0
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 3 deletions.
2 changes: 2 additions & 0 deletions api/src/opentrons/calibration_storage/deck_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class _CutoutFixturePlacementModel(pydantic.BaseModel):
cutoutFixtureId: str
opentronsModuleSerialNumber: Optional[str] = None

model_config = pydantic.ConfigDict(defer_build=True)


class _DeckConfigurationModel(pydantic.BaseModel):
"""The on-filesystem representation of a deck configuration."""
Expand Down
4 changes: 3 additions & 1 deletion api/src/opentrons/calibration_storage/ot2/models/v1.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import typing

from typing_extensions import Literal
from pydantic import field_validator, BaseModel, Field, PlainSerializer
from pydantic import field_validator, BaseModel, ConfigDict, Field, PlainSerializer
from datetime import datetime

from opentrons_shared_data.pipette.types import LabwareUri
Expand All @@ -20,6 +20,8 @@ class CalibrationStatus(BaseModel):
source: typing.Optional[types.SourceType] = None
markedAt: typing.Optional[DatetimeType] = None

model_config = ConfigDict(defer_build=True)


# Schemas used to store the data types
# TODO(lc 09-01-2022) We should ensure that all pydantic models are
Expand Down
4 changes: 3 additions & 1 deletion api/src/opentrons/calibration_storage/ot3/models/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing_extensions import Literal
from opentrons.hardware_control.modules.types import ModuleType
from opentrons.hardware_control.types import OT3Mount
from pydantic import field_validator, BaseModel, Field, PlainSerializer
from pydantic import field_validator, BaseModel, ConfigDict, Field, PlainSerializer
from datetime import datetime

from opentrons_shared_data.pipette.types import LabwareUri
Expand All @@ -23,6 +23,8 @@ class CalibrationStatus(BaseModel):
source: typing.Optional[types.SourceType] = None
markedAt: typing.Optional[DatetimeType] = None

model_config = ConfigDict(defer_build=True)


class TipLengthModel(BaseModel):
tipLength: float = Field(..., description="Tip length data found from calibration.")
Expand Down
24 changes: 23 additions & 1 deletion api/src/opentrons/hardware_control/emulation/settings.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
from typing import List
from opentrons.hardware_control.emulation.types import ModuleType
from opentrons.hardware_control.emulation.util import TEMPERATURE_ROOM
from pydantic import BaseModel
from pydantic import BaseModel, ConfigDict
from pydantic_settings import BaseSettings, SettingsConfigDict


class PipetteSettings(BaseModel):
model: str = "p20_single_v2.0"
id: str = "P20SV202020070101"

model_config = ConfigDict(defer_build=True)


class SmoothieSettings(BaseModel):
left: PipetteSettings = PipetteSettings(
Expand All @@ -20,41 +22,57 @@ class SmoothieSettings(BaseModel):
host: str = "0.0.0.0"
port: int = 9996

model_config = ConfigDict(defer_build=True)


class BaseModuleSettings(BaseModel):
serial_number: str
model: str
version: str

model_config = ConfigDict(defer_build=True)


class TemperatureModelSettings(BaseModel):
degrees_per_tick: float = 2.0
starting: float = float(TEMPERATURE_ROOM)

model_config = ConfigDict(defer_build=True)


class RPMModelSettings(BaseModel):
rpm_per_tick: float = 100.0
starting: float = 0.0

model_config = ConfigDict(defer_build=True)


class MagDeckSettings(BaseModuleSettings):
pass

model_config = ConfigDict(defer_build=True)


class TempDeckSettings(BaseModuleSettings):
temperature: TemperatureModelSettings

model_config = ConfigDict(defer_build=True)


class ThermocyclerSettings(BaseModuleSettings):
lid_temperature: TemperatureModelSettings
plate_temperature: TemperatureModelSettings

model_config = ConfigDict(defer_build=True)


class HeaterShakerSettings(BaseModuleSettings):
temperature: TemperatureModelSettings
rpm: RPMModelSettings
home_delay_time: int = 0

model_config = ConfigDict(defer_build=True)


class ProxySettings(BaseModel):
"""Settings for a proxy."""
Expand All @@ -64,13 +82,17 @@ class ProxySettings(BaseModel):
driver_port: int
use_local_host: bool = True

model_config = ConfigDict(defer_build=True)


class ModuleServerSettings(BaseModel):
"""Settings for the module server"""

host: str = "0.0.0.0"
port: int = 8989

model_config = ConfigDict(defer_build=True)


class Settings(BaseSettings):
modules: List[ModuleType] = [
Expand Down
57 changes: 57 additions & 0 deletions api/src/opentrons/protocol_engine/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from pydantic import (
ConfigDict,
BaseModel,
ConfigDict,
Field,
RootModel,
StrictBool,
Expand Down Expand Up @@ -133,6 +134,8 @@ class DeckSlotLocation(BaseModel):
),
)

model_config = ConfigDict(defer_build=True)


class StagingSlotLocation(BaseModel):
"""The location of something placed in a single staging slot."""
Expand All @@ -147,6 +150,8 @@ class StagingSlotLocation(BaseModel):
),
)

model_config = ConfigDict(defer_build=True)


class AddressableAreaLocation(BaseModel):
"""The location of something place in an addressable area. This is a superset of deck slots."""
Expand All @@ -160,6 +165,8 @@ class AddressableAreaLocation(BaseModel):
),
)

model_config = ConfigDict(defer_build=True)


class ModuleLocation(BaseModel):
"""The location of something placed atop a hardware module."""
Expand All @@ -169,6 +176,8 @@ class ModuleLocation(BaseModel):
description="The ID of a loaded module from a prior `loadModule` command.",
)

model_config = ConfigDict(defer_build=True)


class OnLabwareLocation(BaseModel):
"""The location of something placed atop another labware."""
Expand All @@ -178,6 +187,8 @@ class OnLabwareLocation(BaseModel):
description="The ID of a loaded Labware from a prior `loadLabware` command.",
)

model_config = ConfigDict(defer_build=True)


_OffDeckLocationType = Literal["offDeck"]
OFF_DECK_LOCATION: _OffDeckLocationType = "offDeck"
Expand Down Expand Up @@ -256,6 +267,8 @@ class WellOffset(BaseModel):
y: float = 0
z: float = 0

model_config = ConfigDict(defer_build=True)


class WellLocation(BaseModel):
"""A relative location in reference to a well's location."""
Expand Down Expand Up @@ -291,6 +304,8 @@ class PickUpTipWellLocation(BaseModel):
origin: PickUpTipWellOrigin = PickUpTipWellOrigin.TOP
offset: WellOffset = Field(default_factory=WellOffset)

model_config = ConfigDict(defer_build=True)


class DropTipWellLocation(BaseModel):
"""Like WellLocation, but for dropping tips.
Expand All @@ -302,6 +317,8 @@ class DropTipWellLocation(BaseModel):
origin: DropTipWellOrigin = DropTipWellOrigin.DEFAULT
offset: WellOffset = Field(default_factory=WellOffset)

model_config = ConfigDict(defer_build=True)


@dataclass(frozen=True)
class Dimensions:
Expand All @@ -320,6 +337,8 @@ class DeckPoint(BaseModel):
y: float
z: float

model_config = ConfigDict(defer_build=True)


# TODO(mm, 2023-05-10): Deduplicate with constants in
# opentrons.protocols.api_support.deck_type
Expand All @@ -339,6 +358,8 @@ class LoadedPipette(BaseModel):
pipetteName: PipetteNameType
mount: MountType

model_config = ConfigDict(defer_build=True)


@dataclass
class FlowRates:
Expand Down Expand Up @@ -556,6 +577,8 @@ class ModuleDimensions(BaseModel):
overLabwareHeight: float
lidHeight: Optional[float] = None

model_config = ConfigDict(defer_build=True)


class Vec3f(BaseModel):
"""A 3D vector of floats."""
Expand All @@ -573,6 +596,8 @@ class ModuleCalibrationPoint(BaseModel):
y: float
z: float

model_config = ConfigDict(defer_build=True)


# TODO(mm, 2022-11-07): Deduplicate with Vec3f.
class LabwareOffsetVector(BaseModel):
Expand Down Expand Up @@ -607,6 +632,8 @@ class InstrumentOffsetVector(BaseModel):
y: float
z: float

model_config = ConfigDict(defer_build=True)


# TODO(mm, 2022-11-07): Deduplicate with Vec3f.
class ModuleOffsetVector(BaseModel):
Expand All @@ -616,6 +643,8 @@ class ModuleOffsetVector(BaseModel):
y: float
z: float

model_config = ConfigDict(defer_build=True)


@dataclass
class ModuleOffsetData:
Expand All @@ -628,17 +657,23 @@ class ModuleOffsetData:
class OverlapOffset(Vec3f):
"""Offset representing overlap space of one labware on top of another labware or module."""

model_config = ConfigDict(defer_build=True)


class AddressableOffsetVector(Vec3f):
"""Offset, in deck coordinates, from nominal to actual position of an addressable area."""

model_config = ConfigDict(defer_build=True)


class LabwareMovementOffsetData(BaseModel):
"""Offsets to be used during labware movement."""

pickUpOffset: LabwareOffsetVector
dropOffset: LabwareOffsetVector

model_config = ConfigDict(defer_build=True)


# TODO(mm, 2023-04-13): Move to shared-data, so this binding can be maintained alongside the JSON
# schema that it's sourced from. We already do that for labware definitions and JSON protocols.
Expand Down Expand Up @@ -712,6 +747,8 @@ class LoadedModule(BaseModel):
location: Optional[DeckSlotLocation] = None
serialNumber: Optional[str] = None

model_config = ConfigDict(defer_build=True)


class LabwareOffsetLocation(BaseModel):
"""Parameters describing when a given offset may apply to a given labware load."""
Expand Down Expand Up @@ -759,6 +796,8 @@ class LabwareOffsetLocation(BaseModel):
),
)

model_config = ConfigDict(defer_build=True)


class LabwareOffset(BaseModel):
"""An offset that the robot adds to a pipette's position when it moves to a labware.
Expand All @@ -780,6 +819,8 @@ class LabwareOffset(BaseModel):
description="The offset applied to matching labware.",
)

model_config = ConfigDict(defer_build=True)


class LabwareOffsetCreate(BaseModel):
"""Create request data for a labware offset."""
Expand Down Expand Up @@ -818,12 +859,16 @@ class LoadedLabware(BaseModel):
description="A user-specified display name for this labware, if provided.",
)

model_config = ConfigDict(defer_build=True)


class HexColor(RootModel[str]):
"""Hex color representation."""

root: str = Field(pattern=r"^#(?:[0-9a-fA-F]{3,4}){1,2}$")

model_config = ConfigDict(defer_build=True)


EmptyLiquidId = Literal["EMPTY"]
LiquidId = str | EmptyLiquidId
Expand All @@ -837,6 +882,8 @@ class Liquid(BaseModel):
description: str
displayColor: Optional[HexColor] = None

model_config = ConfigDict(defer_build=True)


class LiquidClassRecord(ByTipTypeSetting, frozen=True):
"""LiquidClassRecord is our internal representation of an (immutable) liquid class.
Expand Down Expand Up @@ -1201,6 +1248,8 @@ class RTPBase(BaseModel):
description="Units (like mL, mm/sec, etc) or a custom suffix for the parameter.",
)

model_config = ConfigDict(defer_build=True)


class NumberParameter(RTPBase):
"""An integer parameter defined in a protocol."""
Expand All @@ -1223,6 +1272,8 @@ class NumberParameter(RTPBase):
description="Default value of the parameter, to be used when there is no client-specified value.",
)

model_config = ConfigDict(defer_build=True)


class BooleanParameter(RTPBase):
"""A boolean parameter defined in a protocol."""
Expand All @@ -1239,6 +1290,8 @@ class BooleanParameter(RTPBase):
description="Default value of the parameter, to be used when there is no client-specified value.",
)

model_config = ConfigDict(defer_build=True)


class EnumChoice(BaseModel):
"""Components of choices used in RTP Enum Parameters."""
Expand All @@ -1250,6 +1303,8 @@ class EnumChoice(BaseModel):
..., description="Enum value of the param's choice."
)

model_config = ConfigDict(defer_build=True)


class EnumParameter(RTPBase):
"""A string enum defined in a protocol."""
Expand All @@ -1270,6 +1325,8 @@ class EnumParameter(RTPBase):
description="Default value of the parameter, to be used when there is no client-specified value.",
)

model_config = ConfigDict(defer_build=True)


class FileInfo(BaseModel):
"""A file UUID descriptor."""
Expand Down

0 comments on commit 12034e0

Please sign in to comment.