diff --git a/api/src/opentrons/protocol_api/core/engine/module_core.py b/api/src/opentrons/protocol_api/core/engine/module_core.py index b921f0b876d..c5b59f30a58 100644 --- a/api/src/opentrons/protocol_api/core/engine/module_core.py +++ b/api/src/opentrons/protocol_api/core/engine/module_core.py @@ -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, @@ -710,7 +715,7 @@ 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, @@ -718,7 +723,7 @@ def retrieve(self) -> None: ) 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, diff --git a/api/src/opentrons/protocol_api/core/engine/protocol.py b/api/src/opentrons/protocol_api/core/engine/protocol.py index bd4a93bf8fb..e6dc505acaf 100644 --- a/api/src/opentrons/protocol_api/core/engine/protocol.py +++ b/api/src/opentrons/protocol_api/core/engine/protocol.py @@ -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, diff --git a/api/src/opentrons/protocol_api/core/legacy/legacy_protocol_core.py b/api/src/opentrons/protocol_api/core/legacy/legacy_protocol_core.py index 115f0dccf90..cf1860d53f6 100644 --- a/api/src/opentrons/protocol_api/core/legacy/legacy_protocol_core.py +++ b/api/src/opentrons/protocol_api/core/legacy/legacy_protocol_core.py @@ -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") diff --git a/api/src/opentrons/protocol_api/core/module.py b/api/src/opentrons/protocol_api/core/module.py index d1086e50644..f97fce62cf5 100644 --- a/api/src/opentrons/protocol_api/core/module.py +++ b/api/src/opentrons/protocol_api/core/module.py @@ -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.""" diff --git a/api/src/opentrons/protocol_api/core/protocol.py b/api/src/opentrons/protocol_api/core/protocol.py index 4ea3cc5fae2..c323f3e8e27 100644 --- a/api/src/opentrons/protocol_api/core/protocol.py +++ b/api/src/opentrons/protocol_api/core/protocol.py @@ -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.""" ... diff --git a/api/src/opentrons/protocol_api/module_contexts.py b/api/src/opentrons/protocol_api/module_contexts.py index 2550f906115..a277403612e 100644 --- a/api/src/opentrons/protocol_api/module_contexts.py +++ b/api/src/opentrons/protocol_api/module_contexts.py @@ -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, @@ -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) diff --git a/api/src/opentrons/protocol_api/protocol_context.py b/api/src/opentrons/protocol_api/protocol_context.py index 45eeaec318b..1ea86aca893 100644 --- a/api/src/opentrons/protocol_api/protocol_context.py +++ b/api/src/opentrons/protocol_api/protocol_context.py @@ -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( @@ -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}", ) diff --git a/api/src/opentrons/protocol_api/validation.py b/api/src/opentrons/protocol_api/validation.py index 8f971075d37..2f2ba11a5ce 100644 --- a/api/src/opentrons/protocol_api/validation.py +++ b/api/src/opentrons/protocol_api/validation.py @@ -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.""" diff --git a/api/src/opentrons/protocol_engine/commands/flex_stacker/configure.py b/api/src/opentrons/protocol_engine/commands/flex_stacker/configure.py index 21c3c7ce153..85c0808b60a 100644 --- a/api/src/opentrons/protocol_engine/commands/flex_stacker/configure.py +++ b/api/src/opentrons/protocol_engine/commands/flex_stacker/configure.py @@ -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 ) @@ -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 diff --git a/api/src/opentrons/protocol_engine/commands/flex_stacker/retrieve.py b/api/src/opentrons/protocol_engine/commands/flex_stacker/retrieve.py index e919d569e22..f03c0e84421 100644 --- a/api/src/opentrons/protocol_engine/commands/flex_stacker/retrieve.py +++ b/api/src/opentrons/protocol_engine/commands/flex_stacker/retrieve.py @@ -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()