-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(api, robot-server): Plate Reader CSV output functionality #16495
Merged
Merged
Changes from 3 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7b46ac0
initial csv file provider infastructure
CaseyBatten ad3687e
csv file writing engine to robot server pipeline and PAPI update for …
CaseyBatten e9bdbff
schema 10 update for plate reader
CaseyBatten 55c2db5
file provider asynchronous fix and directory writing
CaseyBatten cbc0382
test fixture linting fixes and doc strings
CaseyBatten 840e9fb
addition of file output data to run result and tracking of files crea…
CaseyBatten 09fdb0c
ensure file count persists in analysis use of constructors for class …
CaseyBatten 27b4c88
write csv return file id
CaseyBatten a564912
Merge branch 'edge' into plate_reader_csv_engine_file_provider
CaseyBatten 68e1176
test fixtures corrections and file parameter updates
CaseyBatten 0482e96
generic csv build with rules
CaseyBatten b020705
lint
CaseyBatten File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
"""Command models to read absorbance.""" | ||
from __future__ import annotations | ||
from datetime import datetime | ||
from typing import Optional, Dict, TYPE_CHECKING | ||
from typing_extensions import Literal, Type | ||
|
||
|
@@ -9,6 +10,9 @@ | |
from ...errors import CannotPerformModuleAction | ||
from ...errors.error_occurrence import ErrorOccurrence | ||
|
||
from ...resources.file_provider import PlateReaderDataTransform, ReadData | ||
from ...resources import FileProvider | ||
|
||
if TYPE_CHECKING: | ||
from opentrons.protocol_engine.state.state import StateView | ||
from opentrons.protocol_engine.execution import EquipmentHandler | ||
|
@@ -21,6 +25,10 @@ class ReadAbsorbanceParams(BaseModel): | |
"""Input parameters for an absorbance reading.""" | ||
|
||
moduleId: str = Field(..., description="Unique ID of the Absorbance Reader.") | ||
fileName: Optional[str] = Field( | ||
None, | ||
description="Optional file name to use when storing the results of a measurement.", | ||
) | ||
|
||
|
||
class ReadAbsorbanceResult(BaseModel): | ||
|
@@ -40,10 +48,12 @@ def __init__( | |
self, | ||
state_view: StateView, | ||
equipment: EquipmentHandler, | ||
file_provider: FileProvider, | ||
**unused_dependencies: object, | ||
) -> None: | ||
self._state_view = state_view | ||
self._equipment = equipment | ||
self._file_provider = file_provider | ||
|
||
async def execute( | ||
self, params: ReadAbsorbanceParams | ||
|
@@ -63,17 +73,45 @@ async def execute( | |
) | ||
|
||
if abs_reader is not None: | ||
start_time = datetime.now() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You probably want to use
|
||
results = await abs_reader.start_measure() | ||
finish_time = datetime.now() | ||
if abs_reader._measurement_config is not None: | ||
asbsorbance_result: Dict[int, Dict[str, float]] = {} | ||
sample_wavelengths = abs_reader._measurement_config.sample_wavelengths | ||
transform_results = [] | ||
for wavelength, result in zip(sample_wavelengths, results): | ||
converted_values = ( | ||
self._state_view.modules.convert_absorbance_reader_data_points( | ||
data=result | ||
) | ||
) | ||
asbsorbance_result[wavelength] = converted_values | ||
transform_results.append( | ||
ReadData.build(wavelength=wavelength, data=converted_values) | ||
) | ||
|
||
# Begin interfacing with the file provider if the user provided a filename | ||
if params.fileName is not None and abs_reader.serial_number is not None: | ||
plate_read_result = PlateReaderDataTransform.build( | ||
read_results=transform_results, | ||
reference_wavelength=abs_reader_substate.reference_wavelength, | ||
start_time=start_time, | ||
finish_time=finish_time, | ||
serial_number=abs_reader.serial_number, | ||
) | ||
|
||
if isinstance(plate_read_result, PlateReaderDataTransform): | ||
# Write a CSV file for each of the measurements taken | ||
for measurement in plate_read_result.read_results: | ||
await self._file_provider.write_csv( | ||
write_data=plate_read_result.build_generic_csv( | ||
filename=params.fileName, | ||
measurement=measurement, | ||
) | ||
) | ||
|
||
# Return success data to api | ||
return SuccessData( | ||
public=ReadAbsorbanceResult(data=asbsorbance_result), | ||
private=None, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean that if
filename
isn't specified…Plate Reader output [timestamp].csv
My understanding was that we'd always write a file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No file will be written. There is a limit (currently) of 40 files written during a protocol run. The user can do unlimited reads so long as they are not writing a file. They can do 40 reads where they save a file.