File tree Expand file tree Collapse file tree 4 files changed +40
-2
lines changed
protocol-designer/src/file-data
step-generation/src/utils Expand file tree Collapse file tree 4 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,9 @@ requirements = {
119
119
"robotType": "OT-2",
120
120
"apiLevel": "2.23",
121
121
}
122
+
123
+ def run(protocol: protocol_api.ProtocolContext):
124
+ pass
122
125
` . trimStart ( )
123
126
)
124
127
} )
Original file line number Diff line number Diff line change @@ -26,7 +26,12 @@ import {
26
26
getModulesLoadInfo ,
27
27
getPipettesLoadInfo ,
28
28
} from './utils'
29
- import { pythonImports , pythonMetadata , pythonRequirements } from './pythonFile'
29
+ import {
30
+ pythonDefRun ,
31
+ pythonImports ,
32
+ pythonMetadata ,
33
+ pythonRequirements ,
34
+ } from './pythonFile'
30
35
31
36
import type { SecondOrderCommandAnnotation } from '@opentrons/shared-data/commandAnnotation/types'
32
37
import type {
@@ -310,6 +315,7 @@ export const createPythonFile: Selector<string> = createSelector(
310
315
pythonImports ( ) ,
311
316
pythonMetadata ( fileMetadata ) ,
312
317
pythonRequirements ( robotType ) ,
318
+ pythonDefRun ( ) ,
313
319
]
314
320
. filter ( section => section ) // skip any blank sections
315
321
. join ( '\n\n' ) + '\n'
Original file line number Diff line number Diff line change 1
1
/** Generate sections of the Python file for fileCreator.ts */
2
2
3
3
import { FLEX_ROBOT_TYPE , OT2_ROBOT_TYPE } from '@opentrons/shared-data'
4
- import { formatPyDict } from '@opentrons/step-generation'
4
+ import {
5
+ formatPyDict ,
6
+ indentPyLines ,
7
+ PROTOCOL_CONTEXT_NAME ,
8
+ } from '@opentrons/step-generation'
5
9
import type { FileMetadataFields } from '../types'
6
10
import type { RobotType } from '@opentrons/shared-data'
7
11
@@ -46,3 +50,22 @@ export function pythonRequirements(robotType: RobotType): string {
46
50
}
47
51
return `requirements = ${ formatPyDict ( requirements ) } `
48
52
}
53
+
54
+ export function pythonDefRun ( ) : string {
55
+ const sections : string [ ] = [
56
+ // loadModules(),
57
+ // loadLabware(),
58
+ // loadInstruments(),
59
+ // defineLiquids(),
60
+ // loadLiquids(),
61
+ // stepCommands(),
62
+ ]
63
+ const functionBody =
64
+ sections
65
+ . filter ( section => section ) // skip empty sections
66
+ . join ( '\n\n' ) || 'pass'
67
+ return (
68
+ `def run(${ PROTOCOL_CONTEXT_NAME } : protocol_api.ProtocolContext):\n` +
69
+ `${ indentPyLines ( functionBody ) } `
70
+ )
71
+ }
Original file line number Diff line number Diff line change 1
1
/** Utility functions for Python code generation. */
2
2
3
+ /** The variable name for the ProtocolContext object in the run() function.
4
+ * Our docs call it `protocol`, which is slightly misleading since the object is not
5
+ * the protocol itself, but we'll try to stay consistent with the docs.
6
+ */
7
+ export const PROTOCOL_CONTEXT_NAME = 'protocol'
8
+
3
9
const INDENT = ' '
4
10
5
11
/** Indent each of the lines in `text`. */
You can’t perform that action at this time.
0 commit comments