@@ -4,6 +4,7 @@ import min from 'lodash/min'
4
4
5
5
import {
6
6
FLEX_ROBOT_TYPE ,
7
+ getAllLabwareDefs ,
7
8
getPipetteSpecsV2 ,
8
9
POSITION_REFERENCE_BOTTOM ,
9
10
POSITION_REFERENCE_TOP ,
@@ -16,12 +17,10 @@ import {
16
17
PROTOCOL_DESIGNER_SOURCE ,
17
18
} from '../../constants'
18
19
import { getDefaultBlowoutFlowRate , getDefaultPushOutVolume } from '../../utils'
19
- import { getEquipmentLoadInfoFromCommands } from './utils/getEquipmentLoadInfoFromCommands'
20
20
import { getMigratedPositionFromTop } from './utils/getMigrationPositionFromTop'
21
21
22
22
import type {
23
23
LabwareDefinition2 ,
24
- LoadLabwareCreateCommand ,
25
24
PipetteV2Specs ,
26
25
ProtocolFile ,
27
26
} from '@opentrons/shared-data'
@@ -56,21 +55,25 @@ const getMigratedBlowoutLocation = (
56
55
export const migrateFile = (
57
56
appData : ProtocolFile < PDMetadata >
58
57
) : ProtocolFile < PDMetadata > => {
59
- const { designerApplication, commands , labwareDefinitions, robot } = appData
58
+ const { designerApplication, robot , labwareDefinitions } = appData
60
59
if ( designerApplication == null || designerApplication ?. data == null ) {
61
60
throw Error ( 'The designerApplication key in your file is corrupt.' )
62
61
}
63
- const { savedStepForms, ingredients } = designerApplication . data
62
+ const {
63
+ savedStepForms,
64
+ ingredients,
65
+ labware,
66
+ pipettes,
67
+ } = designerApplication . data
64
68
const { model : robotType } = robot
65
- const loadLabwareCommands = commands . filter (
66
- ( command ) : command is LoadLabwareCreateCommand =>
67
- command . commandType === 'loadLabware'
68
- )
69
- const equipmentLoadInfoFromCommands = getEquipmentLoadInfoFromCommands (
70
- commands ,
71
- labwareDefinitions
72
- )
73
69
70
+ const allLabwareDefsByURI =
71
+ // read the labware definitions key first
72
+ // otherwise map to all labware defs as a fallback
73
+ // for OpentronsAI
74
+ Object . values ( labwareDefinitions ) . length > 0
75
+ ? labwareDefinitions
76
+ : getAllLabwareDefs ( )
74
77
const migratedIngredients : Ingredients = Object . entries (
75
78
ingredients
76
79
) . reduce < Ingredients > ( ( acc , [ id , ingredient ] ) => {
@@ -127,19 +130,17 @@ export const migrateFile = (
127
130
blowout_z_offset,
128
131
...rest
129
132
} = form
130
- const aspirateLabwareUri =
131
- equipmentLoadInfoFromCommands . labware [ aspirate_labware ] . labwareDefURI
132
- const isAspirateLabwareTouchtipDisabled = labwareDefinitions [
133
+ const aspirateLabwareUri = labware [ aspirate_labware ] . labwareDefURI
134
+ const isAspirateLabwareTouchtipDisabled = allLabwareDefsByURI [
133
135
aspirateLabwareUri
134
136
] . parameters . quirks ?. includes ( 'touchTipDisabled' )
135
- const dispenseLabwareUri =
136
- equipmentLoadInfoFromCommands . labware [ dispense_labware ] ?. labwareDefURI
137
+ const dispenseLabwareUri = labware [ dispense_labware ] ?. labwareDefURI
137
138
138
139
const isDispenseLabwareTouchtipDisabled =
139
140
// dispense is in a waste chute/trash bin
140
- labwareDefinitions [ dispenseLabwareUri ] == null
141
+ allLabwareDefsByURI [ dispenseLabwareUri ] == null
141
142
? true
142
- : labwareDefinitions [ dispenseLabwareUri ] . parameters . quirks ?. includes (
143
+ : allLabwareDefsByURI [ dispenseLabwareUri ] . parameters . quirks ?. includes (
143
144
'touchTipDisabled'
144
145
)
145
146
@@ -148,21 +149,19 @@ export const migrateFile = (
148
149
firstTrashBinOrWasteChuteId
149
150
)
150
151
const matchingAspirateLabwareWellDepth = getMigratedPositionFromTop (
151
- labwareDefinitions ,
152
- loadLabwareCommands ,
152
+ allLabwareDefsByURI ,
153
153
aspirate_labware as string ,
154
+ labware ,
154
155
'aspirate'
155
156
)
156
157
const matchingDispenseLabwareWellDepth = getMigratedPositionFromTop (
157
- labwareDefinitions ,
158
- loadLabwareCommands ,
158
+ allLabwareDefsByURI ,
159
159
dispense_labware as string ,
160
+ labware ,
160
161
'dispense'
161
162
)
162
- const tipRackDef = labwareDefinitions [ form . tipRack ]
163
- const pipetteName =
164
- equipmentLoadInfoFromCommands . pipettes ?. [ form . pipette ] ?. pipetteName ??
165
- null
163
+ const tipRackDef = allLabwareDefsByURI [ form . tipRack ]
164
+ const pipetteName = pipettes ?. [ form . pipette ] ?. pipetteName ?? null
166
165
const pipetteSpecs =
167
166
pipetteName != null ? getPipetteSpecsV2 ( pipetteName ) : null
168
167
const defaultPushOutVolume =
@@ -272,20 +271,17 @@ export const migrateFile = (
272
271
const {
273
272
id,
274
273
mix_touchTip_mmFromBottom,
275
- labware,
274
+ labware : formLabware ,
276
275
liquidClassesSupported,
277
276
mix_touchTip_checkbox,
278
277
...rest
279
278
} = form
280
- const tipRackDef = labwareDefinitions [ form . tipRack ]
281
- const mixLabwareUri =
282
- equipmentLoadInfoFromCommands . labware [ labware ] . labwareDefURI
283
- const isLabwareTouchtipDisabled = labwareDefinitions [
279
+ const tipRackDef = allLabwareDefsByURI [ form . tipRack ]
280
+ const mixLabwareUri = labware [ formLabware ] . labwareDefURI
281
+ const isLabwareTouchtipDisabled = allLabwareDefsByURI [
284
282
mixLabwareUri
285
283
] . parameters . quirks ?. includes ( 'touchTipDisabled' )
286
- const pipetteName =
287
- equipmentLoadInfoFromCommands . pipettes ?. [ form . pipette ] ?. pipetteName ??
288
- null
284
+ const pipetteName = pipettes ?. [ form . pipette ] ?. pipetteName ?? null
289
285
const pipetteSpecs =
290
286
pipetteName != null ? getPipetteSpecsV2 ( pipetteName ) : null
291
287
const defaultPushOutVolume =
@@ -298,9 +294,9 @@ export const migrateFile = (
298
294
)
299
295
300
296
const matchingLabwareWellDepth = getMigratedPositionFromTop (
301
- labwareDefinitions ,
302
- loadLabwareCommands ,
303
- labware as string ,
297
+ allLabwareDefsByURI ,
298
+ formLabware as string ,
299
+ labware ,
304
300
'mix'
305
301
)
306
302
@@ -321,7 +317,7 @@ export const migrateFile = (
321
317
[ id ] : {
322
318
...rest ,
323
319
id,
324
- labware,
320
+ labware : formLabware ,
325
321
mix_touchTip_checkbox : isLabwareTouchtipDisabled
326
322
? false
327
323
: mix_touchTip_checkbox ,
0 commit comments