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 robot definitions #11428

Merged
merged 2 commits into from
Sep 6, 2022

Conversation

sfoster1
Copy link
Member

@sfoster1 sfoster1 commented Sep 2, 2022

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.
@sfoster1 sfoster1 requested a review from shlokamin September 2, 2022 16:37
@sfoster1 sfoster1 requested review from a team as code owners September 2, 2022 16:37
@codecov
Copy link

codecov bot commented Sep 2, 2022

Codecov Report

Merging #11428 (1c45153) into edge (220c15c) will decrease coverage by 0.02%.
The diff coverage is 95.45%.

Impacted file tree graph

@@            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     
Flag Coverage Δ
app 74.61% <ø> (-0.06%) ⬇️
protocol-designer 45.81% <ø> (ø)
shared-data 86.44% <95.45%> (-7.99%) ⬇️
step-generation 88.39% <ø> (ø)

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

Impacted Files Coverage Δ
...ata/python/opentrons_shared_data/robot/__init__.py 92.30% <92.30%> (ø)
...ta/python/opentrons_shared_data/robot/dev_types.py 100.00% <100.00%> (ø)
app/src/pages/AppSettings/GeneralSettings.tsx 51.85% <0.00%> (-6.05%) ⬇️
shared-data/js/schema.ts 100.00% <0.00%> (ø)
shared-data/js/cypressUtils.ts 0.00% <0.00%> (ø)
shared-data/js/modules.ts 68.42% <0.00%> (ø)
shared-data/js/helpers/getVectorDifference.ts 100.00% <0.00%> (ø)
shared-data/js/labwareTools/index.ts 95.34% <0.00%> (ø)
shared-data/js/pipettes.ts 72.22% <0.00%> (ø)
shared-data/js/getLabware.ts 0.00% <0.00%> (ø)
... and 11 more

Copy link
Contributor

@mcous mcous left a 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):
Copy link
Contributor

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

Copy link
Member Author

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
Copy link
Contributor

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])
Copy link
Contributor

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

Copy link
Member Author

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"]
Copy link
Contributor

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

Copy link
Member Author

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

"type": "#/definitions/robotId"
},
"otId": {
"description": "A UUID for the machine type. Intended for use as a reference in other documents.",
Copy link
Contributor

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?

Copy link
Member Author

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

"properties": {
"otId": {
"description": "Unique internal ID generated using UUID",
"type": "string"
},
but I'm not sure why that's there either

Comment on lines 32 to 33
robotId: RobotId
otId: string
Copy link
Contributor

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

Copy link
Member Author

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.

Comment on lines 30 to 31
friendlyName: string
robotName: RobotName
Copy link
Contributor

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

Copy link
Member Author

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.

Copy link
Member Author

@sfoster1 sfoster1 left a 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 -

  1. 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?
  2. 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 of TypedDict and Literal. 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"]
Copy link
Member Author

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])
Copy link
Member Author

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

Comment on lines 30 to 31
friendlyName: string
robotName: RobotName
Copy link
Member Author

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.

Comment on lines 32 to 33
robotId: RobotId
otId: string
Copy link
Member Author

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):
Copy link
Member Author

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.

"type": "#/definitions/robotId"
},
"otId": {
"description": "A UUID for the machine type. Intended for use as a reference in other documents.",
Copy link
Member Author

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

"properties": {
"otId": {
"description": "Unique internal ID generated using UUID",
"type": "string"
},
but I'm not sure why that's there either

Copy link
Contributor

@mcous mcous left a 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

@sfoster1 sfoster1 merged commit 7e3f1e6 into edge Sep 6, 2022
@sfoster1 sfoster1 deleted the RCORE-126-add-robot-definitions branch September 6, 2022 16:56
sfoster1 added a commit that referenced this pull request Oct 21, 2022
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
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.

3 participants