Skip to content

Commit

Permalink
Demo of Python export from PD.
Browse files Browse the repository at this point in the history
  • Loading branch information
ddcc4 committed Jan 27, 2025
1 parent 68070c0 commit 0aaf1ad
Show file tree
Hide file tree
Showing 14 changed files with 755 additions and 27 deletions.
41 changes: 22 additions & 19 deletions protocol-designer/src/file-data/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,97 +5,100 @@ export const commandCreatorFromStepArgs = (
): StepGeneration.CurriedCommandCreator | null => {
switch (args.commandCreatorFnName) {
case 'consolidate': {
return StepGeneration.curryCommandCreator(
return StepGeneration.curryCommandTopPython(
StepGeneration.consolidate,
args
)
}

case 'delay': {
return StepGeneration.curryCommandCreator(StepGeneration.delay, args)
return StepGeneration.curryCommandTopPython(StepGeneration.delay, args)
}

case 'distribute':
return StepGeneration.curryCommandCreator(StepGeneration.distribute, args)
return StepGeneration.curryCommandTopPython(
StepGeneration.distribute,
args
)

case 'transfer':
return StepGeneration.curryCommandCreator(StepGeneration.transfer, args)
return StepGeneration.curryCommandTopPython(StepGeneration.transfer, args)

case 'mix':
return StepGeneration.curryCommandCreator(StepGeneration.mix, args)
return StepGeneration.curryCommandTopPython(StepGeneration.mix, args)

case 'moveLabware': {
return StepGeneration.curryCommandCreator(
return StepGeneration.curryCommandTopPython(
StepGeneration.moveLabware,
args
)
}

case 'engageMagnet':
return StepGeneration.curryCommandCreator(
return StepGeneration.curryCommandTopPython(
StepGeneration.engageMagnet,
args
)

case 'disengageMagnet':
return StepGeneration.curryCommandCreator(
return StepGeneration.curryCommandTopPython(
StepGeneration.disengageMagnet,
args
)

case 'setTemperature':
return StepGeneration.curryCommandCreator(
return StepGeneration.curryCommandTopPython(
StepGeneration.setTemperature,
args
)

case 'deactivateTemperature':
return StepGeneration.curryCommandCreator(
return StepGeneration.curryCommandTopPython(
StepGeneration.deactivateTemperature,
args
)

case 'waitForTemperature':
return StepGeneration.curryCommandCreator(
return StepGeneration.curryCommandTopPython(
StepGeneration.waitForTemperature,
args
)

case 'thermocyclerProfile':
return StepGeneration.curryCommandCreator(
return StepGeneration.curryCommandTopPython(
StepGeneration.thermocyclerProfileStep,

Check failure on line 69 in protocol-designer/src/file-data/helpers/index.ts

View workflow job for this annotation

GitHub Actions / js checks

Argument of type 'CommandCreator<ThermocyclerProfileStepArgs>' is not assignable to parameter of type 'CommandCreator<CommonArgs>'.
args
)

case 'thermocyclerState':
return StepGeneration.curryCommandCreator(
return StepGeneration.curryCommandTopPython(
StepGeneration.thermocyclerStateStep,

Check failure on line 75 in protocol-designer/src/file-data/helpers/index.ts

View workflow job for this annotation

GitHub Actions / js checks

Argument of type 'CommandCreator<ThermocyclerStateStepArgs>' is not assignable to parameter of type 'CommandCreator<CommonArgs>'.
args
)
case 'heaterShaker':
return StepGeneration.curryCommandCreator(
return StepGeneration.curryCommandTopPython(
StepGeneration.heaterShaker,
args
)
case 'comment':
return StepGeneration.curryCommandCreator(StepGeneration.comment, args)
return StepGeneration.curryCommandTopPython(StepGeneration.comment, args)
case 'absorbanceReaderOpenLid':
return StepGeneration.curryCommandCreator(
return StepGeneration.curryCommandTopPython(
StepGeneration.absorbanceReaderOpenLid,
args
)
case 'absorbanceReaderCloseLid':
return StepGeneration.curryCommandCreator(
return StepGeneration.curryCommandTopPython(
StepGeneration.absorbanceReaderCloseLid,
args
)
case 'absorbanceReaderRead':
return StepGeneration.curryCommandCreator(
return StepGeneration.curryCommandTopPython(
StepGeneration.absorbanceReaderCloseRead,
args
)
case 'absorbanceReaderInitialize':
return StepGeneration.curryCommandCreator(
return StepGeneration.curryCommandTopPython(
StepGeneration.absorbanceReaderCloseInitialize,
args
)
Expand Down
62 changes: 62 additions & 0 deletions protocol-designer/src/file-data/selectors/fileCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import type { LabwareDefByDefURI } from '../../labware-defs'
import type { Selector } from '../../types'
import type { DesignerApplicationData } from '../../load-file/migration/utils/getLoadLiquidCommands'
import type { SecondOrderCommandAnnotation } from '@opentrons/shared-data/commandAnnotation/types'
import genPythonProtocol from './pythonProtocol'

// TODO: BC: 2018-02-21 uncomment this assert, causes test failures
// console.assert(!isEmpty(process.env.OT_PD_VERSION), 'Could not find application version!')
Expand Down Expand Up @@ -355,6 +356,16 @@ export const createFile: Selector<ProtocolFile> = createSelector(

const commands = [...loadCommands, ...nonLoadCommands]

// Print the combined Python commands for every timeline step:
console.log(
robotStateTimeline.timeline
.map(
(timelineFrame, idx) =>
`# Step ${idx + 1}\n${timelineFrame.python || ''}`
)
.join('\n\n')
)

const flexDeckSpec: OT3RobotMixin = {
robot: {
model: FLEX_ROBOT_TYPE,
Expand Down Expand Up @@ -441,3 +452,54 @@ export const createFile: Selector<ProtocolFile> = createSelector(
}
}
)

export const createPythonFile: Selector<string> = createSelector(
getFileMetadata,
getInitialRobotState,
getRobotStateTimeline,
getRobotType,
dismissSelectors.getAllDismissedWarnings,
ingredSelectors.getLiquidGroupsById,
ingredSelectors.getLiquidsByLabwareId,
stepFormSelectors.getSavedStepForms,
stepFormSelectors.getArgsAndErrorsByStepId,
stepFormSelectors.getOrderedStepIds,
stepFormSelectors.getLabwareEntities,
stepFormSelectors.getModuleEntities,
stepFormSelectors.getPipetteEntities,
uiLabwareSelectors.getLabwareNicknamesById,
labwareDefSelectors.getLabwareDefsByURI,
getStepGroups,
(
fileMetadata,
initialRobotState,
robotStateTimeline,
robotType,
dismissedWarnings,
ingredients,
ingredLocations,
savedStepForms,
allStepArgsAndErrors,
orderedStepIds,
labwareEntities,
moduleEntities,
pipetteEntities,
labwareNicknamesById,
labwareDefsByURI,
stepGroups
) => {
const pythonProtocol = genPythonProtocol(
fileMetadata,
robotType,
initialRobotState,
robotStateTimeline,
labwareEntities,
labwareNicknamesById,
moduleEntities,
pipetteEntities,
ingredients,
ingredLocations
)
return pythonProtocol
}
)
Loading

0 comments on commit 0aaf1ad

Please sign in to comment.