Skip to content

Commit

Permalink
feat(app, api-client): add optional runTimeParameterValues when cloni…
Browse files Browse the repository at this point in the history
…ng run (#14787)

closes AUTH-257
  • Loading branch information
ncdiehl11 authored Apr 3, 2024
1 parent 2397044 commit 6ccb243
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions api-client/src/runs/createRun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import type { HostConfig } from '../types'
import type {
Run,
LabwareOffsetCreateData,
RuntimeParameterCreateData,
RunTimeParameterCreateData,
} from './types'

export interface CreateRunData {
protocolId?: string
labwareOffsets?: LabwareOffsetCreateData[]
runTimeParameterValues?: RuntimeParameterCreateData
runTimeParameterValues?: RunTimeParameterCreateData
}

export function createRun(
Expand Down
3 changes: 2 additions & 1 deletion api-client/src/runs/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export interface LegacyGoodRunData {
modules: LoadedModule[]
protocolId?: string
labwareOffsets?: LabwareOffset[]
runTimeParameterValues?: RunTimeParameterCreateData
}

export interface KnownGoodRunData extends LegacyGoodRunData {
Expand Down Expand Up @@ -125,7 +126,7 @@ export interface LabwareOffsetCreateData {
vector: VectorOffset
}

export interface RuntimeParameterCreateData {
export interface RunTimeParameterCreateData {
[key: string]: string | boolean | number
}

Expand Down
3 changes: 2 additions & 1 deletion app/src/organisms/ChooseProtocolSlideout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import { useCreateRunFromProtocol } from '../ChooseRobotToRunProtocolSlideout/us
import { ApplyHistoricOffsets } from '../ApplyHistoricOffsets'
import { useOffsetCandidatesForAnalysis } from '../ApplyHistoricOffsets/hooks/useOffsetCandidatesForAnalysis'
import { getAnalysisStatus } from '../ProtocolsLanding/utils'
import type { RunTimeParameterCreateData } from '@opentrons/api-client'
import type { RunTimeParameter } from '@opentrons/shared-data'
import type { Robot } from '../../redux/discovery/types'
import type { StoredProtocolData } from '../../redux/protocol-storage'
Expand Down Expand Up @@ -161,7 +162,7 @@ export function ChooseProtocolSlideoutComponent(
definitionUri,
}))
: [],
runTimeParametersOverrides.reduce(
runTimeParametersOverrides.reduce<RunTimeParameterCreateData>(
(acc, param) =>
param.value !== param.default
? { ...acc, [param.variableName]: param.value }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {
HostConfig,
LabwareOffsetCreateData,
Protocol,
RuntimeParameterCreateData,
RunTimeParameterCreateData,
} from '@opentrons/api-client'
import type { UseCreateRunMutationOptions } from '@opentrons/react-api-client/src/runs/useCreateRunMutation'
import type { CreateProtocolVariables } from '@opentrons/react-api-client/src/protocols/useCreateProtocolMutation'
Expand All @@ -37,7 +37,7 @@ export function useCreateRunFromProtocol(
options: UseCreateRunMutationOptions,
hostOverride?: HostConfig | null,
labwareOffsets?: LabwareOffsetCreateData[],
runTimeParameterValues?: RuntimeParameterCreateData
runTimeParameterValues?: RunTimeParameterCreateData
): UseCreateRun {
const contextHost = useHost()
const host =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('useCloneRun hook', () => {
id: RUN_ID,
protocolId: 'protocolId',
labwareOffsets: 'someOffset',
runTimeParameterValues: 'someRtp',
},
},
} as any)
Expand Down Expand Up @@ -60,6 +61,7 @@ describe('useCloneRun hook', () => {
expect(mockCreateRun).toHaveBeenCalledWith({
protocolId: 'protocolId',
labwareOffsets: 'someOffset',
runTimeParameterValues: 'someRtp',
})
})
})
8 changes: 6 additions & 2 deletions app/src/organisms/ProtocolUpload/hooks/useCloneRun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ export function useCloneRun(
})
const cloneRun = (): void => {
if (runRecord != null) {
const { protocolId, labwareOffsets } = runRecord.data
createRun({ protocolId, labwareOffsets })
const {
protocolId,
labwareOffsets,
runTimeParameterValues,
} = runRecord.data
createRun({ protocolId, labwareOffsets, runTimeParameterValues })
} else {
console.info('failed to clone run record, source run record not found')
}
Expand Down

0 comments on commit 6ccb243

Please sign in to comment.