-
Notifications
You must be signed in to change notification settings - Fork 179
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(shared-data): Split TypedDict
-based bindings for labware schemas 2 and 3
#17517
Conversation
This unfortunately did not work: `json.loads()` returns vanilla dicts all the way down, and `typeguard.check_type()` expects TypedDicts all the way down.
These classes used to live higher up, in `opentrons.protocol_api.load_info`, and we needed to go out of way to keep them hidden from the public. We no longer need to do that, now that they live in `opentrons.protocol_api.core.legacy`.
0eae7e3
to
dbb4a58
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## edge #17517 +/- ##
===========================================
+ Coverage 26.17% 63.63% +37.45%
===========================================
Files 2835 2835
Lines 217682 217918 +236
Branches 9276 18140 +8864
===========================================
+ Hits 56971 138662 +81691
+ Misses 160694 79061 -81633
- Partials 17 195 +178
Flags with carried forward coverage won't be shown. Click here to find out more.
|
dbb4a58
to
f3b402e
Compare
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.
code changes look good! can we add tests for the legacy to make sure they raise on schema 3? or maybe you did and I missed it?
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.
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.
Nice job! thank you for explaining!
Overview
Goes towards EXEC-1206. See that ticket for background.
Changelog
Split the
opentrons_shared_data.labware.types.LabwareDefinition
TypedDict
intoLabwareDefinition2
andLabwareDefinition3
.Then, audit the consuming code and try to find boundaries between code that needs to handle both schemas vs. code that should limit itself to schema 2:
opentrons.protocol_api.core.legacy
, which handles Python protocols withapiLevel
≤2.13 and JSON protocols with protocol schema ≤5, is limited to labware schema 2 for scope reasons.Labware schema 3 entails major changes in the way we represent labware geometry, including moving a labware's origin from the bottom-left to the top-left. Coping with this will involve a good amount of changes just for new
apiLevel
s (EXEC-78), and I doubt we want to spend time duplicating those changes for oldapiLevel
s too.opentrons.calibration_storage
is limited to labware schema 2 because allowing schema 3 would break users' ability to downgrade, without further changes tocalibration_storage
. In theory, at least.OT-2 calibration (
robot_server.robot.calibration
androbot_server.sessions
) is limited to labware schema 2 because it is built on the two packages above.All of those restrictions could be lifted in the future, if we have reason to.
Implementing those restrictions, for now, basically means littering the code with
assert schemaVersion == 2
. In at least some cases, this is not correct. A user can still load a schema 3 labware, and it will only hit one of theseassert
s later on, causing a confusing internal error. Ideally, we'd prevent the user from loading the schema 3 labware at our API boundaries, before it reaches our innards and hits one of theseassert
s. Improving this is ticketed as EXEC-1210 and EXEC-1230.Next steps
To fully close EXEC-1206, will need to do the same thing for our Pydantic-based models (
opentrons_shared_data.labware.labware_definition.LabwareDefinition
), and that will happen in another PR.Also EXEC-1210 and EXEC-1230, as described above.
Test Plan and Hands on Testing
AssertionError
s now.Review requests
Risk assessment
Medium. There's a risk of something like this happening:
assert
s, and causes a confusing error.I have not found anything that does that, specifically—it seems like labware loads generally default to the first version, not the latest version—but that gives you an idea of what can go wrong with this.