Skip to content
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

fix(api): restrict the labware that can be moved to the plate reader + validate wavelengths. #16649

Merged
merged 5 commits into from
Nov 5, 2024

Conversation

vegano1
Copy link
Contributor

@vegano1 vegano1 commented Oct 30, 2024

Overview

This pull request restricts labware that can be loaded or moved onto a plate reader slot

  • Contains 96 wells exactly
  • Is below a certain height restriction (16 mm)

This also restricts the wavelengths that can be used

Closes: PLAT-541 PLAT-581

Test Plan and Hands on Testing

  • Load and move labware on a plate reader with a height 15mm or less
  • Make sure we raise LabwareMovementNotAllowedError if the labware is not 96 wells or the height is > 15mm
  • Make sure we only accept wavelengths in the range of 350 - 1000 nm or throw analysis error otherwise
  • Make sure we only accept 1 wavelength in single mode and 1-6 wavelengths in multi-mode or throw analysis error otherwise.

Changelog

  • add raise_if_labware_incompatible_with_plate_reader that checks labware compatibility with the plate reader
  • use raise_if_labware_incompatible_with_plate_reader in LoadModule and MoveLabware commands.
  • Add checks to absorbance reader PAPI commands so we fail during analysis if we have invalid wavelengths

Review requests

  • is the labware.py module the correct location for raise_if_labware_incompatible_with_plate_reader

Risk assessment

low

@vegano1 vegano1 requested a review from a team as a code owner October 30, 2024 23:04
@vegano1 vegano1 requested a review from CaseyBatten October 30, 2024 23:05
@vegano1 vegano1 force-pushed the PLAT-541-restrict-plate-reader-labware branch from f32ce9d to 4c2831e Compare October 31, 2024 11:54
@vegano1 vegano1 requested a review from a team as a code owner October 31, 2024 11:54
@vegano1 vegano1 requested review from smb2268 and removed request for a team October 31, 2024 11:54
@vegano1 vegano1 changed the base branch from edge to chore_release-8.2.0 October 31, 2024 11:54
Copy link
Contributor

@CaseyBatten CaseyBatten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, should do what we need. Just a question below about clarifying our final pick for the max height restriction.

