Skip to content

Commit 4f46a83

Browse files
authored
fix(app): do not redundantly check labware in LPC (#14079)
fixes RAUT-889
1 parent f65669a commit 4f46a83

File tree

6 files changed

+44
-32
lines changed

6 files changed

+44
-32
lines changed

app/src/organisms/LabwarePositionCheck/__tests__/CheckItem.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ describe('CheckItem', () => {
4848
section: SECTIONS.CHECK_LABWARE,
4949
pipetteId: mockCompletedAnalysis.pipettes[0].id,
5050
labwareId: mockCompletedAnalysis.labware[0].id,
51+
definitionUri: mockCompletedAnalysis.labware[0].definitionUri,
5152
location: { slotName: 'D1' },
5253
protocolData: mockCompletedAnalysis,
5354
proceed: jest.fn(),

app/src/organisms/LabwarePositionCheck/__tests__/PickUpTip.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ describe('PickUpTip', () => {
5151
section: SECTIONS.PICK_UP_TIP,
5252
pipetteId: mockCompletedAnalysis.pipettes[0].id,
5353
labwareId: mockCompletedAnalysis.labware[0].id,
54+
definitionUri: mockCompletedAnalysis.labware[0].definitionUri,
5455
location: { slotName: 'D1' },
5556
protocolData: mockCompletedAnalysis,
5657
proceed: jest.fn(),

app/src/organisms/LabwarePositionCheck/__tests__/ReturnTip.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ describe('ReturnTip', () => {
4747
section: SECTIONS.RETURN_TIP,
4848
pipetteId: mockCompletedAnalysis.pipettes[0].id,
4949
labwareId: mockCompletedAnalysis.labware[0].id,
50+
definitionUri: mockCompletedAnalysis.labware[0].definitionUri,
5051
location: { slotName: 'D1' },
5152
protocolData: mockCompletedAnalysis,
5253
proceed: jest.fn(),

app/src/organisms/LabwarePositionCheck/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export interface CheckTipRacksStep {
2121
pipetteId: string
2222
labwareId: string
2323
location: LabwareOffsetLocation
24+
definitionUri: string
2425
adapterId?: string
2526
}
2627
export interface AttachProbeStep {
@@ -32,20 +33,23 @@ export interface PickUpTipStep {
3233
pipetteId: string
3334
labwareId: string
3435
location: LabwareOffsetLocation
36+
definitionUri: string
3537
adapterId?: string
3638
}
3739
export interface CheckPositionsStep {
3840
section: typeof SECTIONS.CHECK_POSITIONS
3941
pipetteId: string
4042
labwareId: string
4143
location: LabwareOffsetLocation
44+
definitionUri: string
4245
moduleId?: string
4346
}
4447
export interface CheckLabwareStep {
4548
section: typeof SECTIONS.CHECK_LABWARE
4649
pipetteId: string
4750
labwareId: string
4851
location: LabwareOffsetLocation
52+
definitionUri: string
4953
moduleId?: string
5054
adapterId?: string
5155
}
@@ -54,6 +58,7 @@ export interface ReturnTipStep {
5458
pipetteId: string
5559
labwareId: string
5660
location: LabwareOffsetLocation
61+
definitionUri: string
5762
adapterId?: string
5863
}
5964
export interface DetachProbeStep {

app/src/organisms/LabwarePositionCheck/utils/getProbeBasedLPCSteps.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,14 @@ function getAllCheckSectionSteps(
7575
)
7676

7777
return labwareLocations.map(
78-
({ location, labwareId, moduleId, adapterId }) => ({
78+
({ location, labwareId, moduleId, adapterId, definitionUri }) => ({
7979
section: SECTIONS.CHECK_POSITIONS,
8080
labwareId: labwareId,
8181
pipetteId: getPrimaryPipetteId(pipettes),
8282
location,
8383
moduleId,
8484
adapterId,
85+
definitionUri: definitionUri,
8586
})
8687
)
8788
}

app/src/organisms/LabwarePositionCheck/utils/getTipBasedLPCSteps.ts

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export const getTipBasedLPCSteps = (
4848
pipetteId: lastTiprackCheckStep.pipetteId,
4949
location: lastTiprackCheckStep.location,
5050
adapterId: lastTiprackCheckStep.adapterId,
51+
definitionUri: lastTiprackCheckStep.definitionUri,
5152
}
5253
const checkLabwareSectionSteps = getCheckLabwareSectionSteps(args)
5354

@@ -57,6 +58,7 @@ export const getTipBasedLPCSteps = (
5758
pipetteId: lastTiprackCheckStep.pipetteId,
5859
location: lastTiprackCheckStep.location,
5960
adapterId: lastTiprackCheckStep.adapterId,
61+
definitionUri: lastTiprackCheckStep.definitionUri,
6062
}
6163

6264
return [
@@ -134,12 +136,13 @@ function getCheckTipRackSectionSteps(args: LPCArgs): CheckTipRacksStep[] {
134136

135137
return [
136138
...acc,
137-
...labwareLocations.map(({ location, adapterId }) => ({
139+
...labwareLocations.map(({ location, adapterId, definitionUri }) => ({
138140
section: SECTIONS.CHECK_TIP_RACKS,
139141
labwareId: params.labwareId,
140142
pipetteId: params.pipetteId,
141143
location,
142144
adapterId,
145+
definitionUri: definitionUri,
143146
})),
144147
]
145148
}, [])
@@ -149,47 +152,47 @@ function getCheckLabwareSectionSteps(args: LPCArgs): CheckLabwareStep[] {
149152
const { labware, modules, commands, primaryPipetteId } = args
150153
const labwareDefinitions = getLabwareDefinitionsFromCommands(commands)
151154

152-
return labware.reduce<CheckLabwareStep[]>((acc, currentLabware) => {
155+
const deDupedLabwareLocationCombos = getLabwareLocationCombos(
156+
commands,
157+
labware,
158+
modules
159+
).reduce<LabwareLocationCombo[]>((acc, labwareLocationCombo) => {
153160
const labwareDef = labwareDefinitions.find(
154-
def => getLabwareDefURI(def) === currentLabware.definitionUri
161+
def => getLabwareDefURI(def) === labwareLocationCombo.definitionUri
155162
)
156-
if (currentLabware.id === FIXED_TRASH_ID) return acc
163+
if (labwareLocationCombo.labwareId === FIXED_TRASH_ID) return acc
157164
if (labwareDef == null) {
158165
throw new Error(
159-
`could not find labware definition within protocol with uri: ${currentLabware.definitionUri}`
166+
`could not find labware definition within protocol with uri: ${labwareLocationCombo.definitionUri}`
160167
)
161168
}
162169
const isTiprack = getIsTiprack(labwareDef)
163170
const adapter = (labwareDef?.allowedRoles ?? []).includes('adapter')
164171
if (isTiprack || adapter) return acc // skip any labware that is a tiprack or adapter
165172

166-
const labwareLocationCombos = getLabwareLocationCombos(
167-
commands,
168-
labware,
169-
modules
173+
const comboAlreadyExists = acc.some(
174+
accLocationCombo =>
175+
labwareLocationCombo.definitionUri === accLocationCombo.definitionUri &&
176+
isEqual(labwareLocationCombo.location, accLocationCombo.location)
170177
)
171-
return [
172-
...acc,
173-
...labwareLocationCombos.reduce<CheckLabwareStep[]>(
174-
(innerAcc, { location, labwareId, moduleId, adapterId }) => {
175-
if (labwareId !== currentLabware.id) {
176-
return innerAcc
177-
}
178+
return comboAlreadyExists ? acc : [...acc, labwareLocationCombo]
179+
}, [])
178180

179-
return [
180-
...innerAcc,
181-
{
182-
section: SECTIONS.CHECK_LABWARE,
183-
labwareId,
184-
pipetteId: primaryPipetteId,
185-
location,
186-
moduleId,
187-
adapterId,
188-
},
189-
]
181+
return deDupedLabwareLocationCombos.reduce<CheckLabwareStep[]>(
182+
(acc, { labwareId, location, moduleId, adapterId, definitionUri }) => {
183+
return [
184+
...acc,
185+
{
186+
section: SECTIONS.CHECK_LABWARE,
187+
labwareId,
188+
pipetteId: primaryPipetteId,
189+
location,
190+
moduleId,
191+
adapterId,
192+
definitionUri,
190193
},
191-
[]
192-
),
193-
]
194-
}, [])
194+
]
195+
},
196+
[]
197+
)
195198
}

0 commit comments

Comments
 (0)