Skip to content

Commit

Permalink
fix(app): filter for duplicate defUri after filtering for tipracks us…
Browse files Browse the repository at this point in the history
…ed (#13182)

Fix RQA-1110
  • Loading branch information
smb2268 authored Jul 27, 2023
1 parent 74448b1 commit b0f5fa6
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ const mockLabwareEntities: ProtocolAnalysisOutput['labware'] = [
location: { slotName: '2' },
displayName: 'second labware nickname',
},
{
id: 'secondLabwareId',
loadName: mockLabwareDef.parameters.loadName,
definitionUri: getLabwareDefURI(mockLabwareDef),
location: { slotName: '2' },
displayName: 'second labware nickname',
},
{
id: 'duplicateLabwareId',
loadName: mockLabwareDef.parameters.loadName,
Expand Down Expand Up @@ -159,6 +166,11 @@ describe('getLabwareLocationCombos', () => {
labwareId: 'secondLabwareId',
definitionUri: getLabwareDefURI(mockLabwareDef),
},
{
location: { slotName: '2' },
labwareId: 'duplicateLabwareId',
definitionUri: getLabwareDefURI(mockLabwareDef),
},
{
location: { slotName: '3', moduleModel: 'heaterShakerModuleV1' },
labwareId: 'onModuleLabwareId',
Expand Down Expand Up @@ -263,6 +275,11 @@ describe('getLabwareLocationCombos', () => {
labwareId: 'secondLabwareId',
definitionUri: getLabwareDefURI(mockLabwareDef),
},
{
location: { slotName: '2' },
labwareId: 'duplicateLabwareId',
definitionUri: getLabwareDefURI(mockLabwareDef),
},
{
location: { slotName: '3', moduleModel: 'heaterShakerModuleV1' },
labwareId: 'onModuleLabwareId',
Expand All @@ -279,6 +296,11 @@ describe('getLabwareLocationCombos', () => {
labwareId: 'secondLabwareId',
definitionUri: getLabwareDefURI(mockLabwareDef),
},
{
location: { slotName: '5' },
labwareId: 'duplicateLabwareId',
definitionUri: getLabwareDefURI(mockLabwareDef),
},
])
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
} from '@opentrons/shared-data'
import { LabwareOffsetLocation } from '@opentrons/api-client'

interface LabwareLocationCombo {
export interface LabwareLocationCombo {
location: LabwareOffsetLocation
definitionUri: string
labwareId: string
Expand Down Expand Up @@ -84,6 +84,7 @@ function appendLocationComboIfUniq(
): LabwareLocationCombo[] {
const locationComboAlreadyExists = acc.some(
combo =>
combo.labwareId === locationCombo.labwareId &&
isEqual(combo.location, locationCombo.location) &&
combo.definitionUri === locationCombo.definitionUri
)
Expand Down
24 changes: 20 additions & 4 deletions app/src/organisms/LabwarePositionCheck/utils/getCheckSteps.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isEqual } from 'lodash'
import { SECTIONS } from '../constants'
import { getLabwareDefinitionsFromCommands } from './labware'
import {
Expand All @@ -18,7 +19,8 @@ import type {
RunTimeCommand,
ProtocolAnalysisOutput,
} from '@opentrons/shared-data'
import type { PickUpTipRunTimeCommand } from '@opentrons/shared-data/protocol/types/schemaV7/command/pipetting'
import type { PickUpTipRunTimeCommand } from '@opentrons/shared-data/protocol/types/schemaV6/command/pipetting'
import type { LabwareLocationCombo } from '../../ApplyHistoricOffsets/hooks/getLabwareLocationCombos'

interface LPCArgs {
primaryPipetteId: string
Expand Down Expand Up @@ -109,9 +111,23 @@ function getCheckTipRackSectionSteps(args: LPCArgs): CheckTipRacksStep[] {
...onlySecondaryPipettePickUpTipCommands,
...uniqPrimaryPipettePickUpTipCommands,
].reduce<CheckTipRacksStep[]>((acc, { params }) => {
const labwareLocations = labwareLocationCombos.filter(
combo => combo.labwareId === params.labwareId
)
const labwareLocations = labwareLocationCombos.reduce<
LabwareLocationCombo[]
>((acc, labwareLocationCombo) => {
// remove labware that isn't accessed by a pickup tip command
if (labwareLocationCombo.labwareId !== params.labwareId) {
return acc
}
// remove duplicate definitionUri in same location
const comboAlreadyExists = acc.some(
accLocationCombo =>
labwareLocationCombo.definitionUri ===
accLocationCombo.definitionUri &&
isEqual(labwareLocationCombo.location, accLocationCombo.location)
)
return comboAlreadyExists ? acc : [...acc, labwareLocationCombo]
}, [])

return [
...acc,
...labwareLocations.map(({ location }) => ({
Expand Down

0 comments on commit b0f5fa6

Please sign in to comment.