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

refactor(step-generation, protocol-designer): create HydratedFormData & update atomic command args to match v10 params #17308

Merged
merged 10 commits into from
Jan 21, 2025

Conversation

jerader
Copy link
Collaborator

@jerader jerader commented Jan 18, 2025

Overview

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)

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 substeps

Test Plan and Hands on Testing

Smoke test creating protocols in PD, in particular make sure:

  1. you can properly generate form errors in any form type
  2. disabled fields properly work and dependent fields properly work as well in forms
  3. test that the step-generation commands are what you would expect them to be, i especially changed the module compound commands so test TC, heater-shaker, magnetic module, plate reader, and temperature modules.

Changelog

  • create HydratedFormData and wire it in
  • make sure every hydrated form data type includes description and name and create the form data for the thermocycler which was previously never created for some reason.
  • update the atomic command args to match the command schema v10 command param types. This resulted in some changes like module to moduleId, temperature to celsius, and a few other things I think were changed that were more one-offs
  • fix all the type errors
  • update the tests

Review 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.

Copy link

codecov bot commented Jan 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.84%. Comparing base (0e7b516) to head (9ded968).
Report is 4 commits behind head on edge.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             edge   #17308   +/-   ##
=======================================
  Coverage   73.84%   73.84%           
=======================================
  Files          43       43           
  Lines        3304     3304           
=======================================
  Hits         2440     2440           
  Misses        864      864           
Flag Coverage Δ
shared-data 73.84% <ø> (ø)

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

@jerader jerader marked this pull request as ready for review January 21, 2025 13:37
@jerader jerader requested a review from a team as a code owner January 21, 2025 13:37
@jerader jerader requested review from koji, ddcc4 and ncdiehl11 and removed request for a team January 21, 2025 13:37
@@ -175,19 +175,7 @@ export interface BlowoutFields {
export interface ChangeTipFields {
changeTip?: ChangeTipOptions
}
export type MixForm = AnnotationFields &
Copy link
Collaborator Author

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

Copy link
Contributor

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?

Copy link
Collaborator Author

@jerader jerader Jan 21, 2025

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 &
Copy link
Collaborator Author

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

@jerader jerader changed the title refactor(step-generation, protocol-designer): create HydratedFormData refactor(step-generation, protocol-designer): create HydratedFormData & update atomic command args to match v10 params Jan 21, 2025
prevRobotState
) => {
export const absorbanceReaderCloseLid: CommandCreator<
AbsorbanceReaderOpenLidCreateCommand['params']
Copy link
Collaborator Author

@jerader jerader Jan 21, 2025

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.

Copy link
Contributor

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?

@jerader jerader force-pushed the sg_step-args-cleanup branch from 871f486 to 9ded968 Compare January 21, 2025 19:02
pickUpTip_wellNames?: string[] | null
preWetTip?: boolean | null
}
description?: string | null
Copy link
Contributor

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)

Copy link
Collaborator Author

@jerader jerader Jan 21, 2025

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.

Copy link
Collaborator Author

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.

Copy link
Contributor

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.

Copy link
Collaborator Author

@jerader jerader Jan 21, 2025

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

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?

absorbanceReaderFormType: AbsorbanceReaderFormType | null
fileName: string | null
fileName?: string | null
Copy link
Contributor

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?

Copy link
Collaborator Author

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

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

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.

Copy link
Collaborator Author

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!

@jerader jerader merged commit 73bdb33 into edge Jan 21, 2025
49 checks passed
@jerader jerader deleted the sg_step-args-cleanup branch January 21, 2025 21:51
caila-marashaj pushed a commit that referenced this pull request Feb 11, 2025
… & 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)
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