Skip to content

Commit

Permalink
feat: actually add to protocol api
Browse files Browse the repository at this point in the history
somehow i forgot to do this
  • Loading branch information
sfoster1 committed Nov 5, 2024
1 parent 4923195 commit 35f0806
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ def load_liquid(
"""Load liquid into a well."""
raise APIVersionError(api_element="Loading a liquid")

def load_empty(self) -> None:
"""Mark a well as empty."""
assert False, "load_empty only supported on engine core"

def from_center_cartesian(self, x: float, y: float, z: float) -> Point:
"""Gets point in deck coordinates based on percentage of the radius of each axis."""
return self._geometry.from_center_cartesian(x, y, z)
Expand Down
4 changes: 4 additions & 0 deletions api/src/opentrons/protocol_api/core/well.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ def load_liquid(
) -> None:
"""Load liquid into a well."""

@abstractmethod
def load_empty(self) -> None:
"""Mark a well as containing no liquid."""

@abstractmethod
def from_center_cartesian(self, x: float, y: float, z: float) -> Point:
"""Gets point in deck coordinates based on percentage of the radius of each axis."""
Expand Down
8 changes: 8 additions & 0 deletions api/src/opentrons/protocol_api/labware.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,20 @@ def load_liquid(self, liquid: Liquid, volume: float) -> None:
:param Liquid liquid: The liquid to load into the well.
:param float volume: The volume of liquid to load, in µL.
.. note::
In API Version 2.22 and above, use `load_empty()` to mark a well as empty at the beginning of a protocol.
"""
self._core.load_liquid(
liquid=liquid,
volume=volume,
)

@requires_version(2, 22)
def load_empty(self) -> None:
"""Mark a well as empty."""
self._core.load_empty()

def _from_center_cartesian(self, x: float, y: float, z: float) -> Point:
"""
Private version of from_center_cartesian. Present only for backward
Expand Down
9 changes: 9 additions & 0 deletions api/tests/opentrons/protocol_api/test_well.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from opentrons.protocol_api._liquid import Liquid
from opentrons.types import Point, Location

from . import versions_at_or_above


@pytest.fixture
def mock_well_core(decoy: Decoy) -> WellCore:
Expand Down Expand Up @@ -140,6 +142,13 @@ def test_load_liquid(decoy: Decoy, mock_well_core: WellCore, subject: Well) -> N
)


@pytest.mark.parametrize("api_version", versions_at_or_above(APIVersion(2, 22)))
def test_load_empty(decoy: Decoy, mock_well_core: WellCore, subject: Well) -> None:
"""It should mark a location as empty."""
subject.load_empty()
decoy.verify(mock_well_core.load_empty(), times=1)


def test_diameter(decoy: Decoy, mock_well_core: WellCore, subject: Well) -> None:
"""It should get the diameter from the core."""
decoy.when(mock_well_core.diameter).then_return(12.3)
Expand Down

0 comments on commit 35f0806

Please sign in to comment.