Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxColoring committed Dec 10, 2024
1 parent d5a707d commit 21f2977
Show file tree
Hide file tree
Showing 165 changed files with 802 additions and 802 deletions.
4 changes: 2 additions & 2 deletions api/src/opentrons/calibration_storage/deck_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def serialize_deck_configuration(
cutout_fixture_placements: List[CutoutFixturePlacement], last_modified: datetime
) -> bytes:
"""Serialize a deck configuration for storing on the filesystem."""
data = _DeckConfigurationModel.model_construct(
data = _DeckConfigurationModel.construct(
cutoutFixtures=[
_CutoutFixturePlacementModel.model_construct(
_CutoutFixturePlacementModel.construct(
cutoutId=e.cutout_id,
cutoutFixtureId=e.cutout_fixture_id,
opentronsModuleSerialNumber=e.opentrons_module_serial_number,
Expand Down
6 changes: 3 additions & 3 deletions api/src/opentrons/calibration_storage/file_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def save_to_file(
directory_path.mkdir(parents=True, exist_ok=True)
file_path = directory_path / f"{file_name}.json"
json_data = (
data.model_dump_json()
data.json()
if isinstance(data, pydantic.BaseModel)
else json.dumps(data, cls=encoder)
)
Expand All @@ -112,7 +112,7 @@ def save_to_file(

def serialize_pydantic_model(data: pydantic.BaseModel) -> bytes:
"""Safely serialize data from a Pydantic model into a form suitable for storing on disk."""
return data.model_dump_json(by_alias=True).encode("utf-8")
return data.json(by_alias=True).encode("utf-8")


_ModelT = typing.TypeVar("_ModelT", bound=pydantic.BaseModel)
Expand All @@ -133,7 +133,7 @@ def deserialize_pydantic_model(
Returns `None` if the file is missing or corrupt.
"""
try:
return model.model_validate_json(serialized)
return model.parse_obj_json(serialized)
except json.JSONDecodeError:
_log.warning("Data is not valid JSON.", exc_info=True)
return None
Expand Down
6 changes: 3 additions & 3 deletions api/src/opentrons/calibration_storage/ot2/tip_length.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _convert_tip_length_model_to_dict(
# add encoders when converting to a dict.
dict_of_tip_lengths = {}
for key, item in to_dict.items():
dict_of_tip_lengths[key] = json.loads(item.model_dump_json())
dict_of_tip_lengths[key] = json.loads(item.json())
return dict_of_tip_lengths


Expand Down Expand Up @@ -177,13 +177,13 @@ def delete_tip_length_calibration(
else:
io.delete_file(tip_length_dir / f"{pipette_id}.json")
elif tiprack_hash and any(
tiprack_hash in v.model_dump() for v in tip_lengths.values()
tiprack_hash in v.dict() for v in tip_lengths.values()
):
# NOTE this is for backwards compatibilty only
# TODO delete this check once the tip_length DELETE router
# no longer depends on a tiprack hash
for k, v in tip_lengths.items():
if tiprack_hash in v.model_dump():
if tiprack_hash in v.dict():
tip_lengths.pop(k)
if tip_lengths:
dict_of_tip_lengths = _convert_tip_length_model_to_dict(tip_lengths)
Expand Down
12 changes: 6 additions & 6 deletions api/src/opentrons/cli/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,18 +380,18 @@ async def _analyze(
else:
result = AnalysisResult.OK

results = AnalyzeResults.model_construct(
results = AnalyzeResults.construct(
createdAt=datetime.now(tz=timezone.utc),
files=[
ProtocolFile.model_construct(name=f.path.name, role=f.role)
ProtocolFile.construct(name=f.path.name, role=f.role)
for f in protocol_source.files
],
config=(
JsonConfig.model_construct(
JsonConfig.construct(
schemaVersion=protocol_source.config.schema_version
)
if isinstance(protocol_source.config, JsonProtocolConfig)
else PythonConfig.model_construct(
else PythonConfig.construct(
apiVersion=protocol_source.config.api_version
)
),
Expand All @@ -412,14 +412,14 @@ async def _analyze(
"json",
outputs,
lambda to_file: to_file.write(
results.model_dump_json(exclude_none=True).encode("utf-8"),
results.json(exclude_none=True).encode("utf-8"),
),
)
_call_for_output_of_kind(
"human-json",
outputs,
lambda to_file: to_file.write(
results.model_dump_json(exclude_none=True, indent=2).encode("utf-8")
results.json(exclude_none=True, indent=2).encode("utf-8")
),
)
if check:
Expand Down
2 changes: 1 addition & 1 deletion api/src/opentrons/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ def _create_live_context_pe(
# Non-async would use call_soon_threadsafe(), which makes the waiting harder.
async def add_all_extra_labware() -> None:
for labware_definition_dict in extra_labware.values():
labware_definition = LabwareDefinition.model_validate(
labware_definition = LabwareDefinition.parse_obj(
labware_definition_dict
)
pe.add_labware_definition(labware_definition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async def read(self) -> Message:
"""Read a message from the module server."""
try:
b = await self._reader.readuntil(MessageDelimiter)
m: Message = Message.model_validate_json(b)
m: Message = Message.parse_obj_json(b)
return m
except LimitOverrunError as e:
raise ModuleServerClientError(str(e))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def on_server_connected(
for c in self._clients:
c.write(
Message(status="connected", connections=[connection])
.model_dump_json()
.json()
.encode()
)
c.write(b"\n")
Expand All @@ -75,7 +75,7 @@ def on_server_disconnected(self, identifier: str) -> None:
for c in self._clients:
c.write(
Message(status="disconnected", connections=[connection])
.model_dump_json()
.json()
.encode()
)
c.write(MessageDelimiter)
Expand All @@ -98,7 +98,7 @@ async def _handle_connection(
# A client connected. Send a dump of all connected modules.
m = Message(status="dump", connections=list(self._connections.values()))

writer.write(m.model_dump_json().encode())
writer.write(m.json().encode())
writer.write(MessageDelimiter)

self._clients.add(writer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def load_tip_length_for_pipette(
if isinstance(tiprack, LabwareDefinition):
tiprack = typing.cast(
"TypeDictLabwareDef",
tiprack.model_dump(exclude_none=True, exclude_unset=True),
tiprack.dict(exclude_none=True, exclude_unset=True),
)

tip_length_data = calibration_storage.load_tip_length_calibration(
Expand Down
10 changes: 5 additions & 5 deletions api/src/opentrons/hardware_control/instruments/ot2/pipette.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def __init__(
use_old_aspiration_functions: bool = False,
) -> None:
self._config = config
self._config_as_dict = config.model_dump()
self._config_as_dict = config.dict()
self._pipette_offset = pipette_offset_cal
self._pipette_type = self._config.pipette_type
self._pipette_version = self._config.version
Expand Down Expand Up @@ -273,15 +273,15 @@ def update_config_item(
self._config, elements, liquid_class
)
# Update the cached dict representation
self._config_as_dict = self._config.model_dump()
self._config_as_dict = self._config.dict()

def reload_configurations(self) -> None:
self._config = load_pipette_data.load_definition(
self._pipette_model.pipette_type,
self._pipette_model.pipette_channels,
self._pipette_model.pipette_version,
)
self._config_as_dict = self._config.model_dump()
self._config_as_dict = self._config.dict()

def reset_state(self) -> None:
self._current_volume = 0.0
Expand Down Expand Up @@ -656,8 +656,8 @@ def _reload_and_check_skip(
# Same config, good enough
return attached_instr, True
else:
newdict = new_config.model_dump()
olddict = attached_instr.config.model_dump()
newdict = new_config.dict()
olddict = attached_instr.config.dict()
changed: Set[str] = set()
for k in newdict.keys():
if newdict[k] != olddict[k]:
Expand Down
4 changes: 2 additions & 2 deletions api/src/opentrons/hardware_control/instruments/ot3/gripper.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,8 @@ def _reload_gripper(
# Same config, good enough
return attached_instr, True
else:
newdict = new_config.model_dump()
olddict = attached_instr.config.model_dump()
newdict = new_config.dict()
olddict = attached_instr.config.dict()
changed: Set[str] = set()
for k in newdict.keys():
if newdict[k] != olddict[k]:
Expand Down
8 changes: 4 additions & 4 deletions api/src/opentrons/hardware_control/instruments/ot3/pipette.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(
use_old_aspiration_functions: bool = False,
) -> None:
self._config = config
self._config_as_dict = config.model_dump()
self._config_as_dict = config.dict()
self._plunger_motor_current = config.plunger_motor_configurations
self._pick_up_configurations = config.pick_up_tip_configurations
self._plunger_homing_configurations = config.plunger_homing_configurations
Expand Down Expand Up @@ -251,7 +251,7 @@ def reload_configurations(self) -> None:
self._pipette_model.pipette_channels,
self._pipette_model.pipette_version,
)
self._config_as_dict = self._config.model_dump()
self._config_as_dict = self._config.dict()

def reset_state(self) -> None:
self._current_volume = 0.0
Expand Down Expand Up @@ -770,8 +770,8 @@ def _reload_and_check_skip(
# Same config, good enough
return attached_instr, True
else:
newdict = new_config.model_dump()
olddict = attached_instr.config.model_dump()
newdict = new_config.dict()
olddict = attached_instr.config.dict()
changed: Set[str] = set()
for k in newdict.keys():
if newdict[k] != olddict[k]:
Expand Down
2 changes: 1 addition & 1 deletion api/src/opentrons/hardware_control/ot3_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ def load_attitude_matrix(to_default: bool = True) -> DeckCalibration:
return DeckCalibration(
attitude=apply_machine_transform(calibration_data.attitude),
source=calibration_data.source,
status=types.CalibrationStatus(**calibration_data.status.model_dump()),
status=types.CalibrationStatus(**calibration_data.status.dict()),
belt_attitude=calibration_data.attitude,
last_modified=calibration_data.lastModified,
pipette_calibrated_with=calibration_data.pipetteCalibratedWith,
Expand Down
2 changes: 1 addition & 1 deletion api/src/opentrons/hardware_control/robot_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def load_attitude_matrix() -> DeckCalibration:
return DeckCalibration(
attitude=calibration_data.attitude,
source=calibration_data.source,
status=types.CalibrationStatus(**calibration_data.status.model_dump()),
status=types.CalibrationStatus(**calibration_data.status.dict()),
last_modified=calibration_data.last_modified,
pipette_calibrated_with=calibration_data.pipette_calibrated_with,
tiprack=calibration_data.tiprack,
Expand Down
6 changes: 3 additions & 3 deletions api/src/opentrons/protocol_api/core/engine/labware.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ def get_name(self) -> str:
def get_definition(self) -> LabwareDefinitionDict:
"""Get the labware's definition as a plain dictionary."""
return cast(
LabwareDefinitionDict, self._definition.model_dump(exclude_none=True)
LabwareDefinitionDict, self._definition.dict(exclude_none=True)
)

def get_parameters(self) -> LabwareParametersDict:
return cast(
LabwareParametersDict,
self._definition.parameters.model_dump(exclude_none=True),
self._definition.parameters.dict(exclude_none=True),
)

def get_quirks(self) -> List[str]:
Expand All @@ -120,7 +120,7 @@ def set_calibration(self, delta: Point) -> None:
details={"kind": "labware-not-in-slot"},
)

request = LabwareOffsetCreate.model_construct(
request = LabwareOffsetCreate.construct(
definitionUri=self.get_uri(),
location=offset_location,
vector=LabwareOffsetVector(x=delta.x, y=delta.y, z=delta.z),
Expand Down
2 changes: 1 addition & 1 deletion api/src/opentrons/protocol_api/core/engine/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def add_labware_definition(
) -> LabwareLoadParams:
"""Add a labware definition to the set of loadable definitions."""
uri = self._engine_client.add_labware_definition(
LabwareDefinition.model_validate(definition)
LabwareDefinition.parse_obj(definition)
)
return LabwareLoadParams.from_uri(uri)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ async def execute( # noqa: C901
)
asbsorbance_result[wavelength] = converted_values
transform_results.append(
ReadData.model_construct(
ReadData.construct(
wavelength=wavelength, data=converted_values
)
)
Expand All @@ -140,7 +140,7 @@ async def execute( # noqa: C901
)
asbsorbance_result[wavelength] = converted_values
transform_results.append(
ReadData.model_construct(
ReadData.construct(
wavelength=wavelength, data=converted_values
)
)
Expand All @@ -157,7 +157,7 @@ async def execute( # noqa: C901
file_ids: list[str] = []
if params.fileName is not None:
# Create the Plate Reader Transform
plate_read_result = PlateReaderData.model_construct(
plate_read_result = PlateReaderData.construct(
read_results=transform_results,
reference_wavelength=abs_reader_substate.reference_wavelength,
start_time=start_time,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ async def execute(
calibration_data = result

return SuccessData(
public=CalibrateGripperResult.model_construct(
jawOffset=Vec3f.model_construct(
public=CalibrateGripperResult.construct(
jawOffset=Vec3f.construct(
x=probe_offset.x, y=probe_offset.y, z=probe_offset.z
),
savedCalibration=calibration_data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ async def execute(
await ot3_api.save_instrument_offset(mount=ot3_mount, delta=pipette_offset)

return SuccessData(
public=CalibratePipetteResult.model_construct(
pipetteOffset=InstrumentOffsetVector.model_construct(
public=CalibratePipetteResult.construct(
pipetteOffset=InstrumentOffsetVector.construct(
x=pipette_offset.x, y=pipette_offset.y, z=pipette_offset.z
)
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ async def execute(
self, params: ConfigureNozzleLayoutParams
) -> SuccessData[ConfigureNozzleLayoutResult]:
"""Check that requested pipette can support the requested nozzle layout."""
primary_nozzle = params.configurationParams.model_dump().get("primaryNozzle")
front_right_nozzle = params.configurationParams.model_dump().get(
primary_nozzle = params.configurationParams.dict().get("primaryNozzle")
front_right_nozzle = params.configurationParams.dict().get(
"frontRightNozzle"
)
back_left_nozzle = params.configurationParams.model_dump().get("backLeftNozzle")
back_left_nozzle = params.configurationParams.dict().get("backLeftNozzle")
nozzle_params = await self._tip_handler.available_for_nozzle_layout(
pipette_id=params.pipetteId,
style=params.configurationParams.style,
Expand Down
2 changes: 1 addition & 1 deletion api/src/opentrons/protocol_engine/commands/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CustomImplementation(
async def execute(self, params: CustomParams) -> SuccessData[CustomResult]:
"""A custom command does nothing when executed directly."""
return SuccessData(
public=CustomResult.model_construct(),
public=CustomResult.construct(),
)


Expand Down
8 changes: 4 additions & 4 deletions api/src/opentrons/protocol_engine/commands/movement_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ async def move_to_well(
state_update=StateUpdate().clear_all_pipette_locations(),
)
else:
deck_point = DeckPoint.model_construct(x=position.x, y=position.y, z=position.z)
deck_point = DeckPoint.construct(x=position.x, y=position.y, z=position.z)
return SuccessData(
public=DestinationPositionResult(
position=deck_point,
Expand Down Expand Up @@ -222,7 +222,7 @@ async def move_relative(
state_update=StateUpdate().clear_all_pipette_locations(),
)
else:
deck_point = DeckPoint.model_construct(x=position.x, y=position.y, z=position.z)
deck_point = DeckPoint.construct(x=position.x, y=position.y, z=position.z)
return SuccessData(
public=DestinationPositionResult(
position=deck_point,
Expand Down Expand Up @@ -277,7 +277,7 @@ async def move_to_addressable_area(
.set_addressable_area_used(addressable_area_name=addressable_area_name),
)
else:
deck_point = DeckPoint.model_construct(x=x, y=y, z=z)
deck_point = DeckPoint.construct(x=x, y=y, z=z)
return SuccessData(
public=DestinationPositionResult(position=deck_point),
state_update=StateUpdate()
Expand Down Expand Up @@ -324,7 +324,7 @@ async def move_to_coordinates(
state_update=StateUpdate().clear_all_pipette_locations(),
)
else:
deck_point = DeckPoint.model_construct(x=x, y=y, z=z)
deck_point = DeckPoint.construct(x=x, y=y, z=z)

return SuccessData(
public=DestinationPositionResult(position=DeckPoint(x=x, y=y, z=z)),
Expand Down
Loading

0 comments on commit 21f2977

Please sign in to comment.