Opentrons / opentrons

Software for writing protocols and running them on the Opentrons Flex and Opentrons OT-2
https://opentrons.com
Apache License 2.0
418 stars 178 forks source link

Specify the protocol metadata schema #8334

Open SyntaxColoring opened 3 years ago

SyntaxColoring commented 3 years ago

JSON protocols and Python protocols both have a notion of protocol metadata, which, roughly, is nonessential information like the protocol author. However, they don't have a unified notion of exactly what can be in this metadata.

The new HTTP API will pass protocol metadata straight through to the client. So, it will be more client-friendly if the protocol metadata follows a consistent, unified spec.

Questions to consider

Definition of "done"

SyntaxColoring commented 3 years ago

It would be a good idea to get input from the participant(s) of #8236.

mcous commented 3 years ago

Current de-facto "standard" according to the app: https://github.com/Opentrons/opentrons/blob/6697e394458dfebf7974f7ff0edfd99f8a2e944b/app/src/redux/protocol/selectors.ts#L92-L138

SyntaxColoring commented 3 years ago

Thought:

What happens if something like this happens?

  1. The JSON protocol schema starts with some blessed metadata field, say authors, typed as a str.
  2. This blessed field makes its way into the Pydantic bindings that the robot software uses to parse the metadata.
  3. Later, we change its type to optionally be a list of strings: list[str] | str.

Now, when you upload a new JSON protocol (with a list of authors) to an old robot whose Pydantic models haven't been updated yet, the robot will throw a parse error. Even though it really has no reason to care about that metadata's schema; it should just pass it on to the client transparently. There's unnecessary coupling and fragility.

Options:

mcous commented 3 years ago

I think that's a good thought. I'd be pretty amenable to option 1: do not change the type of a field once "blessed". Add a new field if new information (or shape of information) is needed. Your example makes me think of npm's package.json spec, where there is both an "author" (singular) field and a "contributors" (plural) field