From cd01d610e72c809e41252911bece55d48cc6f3b5 Mon Sep 17 00:00:00 2001 From: caila-marashaj Date: Wed, 14 Aug 2024 11:58:08 -0400 Subject: [PATCH] pull hemisphere out --- .../protocol_runner/test_json_translator.py | 37 +++++++----- .../labware/labware_definition.py | 30 ++++++++-- .../opentrons_shared_data/labware/types.py | 58 ++++++++++--------- 3 files changed, 79 insertions(+), 46 deletions(-) diff --git a/api/tests/opentrons/protocol_runner/test_json_translator.py b/api/tests/opentrons/protocol_runner/test_json_translator.py index 363d564cbd0..41914433b15 100644 --- a/api/tests/opentrons/protocol_runner/test_json_translator.py +++ b/api/tests/opentrons/protocol_runner/test_json_translator.py @@ -15,6 +15,8 @@ WellDefinition, BoundedSection, TopCrossSection, + InnerLabwareGeometry, + Hemisphere, ) from opentrons_shared_data.protocol.models import ( protocol_schema_v6, @@ -687,23 +689,30 @@ def _load_labware_definition_data() -> LabwareDefinition: }, dimensions=Dimensions(yDimension=85.5, zDimension=100, xDimension=127.75), cornerOffsetFromSlot=CornerOffsetFromSlot(x=0, y=0, z=0), - innerWellGeometry=[ - BoundedSection( - geometry=TopCrossSection( - shape="hemisphere", - diameter=25, + innerWellGeometry=InnerLabwareGeometry( + frusta=[ + BoundedSection( + geometry=TopCrossSection( + shape="rectangular", + xDimension=7.6, + yDimension=8.5, + ), + top_height=45, ), - top_height=10, - ), - BoundedSection( - geometry=TopCrossSection( - shape="rectangular", - xDimension=5.6, - yDimension=6.5, + BoundedSection( + geometry=TopCrossSection( + shape="rectangular", + xDimension=5.6, + yDimension=6.5, + ), + top_height=20, ), - top_height=45, + ], + bottom_shape=Hemisphere( + diameter=6, + depth=10, ), - ], + ), brand=BrandData(brand="foo"), metadata=Metadata( displayName="Foo 8 Well Plate 33uL", diff --git a/shared-data/python/opentrons_shared_data/labware/labware_definition.py b/shared-data/python/opentrons_shared_data/labware/labware_definition.py index bba8a55a3a9..2efbeca9d8d 100644 --- a/shared-data/python/opentrons_shared_data/labware/labware_definition.py +++ b/shared-data/python/opentrons_shared_data/labware/labware_definition.py @@ -224,23 +224,33 @@ class Config: ) +class Hemisphere(BaseModel): + diameter: _NonNegativeNumber = Field( + ..., + description="diameter of bottom subsection of wells", + ) + depth: _NonNegativeNumber = Field( + ..., description="The depth of a hemispherical bottom of a well" + ) + + class TopCrossSection(BaseModel): - shape: Literal["rectangular", "circular", "hemisphere"] = Field( + shape: Literal["rectangular", "circular"] = Field( ..., description="Shape of a cross-section of a well used to determine how " "to calculate area", ) xDimension: Optional[_NonNegativeNumber] = Field( None, - description="x dimension of rectangular wells", + description="x dimension of a subsection of wells", ) yDimension: Optional[_NonNegativeNumber] = Field( None, - description="y dimension of rectangular wells", + description="y dimension of a subsection of wells", ) diameter: Optional[_NonNegativeNumber] = Field( None, - description="diameter of circular wells", + description="diameter of a subsection of wells", ) @@ -282,6 +292,16 @@ class Group(BaseModel): ) +class InnerLabwareGeometry(BaseModel): + frusta: List[BoundedSection] = Field( + ..., + description="A list of all of the sections of the well that have a contiguous shape", + ) + bottom_shape: Optional[Hemisphere] = Field( + None, description="An optional non-frustum shape at the bottom of a well" + ) + + class LabwareDefinition(BaseModel): schemaVersion: Literal[1, 2] = Field( ..., description="Which schema version a labware is using" @@ -356,7 +376,7 @@ class LabwareDefinition(BaseModel): default_factory=None, description="Force, in Newtons, with which the gripper should grip the labware.", ) - innerWellGeometry: Optional[List[BoundedSection]] = Field( + innerWellGeometry: Optional[InnerLabwareGeometry] = Field( None, description="A list of bounded sections describing the geometry of the inside of the wells.", ) diff --git a/shared-data/python/opentrons_shared_data/labware/types.py b/shared-data/python/opentrons_shared_data/labware/types.py index 921000bc264..6aa1a72e088 100644 --- a/shared-data/python/opentrons_shared_data/labware/types.py +++ b/shared-data/python/opentrons_shared_data/labware/types.py @@ -3,7 +3,7 @@ types in this file by and large require the use of typing_extensions. this module shouldn't be imported unless typing.TYPE_CHECKING is true. """ -from typing import Dict, List, NewType, Union +from typing import Dict, List, NewType, Union, Optional from typing_extensions import Literal, TypedDict @@ -37,7 +37,6 @@ Circular = Literal["circular"] Rectangular = Literal["rectangular"] -Hemisphere = Literal["hemisphere"] WellShape = Union[Circular, Rectangular] @@ -118,6 +117,35 @@ class WellGroup(TypedDict, total=False): brand: LabwareBrandData +class CircularArea(TypedDict): + shape: Circular + diameter: float + + +class RectangularArea(TypedDict): + shape: Rectangular + xDimension: float + yDimension: float + + +TopCrossSection = Union[CircularArea, RectangularArea] + + +class Hemisphere(TypedDict): + diameter: float + depth: float + + +class BoundedSection(TypedDict): + geometry: TopCrossSection + top_height: float + + +class InnerLabwareGeometry(TypedDict): + frusta: List[BoundedSection] + bottom_shape: Optional[Hemisphere] + + class _RequiredLabwareDefinition(TypedDict): schemaVersion: Literal[2] version: int @@ -139,28 +167,4 @@ class LabwareDefinition(_RequiredLabwareDefinition, total=False): gripperOffsets: Dict[str, GripperOffsets] gripForce: float gripHeightFromLabwareBottom: float - - -class CircularArea(TypedDict): - shape: Circular - diameter: float - - -class RectangularArea(TypedDict): - shape: Rectangular - xDimension: float - yDimension: float - - -class HemisphereDimensions(TypedDict): - shape: Hemisphere - diameter: float - - -# This will either be a 2-Dimensional cross-section or a hemisphere -TopCrossSection = Union[CircularArea, RectangularArea, HemisphereDimensions] - - -class BoundedSection(TypedDict): - geometry: TopCrossSection - top_height: float + innerWellGeometry: Optional[InnerLabwareGeometry]