diff --git a/api/src/opentrons/protocol_engine/commands/absorbance_reader/read.py b/api/src/opentrons/protocol_engine/commands/absorbance_reader/read.py index 559b44efef6..10f21d7fe06 100644 --- a/api/src/opentrons/protocol_engine/commands/absorbance_reader/read.py +++ b/api/src/opentrons/protocol_engine/commands/absorbance_reader/read.py @@ -140,6 +140,9 @@ async def execute( # noqa: C901 "Plate Reader data cannot be requested with a module that has not been initialized." ) + state_update.set_absorbance_reader_data( + module_id=params.moduleId, read_result=asbsorbance_result + ) # TODO (cb, 10-17-2024): FILE PROVIDER - Some day we may want to break the file provider behavior into a seperate API function. # When this happens, we probably will to have the change the command results handler we utilize to track file IDs in engine. # Today, the action handler for the FileStore looks for a ReadAbsorbanceResult command action, this will need to be delinked. @@ -158,10 +161,6 @@ async def execute( # noqa: C901 else "VIRTUAL_SERIAL", ) - state_update.set_absorbance_reader_data( - module_id=params.moduleId, read_result=asbsorbance_result - ) - if isinstance(plate_read_result, PlateReaderData): # Write a CSV file for each of the measurements taken for measurement in plate_read_result.read_results: diff --git a/api/src/opentrons/protocol_engine/state/update_types.py b/api/src/opentrons/protocol_engine/state/update_types.py index f5d0b09be1a..1871ef69045 100644 --- a/api/src/opentrons/protocol_engine/state/update_types.py +++ b/api/src/opentrons/protocol_engine/state/update_types.py @@ -613,12 +613,11 @@ def set_absorbance_reader_data( self, module_id: str, read_result: typing.Dict[int, typing.Dict[str, float]] ) -> Self: """Update an absorbance reader's read data. See `AbsorbanceReaderReadDataUpdate`.""" - # consolidate together + self.module_state_update = ModuleStateUpdate( - module_id=module_id, module_type="absorbanceReaderType" - ) - self.absorbance_reader_data = AbsorbanceReaderDataUpdate( - read_result=read_result + module_id=module_id, + module_type="absorbanceReaderType", + absorbance_reader_data=AbsorbanceReaderDataUpdate(read_result=read_result), ) return self diff --git a/api/tests/opentrons/protocol_engine/commands/absorbance_reader/test_read.py b/api/tests/opentrons/protocol_engine/commands/absorbance_reader/test_read.py index c8d68368e38..fb3eba49040 100644 --- a/api/tests/opentrons/protocol_engine/commands/absorbance_reader/test_read.py +++ b/api/tests/opentrons/protocol_engine/commands/absorbance_reader/test_read.py @@ -1,9 +1,9 @@ """Test absorbance reader initilize command.""" import pytest from decoy import Decoy -from typing import List +from typing import List, Dict -from opentrons.drivers.types import ABSMeasurementMode +from opentrons.drivers.types import ABSMeasurementMode, ABSMeasurementConfig from opentrons.hardware_control.modules import AbsorbanceReader from opentrons.protocol_engine.execution import EquipmentHandler @@ -42,6 +42,7 @@ async def test_absorbance_reader_implementation( mabsorbance_module_substate = decoy.mock(cls=AbsorbanceReaderSubState) absorbance_module_hw = decoy.mock(cls=AbsorbanceReader) verified_module_id = AbsorbanceReaderId("module-id") + asbsorbance_result = {1: {"A1": 1.2}} decoy.when( state_view.modules.get_absorbance_reader_substate("unverified-module-id") @@ -53,19 +54,33 @@ async def test_absorbance_reader_implementation( absorbance_module_hw ) + decoy.when(await absorbance_module_hw.start_measure()).then_return([[1.2, 1.3]]) + decoy.when(absorbance_module_hw._measurement_config).then_return( + ABSMeasurementConfig( + measure_mode=ABSMeasurementMode.SINGLE, + sample_wavelengths=[1, 2], + reference_wavelength=None, + ) + ) + decoy.when( + state_view.modules.convert_absorbance_reader_data_points([1.2, 1.3]) + ).then_return({"A1": 1.2}) + result = await subject.execute(params=params) - decoy.verify( - await absorbance_module_hw.start_measure(), - times=1, - ) assert result == SuccessData( - public=ReadAbsorbanceResult(), + public=ReadAbsorbanceResult( + data=asbsorbance_result, + fileIds=[], + ), state_update=update_types.StateUpdate( + files_added=update_types.FilesAddedUpdate(file_ids=[]), module_state_update=update_types.ModuleStateUpdate( module_id="unverified-module-id", module_type="absorbanceReaderType", - absorbance_reader_data=update_types.AbsorbanceReaderDataUpdate(), - ) + absorbance_reader_data=update_types.AbsorbanceReaderDataUpdate( + read_result=asbsorbance_result + ), + ), ), )