-
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
feat(shared-data): add robot definitions #11428
Conversation
Add some quick and small json files that can represent kinds of robot, primarily as a thing for other files to reference.
Codecov Report
@@ Coverage Diff @@
## edge #11428 +/- ##
==========================================
- Coverage 74.40% 74.38% -0.03%
==========================================
Files 2049 2069 +20
Lines 56732 57260 +528
Branches 5420 5537 +117
==========================================
+ Hits 42214 42591 +377
- Misses 13270 13411 +141
- Partials 1248 1258 +10
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.
Without anything actually using these configs, I'm having a little bit of trouble understanding the intent behind the various fields. Some thoughts, though
RobotId = Literal["ot-2", "ot-3"] | ||
|
||
|
||
class RobotDefinition(TypedDict): |
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.
Would you be opposed to not using TypedDict
for these? They're fairly annoying to work with as a caller
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.
What should we use instead? I really like the pattern of having this module provide a descriptive type for the result of json.load()
, which is a typed dict.
"""A python version of the robot definition type.""" | ||
|
||
otId: str | ||
friendlyName: str |
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.
displayName
, to match other resources?
|
||
RobotSchemaVersion1 = Literal[1] | ||
|
||
RobotSchema = NewType("RobotSchema", Dict[str, Any]) |
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 don't see this used anywhere
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.
it's not right now, but then again none of this is - just seemed like a reasonable thing to provide
|
||
RobotSchema = NewType("RobotSchema", Dict[str, Any]) | ||
|
||
RobotName = Literal["OT-2 Standard", "OT-3 Standard"] |
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.
Similar comment as the TypeDict
one: these type literals are annoying to use as a caller. I see a lot of use with Literal
for doing stuff like @overload
, but here, and Enum
feels more appropriate
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 really hate the use of Enum(str)
as synonymous with string, but I guess I could use that instead
shared-data/robot/schemas/1.json
Outdated
"type": "#/definitions/robotId" | ||
}, | ||
"otId": { | ||
"description": "A UUID for the machine type. Intended for use as a reference in other documents.", |
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.
Both the field name otId
and the value type of UUID seems a bit weird for the purposes of "identify the machine type." Could we use a part number instead?
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 should get rid of it - I added it by analogy to
opentrons/shared-data/deck/schemas/3.json
Lines 67 to 71 in 2041697
"properties": { | |
"otId": { | |
"description": "Unique internal ID generated using UUID", | |
"type": "string" | |
}, |
shared-data/js/types.ts
Outdated
robotId: RobotId | ||
otId: string |
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 don't quite understand the different between these two things
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.
robotId
is for a future interface that would have shorter, nicer, machine-readable machine identification keys. otId
is a uuid I added because other stuff seemed to but I would happily get rid of it.
shared-data/js/types.ts
Outdated
friendlyName: string | ||
robotName: RobotName |
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 also don't really understand the difference between these two things
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.
this and the IDs are a consequence of the only actual backward compatibility concerns. Robots in the field use "OT-2 Standard" as their robot type in their health responses (and edge uses this as mdns txt records), and that value is used to discriminate between robots. That makes it a machine-readable value, if a little gross and overspecific. That's the robotName
.
It also seems like a good idea to have a friendlyName
, or displayName
or whatever, specified separately for use in UIs. For now, it just happens that this is also OT-2 Standard
, but in theory it might not be.
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.
@mcous added some inline responses, but I have two bigger questions -
- You have some notes about some fields, either their values or names; those notes are mostly on the js and python type bindings. These should change in the schema if we change them, right?
- In general, what I've tried to do with the python and js type bindings here - as we've done with other modules in
shared_data
- is to provide descriptive types for the result of loading the json into the language, hence the use ofTypedDict
andLiteral
. I'd kind of like to keep them as this kind of descriptive thing rather than deserializing to dataclass and enum.
|
||
RobotSchema = NewType("RobotSchema", Dict[str, Any]) | ||
|
||
RobotName = Literal["OT-2 Standard", "OT-3 Standard"] |
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 really hate the use of Enum(str)
as synonymous with string, but I guess I could use that instead
|
||
RobotSchemaVersion1 = Literal[1] | ||
|
||
RobotSchema = NewType("RobotSchema", Dict[str, Any]) |
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.
it's not right now, but then again none of this is - just seemed like a reasonable thing to provide
shared-data/js/types.ts
Outdated
friendlyName: string | ||
robotName: RobotName |
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.
this and the IDs are a consequence of the only actual backward compatibility concerns. Robots in the field use "OT-2 Standard" as their robot type in their health responses (and edge uses this as mdns txt records), and that value is used to discriminate between robots. That makes it a machine-readable value, if a little gross and overspecific. That's the robotName
.
It also seems like a good idea to have a friendlyName
, or displayName
or whatever, specified separately for use in UIs. For now, it just happens that this is also OT-2 Standard
, but in theory it might not be.
shared-data/js/types.ts
Outdated
robotId: RobotId | ||
otId: string |
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.
robotId
is for a future interface that would have shorter, nicer, machine-readable machine identification keys. otId
is a uuid I added because other stuff seemed to but I would happily get rid of it.
RobotId = Literal["ot-2", "ot-3"] | ||
|
||
|
||
class RobotDefinition(TypedDict): |
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.
What should we use instead? I really like the pattern of having this module provide a descriptive type for the result of json.load()
, which is a typed dict.
shared-data/robot/schemas/1.json
Outdated
"type": "#/definitions/robotId" | ||
}, | ||
"otId": { | ||
"description": "A UUID for the machine type. Intended for use as a reference in other documents.", |
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 should get rid of it - I added it by analogy to
opentrons/shared-data/deck/schemas/3.json
Lines 67 to 71 in 2041697
"properties": { | |
"otId": { | |
"description": "Unique internal ID generated using UUID", | |
"type": "string" | |
}, |
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.
Talked through this with @sfoster1 and @shlokamin. This PR is good to move forward, and in the longer term, our plan is to reduce our reliance on the shared-data
package for this sort of information, which is more appropriate as robot-side implementation details.
The world we'd like to be for implementation details like robot definitions and pipette definitions involves one-way data flows from the robot (or API code) to the client, with the device being the singular source of truth rather than shared-data
as a side channel that is assumed to be in sync between the two systems. Will get started on a proposal for that in the mean time
Add some quick and small json files that can represent kinds of robot, primarily as a thing for other files to reference. Closes RCORE-126
Add some quick and small json files that can represent kinds of robot,
primarily as a thing for other files to reference.
Closes RCORE-126