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

fix(app): use containers and instruments to set RPC pipette tip rack list #5147

Merged
merged 1 commit into from
Mar 3, 2020
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
28 changes: 21 additions & 7 deletions app/src/robot/api-client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
// TODO(mc, 2018-01-26): typecheck with flow
import { push } from 'connected-react-router'
import find from 'lodash/find'
import functionsIn from 'lodash/functionsIn'
import kebabCase from 'lodash/kebabCase'
import mapKeys from 'lodash/mapKeys'
import pick from 'lodash/pick'
import functionsIn from 'lodash/functionsIn'
import union from 'lodash/union'

import { Client as RpcClient } from '../../rpc/client'
import { actions, actionTypes } from '../actions'
Expand All @@ -27,6 +28,12 @@ const RE_TIPRACK = /tip ?rack/i
const THIS_ROBOT_DOES_NOT_SUPPORT_BUNDLES =
'This robot does not support ZIP protocol bundles. Please update its software to the latest version and upload this protocol again'

const containerIsTiprack = apiContainer => {
return apiContainer.is_tiprack != null
? apiContainer.is_tiprack
: RE_TIPRACK.test(apiContainer.type)
}

export function client(dispatch) {
let freshUpload = false
let rpcClient
Expand Down Expand Up @@ -565,12 +572,23 @@ export function client(dispatch) {
tip_racks,
} = apiInstrument

const containers = apiSession.containers ?? []
const tipRacksFromInstrument = tip_racks.map(t => t._id)
const tipRacksFromContainers = containers
.filter(c => {
return (
containerIsTiprack(c) &&
c.instruments.some(inst => inst.mount === mount)
)
})
.map(t => t._id)

update.pipettesByMount[mount] = {
_id,
mount,
name,
channels,
tipRacks: tip_racks.map(t => t._id),
tipRacks: union(tipRacksFromInstrument, tipRacksFromContainers),
requestedAs: requested_as,
}
}
Expand All @@ -584,11 +602,7 @@ export function client(dispatch) {
position,
is_legacy: isLegacy,
} = apiContainer
const isTiprack =
apiContainer.is_tiprack != null
? apiContainer.is_tiprack
: RE_TIPRACK.test(type)

const isTiprack = containerIsTiprack(apiContainer)
const labware = { _id, name, slot, position, type, isTiprack, isLegacy }

if (isTiprack && apiContainer.instruments.length > 0) {
Expand Down
73 changes: 73 additions & 0 deletions app/src/robot/test/api-client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,79 @@ describe('api client', () => {
)
})

test('reconciles reported tiprack / pipette usage', () => {
const expected = actions.sessionResponse(
null,
expect.objectContaining({
pipettesByMount: {
left: {
_id: 123,
mount: 'left',
name: 'p200',
channels: 1,
tipRacks: [789],
requestedAs: 'bar',
},
right: {
_id: 456,
mount: 'right',
name: 'p50',
channels: 8,
tipRacks: [789],
requestedAs: 'foo',
},
},
labwareBySlot: {
1: {
_id: 789,
slot: '1',
name: 'a',
type: 'tiprack',
isTiprack: true,
calibratorMount: 'left',
},
},
}),
false
)

session.instruments = [
{
_id: 456,
mount: 'right',
name: 'p50',
channels: 8,
tip_racks: [],
requested_as: 'foo',
},
{
_id: 123,
mount: 'left',
name: 'p200',
channels: 1,
tip_racks: [],
requested_as: 'bar',
},
]

session.containers = [
{
_id: 789,
slot: '1',
name: 'a',
type: 'tiprack',
instruments: [
{ mount: 'left', channels: 1 },
{ mount: 'right', channels: 8 },
],
},
]

return sendConnect().then(() =>
expect(dispatch).toHaveBeenCalledWith(expected)
)
})

test('maps api modules to modules by slot', () => {
const expected = actions.sessionResponse(
null,
Expand Down