-
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
feat(app,protocol-designer,shared-data): Allow JSON protocols to mix labware schemas #17560
base: edge
Are you sure you want to change the base?
Conversation
patternProperties: { | ||
'.+': { anyOf: [labwareSchema2, labwareSchema3] }, | ||
}, |
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.
Is this an okay way to validate into a union with ajv?
Because JSON Schema doesn't have a way of specifying a union discriminator, I'm a little worried that this will be slow and cause bad error messages.
It's certainly possible to fix that by switching on schemaVersion
ourselves. I'm just not sure whether that's worth the complexity.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## edge #17560 +/- ##
==========================================
- Coverage 26.17% 26.16% -0.02%
==========================================
Files 2838 2840 +2
Lines 217730 218328 +598
Branches 9280 9294 +14
==========================================
+ Hits 56989 57120 +131
- Misses 160724 161191 +467
Partials 17 17
Flags with carried forward coverage won't be shown. Click here to find out 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.
I think we are going to want a new protocol schema version for this because labware definitions get embedded into the protocol document directly (as opposed to through commands).
This is because of basically what you're identifying in this PR and in your other work: there are many many places where everything involved assumes labware is schema 2. We're going to be significantly changing the geometry definitions in labware 3; code is going to have to change for it; and without having some way to discriminate them up front, older apps and PD are going to see schema 8 protocols that contain schema 3 labware as just protocols that they should understand that contain invalid labware. We need some way to trigger the new code paths up front.
Interesting—I've just realized that the validation functions in protocols.ts are only called by tests, not production code? So what does validate a JSON protocol when it's imported into the app or PD? |
Overview
This allows JSON protocol files to contain a mixture of labware defined in labware schema 2 and labware defined in labware schema 3.
I think this is necessary because schemas 2 and 3 are mutually incompatible, and someone might want to use, for example, their existing schema-2 custom labware alongside our new schema-3 standard labware.
Closes EXEC-1236.
Test Plan and Hands on Testing
So far, just CI.
Changelog
Done:
In the underlying JSON schema, basically deprecate the
labwareDefinitionSchemaId
property.It was already accepting arbitrary strings, and that hasn't changed. However, in the human-readable description, we now say that it should just contain the empty string (
""
), instead of a labware schema ID like"opentronsLabwareSchemaV2"
.Protocol Designer now emits JSON protocols with
labwareDefinitionSchemaId
set to""
.The on-device display's Quick Transfer code now emits JSON protocols with
labwareDefinitionSchemaId
set to""
.Update TypeScript types to reflect that a protocol's
labware
containsLabwareDefinition2 | LabwareDefinition3
, not justLabwareDefinition2
.Update the JSON Schema validation code in shared-data to ignore
labwareDefinitionSchemaId
. Instead, it validates each labware individually into a<labware schema 2> | <labware schema 3>
union.Not done:
labwareDefinitionSchemaId
. It already accepts labware schemas 2 and 3 (though it doesn't yet handle schema 3 fully correctly).Review requests
""
thing a good approach?Risk assessment
Low?