Skip to content

Commit

Permalink
fix up formatting, lint and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Laura-Danielle committed Nov 21, 2024
1 parent cef72e8 commit 6800486
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 57 deletions.
39 changes: 37 additions & 2 deletions api/src/opentrons/protocol_api/core/engine/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from opentrons.protocol_engine.types import DeckPoint, MotorAxis

from opentrons.protocol_api.core.robot import AbstractRobot
from opentrons.protocol_api._types import PlungerPositionTypes, PipetteActionTypes



Expand Down Expand Up @@ -45,6 +44,34 @@ def __init__(
def _convert_to_engine_mount(self, axis_map: AxisMapType) -> Dict[MotorAxis, float]:
return {_AXIS_TYPE_TO_MOTOR_AXIS[ax]: dist for ax, dist in axis_map.items()}

<<<<<<< HEAD
=======
def _ul_per_mm_conversion(
self,
pipette_settings: SupportedTipsDefinition,
ul: float,
action: PipetteActionTypes,
) -> float:
if action == PipetteActionTypes.ASPIRATE_ACTION:
fallback = pipette_settings.aspirate.default[
PIPETTING_FUNCTION_FALLBACK_VERSION
]
sequence = pipette_settings.aspirate.default.get(
PIPETTING_FUNCTION_LATEST_VERSION, fallback
)
elif action == PipetteActionTypes.BLOWOUT_ACTION:
# TODO in followup work we should support handling blow out actions for volume.
return 1.0
else:
fallback = pipette_settings.aspirate.default[
PIPETTING_FUNCTION_FALLBACK_VERSION
]
sequence = pipette_settings.dispense.default.get(
PIPETTING_FUNCTION_LATEST_VERSION, fallback
)
return piecewise_volume_conversion(ul, sequence)

>>>>>>> fix up formatting, lint and tests
def get_pipette_type_from_engine(
self, mount: Union[Mount, str]
) -> Optional[pip_types.PipetteNameType]:
Expand Down Expand Up @@ -89,12 +116,20 @@ def get_plunger_position_from_volume(
maybe_pipette.id, "bottom"
)
)
<<<<<<< HEAD
=======
tip_settings = maybe_pipette_state["supported_tips"][converted_working_volume]
plunger_bottom = maybe_pipette_state["plunger_positions"]["bottom"]

convert_volume = self._ul_per_mm_conversion(tip_settings, volume, action)

>>>>>>> fix up formatting, lint and tests
mm = volume / convert_volume
if robot_type == "OT-2 Standard":
position = plunger_bottom + mm
else:
position = plunger_bottom - mm
return round(position, 6)
return round(position, 6) # type: ignore[no-any-return]

def move_to(self, mount: Mount, destination: Point, speed: Optional[float]) -> None:
engine_mount = MountType[mount.name]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,6 @@ def load_robot(self) -> None: # type: ignore
"""Load an adapter using its identifying parameters"""
raise APIVersionError(api_element="Loading robot")

def load_robot(self) -> None: # type: ignore
"""Load an adapter using its identifying parameters"""
raise APIVersionError(api_element="Loading robot")

def move_labware(
self,
labware_core: LegacyLabwareCore,
Expand Down
2 changes: 1 addition & 1 deletion api/src/opentrons/protocol_api/core/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import annotations

from abc import abstractmethod, ABC
from typing import Generic, Type, List, Optional, Union, Tuple, Dict, TYPE_CHECKING
from typing import Generic, List, Optional, Union, Tuple, Dict, TYPE_CHECKING

from opentrons_shared_data.deck.types import DeckDefinitionV5, SlotDefV3
from opentrons_shared_data.pipette.types import PipetteNameType
Expand Down
50 changes: 0 additions & 50 deletions api/src/opentrons/protocol_engine/execution/gantry_mover.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,56 +550,6 @@ def get_max_travel_z(self, pipette_id: str) -> float:
tip_length = tip.length if tip is not None else 0
return instrument_height - tip_length

def get_max_travel_z_from_mount(self, mount: MountType) -> float:
"""Get the maximum allowed z-height for mount."""
pipette = self._state_view.pipettes.get_by_mount(mount)
if self._state_view.config.robot_type == "OT-2 Standard":
instrument_height = (
self._state_view.pipettes.get_instrument_max_height_ot2(pipette.id)
if pipette
else VIRTUAL_MAX_OT3_HEIGHT
)
else:
instrument_height = VIRTUAL_MAX_OT3_HEIGHT
tip_length = (
self._state_view.tips.get_tip_length(pipette.id) if pipette else 0.0
)

return instrument_height - tip_length

async def move_axes(
self,
axis_map: Dict[MotorAxis, float],
critical_point: Optional[Dict[MotorAxis, float]] = None,
speed: Optional[float] = None,
) -> Dict[MotorAxis, float]:
"""Move the give axes map. No-op in virtual implementation."""
mount = self.pick_mount_from_axis_map(axis_map)
current_position = await self.get_position_from_mount(mount)
axis_map[MotorAxis.X] = axis_map.get(MotorAxis.X, 0.0) + current_position[0]
axis_map[MotorAxis.Y] = axis_map.get(MotorAxis.Y, 0.0) + current_position[1]
if mount == Mount.RIGHT:
axis_map[MotorAxis.RIGHT_Z] = (
axis_map.get(MotorAxis.RIGHT_Z, 0.0) + current_position[2]
)
elif mount == Mount.EXTENSION:
axis_map[MotorAxis.EXTENSION_Z] = (
axis_map.get(MotorAxis.EXTENSION_Z, 0.0) + current_position[2]
)
else:
axis_map[MotorAxis.LEFT_Z] = (
axis_map.get(MotorAxis.LEFT_Z, 0.0) + current_position[2]
)
critical_point = critical_point or {}
return {ax: pos - critical_point.get(ax, 0.0) for ax, pos in axis_map.items()}

async def move_mount_to(
self, mount: Mount, waypoints: List[Waypoint], speed: Optional[float]
) -> Point:
"""Move the hardware mount to a waypoint. No-op in virtual implementation."""
assert len(waypoints) > 0, "Must have at least one waypoint"
return waypoints[-1].position

def get_max_travel_z_from_mount(self, mount: MountType) -> float:
"""Get the maximum allowed z-height for mount."""
pipette = self._state_view.pipettes.get_by_mount(mount)
Expand Down

0 comments on commit 6800486

Please sign in to comment.