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, app): touchTip to emit from top of well origin #17375

Merged
merged 14 commits into from
Jan 30, 2025

Conversation

jerader
Copy link
Collaborator

@jerader jerader commented Jan 29, 2025

closes AUTH-1378

Overview

Previously, touchTip would occur from the bottom of the well, which is a bit confusing since users in python and intuitively would want to start with origin from the top. This PR migrates all touch tip fields and inverses the logic. Here is the summary of the changes:

  1. aspirate_touchTipMmFromBottom is now aspirate_touchTipMmFromTop in moveLiquid form data
  2. dispense_touchTipMmFromBottom is now dispense_touchTipMmFromTop in moveLiquid form data
  3. mix_touchTipMmFromBottom is now mix_touchTipMmFromTop in mix form data
  4. the modal in the form is updated to grab the values starting from the top of the well, going into the well the values are negative. This updated in PD AND Quick transfer
  5. step-generation now emits touchTip to be origin from the top of the well with the new z-index
  6. old protocols now go through a 8_5_0 migration to migrate their form data z-index fields to be origin from the top of the well

Test Plan and Hands on Testing

First test that this makes sense and works in PD by testing a mix's touch tip and move liquid's aspirate and dispense touch tip. See that the modal starts from the top of the well for adjusting the position

Then test importing an old protocol and see that it migrates correclty for those fields, making sure touchtip is now origin at the top of the well and also check the form

Then test that quick transfer's touch tip on the ODD has a min/max that matches this

Changelog

update the touch tip fields and add a 8_5_0 migration file, migrating the cypress e2e tests as well
update step-generation's touch tip atomic command origin
update step args to match the new touch tip field name
fix affected tests
update quick transfer to match this change

Risk assessment

med-ish since this touches a good amount of code. But with unit and cypress tests passing, i'm confident that this change is correctly implemented

@jerader jerader changed the title pd_touch-tip-migrate refactor(step-generation, protocol-designer): touchTip to emit from top of well origin Jan 29, 2025
@jerader jerader changed the title refactor(step-generation, protocol-designer): touchTip to emit from top of well origin refactor(step-generation, protocol-designer, app): touchTip to emit from top of well origin Jan 29, 2025
@jerader jerader marked this pull request as ready for review January 29, 2025 15:36
@jerader jerader requested review from a team as code owners January 29, 2025 15:36
@jerader jerader requested review from mjhuff, koji, smb2268, ddcc4, ncdiehl11 and syao1226 and removed request for a team January 29, 2025 15:36
Copy link
Collaborator

@ncdiehl11 ncdiehl11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a bunch of nits, mostly pertaining to testing. Only blocking fix that needs to be made that I can tell is the hypen issue in the input field

@@ -211,6 +211,7 @@ export function TouchTip(props: TouchTipProps): JSX.Element {
borderRadius="0"
>
<NumericalKeyboard
hasHyphen
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need an input handler because you can enter hypens in invalid places
Screenshot 2025-01-29 at 1 10 11 PM

Copy link
Collaborator Author

@jerader jerader Jan 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this modal from PD? I'm a bit confused because you commented on the code that is part of TouchTip from Quick Transfer

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, i left this comment in the wrong place. this is PD

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, i think i'll leave as is and address that in a follow up. seems like it is an issue for blowOut and touchTip

protocol-designer/src/organisms/TipPositionModal/utils.tsx Outdated Show resolved Hide resolved
step-generation/src/__tests__/consolidate.test.ts Outdated Show resolved Hide resolved
step-generation/src/__tests__/distribute.test.ts Outdated Show resolved Hide resolved
step-generation/src/__tests__/transfer.test.ts Outdated Show resolved Hide resolved
step-generation/src/fixtures/commandFixtures.ts Outdated Show resolved Hide resolved
@@ -0,0 +1,162 @@
import floor from 'lodash/floor'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. What's the reason for lodash floor instead of the built-in floor function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call, i can probably just use Math.floor()

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 lodash floor allows you to specify the decimal points. math.floor() does not. so i'll keep the lodash floor

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine, but I meant: where in the code do you actually specify the places after the decimal then if that's what you want?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we specify the places in the decimal at the form input field level. like the input field restricts users to 1 decimal. I suppose we could convert it upstream at that level. But it seems cleaner to me to convert it here in the migration. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I think I'm confused: In the code, you added stuff like

floor(
  dispense_touchTip_mmFromBottom -
  matchingDispenseLabwareWellDepth
),

I don't see where the rounding to 1 place after the decimal happens. Does lodash floor() default to 1 place? The built-in Math.floor() would just truncate it to an integer.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops i forgot to add back the decimal value. it should be this. thank you for catching this. I had it right initially but then didn't fix it when i reverted the math.floor change.

floor(
  dispense_touchTip_mmFromBottom -
  matchingDispenseLabwareWellDepth, 1
)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, gotcha!
(I'm curious if changing it to floor(..., 1) should change the expected output in any of the tests.)

@jerader jerader requested review from ddcc4 and ncdiehl11 January 29, 2025 20:59
@jerader jerader force-pushed the pd_touch-tip-migrate branch from ffd9f2b to c5535c9 Compare January 29, 2025 21:50
Copy link
Contributor

@smb2268 smb2268 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As is currently, you aren't able to enter the - on the quick transfer touch tip screen because of typing expectations with the input field. I played around with it and think this suggestion fixes the issue, but let me know if you have questions!

@@ -211,6 +211,7 @@ export function TouchTip(props: TouchTipProps): JSX.Element {
borderRadius="0"
>
<NumericalKeyboard
hasHyphen
keyboardRef={keyboardRef}
initialValue={String(position ?? '')}
onChange={e => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the addition of the -, this typing is no longer accurate. I think the type for InputField above has to change to text and this should be setPosition(e) without the cast to Number. We'll then have to update positionError to something like this:

  const positionError =
    position !== null &&
    (position === '-' ||
      position.indexOf('-') !== position.lastIndexOf('-') ||
      Number(position) < positionRange.min ||
      Number(position) > positionRange.max)
      ? t(`value_out_of_range`, {
          min: positionRange.min,
          max: Math.floor(positionRange.max),
        })
      : null

and then handle casting from number to string when grabbing the initial values from state and then from string to number sending them via dispatch

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this Sarah! I just pushed a fix according to your comment. Hopefully it works as expected now.

@jerader jerader requested a review from smb2268 January 30, 2025 14:07
Copy link
Contributor

@ddcc4 ddcc4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, approving. I don't have much context for the Quick Transfer and ODD stuff, so hopefully someone else has looked at those changes.

@@ -0,0 +1,162 @@
import floor from 'lodash/floor'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, gotcha!
(I'm curious if changing it to floor(..., 1) should change the expected output in any of the tests.)

Copy link
Contributor

@smb2268 smb2268 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested out the quick transfer changes and they're now working as expected! Thanks for updating

@jerader jerader merged commit b1684cb into edge Jan 30, 2025
27 checks passed
@jerader jerader deleted the pd_touch-tip-migrate branch January 30, 2025 17:33
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.

4 participants