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 1d800dee7ea..9f2785b7432 100644 --- a/api/src/opentrons/protocol_api/core/engine/module_core.py +++ b/api/src/opentrons/protocol_api/core/engine/module_core.py @@ -586,7 +586,7 @@ def initialize( ) self._initialized_value = wavelengths - def read(self, filename: Optional[str]) -> Dict[int, Dict[str, float]]: + def read(self, filename: Optional[str] = None) -> Dict[int, Dict[str, float]]: """Initiate a read on the Absorbance Reader, and return the results. During Analysis, this will return a measurement of zero for all wells.""" wavelengths = self._engine_client.state.modules.get_absorbance_reader_substate( 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 0ed5270320a..dac8bc44a5b 100644 --- a/api/src/opentrons/protocol_api/core/engine/protocol.py +++ b/api/src/opentrons/protocol_api/core/engine/protocol.py @@ -449,9 +449,10 @@ def load_module( # When the protocol engine is created, we add Module Lids as part of the deck fixed labware # If a valid module exists in the deck config. For analysis, we add the labware here since - # deck fixed labware is not created under the same conditions. - if self._engine_client.state.config.use_virtual_modules: - self._load_virtual_module_lid(module_core) + # deck fixed labware is not created under the same conditions. We also need to inject the Module + # lids when the module isnt already on the deck config, like when adding a new + # module during a protocol setup. + self._load_virtual_module_lid(module_core) self._module_cores_by_id[module_core.module_id] = module_core @@ -461,20 +462,24 @@ def _load_virtual_module_lid( self, module_core: Union[ModuleCore, NonConnectedModuleCore] ) -> None: if isinstance(module_core, AbsorbanceReaderCore): - lid = self._engine_client.execute_command_without_recovery( - cmd.LoadLabwareParams( - loadName="opentrons_flex_lid_absorbance_plate_reader_module", - location=ModuleLocation(moduleId=module_core.module_id), - namespace="opentrons", - version=1, - displayName="Absorbance Reader Lid", - ) + substate = self._engine_client.state.modules.get_absorbance_reader_substate( + module_core.module_id ) + if substate.lid_id is None: + lid = self._engine_client.execute_command_without_recovery( + cmd.LoadLabwareParams( + loadName="opentrons_flex_lid_absorbance_plate_reader_module", + location=ModuleLocation(moduleId=module_core.module_id), + namespace="opentrons", + version=1, + displayName="Absorbance Reader Lid", + ) + ) - self._engine_client.add_absorbance_reader_lid( - module_id=module_core.module_id, - lid_id=lid.labwareId, - ) + self._engine_client.add_absorbance_reader_lid( + module_id=module_core.module_id, + lid_id=lid.labwareId, + ) def _create_non_connected_module_core( self, load_module_result: LoadModuleResult diff --git a/api/src/opentrons/protocol_api/core/module.py b/api/src/opentrons/protocol_api/core/module.py index c93e8ce8de8..e24fbbc54b0 100644 --- a/api/src/opentrons/protocol_api/core/module.py +++ b/api/src/opentrons/protocol_api/core/module.py @@ -365,7 +365,7 @@ def initialize( """Initialize the Absorbance Reader by taking zero reading.""" @abstractmethod - def read(self, filename: Optional[str]) -> Dict[int, Dict[str, float]]: + def read(self, filename: Optional[str] = None) -> Dict[int, Dict[str, float]]: """Get an absorbance reading from the Absorbance Reader.""" @abstractmethod diff --git a/api/src/opentrons/protocol_api/module_contexts.py b/api/src/opentrons/protocol_api/module_contexts.py index f7541da1836..9ae550f8d3f 100644 --- a/api/src/opentrons/protocol_api/module_contexts.py +++ b/api/src/opentrons/protocol_api/module_contexts.py @@ -1035,7 +1035,9 @@ def initialize( ) @requires_version(2, 21) - def read(self, export_filename: Optional[str]) -> Dict[int, Dict[str, float]]: + def read( + self, export_filename: Optional[str] = None + ) -> Dict[int, Dict[str, float]]: """Initiate read on the Absorbance Reader. Returns a dictionary of wavelengths to dictionary of values ordered by well name. diff --git a/robot-server/robot_server/runs/router/base_router.py b/robot-server/robot_server/runs/router/base_router.py index 23f1d6eb446..b7df09f8992 100644 --- a/robot-server/robot_server/runs/router/base_router.py +++ b/robot-server/robot_server/runs/router/base_router.py @@ -575,7 +575,7 @@ async def get_run_commands_error( status.HTTP_409_CONFLICT: {"model": ErrorBody[RunStopped]}, }, ) -async def get_current_state( +async def get_current_state( # noqa: C901 runId: str, run_data_manager: Annotated[RunDataManager, Depends(get_run_data_manager)], hardware: Annotated[HardwareControlAPI, Depends(get_hardware)], @@ -586,6 +586,8 @@ async def get_current_state( Arguments: runId: Run ID pulled from URL. run_data_manager: Run data retrieval interface. + hardware: Hardware control interface. + robot_type: The type of robot. """ try: run = run_data_manager.get(run_id=runId) diff --git a/robot-server/tests/runs/router/test_base_router.py b/robot-server/tests/runs/router/test_base_router.py index e9ec31d9b18..0a0266c0c65 100644 --- a/robot-server/tests/runs/router/test_base_router.py +++ b/robot-server/tests/runs/router/test_base_router.py @@ -58,7 +58,6 @@ from robot_server.runs.run_models import RunNotFoundError from robot_server.runs.router.base_router import ( AllRunsLinks, - PlaceLabwareState, create_run, get_run_data_from_url, get_run, @@ -885,17 +884,17 @@ async def test_get_current_state_success( mock_nozzle_maps ) command_pointer = CommandPointer( - command_id="command-id", - command_key="command-key", - created_at=datetime(year=2024, month=4, day=4), - index=101, - ) + command_id="command-id", + command_key="command-key", + created_at=datetime(year=2024, month=4, day=4), + index=101, + ) decoy.when( mock_run_data_manager.get_last_completed_command(run_id=run_id) ).then_return(command_pointer) - decoy.when( - mock_run_data_manager.get_current_command(run_id=run_id) - ).then_return(command_pointer) + decoy.when(mock_run_data_manager.get_current_command(run_id=run_id)).then_return( + command_pointer + ) result = await get_current_state( runId=run_id,