Skip to content

Commit

Permalink
address pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ahiuchingau committed Jan 17, 2025
1 parent c986a98 commit 0331330
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 46 deletions.
11 changes: 8 additions & 3 deletions api/src/opentrons/protocol_api/core/engine/module_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,12 @@ class FlexStackerCore(ModuleCore, AbstractFlexStackerCore):
_sync_module_hardware: SynchronousAdapter[hw_modules.FlexStacker]

def set_static_mode(self, static: bool) -> None:
"""Set the Flex Stacker's static mode."""
"""Set the Flex Stacker's static mode.
The Flex Stacker cannot retrieve and or store when in static mode.
This allows the Flex Stacker carriage to be used as a staging slot,
and allowed the labware to be loaded onto it.
"""
self._engine_client.execute_command(
cmd.flex_stacker.ConfigureParams(
moduleId=self.module_id,
Expand All @@ -710,15 +715,15 @@ def set_static_mode(self, static: bool) -> None:
)

def retrieve(self) -> None:
"""Retrieve a labware id from the bottom of the Flex Stacker's stack."""
"""Retrieve a labware from the Flex Stacker's hopper."""
self._engine_client.execute_command(
cmd.flex_stacker.RetrieveParams(
moduleId=self.module_id,
)
)

def store(self) -> None:
"""Store a labware at the bottom of the Flex Stacker's stack."""
"""Store a labware into Flex Stacker's hopper."""
self._engine_client.execute_command(
cmd.flex_stacker.StoreParams(
moduleId=self.module_id,
Expand Down
13 changes: 5 additions & 8 deletions api/src/opentrons/protocol_api/core/engine/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,16 +379,13 @@ def load_labware_to_flex_stacker_hopper(
module_core: Union[ModuleCore, NonConnectedModuleCore],
load_name: str,
quantity: int,
label: Optional[str] = None,
namespace: Optional[str] = None,
version: Optional[int] = None,
lid: Optional[str] = None,
label: Optional[str],
namespace: Optional[str],
version: Optional[int],
lid: Optional[str],
) -> None:
"""Load one or more labware with or without a lid to the flex stacker hopper."""
assert (
isinstance(module_core, ModuleCore)
and module_core.MODULE_TYPE == ModuleType.FLEX_STACKER
)
assert isinstance(module_core, FlexStackerCore)
for _ in range(quantity):
labware_core = self.load_labware(
load_name=load_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,10 +529,10 @@ def load_labware_to_flex_stacker_hopper(
module_core: legacy_module_core.LegacyModuleCore,
load_name: str,
quantity: int,
label: str | None = None,
namespace: str | None = None,
version: int | None = None,
lid: str | None = None,
label: Optional[str],
namespace: Optional[str],
version: Optional[int],
lid: Optional[str],
) -> None:
"""Load labware to a Flex stacker hopper."""
raise APIVersionError(api_element="Flex stacker")
Expand Down
4 changes: 2 additions & 2 deletions api/src/opentrons/protocol_api/core/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,8 @@ def set_static_mode(self, static: bool) -> None:

@abstractmethod
def retrieve(self) -> None:
"""Release and return a labware at the bottom of the labware stack."""
"""Release a labware from the hopper to the staging slot."""

@abstractmethod
def store(self) -> None:
"""Store a labware at the bottom of the labware stack."""
"""Store a labware in the stacker hopper."""
8 changes: 4 additions & 4 deletions api/src/opentrons/protocol_api/core/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ def load_labware_to_flex_stacker_hopper(
module_core: ModuleCoreType,
load_name: str,
quantity: int,
label: Optional[str] = None,
namespace: Optional[str] = None,
version: Optional[int] = None,
lid: Optional[str] = None,
label: Optional[str],
namespace: Optional[str],
version: Optional[int],
lid: Optional[str],
) -> None:
"""Load one or more labware with or without a lid to the flex stacker hopper."""
...
Expand Down
23 changes: 5 additions & 18 deletions api/src/opentrons/protocol_api/module_contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1122,18 +1122,7 @@ def load_labware_to_hopper(
version: Optional[int] = None,
lid: Optional[str] = None,
) -> None:
"""Load one or more labware onto the flex stacker.
The parameters of this function behave like those of
:py:obj:`ProtocolContext.load_labware` (which loads labware directly
onto the deck). Note that the parameter ``name`` here corresponds to
``load_name`` on the ``ProtocolContext`` function.
:returns: The initialized and loaded labware object.
.. versionadded:: 2.23
The *label,* *namespace,* and *version* parameters.
"""
"""Load one or more labware onto the flex stacker."""
self._protocol_core.load_labware_to_flex_stacker_hopper(
module_core=self._core,
load_name=load_name,
Expand All @@ -1144,23 +1133,21 @@ def load_labware_to_hopper(
lid=lid,
)

@requires_version(2, 23)
def enter_static_mode(self) -> None:
"""Enter static mode.
In static mode, the Flex Stacker will not move labware between the hopper and
the deck. The stacker can be used as a staging slot area.
.. versionadded:: 2.23
the deck, and can be used as a staging slot area.
"""
self._core.set_static_mode(static=True)

@requires_version(2, 23)
def exit_static_mode(self) -> None:
"""End static mode.
In static mode, the Flex Stacker will not move labware between the hopper and
the deck. This is useful for debugging and manual operation.
.. versionadded:: 2.23
the deck, and can be used as a staging slot area.
"""
self._core.set_static_mode(static=False)

Expand Down
5 changes: 2 additions & 3 deletions api/src/opentrons/protocol_api/protocol_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,6 @@ def load_module(
.. versionchanged:: 2.23
Added ``FlexStackerModuleContext`` return value.
"""
flex_stacker_valid_since = APIVersion(2, 23)
if configuration:
if self._api_version < APIVersion(2, 4):
raise APIVersionError(
Expand Down Expand Up @@ -904,11 +903,11 @@ def load_module(
)
if (
isinstance(requested_model, FlexStackerModuleModel)
and self._api_version < flex_stacker_valid_since
and self._api_version < validation.FLEX_STACKER_VERSION_GATE
):
raise APIVersionError(
api_element=f"Module of type {module_name}",
until_version=str(flex_stacker_valid_since),
until_version=str(validation.FLEX_STACKER_VERSION_GATE),
current_version=f"{self._api_version}",
)

Expand Down
3 changes: 3 additions & 0 deletions api/src/opentrons/protocol_api/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
# The first APIVersion where Python protocols can load lids as stacks and treat them as attributes of a parent labware.
LID_STACK_VERSION_GATE = APIVersion(2, 23)

# The first APIVersion where Python protocols can use the Flex Stacker module.
FLEX_STACKER_VERSION_GATE = APIVersion(2, 23)


class InvalidPipetteMountError(ValueError):
"""An error raised when attempting to load pipettes on an invalid mount."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(
self._state_view = state_view

async def execute(self, params: ConfigureParams) -> SuccessData[ConfigureResult]:
"""Execute the labware retrieval command."""
"""Execute the configurecommand."""
stacker_state = self._state_view.modules.get_flex_stacker_substate(
params.moduleId
)
Expand All @@ -58,7 +58,7 @@ async def execute(self, params: ConfigureParams) -> SuccessData[ConfigureResult]


class Configure(BaseCommand[ConfigureParams, ConfigureResult, ErrorOccurrence]):
"""A command to Configure a labware from a Flex Stacker."""
"""A command to configure the Flex Stacker."""

commandType: ConfigureCommandType = "flexStacker/configure"
params: ConfigureParams
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ async def execute(self, params: RetrieveParams) -> SuccessData[RetrieveResult]:

try:
self._state_view.labware.raise_if_labware_in_location(stacker_loc)
except Exception as e:
except Exception:
raise CannotPerformModuleAction(
f"Cannot retrieve a labware from Flex Stacker if the carriage is occupied: {e}"
"Cannot retrieve a labware from Flex Stacker if the carriage is occupied"
)

state_update = update_types.StateUpdate()
Expand Down

0 comments on commit 0331330

Please sign in to comment.