Skip to content

Commit

Permalink
refactor(protocol-designer, step-generation): multi tiprack uses defU…
Browse files Browse the repository at this point in the history
…RI instead of id (#15096)

closes AUTH-12
  • Loading branch information
jerader authored May 6, 2024
1 parent c867d3f commit c3d6678
Show file tree
Hide file tree
Showing 25 changed files with 121 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"3961e4c0-75c7-11ea-b42f-4b64e50f43e5": {
"pipette": "0b3f2210-75c7-11ea-b42f-4b64e50f43e5",
"volume": "40",
"tipRack": "0b44c760-75c7-11ea-b42f-4b64e50f43e5:opentrons/opentrons_96_tiprack_300ul/1",
"tipRack": "opentrons/opentrons_96_tiprack_300ul/1",
"changeTip": "always",
"path": "multiDispense",
"aspirate_wells_grouped": false,
Expand Down Expand Up @@ -175,7 +175,7 @@
"mix_touchTip_mmFromBottom": 11.8,
"dropTip_location": "8053a205-f2dc-4b1d-8d05-bf8233949e2e:trashBin",
"nozzles": null,
"tipRack": "0b44c760-75c7-11ea-b42f-4b64e50f43e5:opentrons/opentrons_96_tiprack_300ul/1",
"tipRack": "opentrons/opentrons_96_tiprack_300ul/1",
"mix_x_position": 0,
"mix_y_position": 0,
"blowout_z_offset": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"3961e4c0-75c7-11ea-b42f-4b64e50f43e5": {
"pipette": "0b3f2210-75c7-11ea-b42f-4b64e50f43e5",
"volume": "30",
"tipRack": "0b44c760-75c7-11ea-b42f-4b64e50f43e5:opentrons/opentrons_96_tiprack_300ul/1",
"tipRack": "opentrons/opentrons_96_tiprack_300ul/1",
"changeTip": "always",
"path": "single",
"aspirate_wells_grouped": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
"f9a294f1-f42b-4cae-893a-592405349d56": {
"pipette": "2e7c6344-58ab-465c-b542-489883cb63fe",
"volume": "100",
"tipRack": "23ed35de-5bfd-4bb0-8f54-da99a2804ed9:opentrons/opentrons_flex_96_filtertiprack_50ul/1",
"tipRack": "opentrons/opentrons_flex_96_filtertiprack_50ul/1",
"changeTip": "always",
"path": "single",
"aspirate_wells_grouped": false,
Expand Down Expand Up @@ -227,7 +227,7 @@
"mix_touchTip_mmFromBottom": null,
"dropTip_location": "134504e1-b212-41cf-966d-2560deb5b693:trashBin",
"nozzles": null,
"tipRack": "23ed35de-5bfd-4bb0-8f54-da99a2804ed9:opentrons/opentrons_flex_96_filtertiprack_50ul/1",
"tipRack": "opentrons/opentrons_flex_96_filtertiprack_50ul/1",
"mix_x_position": 0,
"mix_y_position": 0,
"blowout_z_offset": 0,
Expand Down
2 changes: 1 addition & 1 deletion protocol-designer/fixtures/protocol/8/doItAllV8.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"d2f74144-a7bf-4ba2-aaab-30d70b2b62c7": {
"pipette": "9fcd50d9-92b2-45ac-acf1-e2cf773feffc",
"volume": "100",
"tipRack": "f2d371ea-5146-4c89-8200-9c056a7f321a:opentrons/opentrons_flex_96_tiprack_1000ul/1",
"tipRack": "opentrons/opentrons_flex_96_tiprack_1000ul/1",
"changeTip": "always",
"path": "single",
"aspirate_wells_grouped": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"e7d36200-92a5-11e9-ac62-1b173f839d9e": {
"pipette": "c6f45030-92a5-11e9-ac62-1b173f839d9e",
"volume": "6",
"tipRack": "c6f4ec70-92a5-11e9-ac62-1b173f839d9e:tiprack-10ul",
"tipRack": "opentrons/opentrons_96_tiprack_10ul/1",
"changeTip": "always",
"path": "single",
"aspirate_wells_grouped": false,
Expand Down Expand Up @@ -161,7 +161,7 @@
"mix_touchTip_mmFromBottom": 30.5,
"dropTip_location": "9b1c0d01-9d4f-4016-afe6-9e08b46acf5e:trashBin",
"nozzles": null,
"tipRack": "c6f4ec70-92a5-11e9-ac62-1b173f839d9e:tiprack-10ul",
"tipRack": "opentrons/opentrons_96_tiprack_10ul/1",
"mix_x_position": 0,
"mix_y_position": 0,
"blowout_z_offset": 0,
Expand Down
2 changes: 1 addition & 1 deletion protocol-designer/fixtures/protocol/8/mix_8_0_0.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"mix_touchTip_mmFromBottom": null,
"dropTip_location": "5ba7047d-d3e2-4845-9eaa-1974af796ead:trashBin",
"nozzles": null,
"tipRack": "f1c677c0-fc3a-11ea-8809-e959e7d61d96:opentrons/opentrons_96_tiprack_10ul/1",
"tipRack": "opentrons/opentrons_96_tiprack_10ul/1",
"mix_x_position": 0,
"mix_y_position": 0,
"blowout_z_offset": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"stepDetails": "",
"pipette": "21087f15-4c03-4587-8a2b-1ba0b5a501a0",
"volume": "10",
"tipRack": "0d39213c-49c2-4170-bf19-4c09e1b72aca:opentrons/opentrons_flex_96_tiprack_50ul/1",
"tipRack": "opentrons/opentrons_flex_96_tiprack_50ul/1",
"changeTip": "always",
"path": "single",
"aspirate_wells_grouped": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"83a095fa-b649-4105-99d4-177f1a3f363a": {
"pipette": "de7da440-95ec-43e8-8723-851321fbd6f9",
"volume": "10",
"tipRack": "75aa666f-98d8-4af9-908e-963ced428580:opentrons/opentrons_flex_96_tiprack_50ul/1",
"tipRack": "opentrons/opentrons_flex_96_tiprack_50ul/1",
"changeTip": "always",
"path": "single",
"aspirate_wells_grouped": false,
Expand Down Expand Up @@ -107,7 +107,7 @@
"f5ea3139-1585-4848-9d5f-832eb88c99ca": {
"pipette": "de7da440-95ec-43e8-8723-851321fbd6f9",
"volume": "10",
"tipRack": "75aa666f-98d8-4af9-908e-963ced428580:opentrons/opentrons_flex_96_tiprack_50ul/1",
"tipRack": "opentrons/opentrons_flex_96_tiprack_50ul/1",
"changeTip": "always",
"path": "single",
"aspirate_wells_grouped": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@ export function TiprackField(props: TiprackFieldProps): JSX.Element {
const [targetProps, tooltipProps] = useHoverTooltip()
const pipetteEntities = useSelector(getPipetteEntities)
const options = useSelector(uiLabwareSelectors.getTiprackOptions)
const defaultTipracks =
const defaultTiprackUris =
pipetteId != null ? pipetteEntities[pipetteId as string].tiprackDefURI : []
const pipetteOptions = options.filter(option =>
defaultTipracks.includes(option.defURI)
const tiprackOptions = options.filter(option =>
defaultTiprackUris.includes(option.value)
)
const hasMissingTiprack = defaultTipracks.length > pipetteOptions.length

const hasMissingTiprack = defaultTiprackUris.length > tiprackOptions.length
return (
<Box {...targetProps}>
<FormGroup
label={t('step_edit_form.tipRack')}
className={styles.large_field}
>
<DropdownField
options={pipetteOptions}
options={tiprackOptions}
name={name}
value={String(value) != null ? String(value) : null}
onBlur={onFieldBlur}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,12 @@ describe('TiprackField', () => {
})
vi.mocked(getTiprackOptions).mockReturnValue([
{
value: 'mockValue',
value: 'mockDefURI1',
name: 'tiprack1',
defURI: 'mockDefURI1',
},
{
value: 'mockValue',
value: 'mockDefURI2',
name: 'tiprack2',
defURI: 'mockDefURI2',
},
])
})
Expand Down
11 changes: 7 additions & 4 deletions protocol-designer/src/load-file/migration/8_1_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ export const migrateFile = (
{}
)

const pipetteTiprackAssignments =
designerApplication.data?.pipetteTiprackAssignments

const loadLabwareCommands = commands.filter(
(command): command is LoadLabwareCreateCommand =>
command.commandType === 'loadLabware'
Expand Down Expand Up @@ -74,9 +77,6 @@ export const migrateFile = (
const tiprackLoadCommands = loadLabwareCommands.filter(
command => command.params.loadName === tiprackLoadName
)
const tiprackIds = tiprackLoadCommands.map(
command => command.params.labwareId
)
const xyKeys =
item.stepType === 'mix'
? { mix_x_position: 0, mix_y_position: 0 }
Expand Down Expand Up @@ -105,6 +105,7 @@ export const migrateFile = (
const pipetteName = loadPipetteCommands.find(
pipette => pipette.params.pipetteId === item.pipette
)?.params.pipetteName

const defaultBlowOutFlowRate = getDefaultBlowoutFlowRate(
pipetteName as PipetteName,
item.volume,
Expand All @@ -116,11 +117,13 @@ export const migrateFile = (
blowoutFlowRate = null
}

const tipRackDefURI = pipetteTiprackAssignments[item.pipette]

acc[item.id] = {
...item,
blowout_flowRate: blowoutFlowRate,
blowout_z_offset: 0,
tipRack: tiprackIds[0],
tipRack: tipRackDefURI,
...xyKeys,
}
return acc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ describe('createPresavedStepForm', () => {
pipette: 'leftPipetteId',
nozzles: null,
stepType: 'moveLiquid',
tipRack: null,
tipRack: 'defaultTipRack',
// default fields
dropTip_location: 'mockTrash',
aspirate_airGap_checkbox: false,
Expand Down Expand Up @@ -228,7 +228,7 @@ describe('createPresavedStepForm', () => {
volume: undefined,
aspirate_flowRate: null,
dispense_flowRate: null,
tipRack: null,
tipRack: 'defaultTipRack',
blowout_flowRate: null,
})
})
Expand Down
12 changes: 2 additions & 10 deletions protocol-designer/src/step-forms/utils/createPresavedStepForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,6 @@ const _patchDefaultTiprack = (args: {
savedStepForms,
orderedStepIds,
} = args
const labware = initialDeckSetup.labware
const tipRackIds = Object.values(labware)
.filter(lw => lw.def.parameters.isTiprack)
.map(lw => lw.id)

const defaultPipetteId = getNextDefaultPipetteId(
savedStepForms,
orderedStepIds,
Expand All @@ -145,15 +140,12 @@ const _patchDefaultTiprack = (args: {

const pipetteFirstTiprackDefUri =
pipetteEntities[defaultPipetteId].tiprackDefURI[0]
const defaultTiprackId = tipRackIds.find(id =>
id.includes(pipetteFirstTiprackDefUri)
)
const formHasTipRackField = formData && 'tipRack' in formData

if (formHasTipRackField && defaultTiprackId != null) {
if (formHasTipRackField) {
const updatedFields = handleFormChange(
{
tipRack: defaultTiprackId,
tipRack: pipetteFirstTiprackDefUri,
},
formData,
pipetteEntities,
Expand Down
6 changes: 4 additions & 2 deletions protocol-designer/src/steplist/test/generateSubsteps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import {
makeContext,
FIXED_TRASH_ID,
} from '@opentrons/step-generation'
import { fixtureTiprack300ul, getLabwareDefURI } from '@opentrons/shared-data'
import { THERMOCYCLER_STATE } from '../../constants'
import { generateSubstepItem } from '../generateSubstepItem'

import type { LabwareDefinition2 } from '@opentrons/shared-data'
import type {
RobotState,
InvariantContext,
Expand Down Expand Up @@ -181,7 +183,7 @@ describe('generateSubstepItem', () => {
dispenseFlowRateUlSec: 5,
dispenseOffsetFromBottomMm: 10,
dropTipLocation: FIXED_TRASH_ID,
tipRack: 'tiprack1Id',
tipRack: getLabwareDefURI(fixtureTiprack300ul as LabwareDefinition2),
}
})
;[
Expand Down Expand Up @@ -404,7 +406,7 @@ describe('generateSubstepItem', () => {
aspirateFlowRateUlSec: 5,
dispenseFlowRateUlSec: 5,
dropTipLocation: FIXED_TRASH_ID,
tipRack: 'tiprack1Id',
tipRack: getLabwareDefURI(fixtureTiprack300ul as LabwareDefinition2),
},
// @ts-expect-error(sa, 2021-6-15): errors should be boolean typed
errors: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import {
} from '@opentrons/step-generation'
import { generateRobotStateTimeline } from '../generateRobotStateTimeline'
import type { StepArgsAndErrorsById } from '../../steplist'
import {
LabwareDefinition2,
fixtureTiprack300ul,
getLabwareDefURI,
} from '@opentrons/shared-data'

vi.mock('../../labware-defs/utils')

Expand Down Expand Up @@ -49,7 +54,7 @@ describe('generateRobotStateTimeline', () => {
mixBeforeAspirate: null,
description: null,
nozzles: null,
tipRack: 'tiprack1Id',
tipRack: getLabwareDefURI(fixtureTiprack300ul as LabwareDefinition2),
aspirateXOffset: 0,
aspirateYOffset: 0,
dispenseXOffset: 0,
Expand Down Expand Up @@ -89,7 +94,7 @@ describe('generateRobotStateTimeline', () => {
mixBeforeAspirate: null,
description: null,
nozzles: null,
tipRack: 'tiprack1Id',
tipRack: getLabwareDefURI(fixtureTiprack300ul as LabwareDefinition2),
aspirateXOffset: 0,
aspirateYOffset: 0,
dispenseXOffset: 0,
Expand Down Expand Up @@ -121,7 +126,7 @@ describe('generateRobotStateTimeline', () => {
aspirateDelaySeconds: null,
dispenseDelaySeconds: null,
nozzles: null,
tipRack: 'tiprack1Id',
tipRack: getLabwareDefURI(fixtureTiprack300ul as LabwareDefinition2),
aspirateXOffset: 0,
aspirateYOffset: 0,
dispenseXOffset: 0,
Expand Down
18 changes: 6 additions & 12 deletions protocol-designer/src/ui/labware/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,27 +241,22 @@ export const getDisposalOptions = createSelector(
}
)

export interface TiprackOption {
name: string
value: string
defURI: string
}
export const getTiprackOptions: Selector<TiprackOption[]> = createSelector(
export const getTiprackOptions: Selector<DropdownOption[]> = createSelector(
stepFormSelectors.getLabwareEntities,
getLabwareNicknamesById,
(labwareEntities, nicknamesById) => {
const options = reduce(
labwareEntities,
(
acc: TiprackOption[],
acc: DropdownOption[],
labwareEntity: LabwareEntity,
labwareId: string
): TiprackOption[] => {
): DropdownOption[] => {
const labwareDefURI = labwareEntity.labwareDefURI
const optionValues = acc.map(option => option.value)
const optionDefURI = acc.map(option => option.value)

if (
optionValues.includes(labwareDefURI) ||
optionDefURI.includes(labwareDefURI) ||
!getIsTiprack(labwareEntity.def)
) {
return acc
Expand All @@ -270,8 +265,7 @@ export const getTiprackOptions: Selector<TiprackOption[]> = createSelector(
...acc,
{
name: nicknamesById[labwareId],
value: labwareId,
defURI: labwareDefURI,
value: labwareDefURI,
},
]
}
Expand Down
11 changes: 8 additions & 3 deletions step-generation/src/__tests__/consolidate.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { beforeEach, describe, it, expect } from 'vitest'
import { getLabwareDefURI, fixtureTiprack300ul } from '@opentrons/shared-data'
import { consolidate } from '../commandCreators/compound/consolidate'
import { FIXED_TRASH_ID } from '../constants'
import {
Expand All @@ -25,7 +26,11 @@ import {
blowoutInPlaceHelper,
} from '../fixtures'
import { DEST_WELL_BLOWOUT_DESTINATION } from '../utils'
import type { AspDispAirgapParams, CreateCommand } from '@opentrons/shared-data'
import type {
AspDispAirgapParams,
CreateCommand,
LabwareDefinition2,
} from '@opentrons/shared-data'
import type { ConsolidateArgs, InvariantContext, RobotState } from '../types'

const airGapHelper = makeAirGapHelper({
Expand Down Expand Up @@ -99,7 +104,7 @@ beforeEach(() => {
mixInDestination: null,
blowoutLocation: null,
dropTipLocation: FIXED_TRASH_ID,
tipRack: 'tiprack1Id',
tipRack: getLabwareDefURI(fixtureTiprack300ul as LabwareDefinition2),
aspirateXOffset: 0,
dispenseXOffset: 0,
aspirateYOffset: 0,
Expand Down Expand Up @@ -3210,7 +3215,7 @@ describe('consolidate multi-channel', () => {
const data: ConsolidateArgs = {
...args,
volume: 140,
tipRack: 'tiprack1Id',
tipRack: getLabwareDefURI(fixtureTiprack300ul as LabwareDefinition2),
changeTip: 'once',
aspirateXOffset: 0,
dispenseXOffset: 0,
Expand Down
Loading

0 comments on commit c3d6678

Please sign in to comment.