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

refactor(app): Use currentState for tip detection #16904

Merged
merged 3 commits into from
Nov 22, 2024

Conversation

mjhuff
Copy link
Contributor

@mjhuff mjhuff commented Nov 20, 2024

Closes EXEC-1027

Overview

After completing a run or during Error Recovery, the app runs tip detection logic to determine whether or not to pop the drop tip wizard. It does so by iterating through protocol analysis, keeping track of attached pipettes, and looking at specific tip exchange commands to determine whether a not a pipette has tips attached. While this approach works, it's both brittle (any changes to tip exchange commands breaks the logic) and also a command scanning operation.

Now that we have tip status on our new /runs/:runId/currentState endpoint, we have a more robust option for determining tip status. There's one caveat: the robot and this util do have ideas of when a tip should be considered attached. On the app, because we want to show drop tip wizard when there might be a tip attached, such as during a failed pick up tip command, we assume there is a tip attached. In this instance however, the robot server does not think a tip is attached. Unfortunately, there's no way around manually accounting for these differences, but luckily they are few, and it's still a significant improvement over tracking every tip exchange command.

There's another optimization we can make too: we don't actually need to poll /instruments for pipette data, because now, the only place we use that data is during the tip detection util. Instead, we can fetch it along with the other necessary resources when determineTipStatus is invoked.

In short, these changes give us:

  • Much easier to reason about tip detection logic.
  • Significantly less brittle.
  • No command scanning.
  • No /instruments polling.

See "Review Requests" for the big question.

Test Plan and Hands on Testing

  • Ran a bunch of drop tip CTA prompting in and out of Error Recovery on both the desktop app and ODD. Verified the modal prompts/doesn't prompt as expected.

Review requests

  • @sfoster1 , Do we want this in 8.2? I think it's pretty easy to reason about, and all changes are contained to the tip detection logic itself, but I understand either way.

Risk assessment

-medium. This does change tip detection logic, but it's pretty easy to reason about now.

@mjhuff mjhuff requested a review from a team as a code owner November 20, 2024 15:54
@mjhuff mjhuff changed the title refactor(app): Use current state tip detection refactor(app): Use currentState for tip detection Nov 20, 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.

I do not think we want this in 8.2 unless we have to create another alpha for other reasons, and maybe not even then if it increases the test surface for the alpha.

@mjhuff mjhuff added the DO NOT MERGE Indicates a PR should not be merged, even if there's a shiny green merge button available label Nov 20, 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 great and much more stable! I think that should be in resources though.

Copy link
Contributor

@SyntaxColoring SyntaxColoring left a comment

Choose a reason for hiding this comment

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

TY!

commands: RunCommandSummary[]
): PipetteTipState[] => {
return Object.entries(tipStates).map(([pipetteId, tipInfo]) => {
const pipetteInfo = pipetteInfoById[pipetteId]
Copy link
Contributor

Choose a reason for hiding this comment

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

Since pipetteInfoById is sourced from the run record, and pipetteId is sourced from the currentState endpoint, and those are two separate network requests, is there any danger here of this index not being present? Like if a new pipette is loaded, and the frontend receives an update to currentState before it receives an update to the run record?

Copy link
Contributor Author

@mjhuff mjhuff Nov 20, 2024

Choose a reason for hiding this comment

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

In terms of network requesting, the requests occur simultaneously, so I don't believe so.

It is possible that we determine tips are attached to a pipette, and then the user ignores the drop tip CTA, decides to remove the pipette without any sort of detach flow, then places on a different one while the drop tip CTA prompt is up, but I'm ok with the app breaking in this spot.

@mjhuff mjhuff changed the base branch from chore_release-8.2.0 to edge November 22, 2024 19:41
@mjhuff mjhuff requested review from a team as code owners November 22, 2024 19:41
@mjhuff mjhuff force-pushed the app_current-state-tip-detection branch from a1d2430 to abf9af0 Compare November 22, 2024 19:41
@mjhuff mjhuff removed the DO NOT MERGE Indicates a PR should not be merged, even if there's a shiny green merge button available label Nov 22, 2024
@mjhuff mjhuff merged commit d0ff76c into edge Nov 22, 2024
32 checks passed
@mjhuff mjhuff deleted the app_current-state-tip-detection branch November 22, 2024 20:15
SyntaxColoring added a commit that referenced this pull request Nov 26, 2024
Conflicts:

api/src/opentrons/protocol_engine/commands/absorbance_reader/read.py:
Conflict in error message wording between PR #16941 in release and PR #16920 in edge. I took the one in release because the one in edge was an outdated cherry pick.

app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunHeader/RunHeaderModalContainer/hooks/useRunHeaderDropTip.ts:
Just import statements.

app/src/organisms/DropTipWizardFlows/hooks/useTipAttachmentStatus/getPipettesWithTipAttached.ts:
Release removed `cursor: null` and `includeFixitCommands: null` from some network requests, leaving those fields unspecified instead (PR ##16893). Edge deleted this whole file in favor of a different one (PR #16904). I removed `cursor: null` from the new file; `includeFixitCommands: null` was already removed.
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