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 for blowout in waste chute #17837

Merged
merged 1 commit into from
Mar 21, 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
35 changes: 21 additions & 14 deletions step-generation/src/__tests__/blowOutinWasteChute.test.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
import { describe, it, expect, vi } from 'vitest'
import { WASTE_CHUTE_CUTOUT } from '@opentrons/shared-data'
import {
DEFAULT_PIPETTE,
getInitialRobotStateStandard,
getSuccessResult,
makeContext,
} from '../fixtures'
import { blowOutInWasteChute } from '../commandCreators/compound'
import type { InvariantContext, PipetteEntities, RobotState } from '../types'
import type { InvariantContext, RobotState } from '../types'

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

const mockId = 'mockId'
const mockPipEntities: PipetteEntities = {
[mockId]: {
name: 'p50_single_flex',
id: mockId,
spec: { channels: 1 },
},
} as any

const wasteChuteId = 'wasteChuteId'
const invariantContext: InvariantContext = {
...makeContext(),
pipetteEntities: mockPipEntities,
additionalEquipmentEntities: {
[wasteChuteId]: {
id: wasteChuteId,
name: 'wasteChute',
pythonName: 'mock_waste_chute_1',
location: WASTE_CHUTE_CUTOUT,
},
},
}
const prevRobotState: RobotState = getInitialRobotStateStandard(
invariantContext
Expand All @@ -30,8 +31,9 @@ describe('blowOutInWasteChute', () => {
it('returns correct commands for blowing out in waste chute', () => {
const result = blowOutInWasteChute(
{
pipetteId: mockId,
pipetteId: DEFAULT_PIPETTE,
flowRate: 10,
wasteChuteId,
},
invariantContext,
prevRobotState
Expand All @@ -41,7 +43,7 @@ describe('blowOutInWasteChute', () => {
commandType: 'moveToAddressableArea',
key: expect.any(String),
params: {
pipetteId: mockId,
pipetteId: DEFAULT_PIPETTE,
addressableAreaName: '1ChannelWasteChute',
offset: { x: 0, y: 0, z: 0 },
},
Expand All @@ -50,10 +52,15 @@ describe('blowOutInWasteChute', () => {
commandType: 'blowOutInPlace',
key: expect.any(String),
params: {
pipetteId: mockId,
pipetteId: DEFAULT_PIPETTE,
flowRate: 10,
},
},
])
expect(getSuccessResult(result).python).toBe(
`
mockPythonName.flow_rate.blow_out = 10
mockPythonName.blow_out(mock_waste_chute_1)`.trim()
)
})
})
1 change: 1 addition & 0 deletions step-generation/src/__tests__/blowoutUtil.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ describe('blowoutUtil', () => {
expect(curryCommandCreator).toHaveBeenCalledWith(blowOutInWasteChute, {
pipetteId: blowoutArgs.pipette,
flowRate: 2.3,
wasteChuteId,
})
})
it('blowoutUtil curries blowout with dest plate params', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,33 @@ import type { CommandCreator, CurriedCommandCreator } from '../../types'
interface BlowOutInWasteChuteArgs {
pipetteId: string
flowRate: number
wasteChuteId: string
}

export const blowOutInWasteChute: CommandCreator<BlowOutInWasteChuteArgs> = (
args,
invariantContext,
prevRobotState
) => {
const { pipetteId, flowRate } = args
const pipetteChannels =
invariantContext.pipetteEntities[pipetteId].spec.channels
const { pipetteId, flowRate, wasteChuteId } = args
const { pipetteEntities, additionalEquipmentEntities } = invariantContext
const pipetteChannels = pipetteEntities[pipetteId].spec.channels
const addressableAreaName = getWasteChuteAddressableAreaNamePip(
pipetteChannels
)
const pipettePythonName = pipetteEntities[pipetteId].pythonName
const wasteChutePythonName =
additionalEquipmentEntities[wasteChuteId].pythonName

const commandCreators: CurriedCommandCreator[] = [
const pythonCommandCreator: CurriedCommandCreator = () => ({
commands: [],
python:
// The Python blow_out() does not take a flow rate argument, so we have to
// reconfigure the pipette's default blow out rate instead:
`${pipettePythonName}.flow_rate.blow_out = ${flowRate}\n` +
`${pipettePythonName}.blow_out(${wasteChutePythonName})`,
})
const commandCreators = [
curryCommandCreator(moveToAddressableArea, {
pipetteId,
addressableAreaName,
Expand All @@ -34,6 +46,7 @@ export const blowOutInWasteChute: CommandCreator<BlowOutInWasteChuteArgs> = (
pipetteId,
flowRate,
}),
pythonCommandCreator,
]

return reduceCommandCreators(
Expand Down
4 changes: 4 additions & 0 deletions step-generation/src/utils/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,10 +379,14 @@ export const blowoutUtil = (args: {
}),
]
} else if (trashOrLabware === 'wasteChute') {
const wasteChute = Object.values(additionalEquipmentEntities).find(
ae => ae.name === 'wasteChute'
)
return [
curryCommandCreator(blowOutInWasteChute, {
pipetteId: pipette,
flowRate,
wasteChuteId: wasteChute?.id as string,
}),
]
} else {
Expand Down
Loading