Skip to content
Open
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ CUSTOM_LABWARE = json.loads("""{"fixture/fixture_trash/1":{"ordering":[["A1"]],"
},
},
},
version: '8.7.0',
version: '8.8.0',
name: 'opentrons/protocol-designer',
},
robot: { model: OT2_ROBOT_TYPE },
Expand Down
71 changes: 62 additions & 9 deletions shared-data/command/types/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ export type ModuleRunTimeCommand =
| AbsorbanceReaderCloseLidRunTimeCommand
| AbsorbanceReaderInitializeRunTimeCommand
| AbsorbanceReaderReadRunTimeCommand
| FlexStackerSetStoredLabwareRunTimeCommand
| FlexStackerEmptyRunTimeCommand
| FlexStackerFillItemsRunTimeCommand
| FlexStackerFillRunTimeCommand
| FlexStackerRetrieveRunTimeCommand
| FlexStackerSetStoredLabwareItemsRunTimeCommand
| FlexStackerSetStoredLabwareRunTimeCommand
| FlexStackerStoreRunTimeCommand
| FlexStackerFillRunTimeCommand
| FlexStackerEmptyRunTimeCommand
| IdentifyModuleRunTimeCommand

export type ModuleCreateCommand =
Expand Down Expand Up @@ -73,14 +75,16 @@ export type ModuleCreateCommand =
| AbsorbanceReaderCloseLidCreateCommand
| AbsorbanceReaderInitializeCreateCommand
| AbsorbanceReaderReadCreateCommand
| FlexStackerSetStoredLabwareCreateCommand
| FlexStackerRetrieveCreateCommand
| FlexStackerStoreCreateCommand
| FlexStackerFillCreateCommand
| FlexStackerCloseLatch
| FlexStackerEmptyCreateCommand
| FlexStackerPrepareShuttleCreateCommand
| FlexStackerFillCreateCommand
| FlexStackerFillItemsCreateCommand
| FlexStackerOpenLatch
| FlexStackerCloseLatch
| FlexStackerPrepareShuttleCreateCommand
| FlexStackerRetrieveCreateCommand
| FlexStackerSetStoredLabwareCreateCommand
| FlexStackerSetStoredLabwareItemsCreateCommand
| FlexStackerStoreCreateCommand
| IdentifyModuleCreateCommand

export interface MagneticModuleEngageMagnetCreateCommand
Expand Down Expand Up @@ -487,6 +491,32 @@ export interface FlexStackerSetStoredLabwareRunTimeCommand
} & StackerStoredLabwareLocationSequences
}

export interface FlexStackerSetStoredLabwareItemsParams {
moduleId: string
labware: string[]
stackingOffsetZ?: number
}
export interface FlexStackerSetStoredLabwareItemsCreateCommand
extends CommonCommandCreateInfo {
commandType: 'flexStacker/setStoredLabwareItems'
params: FlexStackerSetStoredLabwareItemsParams
}

interface FlexStackerSetStoredLabwareResults {
primaryLabwareDefinition: LabwareDefinition
lidLabwareDefinition?: LabwareDefinition | null
adapterLabwareDefinition?: LabwareDefinition | null
count: number
storedLabware: FlexStackerStoredLabwareGroup[]
}

export interface FlexStackerSetStoredLabwareItemsRunTimeCommand
extends FlexStackerSetStoredLabwareItemsCreateCommand,
CommonCommandRunTimeInfo {
result?: FlexStackerSetStoredLabwareResults &
StackerStoredLabwareLocationSequences
}

export interface FlexStackerRetrieveCreateCommand
extends CommonCommandCreateInfo {
commandType: 'flexStacker/retrieve'
Expand Down Expand Up @@ -516,6 +546,29 @@ export interface FlexStackerFillCreateCommand extends CommonCommandCreateInfo {
params: FlexStackerFillParams
}

export interface FlexStackerFillItemsParams {
moduleId: string
labware: string[]
message?: string
}

export interface FlexStackerFillItemsCreateCommand
extends CommonCommandCreateInfo {
commandType: 'flexStacker/fillItems'
params: FlexStackerFillItemsParams
}

export interface FlexStackerFillItemsRunTimeCommand
extends FlexStackerFillItemsCreateCommand,
CommonCommandRunTimeInfo {
result?: {
count: number
storedLabware?: FlexStackerStoredLabwareGroup[] | null
addedLabware?: FlexStackerStoredLabwareGroup[] | null
} & StackerStoredLabwareLocationSequences &
StackerStoredLabwareDefinitionURIs
}

export interface FlexStackerEmptyParams {
moduleId: string
strategy: 'manualWithPause' | 'logical'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
FLEX_STACKER_MODULE_V1,
} from '@opentrons/shared-data'

import { flexStackerFill } from '../commandCreators/atomic/flexStackerFill'
import { flexStackerFillItems } from '../commandCreators/atomic/flexStackerFillItems'
import {
getErrorResult,
getInitialRobotStateStandard,
Expand All @@ -23,9 +23,14 @@ import type {
} from '../types'

const moduleId = 'flexStackerId'
const labwareId = 'labwareId'
const labwareId2 = 'labwareId2'
const labwareId3 = 'labwareId3'
const labwareId4 = 'labwareId4'
const labwareId5 = 'labwareId5'
vi.mock('../robotStateSelectors')

describe('flexStackerFill', () => {
describe('flexStackerFillItems', () => {
let invariantContext: InvariantContext
let robotState: RobotState
beforeEach(() => {
Expand All @@ -37,7 +42,38 @@ describe('flexStackerFill', () => {
model: FLEX_STACKER_MODULE_V1,
pythonName: 'mock_flex_stacker_1',
}

invariantContext.labwareEntities = {
[labwareId]: {
id: labwareId,
def: fixture96Plate as LabwareDefinition2,
labwareDefURI: 'mockURI',
pythonName: 'mock_labware_1',
},
[labwareId2]: {
id: labwareId2,
def: fixture96Plate as LabwareDefinition2,
labwareDefURI: 'mockURI',
pythonName: 'mock_labware_2',
},
[labwareId3]: {
id: labwareId3,
def: fixture96Plate as LabwareDefinition2,
labwareDefURI: 'mockURI',
pythonName: 'mock_labware_3',
},
[labwareId4]: {
id: labwareId4,
def: fixture96Plate as LabwareDefinition2,
labwareDefURI: 'mockURI',
pythonName: 'mock_labware_4',
},
[labwareId5]: {
id: labwareId5,
def: fixture96Plate as LabwareDefinition2,
labwareDefURI: 'mockURI',
pythonName: 'mock_labware_5',
},
}
vi.mocked(flexStackerStateGetter).mockReturnValue({
labwareOnShuttle: {
primaryLabwareId: 'mockLabwareId',
Expand All @@ -54,7 +90,7 @@ describe('flexStackerFill', () => {
maxPoolCount: 10,
storedLabwareDetails: {
moduleId,
initialCount: 5,
initialCount: 1,
primaryLabware: {
loadName: 'fixture_96_plate',
namespace: 'opentrons',
Expand All @@ -66,56 +102,68 @@ describe('flexStackerFill', () => {
type: FLEX_STACKER_MODULE_TYPE,
} as FlexStackerModuleState)
})

it('creates flex stacker fill command with count', () => {
const result = flexStackerFill(
it('creates flex stacker fill command with 1 labware', () => {
const result = flexStackerFillItems(
{
moduleId,
count: 10,
strategy: 'manualWithPause',
labware: [labwareId],
},
invariantContext,
robotState
)
expect(result).toEqual({
commands: [
{
commandType: 'flexStacker/fill',
commandType: 'flexStacker/fillItems',
key: expect.any(String),
params: {
moduleId,
strategy: 'manualWithPause',
count: 10,
labware: [labwareId],
},
},
],
python: 'mock_flex_stacker_1.fill(count=10)',
python: `
mock_flex_stacker_1.fill_items(
labware=[mock_labware_1],
)`.trimStart(),
})
})

it('creates flex stacker fill command with message', () => {
const result = flexStackerFill(
it('creates flex stacker fill command with 5 labware and a message', () => {
const result = flexStackerFillItems(
{
moduleId,
message: 'Filling...',
strategy: 'manualWithPause',
labware: [labwareId, labwareId2, labwareId3, labwareId4, labwareId5],
message: 'a fill message',
},
invariantContext,
robotState
)
expect(result).toEqual({
commands: [
{
commandType: 'flexStacker/fill',
commandType: 'flexStacker/fillItems',
key: expect.any(String),
params: {
moduleId,
strategy: 'manualWithPause',
message: 'Filling...',
labware: [
labwareId,
labwareId2,
labwareId3,
labwareId4,
labwareId5,
],
message: 'a fill message',
},
},
],
python: 'mock_flex_stacker_1.fill(message="Filling...")',
python: `
mock_flex_stacker_1.fill_items(
labware=[
mock_labware_1, mock_labware_2, mock_labware_3, mock_labware_4,
mock_labware_5
],
message="a fill message",
)`.trimStart(),
})
})
it('raises an error if the labware being stored does not match the current labware in the hopper', () => {
Expand Down Expand Up @@ -149,22 +197,10 @@ describe('flexStackerFill', () => {
labware2: { stack: ['labware2', 'D2'] },
},
}
const result = flexStackerFill(
const result = flexStackerFillItems(
{
moduleId,
strategy: 'manualWithPause',
labwareToStore: [
{
primaryLabwareId: 'labware1',
adapterLabwareId: null,
lidLabwareId: null,
},
{
primaryLabwareId: 'labware2',
adapterLabwareId: null,
lidLabwareId: null,
},
],
labware: ['labware1', 'labware2'],
},
mismatchInvariantContext,
mismatchRobotState
Expand Down Expand Up @@ -201,8 +237,8 @@ describe('flexStackerFill', () => {
},
type: FLEX_STACKER_MODULE_TYPE,
} as FlexStackerModuleState)
const result = flexStackerFill(
{ moduleId, strategy: 'manualWithPause' },
const result = flexStackerFillItems(
{ moduleId, labware: [] },
invariantContext,
robotState
)
Expand Down
2 changes: 1 addition & 1 deletion step-generation/src/__tests__/flexStackerRetrieve.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ describe('flexStackerRetrieve', () => {
},
},
],
python: 'wellPlate_1 = mock_flex_stacker_1.retrieve()',
python: 'mock_flex_stacker_1.retrieve()',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks!

})
})
it('raises an error if the hopper is empty', () => {
Expand Down
14 changes: 5 additions & 9 deletions step-generation/src/__tests__/pythonFileUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
WATER_LIQUID_CLASS_NAME,
} from '@opentrons/shared-data'

import { HOPPER_STACKER_LOCATION } from '../constants'
import {
formatChangeTipArg,
formatPyStr,
Expand Down Expand Up @@ -440,7 +441,6 @@ well_plate_3 = protocol.load_labware_from_definition(
},
}
const mockLabwareEntitiesWithFlexStackerLabware = {
...mockLabwareEntities,
[flexStackerLabwareId]: {
id: flexStackerLabwareId,
labwareDefURI: 'opentrons/fixture_96_plate/1',
Expand All @@ -450,10 +450,8 @@ well_plate_3 = protocol.load_labware_from_definition(
}

const mockLabwareRobotStateWithFlexStackerLabware = {
...labwareRobotState,
[flexStackerLabwareId]: {
...labwareRobotState[labwareId6],
stack: [flexStackerLabwareId, moduleId4, 'A4'],
stack: [flexStackerLabwareId, HOPPER_STACKER_LOCATION, moduleId4, 'A4'],
},
}

Expand All @@ -465,11 +463,9 @@ well_plate_3 = protocol.load_labware_from_definition(

expect(setStoredLabware).toBe(
`# Set Stored Labware:
flex_stacker_1 = protocol.set_stored_labware(
loadName="fixture_96_plate",
namespace="opentrons",
version=1,
count=1)`.trimStart()
flex_stacker_1.set_stored_labware_items(
labware=[well_plate_4],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Out of curiosity: Is the PD UI not going to ask the user for a string so that the user has something to look at when the ODD prompts them to fill the hopper? (The message arg to fill_items().)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ooooh this is an option, yes. i'll add the message arg

)`.trimStart()
)
})
})
Expand Down
Loading
Loading