feat(protocol-designer): emit Python for aspirate command #17594
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This implements Python code generation for the PD atomic
aspirate
command. AUTH-1094The generated code looks like this:
Test Plan and Hands on Testing
Added unit tests.
I also took the generated code and added it to a Python protocol and confirmed that it is understandable by
simulate
.Review requests
PD has its own code to load the default flow rates for a particular pipette/tip/volume:
opentrons/protocol-designer/src/utils/index.ts
Lines 211 to 215 in 8fe0be1
I was trying really hard to use those default flow rates to compute the ratio in JavaScript to pass to
aspirate(rate=...)
. E.g., if we knew that the default flow rate is 700 uL/s, and the PD user wants a flow rate of 350 uL/s, I wanted to generate code likeaspirate(rate=0.5)
.But that turned out to be unworkable. PD has a very specific algorithm for picking the default flow rates, which is not the same as what the PAPI implements. Furthermore, we discovered that the current implementation for default flow rates in the PAPI is just wrong.
So in this PR, I had to emit an explicit division expression to generate the
aspirate(rate=...)
argument.Risk assessment
Low. Python export in PD is not available to external users yet.