Skip to content

fix(app): fix blocking LPC on the flex when the protocol does not involve a tip pick up #18214

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

Merged
merged 3 commits into from
Apr 30, 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
63 changes: 63 additions & 0 deletions app/src/local-resources/instruments/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
import { getProtocolUsesGripper } from '/app/transformations/commands'

import type {
CompletedProtocolAnalysis,
LoadedPipette,
ProtocolAnalysisOutput,
} from '@opentrons/shared-data'
import type {
GripperData,
Instruments,
PipetteData,
} from '@opentrons/api-client'

export interface IsPartialTipConfigParams {
channel: 1 | 8 | 96
activeNozzleCount: number
Expand All @@ -16,3 +29,53 @@ export function isPartialTipConfig({
return activeNozzleCount !== 96
}
}

export function getIncompleteInstrumentCount(
analysis: CompletedProtocolAnalysis | ProtocolAnalysisOutput,
attachedInstruments: Instruments
): number {
const speccedPipettes = analysis?.pipettes ?? []

const incompleteInstrumentCount = speccedPipettes.filter(loadedPipette => {
const attachedPipetteMatch = getPipetteMatch(
loadedPipette,
attachedInstruments
)
return attachedPipetteMatch?.data.calibratedOffset?.last_modified == null
}).length

const isExtensionMountReady = getProtocolUsesGripper(analysis)
? getAttachedGripper(attachedInstruments)?.data.calibratedOffset
?.last_modified != null
: true

return incompleteInstrumentCount + (isExtensionMountReady ? 0 : 1)
}

export function getAttachedGripper(
attachedInstruments: Instruments
): GripperData | null {
return (
(attachedInstruments?.data ?? []).find(
(i): i is GripperData =>
i.instrumentType === 'gripper' &&
i.ok &&
i.data.calibratedOffset != null
) ?? null
)
}

export function getPipetteMatch(
loadedPipette: LoadedPipette,
attachedInstruments: Instruments
): PipetteData | null {
return (
(attachedInstruments?.data ?? []).find(
(i): i is PipetteData =>
i.instrumentType === 'pipette' &&
i.ok &&
i.mount === loadedPipette.mount &&
i.instrumentName === loadedPipette.pipetteName
) ?? null
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ import {
OT2_ROBOT_TYPE,
parseAllRequiredModuleModels,
} from '@opentrons/shared-data'
import { useProtocolQuery } from '@opentrons/react-api-client'
import {
useProtocolQuery,
useInstrumentsQuery,
} from '@opentrons/react-api-client'

import { Line } from '/app/atoms/structure'
import { InfoMessage } from '/app/molecules/InfoMessage'
Expand Down Expand Up @@ -65,6 +68,7 @@ import { EmptySetupStep } from './EmptySetupStep'
import { LearnAboutOffsetsLink } from './LearnAboutOffsetsLink'
import { useLPCFlows } from '/app/organisms/LabwarePositionCheck'
import { useUpdateClientLPC } from '/app/resources/client_data'
import { getIncompleteInstrumentCount } from '/app/local-resources/instruments'

import type { RefObject } from 'react'
import type { Dispatch, State } from '/app/redux/types'
Expand Down Expand Up @@ -181,6 +185,13 @@ export function ProtocolRunSetup({

const isMissingModule = missingModuleIds.length > 0

const { data: attachedInstruments } = useInstrumentsQuery()

const incompleteInstrumentCount: number | null =
protocolAnalysis != null && attachedInstruments != null
? getIncompleteInstrumentCount(protocolAnalysis, attachedInstruments)
: null

const hasModules = protocolAnalysis != null && modules.length > 0
// need config compatibility (including check for single slot conflicts)
const requiredDeckConfigCompatibility = getRequiredDeckConfig(
Expand Down Expand Up @@ -285,6 +296,10 @@ export function ProtocolRunSetup({
}
}}
offsetsConfirmed={offsetsConfirmed}
hasMissingModulesForFlex={isMissingModule}
hasMissingCalForFlex={
incompleteInstrumentCount != null && incompleteInstrumentCount > 0
}
lpcUtils={lpcUtils}
/>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,17 @@ export function LPCSetupFlexBtns({
launchLPC,
runId,
robotName,
hasMissingModulesForFlex,
hasMissingCalForFlex,
}: LPCSetupFlexBtnsProps): JSX.Element {
const { t } = useTranslation('protocol_setup')
const { makeSnackbar } = useToaster()
const lpcDisabledReason = useLPCDisabledReason({ robotName, runId })
const lpcDisabledReason = useLPCDisabledReason({
robotName,
runId,
hasMissingCalForFlex: hasMissingCalForFlex,
hasMissingModulesForFlex: hasMissingModulesForFlex,
})
const isNecessaryDefaultOffsetMissing = useSelector(
selectIsAnyNecessaryDefaultOffsetMissing(runId)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export interface SetupLabwarePositionCheckProps {
robotType: RobotType
runId: string
lpcUtils: UseLPCFlowsResult
hasMissingModulesForFlex: boolean
hasMissingCalForFlex: boolean
}

export function SetupLabwarePositionCheck(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,42 +1,11 @@
import type {
CompletedProtocolAnalysis,
LoadedPipette,
} from '@opentrons/shared-data'
import type {
GripperData,
Instruments,
PipetteData,
} from '@opentrons/api-client'
import type { CompletedProtocolAnalysis } from '@opentrons/shared-data'
import type { Instruments } from '@opentrons/api-client'

import { getProtocolUsesGripper } from '/app/transformations/commands'

export function getAttachedGripper(
attachedInstruments: Instruments
): GripperData | null {
return (
(attachedInstruments?.data ?? []).find(
(i): i is GripperData =>
i.instrumentType === 'gripper' &&
i.ok &&
i.data.calibratedOffset != null
) ?? null
)
}

export function getPipetteMatch(
loadedPipette: LoadedPipette,
attachedInstruments: Instruments
): PipetteData | null {
return (
(attachedInstruments?.data ?? []).find(
(i): i is PipetteData =>
i.instrumentType === 'pipette' &&
i.ok &&
i.mount === loadedPipette.mount &&
i.instrumentName === loadedPipette.pipetteName
) ?? null
)
}
import {
getAttachedGripper,
getPipetteMatch,
} from '/app/local-resources/instruments'

export function getAreInstrumentsReady(
analysis: CompletedProtocolAnalysis,
Expand All @@ -57,25 +26,3 @@ export function getAreInstrumentsReady(

return allSpeccedPipettesReady && isExtensionMountReady
}

export function getIncompleteInstrumentCount(
analysis: CompletedProtocolAnalysis,
attachedInstruments: Instruments
): number {
const speccedPipettes = analysis?.pipettes ?? []

const incompleteInstrumentCount = speccedPipettes.filter(loadedPipette => {
const attachedPipetteMatch = getPipetteMatch(
loadedPipette,
attachedInstruments
)
return attachedPipetteMatch?.data.calibratedOffset?.last_modified == null
}).length

const isExtensionMountReady = getProtocolUsesGripper(analysis)
? getAttachedGripper(attachedInstruments)?.data.calibratedOffset
?.last_modified != null
: true

return incompleteInstrumentCount + (isExtensionMountReady ? 0 : 1)
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import {
ProtocolSetupTitleSkeleton,
ProtocolSetupStepSkeleton,
getUnmatchedModulesForProtocol,
getIncompleteInstrumentCount,
} from '/app/organisms/ODD/ProtocolSetup'
import { ConfirmCancelRunModal } from '/app/organisms/ODD/RunningProtocol'
import { mockProtocolModuleInfo } from '/app/organisms/ODD/ProtocolSetup/ProtocolSetupInstruments/__fixtures__'
Expand Down Expand Up @@ -72,6 +71,7 @@ import {
selectOffsetSource,
} from '/app/redux/protocol-runs'
import { useNotifyCurrentMaintenanceRun } from '/app/resources/maintenance_runs'
import { getIncompleteInstrumentCount } from '/app/local-resources/instruments'

import type { UseQueryResult } from 'react-query'
import type * as SharedData from '@opentrons/shared-data'
Expand Down Expand Up @@ -125,6 +125,7 @@ vi.mock('/app/local-resources/dom-utils')
vi.mock('/app/organisms/LabwarePositionCheck')
vi.mock('/app/redux/protocol-runs')
vi.mock('/app/resources/maintenance_runs')
vi.mock('/app/local-resources/instruments')

const render = (path = '/') => {
return renderWithProviders(
Expand Down
7 changes: 4 additions & 3 deletions app/src/pages/ODD/ProtocolSetup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ import {
ProtocolSetupStepSkeleton,
ProtocolSetupTitleSkeleton,
getUnmatchedModulesForProtocol,
getIncompleteInstrumentCount,
ViewOnlyParameters,
} from '/app/organisms/ODD/ProtocolSetup'
import { ConfirmCancelRunModal } from '/app/organisms/ODD/RunningProtocol'
Expand Down Expand Up @@ -97,6 +96,7 @@ import {
} from '/app/redux/protocol-runs'
import { LabwareOffsetsConflictModal } from '/app/organisms/LabwareOffsetsConflictModal'
import { useNotifyCurrentMaintenanceRun } from '/app/resources/maintenance_runs'
import { getIncompleteInstrumentCount } from '/app/local-resources/instruments'

import type { Dispatch, SetStateAction } from 'react'
import type { FlattenSimpleInterpolation } from 'styled-components'
Expand Down Expand Up @@ -753,8 +753,9 @@ export function ProtocolSetup(): JSX.Element {
: null
const lpcDisabledReason = useLPCDisabledReason({
runId,
hasMissingModulesForOdd: isMissingModules,
hasMissingCalForOdd:
robotName,
hasMissingModulesForFlex: isMissingModules,
hasMissingCalForFlex:
incompleteInstrumentCount != null && incompleteInstrumentCount > 0,
})
const protocolName =
Expand Down
36 changes: 18 additions & 18 deletions app/src/resources/runs/__tests__/useLPCDisabledReason.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ describe('useLPCDisabledReason', () => {
() =>
useLPCDisabledReason({
runId: RUN_ID_1,
hasMissingModulesForOdd: false,
hasMissingCalForOdd: false,
hasMissingModulesForFlex: false,
hasMissingCalForFlex: false,
}),
{ wrapper }
)
Expand All @@ -102,8 +102,8 @@ describe('useLPCDisabledReason', () => {
() =>
useLPCDisabledReason({
runId: RUN_ID_1,
hasMissingModulesForOdd: true,
hasMissingCalForOdd: true,
hasMissingModulesForFlex: true,
hasMissingCalForFlex: true,
}),
{ wrapper }
)
Expand All @@ -130,8 +130,8 @@ describe('useLPCDisabledReason', () => {
() =>
useLPCDisabledReason({
runId: RUN_ID_1,
hasMissingModulesForOdd: false,
hasMissingCalForOdd: true,
hasMissingModulesForFlex: false,
hasMissingCalForFlex: true,
}),
{ wrapper }
)
Expand All @@ -152,8 +152,8 @@ describe('useLPCDisabledReason', () => {
() =>
useLPCDisabledReason({
runId: RUN_ID_1,
hasMissingModulesForOdd: true,
hasMissingCalForOdd: false,
hasMissingModulesForFlex: true,
hasMissingCalForFlex: false,
}),
{ wrapper }
)
Expand Down Expand Up @@ -189,8 +189,8 @@ describe('useLPCDisabledReason', () => {
() =>
useLPCDisabledReason({
runId: RUN_ID_1,
hasMissingModulesForOdd: false,
hasMissingCalForOdd: false,
hasMissingModulesForFlex: false,
hasMissingCalForFlex: false,
}),
{ wrapper }
)
Expand All @@ -213,8 +213,8 @@ describe('useLPCDisabledReason', () => {
() =>
useLPCDisabledReason({
runId: RUN_ID_1,
hasMissingModulesForOdd: false,
hasMissingCalForOdd: false,
hasMissingModulesForFlex: false,
hasMissingCalForFlex: false,
}),
{ wrapper }
)
Expand All @@ -239,8 +239,8 @@ describe('useLPCDisabledReason', () => {
() =>
useLPCDisabledReason({
runId: RUN_ID_1,
hasMissingModulesForOdd: false,
hasMissingCalForOdd: false,
hasMissingModulesForFlex: false,
hasMissingCalForFlex: false,
}),
{ wrapper }
)
Expand Down Expand Up @@ -268,8 +268,8 @@ describe('useLPCDisabledReason', () => {
() =>
useLPCDisabledReason({
runId: RUN_ID_1,
hasMissingModulesForOdd: false,
hasMissingCalForOdd: false,
hasMissingModulesForFlex: false,
hasMissingCalForFlex: false,
}),
{ wrapper }
)
Expand Down Expand Up @@ -305,8 +305,8 @@ describe('useLPCDisabledReason', () => {
() =>
useLPCDisabledReason({
runId: RUN_ID_1,
hasMissingModulesForOdd: false,
hasMissingCalForOdd: false,
hasMissingModulesForFlex: false,
hasMissingCalForFlex: false,
}),
{ wrapper }
)
Expand Down
Loading
Loading