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

feat(api): Validate plate reader status using live data hookups for engine and introduce lid status to the PAPI #15872

Merged
merged 31 commits into from
Aug 14, 2024

Conversation

CaseyBatten
Copy link
Contributor

@CaseyBatten CaseyBatten commented Aug 1, 2024

Overview

Ensure that the lid position is automatically updated in live runs, and that the live data is used to validate position on load, open and close. Validate that labware cannot be moved to the plate reader unless the plate reader is open. Add is_lid_on() PAPI exposure for use in python protocols.

Closes: PLAT-208 PLAT-386

Test Plan and Hands on Testing

Run the following protocol and ensure the expected results below occur (NOTE: Must set Max API version to 2.21):

from opentrons import protocol_api

# metadata
metadata = {
    'protocolName': 'Absorbance Reader Test Protocol',
    'author': 'Platform Expansion',
}

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

DRYRUN = 'YES'
USE_GRIPPER = 'TRUE'

# protocol run function
def run(protocol: protocol_api.ProtocolContext):

    mod = protocol.load_module('absorbanceReaderV1', 'D3')
    sample_plate = protocol.load_labware('armadillo_96_wellplate_200ul_pcr_full_skirt','A2')

    #COMMENT OUT THE FOLLOWING TWO LINES FOR TEST 3
    if mod.is_lid_on():
        mod.open_lid()

    protocol.move_labware(
        sample_plate,
        new_location=mod,
        use_gripper=USE_GRIPPER,
    )
    mod.close_lid()

Tests:

  • Begin Protocol on Robot with lid on, ensure lid status check passes and lid removal, labware movement, and lid replacement occur as expected
  • Begin Protocol on Robot with lid off, ensure .open(...) command no ops and moves on
  • Begin Protocol with Lid off, ensure .close(...) command no ops and moves on

Changelog

  • Updated protocol_api/protocol_context.py move_labware(...) function to contain special case validation for moving to a plate reader module when it's lid status is closed (expect error to raise).
  • Added in live data hookup infrastructure for the Absorbance Reader, hooked lid status data into the engine to report live (remaining live data points will be passed into engine in small follow up PR)
  • Addition of Protocol API is_lid_on() method

Review requests

Take a look at the validation workaround that had to be put into move_labware(...). It's a special casing due to the way that plate reader lid labware is being injected into the engine labware store via the deck configuration. Previously, if the lid was closed and an attempt was made to move labware onto the plate reader, we would get a random key error with the unique labware ID of the lid returned. This addition returns a much nicer error, but I'm not entirely sure if special casing is the best approach here, let me know any thoughts on this.

Risk assessment

Low risk - only effects plate reader module data and validations.

ahiuchingau and others added 24 commits July 10, 2024 13:52
…e commands and bump required version to 2.21
this was set to 2 21 for testing but should remain at 2 20
@CaseyBatten CaseyBatten marked this pull request as ready for review August 5, 2024 13:48
@CaseyBatten CaseyBatten requested a review from a team as a code owner August 5, 2024 13:48
Copy link
Contributor

@vegano1 vegano1 left a comment

Choose a reason for hiding this comment

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

This makes sense to me!

Base automatically changed from abs96_move-lid-command to edge August 9, 2024 17:43
@vegano1 vegano1 requested review from a team as code owners August 9, 2024 17:43
@vegano1 vegano1 requested review from mjhuff and removed request for a team August 9, 2024 17:43
@vegano1 vegano1 requested a review from ahiuchingau August 9, 2024 19:54
Copy link
Contributor

@ecormany ecormany left a comment

Choose a reason for hiding this comment

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

Suggestions for some potentially user-facing copy.

self._core.open_lid()

@requires_version(2, 21)
def is_lid_on(self) -> bool:
"""Return True if the Absorbance Reader's lid is currently closed."""
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's Sphinx it up

Suggested change
"""Return True if the Absorbance Reader's lid is currently closed."""
"""Return ``True`` if the Absorbance Reader's lid is currently closed."""

I'm OK with leaving the implication that False means it's open, but if false means open or unknown, we should state that.

if isinstance(new_location, AbsorbanceReaderContext):
if new_location.is_lid_on():
raise CommandPreconditionViolated(
f"Cannot move {labware.name} onto the Absorbance Reader Module when Lid is Closed."
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
f"Cannot move {labware.name} onto the Absorbance Reader Module when Lid is Closed."
f"Cannot move {labware.name} onto the Absorbance Reader Module when its lid is closed."

nit

result = await abs_reader.get_current_lid_status()
if result is not AbsorbanceReaderLidStatus.ON:
raise CannotPerformModuleAction(
"The Opentrons Plate Reader lid mechanicaly position did not match expected Closed state."
Copy link
Contributor

Choose a reason for hiding this comment

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

can this error ever bubble up to be shown to users? if so, needs an edit.

Suggested change
"The Opentrons Plate Reader lid mechanicaly position did not match expected Closed state."
"The mechanical position of the Absorbance Plate Reader's lid did not match the expected 'closed' state."

@vegano1
Copy link
Contributor

vegano1 commented Aug 13, 2024

Looking good to me, i tested this on a PlatypusExpansion robot

@CaseyBatten CaseyBatten merged commit b9daa39 into edge Aug 14, 2024
21 checks passed
@CaseyBatten CaseyBatten deleted the abs96_lid_status_engine branch August 14, 2024 22:30
vegano1 pushed a commit that referenced this pull request Sep 17, 2024
…ngine and introduce lid status to the PAPI (#15872)

Closes: PLAT-208 PLAT-386
Ensure lid status utilizes live data, can no op open() and close() commands, and expose `is_lid_on()` to PAPI for use in protocols
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