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, step-generation, app): introduce pythonName to each entity #17463

Merged
merged 9 commits into from
Feb 7, 2025

Conversation

jerader
Copy link
Collaborator

@jerader jerader commented Feb 7, 2025

closes AUTH-1383

Overview

For python/pd interop, we want to add a pythonName to liquidEntity, labwareEntity, moduleEntity, and pipetteEntity. This PR does that by adding them in redux, that way, the pythonName is not polluting the JSON structure. For Quick Transfer, the pythonName is generated in generateQuickTransferArgs.

The python name patterning is as follows:

  • modules: moduleType minus Type in snake case plus the number so heater_shaker_module_1 and then heater_shaker_module_2 for 2 heater-shaker modules
  • pipettes: pipette_left or pipette_right
  • labware: the labware displayCategory in snake case plus the number. So 2 well plates and 1 reservoir would be well_plate_1, well_plate_2, reservoir_1
  • liquids: just liquid with the number so liquid_1, liquid_2, etc.

Test Plan and Hands on Testing

Since the python names are not included in the JSON structure and not actually held in the redux tree, you'll have to console.log invariant context. I guess an easy one to check is:

add console.log('invariantContext', invariantContext) to delay.ts in step-generation

upload this attached protocol with labware, pipettes, liquids, and modules and go to the step timeline. check console and look at invariant context. test deleting different things and making sure the numbers update correctly

pythonNames.json

there should be 5 well plates, 3 tipracks, 2 adapters, 1 reservoir, 3 liquids, 2 heater-shakers, 2 magnetic blocks, 1 thermocycler, 2 pipettes

Changelog

  • modify redux reducers to add python names
  • make some utils for getting the python name
  • refactor liquids so python name is not in the json file
  • fix affected tests
  • fix quick transfer

Review requests

Review my redux changes in particular. The files to look at for that are:

protocol-designer/src/labware-ingred/actions/thunks.ts for editing subsequent labware numbering -> so if you have 2 well plates and delete 1, it ensures the number of that 1 remaining is well_plate_1

protocol-designer/src/modules/thunks.ts for editing subsequent module numbering -> so if you have 2 h-s and delete 1, it ensures the number of that 1 remaining is heater_shaker_1

protocol-designer/src/step-forms/reducers/index.ts has the redux reducer logic for adding the python name to modules and labware

protocol-designer/src/step-forms/selectors/index.ts has the pipette selector logic for adding the python name

Risk assessment

med-ish but its contained in redux and only adding stuff on instead of changing how the entities are generated

Copy link

codecov bot commented Feb 7, 2025

Codecov Report

Attention: Patch coverage is 28.49162% with 256 lines in your changes missing coverage. Please review.

Project coverage is 20.06%. Comparing base (f16f6a0) to head (4818287).
Report is 15 commits behind head on edge.

Files with missing lines Patch % Lines
protocol-designer/src/step-forms/reducers/index.ts 33.33% 74 Missing ⚠️
...ocol-designer/src/labware-ingred/actions/thunks.ts 7.27% 51 Missing ⚠️
protocol-designer/src/modules/thunks.ts 5.00% 38 Missing ⚠️
...ol-designer/src/file-data/selectors/fileCreator.ts 33.33% 16 Missing ⚠️
...ickTransferFlow/utils/generateQuickTransferArgs.ts 0.00% 14 Missing ⚠️
...ocol-designer/src/labware-ingred/reducers/index.ts 0.00% 13 Missing ⚠️
protocol-designer/src/utils/index.ts 18.75% 13 Missing ⚠️
...rotocol-designer/src/step-forms/selectors/index.ts 26.66% 11 Missing ⚠️
...col-designer/src/labware-ingred/actions/actions.ts 0.00% 6 Missing ⚠️
protocol-designer/src/ui/modules/utils.ts 0.00% 5 Missing ⚠️
... and 7 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             edge   #17463      +/-   ##
==========================================
+ Coverage   18.19%   20.06%   +1.86%     
==========================================
  Files        3175     3194      +19     
  Lines      229678   230611     +933     
  Branches     6907     8217    +1310     
==========================================
+ Hits        41787    46266    +4479     
+ Misses     187891   184345    -3546     
Flag Coverage Δ
protocol-designer 17.39% <28.49%> (+0.01%) ⬆️
step-generation 4.08% <4.21%> (?)

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

Files with missing lines Coverage Δ
.../file-data/__fixtures__/createFile/commonFields.ts 100.00% <100.00%> (ø)
protocol-designer/src/file-types.ts 75.00% <ø> (+3.57%) ⬆️
protocol-designer/src/labware-ingred/types.ts 100.00% <ø> (ø)
...src/organisms/EditInstrumentsModal/editPipettes.ts 1.92% <ø> (ø)
...signer/src/pages/CreateNewProtocolWizard/index.tsx 0.00% <ø> (ø)
...er/src/pages/Designer/DeckSetup/DeckSetupTools.tsx 67.82% <100.00%> (ø)
.../src/pages/Designer/DeckSetup/SlotOverflowMenu.tsx 79.58% <100.00%> (ø)
...rotocol-designer/src/step-forms/actions/modules.ts 23.07% <ø> (+2.02%) ⬆️
...ocol-designer/src/step-forms/test/reducers.test.ts 100.00% <100.00%> (ø)
protocol-designer/src/step-forms/types.ts 100.00% <ø> (ø)
... and 21 more

