Skip to content

Commit

Permalink
fix pip dict related commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Laura-Danielle committed Oct 30, 2024
1 parent 34025ba commit 12d7673
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,6 @@ def as_dict(self) -> "Pipette.DictType":
"versioned_tip_overlap": self.tip_overlap,
"back_compat_names": self._config.pipette_backcompat_names,
"supported_tips": self.liquid_class.supported_tips,
"plunger_positions": self.plunger_positions,
}
)
return self._config_as_dict
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ def get_attached_instrument(self, mount: MountType) -> PipetteDict:
"back_compat_names",
"supported_tips",
"lld_settings",
"plunger_positions",
]

instr_dict = instr.as_dict()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,6 @@ def as_dict(self) -> "Pipette.DictType":
"versioned_tip_overlap": self.tip_overlap,
"back_compat_names": self._config.pipette_backcompat_names,
"supported_tips": self.liquid_class.supported_tips,
"plunger_positions": self.plunger_positions,
}
)
return self._config_as_dict
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ def get_attached_instrument(self, mount: OT3Mount) -> PipetteDict:
"back_compat_names",
"supported_tips",
"lld_settings",
"plunger_positions",
]

instr_dict = instr.as_dict()
Expand Down
31 changes: 20 additions & 11 deletions api/src/opentrons/protocol_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,16 @@
)
from .disposal_locations import TrashBin, WasteChute
from ._liquid import Liquid
from ._types import OFF_DECK, PLUNGER_BLOWOUT, PLUNGER_TOP, PLUNGER_BOTTOM, PLUNGER_DROPTIP, ASPIRATE_ACTION, DISPENSE_ACTION, BLOWOUT_ACTION
from ._types import (
OFF_DECK,
PLUNGER_BLOWOUT,
PLUNGER_TOP,
PLUNGER_BOTTOM,
PLUNGER_DROPTIP,
ASPIRATE_ACTION,
DISPENSE_ACTION,
BLOWOUT_ACTION,
)
from ._nozzle_layout import (
COLUMN,
PARTIAL_COLUMN,
Expand Down Expand Up @@ -68,22 +77,22 @@
"Well",
"Liquid",
"Parameters",
# Partial Tip types
# Partial Tip types
"COLUMN",
"PARTIAL_COLUMN",
"SINGLE",
"ROW",
"ALL",
# Deck location types
# Deck location types
"OFF_DECK",
# Pipette plunger types
"PLUNGER_BLOWOUT",
"PLUNGER_TOP",
"PLUNGER_BOTTOM",
"PLUNGER_DROPTIP",
"ASPIRATE_ACTION",
"DISPENSE_ACTION",
"BLOWOUT_ACTION",
# Pipette plunger types
"PLUNGER_BLOWOUT",
"PLUNGER_TOP",
"PLUNGER_BOTTOM",
"PLUNGER_DROPTIP",
"ASPIRATE_ACTION",
"DISPENSE_ACTION",
"BLOWOUT_ACTION",
"RuntimeParameterRequiredError",
"CSVParameter",
# For internal Opentrons use only:
Expand Down
16 changes: 9 additions & 7 deletions api/src/opentrons/protocol_api/core/engine/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from opentrons.hardware_control import SyncHardwareAPI

from opentrons.types import Mount, MountType, Point, AxisType, AxisMapType
from opentrons_shared_data.pipette import types as pip_types
from opentrons_shared_data.pipette.ul_per_mm import (
piecewise_volume_conversion,
PIPETTING_FUNCTION_FALLBACK_VERSION,
Expand Down Expand Up @@ -76,30 +77,31 @@ def get_plunger_position_from_name(
maybe_pipette_state = self._sync_hardware_api.get_attached_instrument(mount)
if not maybe_pipette_state:
return 0.0
return maybe_pipette_state.plunger_positions[position_name.value]
return maybe_pipette_state["plunger_positions"][position_name.value]

def get_plunger_position_from_volume(
self, mount: Mount, volume: float, action: PlungerPositionTypes, robot_type: str
) -> float:
maybe_pipette_state = self._sync_hardware_api.get_attached_instrument(mount)
if not maybe_pipette_state:
return 0.0
tip_settings = maybe_pipette_state.supported_tips[
maybe_pipette_state.working_volume
]

converted_working_volume = pip_types.PipetteTipType.check_and_return_type(
maybe_pipette_state["working_volume"], maybe_pipette_state["max_volume"]
)
tip_settings = maybe_pipette_state["supported_tips"][converted_working_volume]
plunger_bottom = maybe_pipette_state["plunger_positions"]["bottom"]
if robot_type == "OT-2 Standard":
convert_volume = self._ul_per_mm_conversion(
tip_settings, volume, action, PIPETTING_FUNCTION_FALLBACK_VERSION
)
mm = volume / convert_volume
position = maybe_pipette_state.plunger_positions.bottom + mm
position = plunger_bottom + mm
else:
convert_volume = self._ul_per_mm_conversion(
tip_settings, volume, action, PIPETTING_FUNCTION_LATEST_VERSION
)
mm = volume / convert_volume
position = maybe_pipette_state.plunger_positions.bottom - mm
position = plunger_bottom - mm
return round(position, 6)

def move_to(self, mount: Mount, destination: Point, speed: Optional[float]) -> None:
Expand Down
1 change: 1 addition & 0 deletions api/src/opentrons/protocol_api/core/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from opentrons.types import AxisMapType, Mount, Point
from opentrons.protocol_api._types import PlungerPositionTypes, PipetteActionTypes


class AbstractRobot(ABC):
@abstractmethod
def get_pipette_type_from_engine(self, mount: Union[Mount, str]) -> Optional[str]:
Expand Down

0 comments on commit 12d7673

Please sign in to comment.