Skip to content

Commit 2d58c37

Browse files
chore: pydantic 2.11 (#18872)
Bumps the system to use pydantic 2.11, which has much less memory usage when building model classes. Pretty well tested on flex and ot-2 (ot-2 requires the buildroot pr). --------- Co-authored-by: Max Marrone <[email protected]>
1 parent bbf819b commit 2d58c37

File tree

19 files changed

+1839
-1747
lines changed

19 files changed

+1839
-1747
lines changed

api/Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ name = "pypi"
55

66
[packages]
77
jsonschema = "==4.17.3"
8-
pydantic = "==2.9.0"
8+
pydantic = "==2.11.7"
99
pydantic-settings = "==2.4.0"
1010
anyio = "==3.7.1"
1111
opentrons-shared-data = { editable = true, path = "../shared-data" }

api/Pipfile.lock

Lines changed: 322 additions & 285 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/src/opentrons/protocol_engine/commands/configure_for_volume.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Configure for volume command request, result, and implementation models."""
2+
23
from __future__ import annotations
34
from typing import TYPE_CHECKING, Optional, Type, Any
45

@@ -29,7 +30,7 @@ class ConfigureForVolumeParams(PipetteIdMixin):
2930
...,
3031
description="Amount of liquid in uL. Must be at least 0 and no greater "
3132
"than a pipette-specific maximum volume.",
32-
ge=0,
33+
ge=0.0,
3334
)
3435
tipOverlapNotAfterVersion: str | SkipJsonSchema[None] = Field(
3536
None,

api/src/opentrons/protocol_engine/commands/pick_up_tip.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,21 @@ class PickUpTipResult(DestinationPositionResult):
5151

5252
# Tip volume has a default ONLY for parsing data from earlier versions, which did not include this in the result
5353
tipVolume: float = Field(
54-
0,
54+
0.0,
5555
description="Maximum volume of liquid that the picked up tip can hold, in µL.",
56-
ge=0,
56+
ge=0.0,
5757
)
5858

5959
tipLength: float = Field(
60-
0,
60+
0.0,
6161
description="The length of the tip in mm.",
62-
ge=0,
62+
ge=0.0,
6363
)
6464

6565
tipDiameter: float = Field(
66-
0,
66+
0.0,
6767
description="The diameter of the tip in mm.",
68-
ge=0,
68+
ge=0.0,
6969
)
7070

7171

api/src/opentrons/protocol_engine/commands/pipetting_common.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class AspirateVolumeMixin(BaseModel):
4343
" the pipette (see `loadPipette`), its configuration (see `configureForVolume`),"
4444
" the tip (see `pickUpTip`), and the amount you've aspirated so far."
4545
" There is some tolerance for floating point rounding errors.",
46-
ge=0,
46+
ge=0.0,
4747
)
4848
correctionVolume: Optional[float] = Field(
4949
None,
@@ -59,7 +59,7 @@ class DispenseVolumeMixin(BaseModel):
5959
description="The amount of liquid to dispense, in µL."
6060
" Must not be greater than the currently aspirated volume."
6161
" There is some tolerance for floating point rounding errors.",
62-
ge=0,
62+
ge=0.0,
6363
)
6464
correctionVolume: Optional[float] = Field(
6565
None,
@@ -71,7 +71,7 @@ class FlowRateMixin(BaseModel):
7171
"""Mixin for command requests that take a flow rate."""
7272

7373
flowRate: float = Field(
74-
..., description="Speed in µL/s configured for the pipette", gt=0
74+
..., description="Speed in µL/s configured for the pipette", gt=0.0
7575
)
7676

7777

@@ -81,7 +81,7 @@ class BaseLiquidHandlingResult(BaseModel):
8181
volume: float = Field(
8282
...,
8383
description="Amount of liquid in uL handled in the operation.",
84-
ge=0,
84+
ge=0.0,
8585
)
8686

8787

api/src/opentrons/protocol_engine/commands/seal_pipette_to_tip.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,21 @@ class SealPipetteToTipResult(DestinationPositionResult):
8484
"""Result data from the execution of a SealPipetteToTip."""
8585

8686
tipVolume: float = Field(
87-
0,
87+
0.0,
8888
description="Maximum volume of liquid that the picked up tip can hold, in µL.",
89-
ge=0,
89+
ge=0.0,
9090
)
9191

9292
tipLength: float = Field(
93-
0,
93+
0.0,
9494
description="The length of the tip in mm.",
95-
ge=0,
95+
ge=0.0,
9696
)
9797

9898
tipDiameter: float = Field(
99-
0,
99+
0.0,
100100
description="The diameter of the tip in mm.",
101-
ge=0,
101+
ge=0.0,
102102
)
103103

104104

api/src/opentrons/protocol_engine/types/module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ class ModuleDefinition(BaseModel):
197197
...,
198198
)
199199
gripperOffsets: Optional[Dict[str, LabwareMovementOffsetData]] = Field(
200-
default_factory=dict,
200+
default_factory=lambda: {},
201201
)
202202

203203
features: LocatingFeatures = Field(

hardware/Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ python-can = "==4.2.2"
88
pyserial = "==3.5"
99
typing-extensions = ">=4.0.0,<5"
1010
numpy = "==1.22.3"
11-
pydantic = "==2.9.0"
11+
pydantic = "==2.11.7"
1212
pydantic-settings = "==2.4.0"
1313
opentrons-shared-data = { editable = true, path = "../shared-data" }
1414

hardware/Pipfile.lock

Lines changed: 496 additions & 433 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

robot-server/Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ aiohttp = "==3.8.1"
4545
fastapi = "==0.100.0"
4646
python-dotenv = "==1.0.1"
4747
python-multipart = "==0.0.6"
48-
pydantic = "==2.9.0"
48+
pydantic = "==2.11.7"
4949
typing-extensions = ">=4.0.0,<5"
5050
uvicorn = "==0.27.0.post1"
5151
wsproto = "==1.2.0"

0 commit comments

Comments
 (0)