Skip to content

Commit 3e32214

Browse files
authored
refactor(protocol-designer): merge getMatchingTipLiquidSpecs() and getMatchingTipLiquidSpecsFromSpec() (#20048)
# Overview The last one! Back in PR #19041, @ncdiehl introduced `getMatchingTipLiquidSpecsFromSpec()`, which was almost an exact a copy of `getMatchingTipLiquidSpecs()` except that it looked up the tiprack definition differently, because Nick's `getMatchingTipLiquidSpecsFromSpec()` did not have access to the `PipetteEntity.tiprackLabwareDef`. After the recent refactorings, the caller passes in the tiprack definition into both `getMatchingTipLiquidSpecs()` and `getMatchingTipLiquidSpecsFromSpec()`, so now there is no difference between the 2 functions anymore. So this PR merges the 2 functions together and eliminates `getMatchingTipLiquidSpecsFromSpec()`. ## Test Plan and Hands on Testing Run CI tests. ## Risk assessment Low.
1 parent a4ed379 commit 3e32214

File tree

6 files changed

+11
-54
lines changed

6 files changed

+11
-54
lines changed

protocol-designer/src/load-file/migration/8_5_0.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { getMaxUiFlowRate } from '../../pages/Designer/ProtocolSteps/StepForm/Pi
2626
import {
2727
getDefaultBlowoutFlowRate,
2828
getDefaultPushOutVolume,
29-
getMatchingTipLiquidSpecsFromSpec,
29+
getMatchingTipLiquidSpecs,
3030
} from '../../utils'
3131
import { getMigratedPositionFromTop } from './utils/getMigrationPositionFromTop'
3232

@@ -132,7 +132,7 @@ const getClippedFlowRateForMoveLiquid = (args: {
132132
) ?? 0
133133
}
134134

135-
const matchingTipLiquidSpecs = getMatchingTipLiquidSpecsFromSpec(
135+
const matchingTipLiquidSpecs = getMatchingTipLiquidSpecs(
136136
pipetteSpecs,
137137
volume,
138138
tiprackDef

protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/PipetteFields/FlowRateField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export function FlowRateField(props: FlowRateFieldProps): JSX.Element {
6767

6868
const matchingTipLiquidSpecs =
6969
pipette != null && tiprack != null
70-
? getMatchingTipLiquidSpecs(pipette, volume as number, tiprackDef)
70+
? getMatchingTipLiquidSpecs(pipette.spec, volume as number, tiprackDef)
7171
: null
7272

7373
let airGapByVolume: Array<[number, number]> = []

protocol-designer/src/steplist/formLevel/handleFormChange/utils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ const getNoLiquidClassValuesMoveLiquid = (args: {
570570
const allOT2Defaults = getDefaultsForStepType('moveLiquid')
571571
const matchingTipLiquidSpecs =
572572
pipetteEntity != null
573-
? getMatchingTipLiquidSpecs(pipetteEntity, volume, tiprackDef)
573+
? getMatchingTipLiquidSpecs(pipetteEntity.spec, volume, tiprackDef)
574574
: null
575575
const aspirateOT2Defaults = {
576576
aspirate_wellOrder_first: allOT2Defaults.aspirate_wellOrder_first,
@@ -675,7 +675,7 @@ const getNoLiquidClassValuesMoveLiquid = (args: {
675675

676676
const matchingTipLiquidSpecs =
677677
pipetteEntity != null
678-
? getMatchingTipLiquidSpecs(pipetteEntity, volume, tiprackDef)
678+
? getMatchingTipLiquidSpecs(pipetteEntity.spec, volume, tiprackDef)
679679
: null
680680

681681
const aspirateCorrectionVolume =
@@ -870,7 +870,7 @@ const getNoLiquidClassValuesMix = (args: {
870870

871871
const matchingTipLiquidSpecs =
872872
pipetteEntity != null
873-
? getMatchingTipLiquidSpecs(pipetteEntity, volume, tiprackDef)
873+
? getMatchingTipLiquidSpecs(pipetteEntity.spec, volume, tiprackDef)
874874
: null
875875
const aspirateCorrectionVolume =
876876
linearInterpolate(
@@ -1074,7 +1074,7 @@ const getLiquidClassValuesMoveLiquid = (args: {
10741074
const aspirateOffsetFields = getOffsetFields(aspirateOffset, 'aspirate')
10751075
const matchingTipLiquidSpecs =
10761076
pipetteEntity != null
1077-
? getMatchingTipLiquidSpecs(pipetteEntity, volume, tiprackDef)
1077+
? getMatchingTipLiquidSpecs(pipetteEntity.spec, volume, tiprackDef)
10781078
: null
10791079

10801080
const aspirateCorrectionVolume =
@@ -1302,7 +1302,7 @@ const getLiquidClassValuesMix = (args: {
13021302

13031303
const matchingTipLiquidSpecs =
13041304
pipetteEntity != null
1305-
? getMatchingTipLiquidSpecs(pipetteEntity, volume, tiprackDef)
1305+
? getMatchingTipLiquidSpecs(pipetteEntity.spec, volume, tiprackDef)
13061306
: null
13071307

13081308
const aspirateCorrectionVolume =

protocol-designer/src/steplist/formLevel/stepFormToArgs/mixFormToArgs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const mixFormToArgs = (
3737
pushOut_volume,
3838
} = hydratedFormData
3939
const matchingTipLiquidSpecs = getMatchingTipLiquidSpecs(
40-
pipette,
40+
pipette?.spec,
4141
hydratedFormData.volume,
4242
hydratedFormData.tipRack
4343
)

protocol-designer/src/steplist/formLevel/stepFormToArgs/moveLiquidFormToArgs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ export const moveLiquidFormToArgs = (
294294
'dispense_airGap_volume'
295295
)
296296
const matchingTipLiquidSpecs = getMatchingTipLiquidSpecs(
297-
hydratedFormData.pipette,
297+
hydratedFormData.pipette?.spec,
298298
hydratedFormData.volume,
299299
tipRack
300300
)

protocol-designer/src/utils/index.ts

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
getTiprackVolume,
88
INTERACTIVE_WELL_DATA_ATTRIBUTE,
99
isAddressableAreaStandardSlot,
10-
LOW_VOLUME_PIPETTES,
1110
makeWellSetHelpers,
1211
STAGING_AREA_RIGHT_SLOT_FIXTURE,
1312
} from '@opentrons/shared-data'
@@ -32,7 +31,6 @@ import type {
3231
AdditionalEquipmentEntity,
3332
LabwareEntities,
3433
PipetteEntities,
35-
PipetteEntity,
3634
} from '@opentrons/step-generation'
3735
import type { BoundingRect, GenericRect } from '../collision-types'
3836
import type {
@@ -185,7 +183,7 @@ export const getStagingAreaAddressableAreas = (
185183
return addressableAreasRaw
186184
}
187185

188-
export function getMatchingTipLiquidSpecsFromSpec(
186+
export function getMatchingTipLiquidSpecs(
189187
pipetteSpecs: PipetteV2Specs,
190188
volume: number,
191189
tiprackDef: LabwareDefinition2
@@ -203,7 +201,6 @@ export function getMatchingTipLiquidSpecsFromSpec(
203201
const isLowVolumePipette = Object.keys(pipetteSpecs.liquids).some(
204202
key => key === 'lowVolumeDefault'
205203
)
206-
207204
const isUsingLowVolume = volume < 5
208205
const liquidType =
209206
isLowVolumePipette && isUsingLowVolume ? 'lowVolumeDefault' : 'default'
@@ -228,46 +225,6 @@ export function getMatchingTipLiquidSpecsFromSpec(
228225
return matchingTipLiquidSpecs
229226
}
230227

231-
export function getMatchingTipLiquidSpecs(
232-
pipetteEntity: PipetteEntity,
233-
volume: number,
234-
tiprackDef: LabwareDefinition2
235-
): SupportedTip {
236-
const tipLength = tiprackDef?.parameters.tipLength ?? 0
237-
238-
if (tipLength === 0) {
239-
console.error(
240-
`expected to find a tiplength with tiprack ${
241-
tiprackDef?.metadata.displayName ?? 'unknown displayName'
242-
} but could not`
243-
)
244-
}
245-
246-
const isLowVolumePipette = LOW_VOLUME_PIPETTES.includes(pipetteEntity.name)
247-
const isUsingLowVolume = volume < 5
248-
const liquidType =
249-
isLowVolumePipette && isUsingLowVolume ? 'lowVolumeDefault' : 'default'
250-
const liquidSupportedTips = Object.values(
251-
pipetteEntity.spec.liquids[liquidType].supportedTips
252-
)
253-
254-
// find the supported tip liquid specs that either exactly match
255-
// tipLength or are closest, this accounts for custom tipracks
256-
const matchingTipLiquidSpecs = liquidSupportedTips.sort((tipA, tipB) => {
257-
const differenceA = Math.abs(tipA.defaultTipLength - tipLength)
258-
const differenceB = Math.abs(tipB.defaultTipLength - tipLength)
259-
return differenceA - differenceB
260-
})[0]
261-
console.assert(
262-
matchingTipLiquidSpecs,
263-
`expected to find the tip liquid specs but could not with pipette tiprack displayname ${
264-
tiprackDef?.metadata.displayName ?? 'unknown displayname'
265-
}`
266-
)
267-
268-
return matchingTipLiquidSpecs
269-
}
270-
271228
/**
272229
* Removes specific phrases from the input string.
273230
*

0 commit comments

Comments
 (0)