Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(step-generation): py command generation for mix() #17833

Merged
merged 8 commits into from
Mar 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,14 @@ mockPythonName.drop_tip()
// Step c:
`
mockPythonName.pick_up_tip(location=mockPythonName)
mockPythonName.aspirate(...)
mockPythonName.dispense(...)
mockPythonName.aspirate(...)
mockPythonName.dispense(...)
mockPythonName.flow_rate.aspirate = 3.78
mockPythonName.flow_rate.dispense = 3.78
mockPythonName.mix(...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wow, we already had a test for a Mix step. That's nice :)

mockPythonName.drop_tip()
mockPythonName.pick_up_tip(location=mockPythonName)
mockPythonName.aspirate(...)
mockPythonName.dispense(...)
mockPythonName.aspirate(...)
mockPythonName.dispense(...)
mockPythonName.flow_rate.aspirate = 3.78
mockPythonName.flow_rate.dispense = 3.78
mockPythonName.mix(...)
mockPythonName.drop_tip()
`.trim(),
])
Expand Down
2 changes: 1 addition & 1 deletion shared-data/command/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export * from './pipetting'
export * from './setup'
export * from './timing'
export * from './unsafe'

export * from './support'
// NOTE: these key/value pairs will only be present on commands at analysis/run time
// they pertain only to the actual execution status of a command on hardware, as opposed to
// the command's identity and parameters which can be known prior to runtime
Expand Down
195 changes: 189 additions & 6 deletions step-generation/src/__tests__/mix.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('mix: change tip', () => {
wells: ['A1', 'B1', 'C1'],
changeTip,
} as MixArgs)
it('changeTip="always"', () => {
it('changeTip="always" with no advanced settings', () => {
const args = makeArgs('always')
const result = mix(args, invariantContext, robotStateWithTip)
const res = getSuccessResult(result)
Expand All @@ -100,6 +100,36 @@ describe('mix: change tip', () => {
dispenseHelper(well, volume, mockWellLocation),
])
)
expect(res.python).toBe(
`
mockPythonName.drop_tip()
mockPythonName.pick_up_tip(location=mockPythonName)
mockPythonName.flow_rate.aspirate = 2.1
mockPythonName.flow_rate.dispense = 2.2
mockPythonName.mix(
repetitions=2,
volume=5,
location=mockPythonName["A1"].bottom(z=3.2),
)
mockPythonName.drop_tip()
mockPythonName.pick_up_tip(location=mockPythonName)
mockPythonName.flow_rate.aspirate = 2.1
mockPythonName.flow_rate.dispense = 2.2
mockPythonName.mix(
repetitions=2,
volume=5,
location=mockPythonName["B1"].bottom(z=3.2),
)
mockPythonName.drop_tip()
mockPythonName.pick_up_tip(location=mockPythonName)
mockPythonName.flow_rate.aspirate = 2.1
mockPythonName.flow_rate.dispense = 2.2
mockPythonName.mix(
repetitions=2,
volume=5,
location=mockPythonName["C1"].bottom(z=3.2),
)`.trimStart()
)
})

it('changeTip="once"', () => {
Expand Down Expand Up @@ -303,7 +333,7 @@ describe('mix: advanced options', () => {
)
})
describe('all advanced settings enabled', () => {
it('should create commands in the expected order with expected params', () => {
it('should create commands in the expected order with expected params with all args', () => {
const args: MixArgs = {
...mixinArgs,
touchTip: true,
Expand All @@ -314,21 +344,28 @@ describe('mix: advanced options', () => {
times,
changeTip: 'always',
wells: ['A1', 'B1', 'C1'],
yOffset: 1,
} as MixArgs
const mockWellLocationCustomXY: Partial<AspDispAirgapParams> = {
wellLocation: {
origin: 'bottom',
offset: { x: 0, y: 1, z: 3.2 },
},
}

const result = mix(args, invariantContext, robotStateWithTip)
const res = getSuccessResult(result)

expect(res.commands).toEqual(
flatMap(args.wells, (well, idx) => [
...replaceTipCommands(idx),
aspirateHelper(well, volume, mockWellLocation),
aspirateHelper(well, volume, mockWellLocationCustomXY),
delayCommand(10),
dispenseHelper(well, volume, mockWellLocation),
dispenseHelper(well, volume, mockWellLocationCustomXY),
delayCommand(12),
aspirateHelper(well, volume, mockWellLocation),
aspirateHelper(well, volume, mockWellLocationCustomXY),
delayCommand(10),
dispenseHelper(well, volume, mockWellLocation),
dispenseHelper(well, volume, mockWellLocationCustomXY),
delayCommand(12),
blowoutHelper(blowoutLabwareId, {
wellLocation: {
Expand All @@ -341,8 +378,154 @@ describe('mix: advanced options', () => {
touchTipHelper(well),
])
)
expect(res.python).toBe(
`
mockPythonName.drop_tip()
mockPythonName.pick_up_tip(location=mockPythonName)
mockPythonName.aspirate(
volume=8,
location=mockPythonName["A1"].bottom(z=3.2).move(types.Point(y=1)),
rate=2.1 / mockPythonName.flow_rate.aspirate,
)
protocol.delay(seconds=10)
mockPythonName.dispense(
volume=8,
location=mockPythonName["A1"].bottom(z=3.2).move(types.Point(y=1)),
rate=2.2 / mockPythonName.flow_rate.dispense,
)
protocol.delay(seconds=12)
mockPythonName.aspirate(
volume=8,
location=mockPythonName["A1"].bottom(z=3.2).move(types.Point(y=1)),
rate=2.1 / mockPythonName.flow_rate.aspirate,
)
protocol.delay(seconds=10)
mockPythonName.dispense(
volume=8,
location=mockPythonName["A1"].bottom(z=3.2).move(types.Point(y=1)),
rate=2.2 / mockPythonName.flow_rate.dispense,
)
protocol.delay(seconds=12)
mockPythonName.flow_rate.blow_out = 2.3
mockPythonName.blow_out(mockPythonName["A1"].top(z=3.3))
mockPythonName.touch_tip(mockPythonName["A1"], v_offset=-3.4)
mockPythonName.drop_tip()
mockPythonName.pick_up_tip(location=mockPythonName)
mockPythonName.aspirate(
volume=8,
location=mockPythonName["B1"].bottom(z=3.2).move(types.Point(y=1)),
rate=2.1 / mockPythonName.flow_rate.aspirate,
)
protocol.delay(seconds=10)
mockPythonName.dispense(
volume=8,
location=mockPythonName["B1"].bottom(z=3.2).move(types.Point(y=1)),
rate=2.2 / mockPythonName.flow_rate.dispense,
)
protocol.delay(seconds=12)
mockPythonName.aspirate(
volume=8,
location=mockPythonName["B1"].bottom(z=3.2).move(types.Point(y=1)),
rate=2.1 / mockPythonName.flow_rate.aspirate,
)
protocol.delay(seconds=10)
mockPythonName.dispense(
volume=8,
location=mockPythonName["B1"].bottom(z=3.2).move(types.Point(y=1)),
rate=2.2 / mockPythonName.flow_rate.dispense,
)
protocol.delay(seconds=12)
mockPythonName.flow_rate.blow_out = 2.3
mockPythonName.blow_out(mockPythonName["A1"].top(z=3.3))
mockPythonName.touch_tip(mockPythonName["B1"], v_offset=-3.4)
mockPythonName.drop_tip()
mockPythonName.pick_up_tip(location=mockPythonName)
mockPythonName.aspirate(
volume=8,
location=mockPythonName["C1"].bottom(z=3.2).move(types.Point(y=1)),
rate=2.1 / mockPythonName.flow_rate.aspirate,
)
protocol.delay(seconds=10)
mockPythonName.dispense(
volume=8,
location=mockPythonName["C1"].bottom(z=3.2).move(types.Point(y=1)),
rate=2.2 / mockPythonName.flow_rate.dispense,
)
protocol.delay(seconds=12)
mockPythonName.aspirate(
volume=8,
location=mockPythonName["C1"].bottom(z=3.2).move(types.Point(y=1)),
rate=2.1 / mockPythonName.flow_rate.aspirate,
)
protocol.delay(seconds=10)
mockPythonName.dispense(
volume=8,
location=mockPythonName["C1"].bottom(z=3.2).move(types.Point(y=1)),
rate=2.2 / mockPythonName.flow_rate.dispense,
)
protocol.delay(seconds=12)
mockPythonName.flow_rate.blow_out = 2.3
mockPythonName.blow_out(mockPythonName["A1"].top(z=3.3))
mockPythonName.touch_tip(mockPythonName["C1"], v_offset=-3.4)`.trimStart()
)
})
})
it('should create python commands with mix() with touchTip and blowOut and no delay or x/y offset set', () => {
const args: MixArgs = {
...mixinArgs,
touchTip: true,
blowoutLocation: blowoutLabwareId,
volume,
times,
changeTip: 'always',
wells: ['A1', 'B1', 'C1'],
xOffset: 1,
yOffset: 1,
} as MixArgs

const result = mix(args, invariantContext, robotStateWithTip)
const res = getSuccessResult(result)

expect(res.python).toBe(
`
mockPythonName.drop_tip()
mockPythonName.pick_up_tip(location=mockPythonName)
mockPythonName.flow_rate.aspirate = 2.1
mockPythonName.flow_rate.dispense = 2.2
mockPythonName.mix(
repetitions=2,
volume=8,
location=mockPythonName["A1"].bottom(z=3.2).move(types.Point(x=1, y=1)),
)
mockPythonName.flow_rate.blow_out = 2.3
mockPythonName.blow_out(mockPythonName["A1"].top(z=3.3))
mockPythonName.touch_tip(mockPythonName["A1"], v_offset=-3.4)
mockPythonName.drop_tip()
mockPythonName.pick_up_tip(location=mockPythonName)
mockPythonName.flow_rate.aspirate = 2.1
mockPythonName.flow_rate.dispense = 2.2
mockPythonName.mix(
repetitions=2,
volume=8,
location=mockPythonName["B1"].bottom(z=3.2).move(types.Point(x=1, y=1)),
)
mockPythonName.flow_rate.blow_out = 2.3
mockPythonName.blow_out(mockPythonName["A1"].top(z=3.3))
mockPythonName.touch_tip(mockPythonName["B1"], v_offset=-3.4)
mockPythonName.drop_tip()
mockPythonName.pick_up_tip(location=mockPythonName)
mockPythonName.flow_rate.aspirate = 2.1
mockPythonName.flow_rate.dispense = 2.2
mockPythonName.mix(
repetitions=2,
volume=8,
location=mockPythonName["C1"].bottom(z=3.2).move(types.Point(x=1, y=1)),
)
mockPythonName.flow_rate.blow_out = 2.3
mockPythonName.blow_out(mockPythonName["A1"].top(z=3.3))
mockPythonName.touch_tip(mockPythonName["C1"], v_offset=-3.4)`.trimStart()
)
})
})

describe('mix: errors', () => {
Expand Down
3 changes: 3 additions & 0 deletions step-generation/src/commandCreators/compound/consolidate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@
xOffset: aspirateXOffset,
yOffset: aspirateYOffset,
nozzles,
invariantContext,
})
: []
const preWetTipCommands = args.preWetTip // Pre-wet tip is equivalent to a single mix, with volume equal to the consolidate volume.
Expand All @@ -349,6 +350,7 @@
xOffset: aspirateXOffset,
yOffset: aspirateYOffset,
nozzles,
invariantContext,

Check warning on line 353 in step-generation/src/commandCreators/compound/consolidate.ts

View check run for this annotation

Codecov / codecov/patch

step-generation/src/commandCreators/compound/consolidate.ts#L353

Added line #L353 was not covered by tests
})
: []
// can not mix in a waste chute
Expand All @@ -369,6 +371,7 @@
xOffset: dispenseXOffset,
yOffset: dispenseYOffset,
nozzles,
invariantContext,
})
: []

Expand Down
2 changes: 2 additions & 0 deletions step-generation/src/commandCreators/compound/distribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ export const distribute: CommandCreator<DistributeArgs> = (
xOffset: aspirateXOffset,
yOffset: aspirateYOffset,
nozzles,
invariantContext,
})
: []

Expand Down Expand Up @@ -502,6 +503,7 @@ export const distribute: CommandCreator<DistributeArgs> = (
xOffset: aspirateXOffset,
yOffset: aspirateYOffset,
nozzles,
invariantContext,
})
: []
return [
Expand Down
Loading
Loading