-
Notifications
You must be signed in to change notification settings - Fork 180
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): Support simulating PAPIv≥2.14 #13709
Conversation
b5902a3
to
163b8ba
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## chore_release-7.0.1 #13709 +/- ##
=======================================================
- Coverage 71.23% 71.23% -0.01%
=======================================================
Files 2430 2430
Lines 68439 68383 -56
Branches 8043 8043
=======================================================
- Hits 48755 48713 -42
+ Misses 17786 17772 -14
Partials 1898 1898
Flags with carried forward coverage won't be shown. Click here to find out more.
|
* Mark CommandScraper and AccumulatingHandler as private. * Tighten up typing on CommandScraper queue. * Add comment about _CommandScraper setting the log level.
…cols. Rewrite simulate.py to be structured like execute.py.
This helps us deal with `ProtocolReader` requiring a filename to infer the protocol type, while `opentrons.simulate.simulate()` doesn't always have a trustworthy protocol filename to work with. By accepting a `Protocol` object as input, we can reuse `opentrons.protocols.parse`'s logic for guessing the protocol type.
163b8ba
to
3516a4f
Compare
This comment was marked as resolved.
This comment was marked as resolved.
… internal errors.
filename=getattr(protocol, "co_filename", "<protocol>"), | ||
filename=filename, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Falling back to "<protocol>"
at this level was lossy. If we weren't given a filename, we want to preserve that information for the caller, by returning None
, so they can choose their own fallback.
This comment was marked as resolved.
This comment was marked as resolved.
Running locally, so far so good, need to test standard and JSON protocols on a Flex, might I recommend a change here: opentrons/api/src/opentrons/simulate.py Line 928 in ca8da73
Should say something more like this to clarify support for the Flex:
I'll update again once I have run this on actual Flex hardware. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Went through code and tested in a live review, looks good. Welcome back opentrons_simulate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌 Great work! Changes make sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was capable of running multiple Flex python and JSONv5 protocols via the simulation CLI. Did not interrupt standard Flex operation.
Notable changes: * Rework `simulate.py` to support PAPIv≥2.14 protocols, via Protocol Engine. This rework mirrors what we did to `execute.py` in #12970. * Rework the `adapt_protocol_source()` helper to cope with protocols for which we don't know the filename. This is necessary to support `opentrons.simulate.simulate()`, whose `filename` argument is optional. Unfortunately, this requires modifications to `opentrons.protocols.parse` to make the filename more pass-through, so `adapt_protocol_source()` can tell when it wasn't provided. Plus various smaller refactors for type safety, deduplication, and consistency.
Overview
Closes RSS-322. Lets you run new Python protocols through
opentrons_simulate
,opentrons.simulate.simulate()
, andopentrons.simulate.get_protocol_api()
.Also fixes a straggling instance of RSS-156, incorrectly using the machine's current deck type in simulation, instead of the correct deck type to match the protocol.
Test Plan
See this document.
Changelog
Notable changes:
Rework
simulate.py
to support PAPIv≥2.14 protocols, via Protocol Engine. This rework mirrors what we did toexecute.py
in feat(api): Limited support for programmatically running PAPIv≥2.14 #12970.Rework the
adapt_protocol_source()
helper to cope with protocols for which we don't know the filename. This is necessary to supportopentrons.simulate.simulate()
, whosefilename
argument is optional.Unfortunately, this requires modifications to
opentrons.protocols.parse
to make the filename more pass-through, soadapt_protocol_source()
can tell when it wasn't provided.Plus various smaller refactors for type safety, deduplication, and consistency.
Code review requests
I suggest code-reviewing this in two ways:
simulate.py
file side-by-side with the latestexecute.py
file. They should mirror each other almost exactly.simulate.py
returns the run log, whereas the stuff inexecute.py
sends run log events to a callback.execute.py
has a global hardware controller and globalProtocolEngine
s, whereassimulate.py
only has the globalProtocolEngine
s.Some special things to watch out for:
simulate.py
to make it look likeexecute.py
, make sure I didn't accidentally drop anything unique to the oldsimulate.py
that was important.adapt_protocol_source()
andopentrons.protocols.parse
.Risk assessment
Medium.
This touches some subtle parts of
opentrons.protocols.parse
andopentrons.protocols.execute
. The touches are light, but those areas are critical to protocol execution.It also touches the simulation of PAPIv≤2.13 and JSONv≤5 protocols, so we need regression testing on those. See the test plan.