Skip to content

Commit 45b6fa9

Browse files
authored
feat(app, api-client): implement runTimeParametersValues in run creation (#14742)
closes [AUTH-101](https://opentrons.atlassian.net/browse/AUTH-101)
1 parent 53ecdbb commit 45b6fa9

File tree

5 files changed

+40
-9
lines changed

5 files changed

+40
-9
lines changed

api-client/src/runs/createRun.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@ import { POST, request } from '../request'
22

33
import type { ResponsePromise } from '../request'
44
import type { HostConfig } from '../types'
5-
import type { Run, LabwareOffsetCreateData } from './types'
5+
import type {
6+
Run,
7+
LabwareOffsetCreateData,
8+
RuntimeParameterCreateData,
9+
} from './types'
610

711
export interface CreateRunData {
812
protocolId?: string
913
labwareOffsets?: LabwareOffsetCreateData[]
14+
runTimeParameterValues?: RuntimeParameterCreateData
1015
}
1116

1217
export function createRun(

api-client/src/runs/types.ts

+4
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ export interface LabwareOffsetCreateData {
125125
vector: VectorOffset
126126
}
127127

128+
export interface RuntimeParameterCreateData {
129+
[key: string]: string | boolean | number
130+
}
131+
128132
export interface CommandData {
129133
data: RunTimeCommand
130134
}

app/src/organisms/ChooseRobotToRunProtocolSlideout/__tests__/ChooseRobotToRunProtocolSlideout.test.tsx

+14-5
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,20 @@ describe('ChooseRobotToRunProtocolSlideout', () => {
9595
.calledWith(
9696
expect.any(Object),
9797
{ hostname: expect.any(String) },
98-
expect.any(Array)
98+
expect.any(Array),
99+
expect.any(Object)
99100
)
100101
.thenReturn({
101102
createRunFromProtocolSource: mockCreateRunFromProtocolSource,
102103
reset: mockResetCreateRun,
103104
} as any)
104105
when(vi.mocked(useCreateRunFromProtocol))
105-
.calledWith(expect.any(Object), null, expect.any(Array))
106+
.calledWith(
107+
expect.any(Object),
108+
null,
109+
expect.any(Array),
110+
expect.any(Object)
111+
)
106112
.thenReturn({
107113
createRunFromProtocolSource: mockCreateRunFromProtocolSource,
108114
reset: mockResetCreateRun,
@@ -315,7 +321,8 @@ describe('ChooseRobotToRunProtocolSlideout', () => {
315321
location: mockOffsetCandidate.location,
316322
definitionUri: mockOffsetCandidate.definitionUri,
317323
},
318-
]
324+
],
325+
{}
319326
)
320327
expect(screen.getByRole('checkbox')).toBeChecked()
321328
const proceedButton = screen.getByRole('button', {
@@ -373,13 +380,15 @@ describe('ChooseRobotToRunProtocolSlideout', () => {
373380
location: mockOffsetCandidate.location,
374381
definitionUri: mockOffsetCandidate.definitionUri,
375382
},
376-
]
383+
],
384+
{}
377385
)
378386
expect(vi.mocked(useCreateRunFromProtocol)).nthCalledWith(
379387
3,
380388
expect.any(Object),
381389
{ hostname: 'otherIp' },
382-
[]
390+
[],
391+
{}
383392
)
384393
})
385394
})

app/src/organisms/ChooseRobotToRunProtocolSlideout/index.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,14 @@ export function ChooseRobotToRunProtocolSlideoutComponent(
165165
location,
166166
definitionUri,
167167
}))
168-
: []
168+
: [],
169+
runTimeParametersOverrides.reduce(
170+
(acc, param) =>
171+
param.value !== param.default
172+
? { ...acc, [param.variableName]: param.value }
173+
: acc,
174+
{}
175+
)
169176
)
170177
const handleProceed: React.MouseEventHandler<HTMLButtonElement> = () => {
171178
trackCreateProtocolRunEvent({ name: 'createProtocolRecordRequest' })

app/src/organisms/ChooseRobotToRunProtocolSlideout/useCreateRunFromProtocol.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import type {
1414
HostConfig,
1515
LabwareOffsetCreateData,
1616
Protocol,
17+
RuntimeParameterCreateData,
1718
} from '@opentrons/api-client'
1819
import type { UseCreateRunMutationOptions } from '@opentrons/react-api-client/src/runs/useCreateRunMutation'
1920
import type { CreateProtocolVariables } from '@opentrons/react-api-client/src/protocols/useCreateProtocolMutation'
@@ -35,7 +36,8 @@ export interface UseCreateRun {
3536
export function useCreateRunFromProtocol(
3637
options: UseCreateRunMutationOptions,
3738
hostOverride?: HostConfig | null,
38-
labwareOffsets?: LabwareOffsetCreateData[]
39+
labwareOffsets?: LabwareOffsetCreateData[],
40+
runTimeParameterValues?: RuntimeParameterCreateData
3941
): UseCreateRun {
4042
const contextHost = useHost()
4143
const host =
@@ -74,7 +76,11 @@ export function useCreateRunFromProtocol(
7476
} = useCreateProtocolMutation(
7577
{
7678
onSuccess: data => {
77-
createRun({ protocolId: data.data.id, labwareOffsets })
79+
createRun({
80+
protocolId: data.data.id,
81+
labwareOffsets,
82+
runTimeParameterValues,
83+
})
7884
},
7985
},
8086
host

0 commit comments

Comments
 (0)