Comment on lines 824 to 828
def raise_if_labware_incompatible_with_plate_reader(
self,
labware_id: str,
) -> None:
"""Raise an error if the labware is not compatible with the plate reader."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solid, the two cases in here should cover us pretty well.

@@ -81,6 +81,10 @@
}


# The max height of the labware that can fit in a plate reader
_PLATE_READER_MAX_LABWARE_Z_MM = 15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure we want the limit to be 15mm? Inner dimension of the plate reader lid was measured to approximately 16mm.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, just as a margin of error.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would rule out the Tough PCR plate, which has a definition height of 16.00 mm. I think we definitely want to allow it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ecormany
good call out, fixed it.

@ecormany
Copy link
Contributor

ecormany commented Nov 1, 2024

I'm getting simulation/analysis errors just trying to load a plate reader on this branch. Is this something wrong with my setup?

Protocol (truncated, but it fails on line 23, the one that starts pr =)


requirements = {"robotType": "Flex", "apiLevel": "2.21"}

def run(protocol: protocol_api.ProtocolContext):
    # load tip rack
    tiprack = protocol.load_labware(
        load_name="opentrons_flex_96_tiprack_1000ul", location="C3"
    )
    # attach pipette to left mount
    pipette = protocol.load_instrument(
        instrument_name="flex_1channel_1000",
        mount="left",
        tip_racks=[tiprack]
    )
    # load well plate in deck slot D2
    plate = protocol.load_labware(
        load_name="corning_96_wellplate_360ul_flat", location="D2"
    )
    # load trash bin
    trash = protocol.load_trash_bin("A3")

    pr = protocol.load_module(
        module_name="absorbanceReaderV1",
        location="D3"
    )

Result

ProtocolCommandFailedError [line 23]: Error 4000 GENERAL_ERROR (ProtocolCommandFailedError): LabwareNotLoadedError: Labware 87f8d4f8-4a13-4351-aab3-87d991554d43 not found.
Caught exception: {'message': 'Task was destroyed but it is pending!', 'task': <Task pending name='Task-17' coro=<Poller._poll_forever() done, defined at /Users/edwardcormany/opentrons/api/src/opentrons/hardware_control/poller.py:76> wait_for=<Future pending cb=[Task.task_wakeup()]>>}

@vegano1 vegano1 requested a review from a team as a code owner November 1, 2024 19:33
@vegano1
Copy link
Contributor Author

vegano1 commented Nov 1, 2024

I'm getting simulation/analysis errors just trying to load a plate reader on this branch. Is this something wrong with my setup?

Protocol (truncated, but it fails on line 23, the one that starts pr =)


requirements = {"robotType": "Flex", "apiLevel": "2.21"}

def run(protocol: protocol_api.ProtocolContext):
    # load tip rack
    tiprack = protocol.load_labware(
        load_name="opentrons_flex_96_tiprack_1000ul", location="C3"
    )
    # attach pipette to left mount
    pipette = protocol.load_instrument(
        instrument_name="flex_1channel_1000",
        mount="left",
        tip_racks=[tiprack]
    )
    # load well plate in deck slot D2
    plate = protocol.load_labware(
        load_name="corning_96_wellplate_360ul_flat", location="D2"
    )
    # load trash bin
    trash = protocol.load_trash_bin("A3")

    pr = protocol.load_module(
        module_name="absorbanceReaderV1",
        location="D3"
    )

Result

ProtocolCommandFailedError [line 23]: Error 4000 GENERAL_ERROR (ProtocolCommandFailedError): LabwareNotLoadedError: Labware 87f8d4f8-4a13-4351-aab3-87d991554d43 not found.
Caught exception: {'message': 'Task was destroyed but it is pending!', 'task': <Task pending name='Task-17' coro=<Poller._poll_forever() done, defined at /Users/edwardcormany/opentrons/api/src/opentrons/hardware_control/poller.py:76> wait_for=<Future pending cb=[Task.task_wakeup()]>>}

Yeah there was a bug, should be fixed now.

@vegano1 vegano1 changed the title fix(api): restrict the labware that can be loaded/moved to the plate reader. fix(api): restrict the labware that can be moved to the plate reader. Nov 1, 2024
@vegano1 vegano1 force-pushed the PLAT-541-restrict-plate-reader-labware branch from 369c920 to e25402a Compare November 1, 2024 19:40
@vegano1 vegano1 requested a review from ecormany November 1, 2024 19:50
@vegano1 vegano1 force-pushed the PLAT-541-restrict-plate-reader-labware branch from 5b86acb to 6fc53da Compare November 1, 2024 20:02
@ecormany
Copy link
Contributor

ecormany commented Nov 1, 2024

It loads and the restrictions on wavelengths are working now too! Fantastic.

One question: do we care to distinguish between loading and moving oversize labware to the reader? Currently they both raise the same error:

    reservoir = pr.load_labware(
        name="usascientific_12_reservoir_22ml",
    )

ProtocolCommandFailedError [line 29]: Error 4000 GENERAL_ERROR (ProtocolCommandFailedError): LabwareMovementNotAllowedError: Cannot move 'usascientific_12_reservoir_22ml' into plate reader because the labware contains 12 wells where 96 wells is expected.

Copy link

codecov bot commented Nov 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (chore_release-8.2.0@c4a1f35). Learn more about missing BASE report.

Additional details and impacted files

Impacted file tree graph

@@                  Coverage Diff                   @@
##             chore_release-8.2.0   #16649   +/-   ##
======================================================
  Coverage                       ?   92.43%           
======================================================
  Files                          ?       77           
  Lines                          ?     1283           
  Branches                       ?        0           
======================================================
  Hits                           ?     1186           
  Misses                         ?       97           
  Partials                       ?        0           
Flag Coverage Δ
g-code-testing 92.43% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

@vegano1 vegano1 force-pushed the PLAT-541-restrict-plate-reader-labware branch from 04b0cc8 to a950f15 Compare November 1, 2024 21:24
validate wavelengths for analysis
update max height to 16mm and clean up
@vegano1 vegano1 force-pushed the PLAT-541-restrict-plate-reader-labware branch from a950f15 to 3129f05 Compare November 3, 2024 22:01
@vegano1 vegano1 changed the title fix(api): restrict the labware that can be moved to the plate reader. fix(api): restrict the labware that can be moved to the plate reader + validate wavelengths. Nov 3, 2024
Copy link
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good but maybe make the wavelength limits a constant?

)

if reference_wavelength is not None and (
reference_wavelength < 350 or reference_wavelength > 1000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we maybe get these as consts

@vegano1 vegano1 merged commit 01c06d5 into chore_release-8.2.0 Nov 5, 2024
21 checks passed
@vegano1 vegano1 deleted the PLAT-541-restrict-plate-reader-labware branch November 5, 2024 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants