Skip to content

Commit 23bf086

Browse files
committed
Merge branch 'edge' into sg_mix-py
2 parents ea5b138 + c7bcbad commit 23bf086

18 files changed

+206
-86
lines changed

protocol-designer/src/file-data/__tests__/createFile.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -137,21 +137,21 @@ def run(protocol: protocol_api.ProtocolContext):
137137
# Load Labware:
138138
mock_python_name_1 = protocol.load_labware(
139139
"fixture_trash",
140-
"12",
140+
location="12",
141141
label="Trash",
142142
namespace="fixture",
143143
version=1,
144144
)
145145
mock_python_name_2 = protocol.load_labware(
146146
"fixture_tiprack_10_ul",
147-
"1",
147+
location="1",
148148
label="Opentrons 96 Tip Rack 10 µL",
149149
namespace="fixture",
150150
version=1,
151151
)
152152
mock_python_name_3 = protocol.load_labware(
153153
"fixture_96_plate",
154-
"7",
154+
location="7",
155155
label="NEST 96 Well Plate 100 µL PCR Full Skirt",
156156
namespace="fixture",
157157
version=1,

protocol-designer/src/file-data/__tests__/pythonFile.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ well_plate_2 = magnetic_block_2.load_labware(
238238
)
239239
well_plate_3 = protocol.load_labware(
240240
"fixture_96_plate",
241-
"C2",
241+
location="C2",
242242
label="sample plate",
243243
namespace="fixture",
244244
version=1,

protocol-designer/src/file-data/selectors/pythonFile.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export function getLoadLabware(
163163
`${formatPyStr(parameters.loadName)}`,
164164
...(!onModule && !onAdapter
165165
? [
166-
`${formatPyStr(
166+
`location=${formatPyStr(
167167
labwareSlot === 'offDeck' ? OFF_DECK : labwareSlot
168168
)}`,
169169
]

protocol-designer/src/timelineMiddleware/generateRobotStateTimeline.ts

+3-15
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import {
2-
dropTipInPlace,
3-
moveToAddressableArea,
4-
getWasteChuteAddressableAreaNamePip,
52
dropTipInTrash,
3+
dropTipInWasteChute,
64
curryCommandCreator,
75
dropTip,
86
reduceCommandCreators,
97
commandCreatorsTimeline,
108
getPipetteIdFromCCArgs,
11-
ZERO_OFFSET,
129
} from '@opentrons/step-generation'
1310
import { commandCreatorFromStepArgs } from '../file-data/helpers'
1411
import type { StepArgsAndErrorsById } from '../steplist/types'
@@ -75,11 +72,6 @@ export const generateRobotStateTimeline = (
7572
const isWasteChute = dropTipEntity?.name === 'wasteChute'
7673
const isTrashBin = dropTipEntity?.name === 'trashBin'
7774

78-
const pipetteSpec = invariantContext.pipetteEntities[pipetteId]?.spec
79-
const addressableAreaNameWasteChute = getWasteChuteAddressableAreaNamePip(
80-
pipetteSpec.channels
81-
)
82-
8375
let dropTipCommands = [
8476
curryCommandCreator(dropTip, {
8577
pipette: pipetteId,
@@ -88,13 +80,9 @@ export const generateRobotStateTimeline = (
8880
]
8981
if (isWasteChute) {
9082
dropTipCommands = [
91-
curryCommandCreator(moveToAddressableArea, {
92-
pipetteId,
93-
addressableAreaName: addressableAreaNameWasteChute,
94-
offset: ZERO_OFFSET,
95-
}),
96-
curryCommandCreator(dropTipInPlace, {
83+
curryCommandCreator(dropTipInWasteChute, {
9784
pipetteId,
85+
wasteChuteId: dropTipEntity.id,
9886
}),
9987
]
10088
}
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,42 @@
11
import { describe, it, expect, vi } from 'vitest'
22
import {
3+
DEFAULT_PIPETTE,
34
getInitialRobotStateStandard,
45
getSuccessResult,
56
makeContext,
67
} from '../fixtures'
78
import { dispenseInTrash } from '../commandCreators/compound'
89
import type { CutoutId } from '@opentrons/shared-data'
910
import type { InvariantContext, RobotState } from '../types'
11+
import { PROTOCOL_CONTEXT_NAME } from '../utils'
1012

1113
vi.mock('../getNextRobotStateAndWarnings/dispenseUpdateLiquidState')
1214

13-
const mockId = 'mockId'
1415
const mockCutout: CutoutId = 'cutoutA3'
15-
const invariantContext: InvariantContext = makeContext()
16+
const mockTrashId = 'mockTrashId'
17+
let invariantContext: InvariantContext = {
18+
...makeContext(),
19+
additionalEquipmentEntities: {
20+
[mockTrashId]: {
21+
id: mockTrashId,
22+
name: 'trashBin',
23+
pythonName: 'mock_trash_bin_1',
24+
location: mockCutout,
25+
},
26+
},
27+
}
1628
const prevRobotState: RobotState = getInitialRobotStateStandard(
1729
invariantContext
1830
)
1931

2032
describe('dispenseInTrash', () => {
21-
it('returns correct commands for dispenseInTrash in trash bin', () => {
33+
it('returns correct commands for dispenseInTrash in trash bin for flex', () => {
2234
const result = dispenseInTrash(
2335
{
24-
pipetteId: mockId,
36+
pipetteId: DEFAULT_PIPETTE,
2537
flowRate: 10,
2638
volume: 10,
27-
trashLocation: mockCutout,
39+
trashId: mockTrashId,
2840
},
2941
invariantContext,
3042
prevRobotState
@@ -34,7 +46,7 @@ describe('dispenseInTrash', () => {
3446
commandType: 'moveToAddressableArea',
3547
key: expect.any(String),
3648
params: {
37-
pipetteId: mockId,
49+
pipetteId: DEFAULT_PIPETTE,
3850
addressableAreaName: 'movableTrashA3',
3951
offset: { x: 0, y: 0, z: 0 },
4052
},
@@ -43,11 +55,71 @@ describe('dispenseInTrash', () => {
4355
commandType: 'dispenseInPlace',
4456
key: expect.any(String),
4557
params: {
46-
pipetteId: mockId,
58+
pipetteId: DEFAULT_PIPETTE,
4759
volume: 10,
4860
flowRate: 10,
4961
},
5062
},
5163
])
64+
expect(getSuccessResult(result).python).toBe(
65+
`
66+
mockPythonName.dispense(
67+
volume=10,
68+
location=mock_trash_bin_1,
69+
rate=10 / mockPythonName.flow_rate.dispense,
70+
)`.trimStart()
71+
)
72+
})
73+
it('returns correct commands for dispenseInTrash in trash bin for ot-2', () => {
74+
const mockFixedTrashId = 'fixedTrashId'
75+
invariantContext = {
76+
...invariantContext,
77+
additionalEquipmentEntities: {
78+
[mockFixedTrashId]: {
79+
id: mockFixedTrashId,
80+
name: 'trashBin',
81+
pythonName: `${PROTOCOL_CONTEXT_NAME}.fixed_trash`,
82+
location: 'cutout12',
83+
},
84+
},
85+
}
86+
const result = dispenseInTrash(
87+
{
88+
pipetteId: DEFAULT_PIPETTE,
89+
flowRate: 10,
90+
volume: 10,
91+
trashId: mockFixedTrashId,
92+
},
93+
invariantContext,
94+
prevRobotState
95+
)
96+
expect(getSuccessResult(result).commands).toEqual([
97+
{
98+
commandType: 'moveToAddressableArea',
99+
key: expect.any(String),
100+
params: {
101+
pipetteId: DEFAULT_PIPETTE,
102+
addressableAreaName: 'fixedTrash',
103+
offset: { x: 0, y: 0, z: 0 },
104+
},
105+
},
106+
{
107+
commandType: 'dispenseInPlace',
108+
key: expect.any(String),
109+
params: {
110+
pipetteId: DEFAULT_PIPETTE,
111+
volume: 10,
112+
flowRate: 10,
113+
},
114+
},
115+
])
116+
expect(getSuccessResult(result).python).toBe(
117+
`
118+
mockPythonName.dispense(
119+
volume=10,
120+
location=protocol.fixed_trash,
121+
rate=10 / mockPythonName.flow_rate.dispense,
122+
)`.trimStart()
123+
)
52124
})
53125
})

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

+19
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,27 @@ import type { InvariantContext, PipetteEntities, RobotState } from '../types'
1010
vi.mock('../getNextRobotStateAndWarnings/dispenseUpdateLiquidState')
1111

1212
const mockId = 'mockId'
13+
const mockWasteChuteId = 'mockWasteChute'
1314
const mockPipEntities: PipetteEntities = {
1415
[mockId]: {
1516
name: 'p50_single_flex',
1617
id: mockId,
1718
spec: { channels: 1 },
19+
pythonName: 'mock_pipette_left',
1820
},
1921
} as any
2022

2123
const invariantContext: InvariantContext = {
2224
...makeContext(),
2325
pipetteEntities: mockPipEntities,
26+
additionalEquipmentEntities: {
27+
[mockWasteChuteId]: {
28+
id: mockWasteChuteId,
29+
name: 'wasteChute',
30+
pythonName: 'mock_waste_chute_1',
31+
location: mockWasteChuteId,
32+
},
33+
},
2434
}
2535
const prevRobotState: RobotState = getInitialRobotStateStandard(
2636
invariantContext
@@ -33,6 +43,7 @@ describe('dispenseInWasteChute', () => {
3343
pipetteId: mockId,
3444
volume: 10,
3545
flowRate: 10,
46+
wasteChuteId: mockWasteChuteId,
3647
},
3748
invariantContext,
3849
prevRobotState
@@ -57,5 +68,13 @@ describe('dispenseInWasteChute', () => {
5768
},
5869
},
5970
])
71+
expect(getSuccessResult(result).python).toBe(
72+
`
73+
mock_pipette_left.dispense(
74+
volume=10,
75+
location=mock_waste_chute_1,
76+
rate=10 / mock_pipette_left.flow_rate.dispense,
77+
)`.trimStart()
78+
)
6079
})
6180
})
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,42 @@
11
import { describe, it, expect, vi } from 'vitest'
22
import { WASTE_CHUTE_CUTOUT } from '@opentrons/shared-data'
3-
import { getSuccessResult, makeContext } from '../fixtures'
3+
import { DEFAULT_PIPETTE, getSuccessResult, makeContext } from '../fixtures'
44
import { dropTipInWasteChute } from '../commandCreators'
55

6-
import type { InvariantContext, PipetteEntities, RobotState } from '../types'
6+
import type { InvariantContext, RobotState } from '../types'
77

88
vi.mock('../getNextRobotStateAndWarnings/dispenseUpdateLiquidState')
99

1010
const mockWasteChuteId = 'mockWasteChuteId'
11-
const mockId = 'mockId'
12-
13-
const mockPipEntities: PipetteEntities = {
14-
[mockId]: {
15-
name: 'p50_single_flex',
16-
id: mockId,
17-
spec: { channels: 1 },
18-
},
19-
} as any
2011

2112
const invariantContext: InvariantContext = {
2213
...makeContext(),
23-
pipetteEntities: mockPipEntities,
2414
additionalEquipmentEntities: {
2515
[mockWasteChuteId]: {
2616
name: 'wasteChute' as const,
2717
location: WASTE_CHUTE_CUTOUT,
2818
id: mockWasteChuteId,
19+
pythonName: 'mock_waste_chute_1',
2920
},
3021
},
3122
}
3223
const prevRobotState: RobotState = {
33-
tipState: { pipettes: { [mockId]: true } } as any,
24+
tipState: { pipettes: { [DEFAULT_PIPETTE]: true } } as any,
3425
} as any
3526

3627
describe('dropTipInWasteChute', () => {
37-
it('returns correct commands for drop tip', () => {
28+
it('returns correct commands for drop tip in waste chute', () => {
3829
const args = {
39-
pipetteId: mockId,
30+
pipetteId: DEFAULT_PIPETTE,
31+
wasteChuteId: mockWasteChuteId,
4032
}
4133
const result = dropTipInWasteChute(args, invariantContext, prevRobotState)
4234
expect(getSuccessResult(result).commands).toEqual([
4335
{
4436
commandType: 'moveToAddressableArea',
4537
key: expect.any(String),
4638
params: {
47-
pipetteId: mockId,
39+
pipetteId: DEFAULT_PIPETTE,
4840
addressableAreaName: '1ChannelWasteChute',
4941
offset: { x: 0, y: 0, z: 0 },
5042
},
@@ -53,9 +45,12 @@ describe('dropTipInWasteChute', () => {
5345
commandType: 'dropTipInPlace',
5446
key: expect.any(String),
5547
params: {
56-
pipetteId: mockId,
48+
pipetteId: DEFAULT_PIPETTE,
5749
},
5850
},
5951
])
52+
expect(getSuccessResult(result).python).toBe(
53+
'mockPythonName.drop_tip(mock_waste_chute_1)'
54+
)
6055
})
6156
})

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

+2-12
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,7 @@ describe('touchTip', () => {
5858
},
5959
])
6060
expect(res.python).toBe(
61-
`
62-
mockPythonName.touch_tip(
63-
mockPythonName["A1"],
64-
v_offset=10,
65-
speed=10,
66-
mm_from_edge=0.2,
67-
)`.trimStart()
61+
`mockPythonName.touch_tip(mockPythonName["A1"], v_offset=10, speed=10, mm_from_edge=0.2)`
6862
)
6963
})
7064

@@ -82,11 +76,7 @@ mockPythonName.touch_tip(
8276
const res = getSuccessResult(result)
8377

8478
expect(res.python).toBe(
85-
`
86-
mockPythonName.touch_tip(
87-
mockPythonName["A1"],
88-
v_offset=10,
89-
)`.trimStart()
79+
`mockPythonName.touch_tip(mockPythonName["A1"], v_offset=10)`
9080
)
9181
})
9282

step-generation/src/commandCreators/atomic/touchTip.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { formatPyStr, indentPyLines, uuid } from '../../utils'
1+
import { formatPyStr, uuid } from '../../utils'
22
import { noTipOnPipette, pipetteDoesNotExist } from '../../errorCreators'
33
import type { CreateCommand, TouchTipParams } from '@opentrons/shared-data'
44
import type { CommandCreator, CommandCreatorError } from '../../types'
@@ -56,16 +56,14 @@ export const touchTip: CommandCreator<TouchTipAtomicParams> = (
5656
invariantContext.labwareEntities[labwareId].pythonName
5757

5858
const pythonArgs = [
59-
`${labwarePythonName}[${formatPyStr(wellName)}],`,
60-
`v_offset=${zOffsetFromTop},`,
61-
...(speed != null ? [`speed=${speed},`] : []),
62-
...(mmFromEdge != null ? [`mm_from_edge=${mmFromEdge},`] : []),
59+
`${labwarePythonName}[${formatPyStr(wellName)}]`,
60+
`v_offset=${zOffsetFromTop}`,
61+
...(speed != null ? [`speed=${speed}`] : []),
62+
...(mmFromEdge != null ? [`mm_from_edge=${mmFromEdge}`] : []),
6363
]
6464

6565
// TODO: add mmFromEdge to python and commandCreator
66-
const python = `${pipettePythonName}.touch_tip(\n${indentPyLines(
67-
pythonArgs.join('\n')
68-
)}\n)`
66+
const python = `${pipettePythonName}.touch_tip(${pythonArgs.join(', ')})`
6967

7068
const commands: CreateCommand[] = [
7169
{

0 commit comments

Comments
 (0)