... and 190 files with indirect coverage changes

@jerader jerader marked this pull request as ready for review February 7, 2025 14:10
@jerader jerader requested review from a team as code owners February 7, 2025 14:10
@jerader jerader requested review from smb2268 and ddcc4 and removed request for a team February 7, 2025 14:10
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.

The quick transfer changes make sense - just left one comment. Thanks for adding that version bump!

@@ -204,7 +204,7 @@ export function createQuickTransferFile(
},
designerApplication: {
name: 'opentrons/quick-transfer',
version: '1.0.0',
version: '1.1.0',
Copy link
Contributor

Choose a reason for hiding this comment

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

How does Quick Transfer versioning work? Like, what cares about this version number?

Copy link
Contributor

Choose a reason for hiding this comment

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

@ddcc4 Right now, nothing cares about this version number since once these files are created the designerApplicationData isn't read. However, we may want to read it and add migration functionality in the future. I'm working on a doc to keep track of this - you can see my draft here: https://github.com/Opentrons/opentrons/blob/e9a77696e65022c480ae704edecb22c794c45111/app/src/organisms/ODD/QuickTransferFlow/README.md

@@ -96,18 +98,28 @@ function getInvariantContextAndRobotState(
},
}
}
const sourceDisplayCategory =
quickTransferState.source.metadata.displayCategory
Copy link
Contributor

Choose a reason for hiding this comment

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

What's a sourceDisplayCategory?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it is the source labware in quick transfer (aka where you are aspirating from). quick transfer is limited to only a source and destination labware

interface DeleteContainerArgs {
labwareId: string
}
export const deleteContainer: (
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey, what is the container that this is referring to?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

deleteContainer is our redux action for deleting a labware. idk why we called it container (definitely from before my time working on PD) but i made a new one in the thunk since the old deleteContainer was a singular action. This way in the future when devs need to delete a container, they can just refer to an intuitive fn name like deleteContainer instead of something more in depth like deleteContainerAndRenamePythonName

},
})

if (typeCount > 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this limited to typeCount > 1? What happens if it's 1?

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 if its equal to 1, you won't need to call the action that renames the rest of the pythonNames. like if you have 1 wellPlate and you delete it, no sense calling the action to rename the rest of the pythonNames in labware because they don't exist

protocol-designer/src/step-forms/reducers/index.ts Outdated Show resolved Hide resolved
model: moduleLoadInfo.model,
pythonName: getModulePythonName(moduleType, typeCount + 1),
Copy link
Contributor

Choose a reason for hiding this comment

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

Ohhh! ... I figured out what this is doing :) I was confused at first because I thought "Isn't typeCount a constant? Won't this give all the modules the same pythonName when you LOAD_FILE?"

But you're recomputing typeCount for each module in the loop, so this works.

export type Ingredient = Omit<LiquidEntity, 'pythonName'>
export interface Ingredients {
[liquidId: string]: Ingredient
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Trying to keep all the types straight in my head: when do we use LiquidEntities and when do we use Ingredients?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ingredients refers to the json structure type for the ingredients key, it is just like liquidEntities but does not include pythonName. It's similar to how we have a labwareLoadInfo, moduleLoadInfo, etc for the labware and modules keys in designerApplication

@jerader jerader merged commit f687a3a into edge Feb 7, 2025
41 checks passed
@jerader jerader deleted the pd_pythonNames-to-entities branch February 7, 2025 21:21
caila-marashaj pushed a commit that referenced this pull request Feb 11, 2025
…o each entity (#17463)

closes AUTH-1383

For python/pd interop, we want to add a `pythonName` to `liquidEntity`,
`labwareEntity`, `moduleEntity`, and `pipetteEntity`. This PR does that
by adding them in redux, that way, the `pythonName` is not polluting the
JSON structure. For Quick Transfer, the `pythonName` is generated in
`generateQuickTransferArgs`.

The python name patterning is as follows:
- modules: moduleType minus `Type` in snake case plus the number so
`heater_shaker_module_1` and then `heater_shaker_module_2` for 2
heater-shaker modules
- pipettes: `pipette_left` or `pipette_right`
- labware: the labware displayCategory in snake case plus the number. So
2 well plates and 1 reservoir would be `well_plate_1`, `well_plate_2`,
`reservoir_1`
- liquids: just liquid with the number so `liquid_1`, `liquid_2`, etc.
TamarZanzouri pushed a commit that referenced this pull request Feb 11, 2025
…o each entity (#17463)

closes AUTH-1383

For python/pd interop, we want to add a `pythonName` to `liquidEntity`,
`labwareEntity`, `moduleEntity`, and `pipetteEntity`. This PR does that
by adding them in redux, that way, the `pythonName` is not polluting the
JSON structure. For Quick Transfer, the `pythonName` is generated in
`generateQuickTransferArgs`.

The python name patterning is as follows:
- modules: moduleType minus `Type` in snake case plus the number so
`heater_shaker_module_1` and then `heater_shaker_module_2` for 2
heater-shaker modules
- pipettes: `pipette_left` or `pipette_right`
- labware: the labware displayCategory in snake case plus the number. So
2 well plates and 1 reservoir would be `well_plate_1`, `well_plate_2`,
`reservoir_1`
- liquids: just liquid with the number so `liquid_1`, `liquid_2`, etc.
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.

3 participants