Skip to content

feat(api): implement mix() parameters aspirate_delay and dispense_delay #18000

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

Open
wants to merge 7 commits into
base: edge
Choose a base branch
from

Conversation

ddcc4
Copy link
Contributor

@ddcc4 ddcc4 commented Apr 7, 2025

Overview

In PD, you can specify a delay after each aspirate and dispense in a Mix step. There is no way to specify a delay in the PAPI mix() call, which means that we can't translate a PD Mix step into a PAPI mix() call.

This PR introduces the parameters aspirate_delay and dispense_delay to the InstrumentContext.mix() function. The new parameters are gated to API version 2.24 and above. AUTH-1366

Test Plan and Hands on Testing

I added tests to demonstrate that this implementation emits the correct calls to delay() when the caller requests a delay in the mix().

This is what the output looks like in simulate:

Mixing 2 times with a volume of 20.0 ul
	Aspirating 20.0 uL from C2 of (Retired) Armadillo 96 Well Plate 200 µL PCR Full Skirt on slot A2 at 716.0 uL/sec
	Delaying for 0 minutes and 2.5 seconds
	Dispensing 20.0 uL into C2 of (Retired) Armadillo 96 Well Plate 200 µL PCR Full Skirt on slot A2 at 716.0 uL/sec
	...

Review requests

InstrumentContext.mix() calls InstrumentContext.aspirate() and InstrumentContext.dispense() to implement the mix, which is nice because the public aspirate() and dispense() functions handle things like publishing messages for the simulator.

Ideally, we would also call the public delay() function for the delay. But the delay() function is in ProtocolContext, and InstrumentContext doesn't have access to that. We only have access to the ProtocolCore, so we have to publish messages to the simulator manually.

I ended up refactoring the code of mix() a bit because it was going to get too repetitive and nested with the delays and publish_context() messages added.

Risk assessment

Should be low. The new parameters are version-gated. The main risk is that we release this, and then decide that we don't want to change the public API this way.

@ddcc4 ddcc4 requested review from sanni-t and jerader April 7, 2025 20:42
@ddcc4 ddcc4 requested a review from a team as a code owner April 7, 2025 20:42
Copy link

codecov bot commented Apr 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 24.44%. Comparing base (31448fc) to head (460f249).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             edge   #18000   +/-   ##
=======================================
  Coverage   24.44%   24.44%           
=======================================
  Files        2956     2956           
  Lines      228425   228425           
  Branches    19032    19032           
=======================================
  Hits        55843    55843           
  Misses     172570   172570           
  Partials       12       12           
Flag Coverage Δ
protocol-designer 18.79% <ø> (ø)
step-generation 4.42% <ø> (ø)

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Collaborator

@jerader jerader left a comment

Choose a reason for hiding this comment

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

this is great, getting closer to always emitting python mix() when a mix step is added.

Copy link
Collaborator

@ncdiehl11 ncdiehl11 left a comment

Choose a reason for hiding this comment

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

This is looking good! Thank you for the details about why we need to manually publish a message to the broker. Tested simulation and the output looks as expected (snipped below). Approving with the caveat that a robot server dev should put eyes on this :)
Screenshot 2025-04-10 at 11 25 10 AM

@ddcc4
Copy link
Contributor Author

ddcc4 commented Apr 10, 2025

Tested simulation and the output looks as expected (snipped below).

Oh wow, thanks for testing it in the app!

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