diff --git a/.gitignore b/.gitignore index 86b8b644..1dddca1d 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,5 @@ npm-debug.log.* *.sass.d.ts *.scss.d.ts keys.js + +app/utils/pyodide/src diff --git a/app/actions/index.tsx b/app/actions/index.tsx index 1c8728d1..8225074b 100644 --- a/app/actions/index.tsx +++ b/app/actions/index.tsx @@ -1,3 +1,3 @@ export * from './experimentActions'; -export * from './jupyterActions'; +export * from './pyodideActions'; export * from './deviceActions'; diff --git a/app/actions/jupyterActions.ts b/app/actions/jupyterActions.ts deleted file mode 100644 index d8b1867b..00000000 --- a/app/actions/jupyterActions.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { createAction } from '@reduxjs/toolkit'; -import { ActionType } from 'typesafe-actions'; -import { JUPYTER_VARIABLE_NAMES } from '../constants/constants'; - -// ------------------------------------------------------------------------- -// Actions - -export const JupyterActions = { - LaunchKernel: createAction('LAUNCH_KERNEL'), - RequestKernelInfo: createAction('REQUEST_KERNEL_INFO'), - SendExecuteRequest: createAction( - 'SEND_EXECUTE_REQUEST' - ), - LoadEpochs: createAction('LOAD_EPOCHS'), - LoadCleanedEpochs: createAction( - 'LOAD_CLEANED_EPOCHS' - ), - LoadPSD: createAction('LOAD_PSD'), - LoadERP: createAction('LOAD_ERP'), - LoadTopo: createAction('LOAD_TOPO'), - CleanEpochs: createAction('CLEAN_EPOCHS'), - CloseKernel: createAction('CLOSE_KERNEL'), - SetKernel: createAction('SET_KERNEL'), - GetEpochsInfo: createAction( - 'GET_EPOCHS_INFO' - ), - GetChannelInfo: createAction('GET_CHANNEL_INFO'), - SetKernelStatus: createAction('SET_KERNEL_STATUS'), - SetKernelInfo: createAction('SET_KERNEL_INFO'), - SetMainChannel: createAction('SET_MAIN_CHANNEL'), - SetEpochInfo: createAction('SET_EPOCH_INFO'), - SetChannelInfo: createAction('SET_CHANNEL_INFO'), - SetPSDPlot: createAction('SET_PSD_PLOT'), - SetTopoPlot: createAction('SET_TOPO_PLOT'), - SetERPPlot: createAction('SET_ERP_PLOT'), - ReceiveExecuteReply: createAction( - 'RECEIVE_EXECUTE_REPLY' - ), - ReceiveExecuteResult: createAction( - 'RECEIVE_EXECUTE_RESULT' - ), - ReceiveDisplayData: createAction( - 'RECEIVE_DISPLAY_DATA' - ), - ReceiveStream: createAction('RECEIVE_STREAM'), -} as const; - -export type JupyterActionType = ActionType< - typeof JupyterActions[keyof typeof JupyterActions] ->; diff --git a/app/actions/pyodideActions.ts b/app/actions/pyodideActions.ts new file mode 100644 index 00000000..69d7678c --- /dev/null +++ b/app/actions/pyodideActions.ts @@ -0,0 +1,36 @@ +import { createAction } from '@reduxjs/toolkit'; +import { ActionType } from 'typesafe-actions'; +import { PYODIDE_VARIABLE_NAMES } from '../constants/constants'; + +// ------------------------------------------------------------------------- +// Actions + +export const PyodideActions = { + Launch: createAction('LAUNCH'), + SetPyodideWorker: createAction( + 'SET_PYODIDE_WORKER' + ), + LoadEpochs: createAction('LOAD_EPOCHS'), + LoadCleanedEpochs: createAction( + 'LOAD_CLEANED_EPOCHS' + ), + LoadPSD: createAction('LOAD_PSD'), + LoadERP: createAction('LOAD_ERP'), + LoadTopo: createAction('LOAD_TOPO'), + CleanEpochs: createAction('CLEAN_EPOCHS'), + GetEpochsInfo: createAction( + 'GET_EPOCHS_INFO' + ), + GetChannelInfo: createAction('GET_CHANNEL_INFO'), + SetEpochInfo: createAction('SET_EPOCH_INFO'), + SetChannelInfo: createAction('SET_CHANNEL_INFO'), + SetPSDPlot: createAction('SET_PSD_PLOT'), + SetTopoPlot: createAction('SET_TOPO_PLOT'), + SetERPPlot: createAction('SET_ERP_PLOT'), + ReceiveMessage: createAction('RECEIVE_MESSAGE'), + ReceiveError: createAction('RECEIVE_ERROR'), +} as const; + +export type PyodideActionType = ActionType< + typeof PyodideActions[keyof typeof PyodideActions] +>; diff --git a/app/components/AnalyzeComponent.tsx b/app/components/AnalyzeComponent.tsx index 69501f70..911f856f 100644 --- a/app/components/AnalyzeComponent.tsx +++ b/app/components/AnalyzeComponent.tsx @@ -18,7 +18,6 @@ import { DEVICES, MUSE_CHANNELS, EMOTIV_CHANNELS, - KERNEL_STATUS, EXPERIMENTS, } from '../constants/constants'; import { @@ -34,10 +33,9 @@ import { } from '../utils/behavior/compute'; import SecondaryNavComponent from './SecondaryNavComponent'; import ClickableHeadDiagramSVG from './svgs/ClickableHeadDiagramSVG'; -import JupyterPlotWidget from './JupyterPlotWidget'; +import PyodidePlotWidget from './PyodidePlotWidget'; import { HelpButton } from './CollectComponent/HelpSidebar'; -import { Kernel } from '../constants/interfaces'; -import { JupyterActions } from '../actions/jupyterActions'; +import { PyodideActions } from '../actions/pyodideActions'; const ANALYZE_STEPS = { OVERVIEW: 'OVERVIEW', @@ -54,9 +52,6 @@ interface Props { type: EXPERIMENTS; deviceType: DEVICES; isEEGEnabled: boolean; - kernel: Kernel; - kernelStatus: KERNEL_STATUS; - mainChannel: any; epochsInfo: Array<{ [key: string]: number | string; }>; @@ -74,7 +69,7 @@ interface Props { [key: string]: string; }; - JupyterActions: typeof JupyterActions; + PyodideActions: typeof PyodideActions; } interface State { @@ -163,9 +158,6 @@ export default class Analyze extends Component { const workspaceCleanData = await readWorkspaceCleanedEEGData( this.props.title ); - if (this.props.kernelStatus === KERNEL_STATUS.OFFLINE) { - this.props.JupyterActions.LaunchKernel(); - } const behavioralData = await readWorkspaceBehaviorData(this.props.title); this.setState({ eegFilePaths: workspaceCleanData.map((filepath) => ({ @@ -200,7 +192,7 @@ export default class Analyze extends Component { selectedFilePaths: data.value, selectedSubjects: getSubjectNamesFromFiles(data.value), }); - this.props.JupyterActions.LoadCleanedEpochs(data.value); + this.props.PyodideActions.LoadCleanedEpochs(data.value); } } @@ -343,7 +335,7 @@ export default class Analyze extends Component { handleChannelSelect(channelName: string) { this.setState({ selectedChannel: channelName }); - this.props.JupyterActions.LoadERP(channelName); + this.props.PyodideActions.LoadERP(channelName); } handleStepClick(step: string) { @@ -480,7 +472,7 @@ export default class Analyze extends Component { - { - ; - JupyterActions: typeof JupyterActions; + PyodideActions: typeof PyodideActions; ExperimentActions: typeof ExperimentActions; subject: string; session: number; @@ -72,9 +68,6 @@ export default class Clean extends Component { async componentDidMount() { const workspaceRawData = await readWorkspaceRawEEGData(this.props.title); - if (this.props.kernelStatus === KERNEL_STATUS.OFFLINE) { - this.props.JupyterActions.LaunchKernel(); - } this.setState({ subjects: workspaceRawData .map( @@ -116,7 +109,7 @@ export default class Clean extends Component { handleLoadData() { this.props.ExperimentActions.SetSubject(this.state.selectedSubject); - this.props.JupyterActions.LoadEpochs(this.state.selectedFilePaths); + this.props.PyodideActions.LoadEpochs(this.state.selectedFilePaths); } handleSidebarToggle() { @@ -230,17 +223,7 @@ export default class Clean extends Component {