Skip to content
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(shared-data): Add "$otSharedSchema" property to labware schema 3 #17421

Draft
wants to merge 8 commits into
base: edge
Choose a base branch
from

Conversation

SyntaxColoring
Copy link
Contributor

@SyntaxColoring SyntaxColoring commented Feb 4, 2025

Background

Labware definitions currently do not have any way of self-identifying as labware definitions. They are just JSON files, with a .json file extension, and they do not contain any field that explicitly identifies them as labware definitions. So the system has to rely on heuristics, which is a little gross:

def _json_seems_like_labware(json: JsonDict) -> bool:
# "ordering" and "wells" are required properties in our labware schema v2.
return "ordering" in json and "wells" in json

This fixes that in the yet-to-be-released labware schema 3.

Closes EXEC-1156.

Test Plan and Hands on Testing

Our automated tests do not currently validate our labware definitions against schema 3. That's an accident and we're fixing it in #17425. Meanwhile, I've verified locally that the updated definitions conform to the updated schema.

Changelog

  • Add an "$otSharedSchema": "#/labware/schemas/3" top-level property to labware schema 3. This follows the pattern set by our JSON protocol schema and others.
  • Update Python and TS bindings accordingly.
  • Update labware definitions accordingly.

Review requests

See comments.

Risk assessment

At least medium because of Pydantic round-trip lossiness—see comments.

High if I'm also right about schema 3 already being released into the wild—see comments.

Copy link

codecov bot commented Feb 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 21.66%. Comparing base (2ec42e1) to head (cd1aadf).
Report is 1 commits behind head on edge.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             edge   #17421      +/-   ##
==========================================
+ Coverage   20.09%   21.66%   +1.56%     
==========================================
  Files        3191     3151      -40     
  Lines      230123   226968    -3155     
  Branches     8204     8390     +186     
==========================================
+ Hits        46246    49163    +2917     
+ Misses     183877   177803    -6074     
- Partials        0        2       +2     
Flag Coverage Δ
protocol-designer 17.41% <ø> (ø)
shared-data ?
step-generation 4.08% <ø> (-0.01%) ⬇️

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

see 161 files with indirect coverage changes

@SyntaxColoring SyntaxColoring added the gen-analyses-snapshot-pr Generate a healing PR if the analyses snapshot test fails label Feb 4, 2025

This comment was marked as resolved.

@@ -1240,6 +1240,7 @@
},
"result": {
"definition": {
"$otSharedSchema": "#/labware/schemas/3",
Copy link
Contributor Author

@SyntaxColoring SyntaxColoring Feb 5, 2025

Choose a reason for hiding this comment

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

It's surprising to me that any analysis snapshots need to change. These are for PAPIv2.21 protocols. PAPIv2.21
was released in robot software v8.2.0. Are schema 3 labware already being used in the wild? Because my understanding was that schema 3 was not ready for that.

It's a bummer if that's the case because it means it'll be difficult to make breaking schema changes. And if we can't make any breaking schema changes then we may as well have stayed on schema 2 in the first place.

Copy link
Member

Choose a reason for hiding this comment

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

Interesting. It looks like the answer to this is that these labware have only a schema v3 definition:

  • evotips_flex_96_tiprack_adapter
  • evotips_opentrons_96_labware
  • opentrons_tough_pcr_auto_sealing_lid
  • protocol_engine_lid_stack_object
  • opentrons_flex_tiprack_lid

and what's in these analyses is the thermocycler lid. these haven't shipped yet, so as long as we make sure there's v2 definitions in 8.3 before it ships we're good.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For posterity: the above is EXEC-1179 + EXEC-1180.

Comment on lines +322 to +325
"$otSharedSchema": {
"description": "The path to a valid Opentrons shared schema relative to the shared-data directory, without its extension.",
"enum": ["#/labware/schemas/3"]
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we like $otSharedSchema for this, or do we want to try use something like $id instead? $id is more standard but it would be new to us.

Copy link
Member

Choose a reason for hiding this comment

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

I would say just stick with $otSharedSchema if we're not doing a full uri ref to a schema

Comment on lines 686 to 701
class LabwareDefinition(BaseModel):
model_config = {
# `"extra": "allow"` gives us lossless preservation of the $otSharedSchema field
# (which should always be omitted in schema 2 and always be present in schema 3)
# across parse/serialize round trips. Pydantic doesn't seem to have a good way
# of doing that when the $otSharedSchema field is declared explicitly on this
# model.
#
# Splitting this model into separate ones for schemas 2 and 3 would also solve this.
"extra": "allow"
}

# $otSharedSchema deliberately omitted for now. See `"extra": "allow"` in model_config.
schemaVersion: Literal[1, 2, 3] = Field(
..., description="Which schema version a labware is using"
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this a reasonable way to avoid Pydantic hazards, at least for now?

Copy link
Member

Choose a reason for hiding this comment

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

Should be, yeah

@SyntaxColoring SyntaxColoring marked this pull request as ready for review February 5, 2025 13:59
@SyntaxColoring SyntaxColoring requested review from a team as code owners February 5, 2025 13:59
@SyntaxColoring SyntaxColoring requested review from mjhuff and removed request for a team February 5, 2025 13:59
@SyntaxColoring SyntaxColoring removed the gen-analyses-snapshot-pr Generate a healing PR if the analyses snapshot test fails label Feb 5, 2025
@SyntaxColoring
Copy link
Contributor Author

Re-drafting while #17421 (comment) is worked out.

@SyntaxColoring SyntaxColoring marked this pull request as draft February 5, 2025 22:40
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.

2 participants