Skip to content

Commit f043cad

Browse files
authored
feat(step-generation): add lid arg to load_labware() (#18729)
closes AUTH-2007
1 parent 5360a40 commit f043cad

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

step-generation/src/__tests__/pythonFileUtils.test.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ const labwareId2 = 'labwareId2'
127127
const labwareId3 = 'labwareId3'
128128
const labwareId4 = 'labwareId4'
129129
const labwareId5 = 'labwareId5'
130+
const labwareId6 = 'labwareId6'
130131

131132
const mockLabwareEntities: LabwareEntities = {
132133
[labwareId1]: {
@@ -159,6 +160,16 @@ const mockLabwareEntities: LabwareEntities = {
159160
def: fixture96Plate as LabwareDefinition2,
160161
pythonName: 'well_plate_3',
161162
},
163+
[labwareId6]: {
164+
id: labwareId6,
165+
labwareDefURI: 'opentrons/mock_lid/1',
166+
def: {
167+
...opentrons96Plate,
168+
allowedRoles: ['lid'],
169+
parameters: { loadName: 'mock_lid' } as any,
170+
},
171+
pythonName: 'lid_1',
172+
},
162173
}
163174

164175
const labwareRobotState: TimelineFrame['labware'] = {
@@ -172,6 +183,8 @@ const labwareRobotState: TimelineFrame['labware'] = {
172183
[labwareId4]: { stack: [labwareId4, moduleId3, 'A2'] },
173184
// labware on a slot
174185
[labwareId5]: { stack: [labwareId5, 'C2'] },
186+
// lid on labware
187+
[labwareId6]: { stack: [labwareId6, labwareId3, labwareId2, 'B2'] },
175188
}
176189

177190
const mockLabwareNicknames: Record<string, string> = {
@@ -223,7 +236,7 @@ adapter_2 = protocol.load_adapter_from_definition(
223236
})
224237

225238
describe('getLoadLabware', () => {
226-
it('should generate loadLabware for 3 labware', () => {
239+
it('should generate loadLabware for 3 labware with a lid on the first one', () => {
227240
expect(
228241
getLoadLabware(
229242
mockModuleEntities,
@@ -238,6 +251,7 @@ well_plate_1 = adapter_2.load_labware(
238251
"fixture_96_plate",
239252
label="reagent plate",
240253
namespace="opentrons",
254+
lid="mock_lid",
241255
)
242256
well_plate_2 = magnetic_block_2.load_labware(
243257
"fixture_96_plate",

step-generation/src/utils/pythonFileUtils.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,20 @@ export function getLoadLabware(
167167
labwareNicknamesById: Record<string, string>
168168
): string {
169169
const labwareEntities = Object.values(allLabwareEntities).filter(
170-
lw => !lw.def.allowedRoles?.includes('adapter')
170+
lw =>
171+
!lw.def.allowedRoles?.includes('adapter') &&
172+
!lw.def.allowedRoles?.includes('lid')
173+
)
174+
const lidEntities = Object.values(allLabwareEntities).filter(lw =>
175+
lw.def.allowedRoles?.includes('lid')
171176
)
172177
const pythonLabware = Object.values(labwareEntities)
173178
.map(labware => {
174179
const { id, def, pythonName } = labware
175180
const { metadata, parameters, namespace } = def
181+
const lidEntity = Object.values(lidEntities).find(
182+
lid => labwareRobotState[lid.id].stack[1] === id
183+
)
176184
const hasNickname =
177185
labwareNicknamesById[id] != null &&
178186
labwareNicknamesById[id] !== metadata.displayName
@@ -204,6 +212,9 @@ export function getLoadLabware(
204212
...(locationArg ? [locationArg] : []),
205213
...(labelArg ? [labelArg] : []),
206214
`namespace=${formatPyStr(namespace)}`,
215+
...(lidEntity != null
216+
? [`lid=${formatPyStr(lidEntity.def.parameters.loadName)}`]
217+
: []),
207218
// NOTE: temporarily removing version number
208219
// until PD migrated labware defs to the latest version
209220
// upon re-import

0 commit comments

Comments
 (0)