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 Dec 20, 2024
1 parent 35422b6 commit 6a1e9ec
Show file tree
Hide file tree
Showing 5 changed files with 449 additions and 2 deletions.
17 changes: 17 additions & 0 deletions protocol-designer/src/file-data/__tests__/pythonProtocol.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'

Check failure on line 1 in protocol-designer/src/file-data/__tests__/pythonProtocol.test.tsx

View workflow job for this annotation

GitHub Actions / js checks

'expect' is defined but never used

Check failure on line 1 in protocol-designer/src/file-data/__tests__/pythonProtocol.test.tsx

View workflow job for this annotation

GitHub Actions / js checks

'vi' is defined but never used

Check failure on line 1 in protocol-designer/src/file-data/__tests__/pythonProtocol.test.tsx

View workflow job for this annotation

GitHub Actions / js checks

'beforeEach' is defined but never used
import genPythonProtocol from '../selectors/pythonProtocol'

Check failure on line 2 in protocol-designer/src/file-data/__tests__/pythonProtocol.test.tsx

View workflow job for this annotation

GitHub Actions / js checks

'genPythonProtocol' is defined but never used
import { FLEX_ROBOT_TYPE } from '@opentrons/shared-data';

Check failure on line 3 in protocol-designer/src/file-data/__tests__/pythonProtocol.test.tsx

View workflow job for this annotation

GitHub Actions / js checks

'FLEX_ROBOT_TYPE' is defined but never used

describe('Python', () => {

it('should render Python protocol', () => {
// console.log(genPythonProtocol({
// fileMetadata: {
// protocolName: 'My Protocol',
// author: [1.23, 'cat', true, false, null, undefined, -1./0, {nested: 42, hm: 43}, 0./0],
// },
// robotType: FLEX_ROBOT_TYPE,
// }));
});

})
61 changes: 61 additions & 0 deletions protocol-designer/src/file-data/selectors/fileCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,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 @@ -432,6 +433,18 @@ export const createFile: Selector<ProtocolFile> = createSelector(
designerApplication,
}

console.log(genPythonProtocol(
fileMetadata,
robotType,
initialRobotState,
labwareEntities,
labwareNicknamesById,
moduleEntities,
pipetteEntities,
ingredients,
ingredLocations,
));

return {
...protocolBase,
...deckStructure,
Expand All @@ -442,3 +455,51 @@ 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.getOrderedStepIds,
stepFormSelectors.getLabwareEntities,
stepFormSelectors.getModuleEntities,
stepFormSelectors.getPipetteEntities,
uiLabwareSelectors.getLabwareNicknamesById,
labwareDefSelectors.getLabwareDefsByURI,
getStepGroups,
(
fileMetadata,
initialRobotState,
robotStateTimeline,
robotType,
dismissedWarnings,
ingredients,
ingredLocations,
savedStepForms,
orderedStepIds,
labwareEntities,
moduleEntities,
pipetteEntities,
labwareNicknamesById,
labwareDefsByURI,
stepGroups
) => {
const pythonProtocol = genPythonProtocol(
fileMetadata,
robotType,
initialRobotState,
labwareEntities,
labwareNicknamesById,
moduleEntities,
pipetteEntities,
ingredients,
ingredLocations,
);
return pythonProtocol;
}
)
Loading

0 comments on commit 6a1e9ec

Please sign in to comment.