Skip to content

Commit

Permalink
fix(app): do not redundantly check labware in LPC (#14079)
Browse files Browse the repository at this point in the history
fixes RAUT-889
  • Loading branch information
shlokamin authored Dec 4, 2023
1 parent f65669a commit 4f46a83
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ describe('CheckItem', () => {
section: SECTIONS.CHECK_LABWARE,
pipetteId: mockCompletedAnalysis.pipettes[0].id,
labwareId: mockCompletedAnalysis.labware[0].id,
definitionUri: mockCompletedAnalysis.labware[0].definitionUri,
location: { slotName: 'D1' },
protocolData: mockCompletedAnalysis,
proceed: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ describe('PickUpTip', () => {
section: SECTIONS.PICK_UP_TIP,
pipetteId: mockCompletedAnalysis.pipettes[0].id,
labwareId: mockCompletedAnalysis.labware[0].id,
definitionUri: mockCompletedAnalysis.labware[0].definitionUri,
location: { slotName: 'D1' },
protocolData: mockCompletedAnalysis,
proceed: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ describe('ReturnTip', () => {
section: SECTIONS.RETURN_TIP,
pipetteId: mockCompletedAnalysis.pipettes[0].id,
labwareId: mockCompletedAnalysis.labware[0].id,
definitionUri: mockCompletedAnalysis.labware[0].definitionUri,
location: { slotName: 'D1' },
protocolData: mockCompletedAnalysis,
proceed: jest.fn(),
Expand Down
5 changes: 5 additions & 0 deletions app/src/organisms/LabwarePositionCheck/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface CheckTipRacksStep {
pipetteId: string
labwareId: string
location: LabwareOffsetLocation
definitionUri: string
adapterId?: string
}
export interface AttachProbeStep {
Expand All @@ -32,20 +33,23 @@ export interface PickUpTipStep {
pipetteId: string
labwareId: string
location: LabwareOffsetLocation
definitionUri: string
adapterId?: string
}
export interface CheckPositionsStep {
section: typeof SECTIONS.CHECK_POSITIONS
pipetteId: string
labwareId: string
location: LabwareOffsetLocation
definitionUri: string
moduleId?: string
}
export interface CheckLabwareStep {
section: typeof SECTIONS.CHECK_LABWARE
pipetteId: string
labwareId: string
location: LabwareOffsetLocation
definitionUri: string
moduleId?: string
adapterId?: string
}
Expand All @@ -54,6 +58,7 @@ export interface ReturnTipStep {
pipetteId: string
labwareId: string
location: LabwareOffsetLocation
definitionUri: string
adapterId?: string
}
export interface DetachProbeStep {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,14 @@ function getAllCheckSectionSteps(
)

return labwareLocations.map(
({ location, labwareId, moduleId, adapterId }) => ({
({ location, labwareId, moduleId, adapterId, definitionUri }) => ({
section: SECTIONS.CHECK_POSITIONS,
labwareId: labwareId,
pipetteId: getPrimaryPipetteId(pipettes),
location,
moduleId,
adapterId,
definitionUri: definitionUri,
})
)
}
65 changes: 34 additions & 31 deletions app/src/organisms/LabwarePositionCheck/utils/getTipBasedLPCSteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const getTipBasedLPCSteps = (
pipetteId: lastTiprackCheckStep.pipetteId,
location: lastTiprackCheckStep.location,
adapterId: lastTiprackCheckStep.adapterId,
definitionUri: lastTiprackCheckStep.definitionUri,
}
const checkLabwareSectionSteps = getCheckLabwareSectionSteps(args)

Expand All @@ -57,6 +58,7 @@ export const getTipBasedLPCSteps = (
pipetteId: lastTiprackCheckStep.pipetteId,
location: lastTiprackCheckStep.location,
adapterId: lastTiprackCheckStep.adapterId,
definitionUri: lastTiprackCheckStep.definitionUri,
}

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

return [
...acc,
...labwareLocations.map(({ location, adapterId }) => ({
...labwareLocations.map(({ location, adapterId, definitionUri }) => ({
section: SECTIONS.CHECK_TIP_RACKS,
labwareId: params.labwareId,
pipetteId: params.pipetteId,
location,
adapterId,
definitionUri: definitionUri,
})),
]
}, [])
Expand All @@ -149,47 +152,47 @@ function getCheckLabwareSectionSteps(args: LPCArgs): CheckLabwareStep[] {
const { labware, modules, commands, primaryPipetteId } = args
const labwareDefinitions = getLabwareDefinitionsFromCommands(commands)

return labware.reduce<CheckLabwareStep[]>((acc, currentLabware) => {
const deDupedLabwareLocationCombos = getLabwareLocationCombos(
commands,
labware,
modules
).reduce<LabwareLocationCombo[]>((acc, labwareLocationCombo) => {
const labwareDef = labwareDefinitions.find(
def => getLabwareDefURI(def) === currentLabware.definitionUri
def => getLabwareDefURI(def) === labwareLocationCombo.definitionUri
)
if (currentLabware.id === FIXED_TRASH_ID) return acc
if (labwareLocationCombo.labwareId === FIXED_TRASH_ID) return acc
if (labwareDef == null) {
throw new Error(
`could not find labware definition within protocol with uri: ${currentLabware.definitionUri}`
`could not find labware definition within protocol with uri: ${labwareLocationCombo.definitionUri}`
)
}
const isTiprack = getIsTiprack(labwareDef)
const adapter = (labwareDef?.allowedRoles ?? []).includes('adapter')
if (isTiprack || adapter) return acc // skip any labware that is a tiprack or adapter

const labwareLocationCombos = getLabwareLocationCombos(
commands,
labware,
modules
const comboAlreadyExists = acc.some(
accLocationCombo =>
labwareLocationCombo.definitionUri === accLocationCombo.definitionUri &&
isEqual(labwareLocationCombo.location, accLocationCombo.location)
)
return [
...acc,
...labwareLocationCombos.reduce<CheckLabwareStep[]>(
(innerAcc, { location, labwareId, moduleId, adapterId }) => {
if (labwareId !== currentLabware.id) {
return innerAcc
}
return comboAlreadyExists ? acc : [...acc, labwareLocationCombo]
}, [])

return [
...innerAcc,
{
section: SECTIONS.CHECK_LABWARE,
labwareId,
pipetteId: primaryPipetteId,
location,
moduleId,
adapterId,
},
]
return deDupedLabwareLocationCombos.reduce<CheckLabwareStep[]>(
(acc, { labwareId, location, moduleId, adapterId, definitionUri }) => {
return [
...acc,
{
section: SECTIONS.CHECK_LABWARE,
labwareId,
pipetteId: primaryPipetteId,
location,
moduleId,
adapterId,
definitionUri,
},
[]
),
]
}, [])
]
},
[]
)
}

0 comments on commit 4f46a83

Please sign in to comment.