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): Do not enter recovery mode if detect_liquid_presence() detects no liquid #15698

Merged
merged 8 commits into from
Jul 18, 2024

Conversation

SyntaxColoring
Copy link
Contributor

@SyntaxColoring SyntaxColoring commented Jul 17, 2024

Overview

This closes EXEC-598.

Test plan

Run this protocol without any liquid:

from opentrons import protocol_api

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


def run(protocol: protocol_api.ProtocolContext) -> None:
    pipette = protocol.load_instrument("flex_1channel_1000", mount="left")
    tip_rack = protocol.load_labware("opentrons_flex_96_tiprack_200ul", "C2")

    labware = protocol.load_labware("opentrons_96_wellplate_200ul_pcr_full_skirt", "D2")

    pipette.pick_up_tip(tip_rack["A1"])
    result = pipette.detect_liquid_presence(labware["A1"])
    protocol.pause("Liquid present? " + str(result))
    pipette.require_liquid_presence(labware["A1"])
    pipette.return_tip()
  • The detect_liquid_presence() call should return False without entering recovery mode.
  • Then, the require_liquid_presence() call should enter recovery mode.

Changelog

Reimplement InstrumentContext.detect_liquid_presence() atop the new tryLiquidProbe command, implemented in #15667.

Review requests

Any thoughts on my big comment in api/src/opentrons/protocol_api/core/engine/instrument.py? I think one of the "right" solutions in EXEC-598 would help. But even with that, it remains unclear to me how we want the overall system to behave when something like this happens:

  1. The protocol asks for a detect_liquid_presence() result (True/False)
  2. The command fails for an error unrelated to liquid probing

Risk assessment

Low.

@SyntaxColoring SyntaxColoring requested a review from a team as a code owner July 17, 2024 21:16
@SyntaxColoring SyntaxColoring requested a review from a team July 17, 2024 21:16
Resolve conflicts in api/tests/opentrons/protocol_api/core/engine/test_instrument_core.py.
Comment on lines 847 to 864
# The error handling here is a bit nuanced and also a bit broken:
#
# - If the hardware detects liquid, the `tryLiquidProbe` engine command will
# succeed and return a height, which we'll convert to a `True` return.
# Okay so far.
#
# - If the hardware detects no liquid, the `tryLiquidProbe` engine command will
# suceced and return `None`, which we'll convert to a `False` return.
# Still okay so far.
#
# - If there is any other error within the `tryLiquidProbe` command, things get
# messy. It may kick the run into recovery mode. At that point, all bets are
# off--we lose our guarantee of having a `tryLiquidProbe` command whose
# `result` we can inspect. We don't know how to deal with that here, so we
# currently propagate the exception up, which will quickly kill the protocol,
# after a potential split second of recovery mode. It's unclear what would
# be good user-facing behavior here, but it's unfortunate to kill the protocol
# for an error that the engine thinks should be recoverable.
Copy link
Contributor Author

@SyntaxColoring SyntaxColoring Jul 17, 2024

Choose a reason for hiding this comment

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

This third case, I believe, cannot happen in practice right now because our error recovery policy does not do error recovery for any tryLiquidProbe failures . But who knows how long that will last.

Copy link
Member

Choose a reason for hiding this comment

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

Is this unique to liquid probe? Wouldn't this be the case for any kind of command run from the protocol api via execute_command_without_recovery? Or even executing a command that returns structured errors with execute_command_without_recovery?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is not unique to liquid_probe(), you're correct. It's any time PAPI uses execute_command_without_recovery(), or, even more generally, any time PAPI has potentially different error-handling ideas than PE.

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 to me, and I agree with the fundamentals of your comment - but is that really unique to liquid probe?

Comment on lines 847 to 864
# The error handling here is a bit nuanced and also a bit broken:
#
# - If the hardware detects liquid, the `tryLiquidProbe` engine command will
# succeed and return a height, which we'll convert to a `True` return.
# Okay so far.
#
# - If the hardware detects no liquid, the `tryLiquidProbe` engine command will
# suceced and return `None`, which we'll convert to a `False` return.
# Still okay so far.
#
# - If there is any other error within the `tryLiquidProbe` command, things get
# messy. It may kick the run into recovery mode. At that point, all bets are
# off--we lose our guarantee of having a `tryLiquidProbe` command whose
# `result` we can inspect. We don't know how to deal with that here, so we
# currently propagate the exception up, which will quickly kill the protocol,
# after a potential split second of recovery mode. It's unclear what would
# be good user-facing behavior here, but it's unfortunate to kill the protocol
# for an error that the engine thinks should be recoverable.
Copy link
Member

Choose a reason for hiding this comment

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

Is this unique to liquid probe? Wouldn't this be the case for any kind of command run from the protocol api via execute_command_without_recovery? Or even executing a command that returns structured errors with execute_command_without_recovery?

Copy link
Contributor

@TamarZanzouri TamarZanzouri left a comment

Choose a reason for hiding this comment

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

LGTM! small typo fix

@Opentrons Opentrons deleted a comment from github-actions bot Jul 18, 2024
@SyntaxColoring
Copy link
Contributor Author

Failing tests look like a setuptools update thing, unrelated to this PR.

@SyntaxColoring SyntaxColoring merged commit 641194f into edge Jul 18, 2024
37 of 44 checks passed
@SyntaxColoring SyntaxColoring deleted the papi_try_liquid_probe branch July 18, 2024 17:08
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.

3 participants