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(protocol-designer,-shared-data): add liquid class scaffolding to PD #17126

Open
wants to merge 7 commits into
base: edge
Choose a base branch
from

Conversation

ncdiehl11
Copy link
Collaborator

@ncdiehl11 ncdiehl11 commented Dec 17, 2024

Overview

This PR introduces initial work for liquid class support in protocol designer. I create a full liquid class interface based on the API's Pydantic model. I also add utilities for getting all liquid class definitions and a feature flag to hide liquid classes from the UI. Lastly, I add some of the basic functionality for assigning a liquid class to a defined liquid, and displaying that liquid class in LiquidCard. A liquid class assigned to a defined liquid will be accessible through extended existing selectors (allIngredientNamesIds) for step forms.

closes AUTH-965
closes AUTH-968

Test Plan and Hands on Testing

  • navigate to settings and flip on liquid classes feature flag
  • navigate to protocol overview and add or modify a liquid
  • select a liquid class (should only see water as this is the only built out definition as of now)
  • save and verify that liquid definitions reflect liquid class
  • add this liquid to a labware or inspect a labware that has already loaded this liquid
  • verify that liquid card in toolbox reflects liquid class
Screen.Recording.2024-12-17.at.2.44.38.PM.mov

Changelog

  • add liquid class interface
  • add liquid class feature flag
  • add liquid class definitions getter
  • update selectors to accommodate liquid classes
  • dad liquid class feature to DefineLiquidsModal, LiquidsToolbox, LiquidCard, LiquidDefinitions (behind feature flag)
  • update tests

Review requests

  • see test plan

Risk assessment

medium

This PR introduces initial work for liquid class support in protocol designer. I create a full liquid class interface based on the API's Pydantic model. I also add utilities for getting all liquid class definitions and a feature flag to hide liquid classes from the UI. Lastly, I add some of the basic functionality for assigning a liquid class to a defined liquid, and displaying that liquid class in LiquidCard. A liquid class assigned to a defined liquid will be accessible through extended existing selectors (allIngredientNamesIds) for step forms.
@ncdiehl11 ncdiehl11 self-assigned this Dec 17, 2024
@ncdiehl11 ncdiehl11 marked this pull request as ready for review December 17, 2024 19:51
@ncdiehl11 ncdiehl11 requested review from a team as code owners December 17, 2024 19:51
@ncdiehl11 ncdiehl11 removed request for a team December 17, 2024 19:51
// ==== INGREDIENTS ====
export type OrderedLiquids = Array<{
ingredientId: string
name: string | null | undefined
displayColor: string | null | undefined
liquidClass: string | null | undefined
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit, the other fields can be refactored as well.

Suggested change
liquidClass: string | null | undefined
liquidClass?: string | null

Copy link
Collaborator

Choose a reason for hiding this comment

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

is this undefined here to avoid needing to add this to a migration?

Copy link
Collaborator Author

@ncdiehl11 ncdiehl11 Dec 17, 2024

Choose a reason for hiding this comment

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

I think these are unnecessarily allowed to be undefined or null in some cases. The modal disallows saving without a liquid name, and displayColor is always a valid hex string. I think description can be set to null for easier use downstream as well. Thoughts on this interface for the selector allIngredientGroupFields:

export interface LiquidGroup {
  name: string
  description: string | null
  displayColor: string
  liquidClass: string | null
  serialize: boolean
}

Copy link
Collaborator Author

@ncdiehl11 ncdiehl11 Dec 17, 2024

Choose a reason for hiding this comment

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

and since we're dealing with nullish initial values in DefineLiquidsModal, we can update that interface to

interface LiquidEditFormValues {
  name: string
  displayColor: string
  description: string
  liquidClass: string
  serialize: boolean
  [key: string]: unknown
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

i see, that makes sense to me.

i think we would need liquidClass to be undefined in OrderedLiquids at least because its included in the JSON protocols and if it is always null or a string, we'd need to make a migration for it. i'm all for adding this to the migration but not right now since there's no way to put it behind a FF. Do you mind adding a TODO or something above the type to remind us to migrate it later?

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 will keep it as an optional property for now and we can remove the optionality and add a migration later

| 'well-top'
| 'well-center'
| 'liquid-meniscus'
type BlowoutLocation = 'source' | 'destination' | 'trash'
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we not have this type already?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't see it anywhere in ts types

Copy link
Collaborator

@jerader jerader left a comment

Choose a reason for hiding this comment

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

looks great! left some comments. curious if adding liquidClass to the ingredients would be nice to have in the migration -- like populating it to null. though it'd be tricky to make a migration right now since we may need one in 8.3.0 or for plate reader, so i'd recommend adding a TODO for that for now if we decide to go down that route.

IngredInputs,
} from '../../labware-ingred/types'

const getLiquidDescription = (
Copy link
Contributor

@koji koji Dec 17, 2024

Choose a reason for hiding this comment

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

for consistency

Suggested change
const getLiquidDescription = (
function getLiquidDescription(

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought we usually defined utility functions with const notation?

Copy link
Collaborator

Choose a reason for hiding this comment

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

wait i thought so too?

Copy link
Contributor

Choose a reason for hiding this comment

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

sorry the comment isn't clear enough.

This returns JSX.Elment so the following method would be consistent.

function LiquidDescription()

touchTip: TouchTipProperties
delay: DelayProperties
}
type RetractAspirate = BaseRetract
Copy link
Contributor

Choose a reason for hiding this comment

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

need this?

extends BaseLiquidHandlingProperties<BaseRetract>

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think so, since the interface is exactly the same. I wanted to add a Base interface so that Aspirate and Dispense could share it

@koji
Copy link
Contributor

koji commented Dec 17, 2024

probably add ff mock code to protocol-designer/src/pages/ProtocolOverview/__tests__/LiquidDefinitions.test.tsx

@ncdiehl11 ncdiehl11 requested review from jerader and koji December 17, 2024 21:41
Copy link
Collaborator

@jerader jerader left a comment

Choose a reason for hiding this comment

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

awesome! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants