-
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
refactor(step-generation, protocol-designer): create HydratedFormData & update atomic command args to match v10 params #17308
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## edge #17308 +/- ##
=======================================
Coverage 73.84% 73.84%
=======================================
Files 43 43
Lines 3304 3304
=======================================
Hits 2440 2440
Misses 864 864
Flags with carried forward coverage won't be shown. Click here to find out more. |
@@ -175,19 +175,7 @@ export interface BlowoutFields { | |||
export interface ChangeTipFields { | |||
changeTip?: ChangeTipOptions | |||
} | |||
export type MixForm = AnnotationFields & |
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.
note: MixForm
wasn't in use 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.
So what's the deal with some of the form classes that are named "legacy," like HydratedMixFormDataLegacy
?
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.
the HydratedMoveLiquidFormDataLegacy
is not in use. HydratedMixFormDataLegacy
was in use, so i just removed Legacy
because it matches the pattern we are using for the other form data types. Not sure why Legacy
was added initially...
@@ -397,13 +396,7 @@ export interface HydratedAbsorbanceReaderFormData { | |||
referenceWavelength: number | null | |||
wavelengths: number[] | null | |||
} | |||
// TODO: Ian 2019-01-17 Moving away from this and towards nesting all form fields | |||
// inside `fields` key, but deprecating transfer/consolidate/distribute is a pre-req | |||
export type HydratedMoveLiquidFormDataLegacy = AnnotationFields & |
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 was also not in use anywhere, plus it was a legacy type
prevRobotState | ||
) => { | ||
export const absorbanceReaderCloseLid: CommandCreator< | ||
AbsorbanceReaderOpenLidCreateCommand['params'] |
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.
note: the reason why I updated the args type for a lot of atomic commands is because they didn't align with the command schema v10 command params. This pattern is established in a few atomic commands already, so I extended it to match more atomic commands (just realized i need to extend to match the pipetting atomic commands, maybe i'll do that in a follow up). With this update in pattern, it ensures the args match the latest command schema params exactly which makes atomic commands cleaner.
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.
OK, to make sure I understand:
Params
is the "bigger" object that contains the Args
, among other things?
Why do you have named Params
interfaces for things like AspirateInPlaceParams
down below, but not for AbsorbanceReaderOpenLidCreateCommand['params']
here?
871f486
to
9ded968
Compare
pickUpTip_wellNames?: string[] | null | ||
preWetTip?: boolean | null | ||
} | ||
description?: string | null |
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 this PR makes a lot of sense for consistency. But how does this not break all the existing code that used fields like description
? (and all the old saved JSON protocols)
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.
Good question, i updated the HydratedFormData
types which are only used for ...inArgs
fns and various form utils such as getDisabledFields
. the steps in a JSON file uses FormData
, before it was hydrated. Here is the util that hydrates the certain fields, if a field is not hydrated, it is left as it was in form data.
An example of a hydrated field is labware
in mix and move liquid. When a user selects it in a form, it is just the labwareId
. When hydrated, that labware id is mapped against the labware entities for its match and is hydrated as a LabwareEntity
.
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.
So a JSON file shouldn't break when reimported because the fields are just the form data, not hydrated yet.
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.
Ah! I wasn't aware that the Hydrated*Data
was a separate thing from the data in the imported form.
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.
In terms of description
, it was never wired up in the form or FormData
. so a JSON file shouldn't have that field. But also, i only edited the HydratedFormData
for that, i think. 😄
times?: number | null | ||
} | ||
export type MagnetAction = 'engage' | 'disengage' | ||
export type HydratedMagnetFormData = AnnotationFields & { | ||
engageHeight: string | null | ||
id: string | ||
magnetAction: MagnetAction | ||
moduleId: string | null | ||
moduleId: 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.
Again, I don't understand how this doesn't break old files? Like, what was it possible to export a file that had the moduleId
missing? What happens if you try to import it after this change?
protocol-designer/src/form-types.ts
Outdated
absorbanceReaderFormType: AbsorbanceReaderFormType | null | ||
fileName: string | null | ||
fileName?: string | null |
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.
OK. So if this data structure is the form after hydration, what is the purpose of allowing both a missing fileName
and a null fileName
here?
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.
oh ya good question! let me see if i can remove the undefined
prevRobotState | ||
) => { | ||
export const absorbanceReaderCloseLid: CommandCreator< | ||
AbsorbanceReaderOpenLidCreateCommand['params'] |
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.
OK, to make sure I understand:
Params
is the "bigger" object that contains the Args
, among other things?
Why do you have named Params
interfaces for things like AspirateInPlaceParams
down below, but not for AbsorbanceReaderOpenLidCreateCommand['params']
here?
import type { MixArgs } from '@opentrons/step-generation' | ||
type MixStepArgs = MixArgs | ||
export const mixFormToArgs = ( | ||
hydratedFormData: HydratedMixFormDataLegacy | ||
hydratedFormData: HydratedMixFormData |
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 might be the wrong PR for this question, but we still need a verdict on what we do about form fields that are lost when we go from the form -> args, right?
Here for example, the form has fields like mix_wellOrder_first
and mix_wellOrder_second
that don't make it into the MixStepArgs
. But that means that if we generate Python from the MixStepArgs
, there's no way for the Python generator to know what the original values of mix_wellOrder_first
/mix_wellOrder_second
were, which means there's no way for the Python generator to emit them into the Python file so that we can re-hydrate them on import.
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.
for sure, i'll think about that more in a follow up!
… & update atomic command args to match v10 params (#17308) Was cleaning up `StepArgs` a bit so it matches the command params a bit better and then ended up creating `HydratedFormData` type and wired it up. This resulted in a bit of a refactor and changing some arg names. Additionally, this PR updates some of the atomic command types to using the command's `Param` types to the latest command schema and updates the stepArgs accordingly. The reason why I did this is because some atomic command args were still using outdated params (from command schema V4, V6, etc. When we are currently on command schema V10)
Overview
Was cleaning up
StepArgs
a bit so it matches the command params a bit better and then ended up creatingHydratedFormData
type and wired it up. This resulted in a bit of a refactor and changing some arg names.Additionally, this PR updates some of the atomic command types to using the command's
Param
types to the latest command schema and updates the stepArgs accordingly. The reason why I did this is because some atomic command args were still using outdated params (from command schema V4, V6, etc. When we are currently on command schema V10)I also deleted a bunch of stuff in
generateSubsteps
because we no longer have substeps for every step type now. only thermocycler and mix and move liquid have substepsTest Plan and Hands on Testing
Smoke test creating protocols in PD, in particular make sure:
Changelog
HydratedFormData
and wire it indescription
andname
and create the form data for the thermocycler which was previously never created for some reason.module
tomoduleId
,temperature
tocelsius
, and a few other things I think were changed that were more one-offsReview requests
lmk if anything seems weird to you!
Risk assessment
medium - this touches a bunch of code, if all tests pass (most importantly the migration files) then I am confident that these changes don't break anything.