diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-06-01 03:59:25 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-06-01 03:59:25 +0200 |
| commit | dbbeffd02629209f42affe3fb4bb4c46639ba0e3 (patch) | |
| tree | fbd15c10cd5303eaaccbf0162401424209b684e6 /app/client | |
| parent | 964ac7009e6db5a06233bdc07fa63778eebf2db7 (diff) | |
remote IPC... done so sweetly, with promises and async
Diffstat (limited to 'app/client')
| -rw-r--r-- | app/client/actions.js | 4 | ||||
| -rw-r--r-- | app/client/common/fileList.component.js | 3 | ||||
| -rw-r--r-- | app/client/dashboard/dashboard.component.js | 8 | ||||
| -rw-r--r-- | app/client/dashboard/dashboardHeader.component.js | 1 | ||||
| -rw-r--r-- | app/client/modules/samplernn/samplernn.actions.js | 34 | ||||
| -rw-r--r-- | app/client/modules/samplernn/samplernn.datasets.js | 32 | ||||
| -rw-r--r-- | app/client/modules/samplernn/samplernn.reducer.js | 29 | ||||
| -rw-r--r-- | app/client/queue/queue.actions.js (renamed from app/client/task/task.actions.js) | 0 | ||||
| -rw-r--r-- | app/client/queue/queue.reducer.js (renamed from app/client/task/task.reducer.js) | 17 | ||||
| -rw-r--r-- | app/client/socket/socket.actions.js | 6 | ||||
| -rw-r--r-- | app/client/socket/socket.system.js | 6 | ||||
| -rw-r--r-- | app/client/store.js | 4 | ||||
| -rw-r--r-- | app/client/types.js | 1 |
13 files changed, 72 insertions, 73 deletions
diff --git a/app/client/actions.js b/app/client/actions.js index ff170bb..9f43743 100644 --- a/app/client/actions.js +++ b/app/client/actions.js @@ -1,7 +1,7 @@ import { bindActionCreators } from 'redux' import { actions as crudActions } from './api' -import * as taskActions from './task/task.actions' import * as liveActions from './live/live.actions' +import * as queueActions from './queue/queue.actions' import * as systemActions from './system/system.actions' import * as socketActions from './socket/socket.actions' import * as datasetActions from './dataset/dataset.actions' @@ -12,8 +12,8 @@ export default Object.keys(crudActions) .map(a => [a, crudActions[a]]) .concat([ - ['task', taskActions], ['live', liveActions], + ['queue', queueActions], ['system', systemActions], ['dataset', datasetActions], ]) diff --git a/app/client/common/fileList.component.js b/app/client/common/fileList.component.js index 09e4268..8f7ff5a 100644 --- a/app/client/common/fileList.component.js +++ b/app/client/common/fileList.component.js @@ -11,7 +11,7 @@ class FileList extends Component { super() } render(){ - const { files, linkFiles, onClick } = this.props + const { files, linkFiles, title, onClick } = this.props if (!files.length) return null let fields = this.props.fields || defaultFields const fileList = files.map(file => { @@ -56,6 +56,7 @@ class FileList extends Component { }) return ( <div className='filelist rows'> + {title && <h3>{title}</h3>} {fileList} </div> ) diff --git a/app/client/dashboard/dashboard.component.js b/app/client/dashboard/dashboard.component.js index 2feba32..64200b0 100644 --- a/app/client/dashboard/dashboard.component.js +++ b/app/client/dashboard/dashboard.component.js @@ -25,17 +25,17 @@ class Dashboard extends Component { // } } render(){ - const { tasks, files, images, site } = this.props + const { queue, files, images, site } = this.props return ( <div className='dashboard'> <DashboardHeader /> <div className='params'> <div className='column'> <Group title='Completed Tasks'> - <TaskList tasks={tasks} /> + <TaskList tasks={queue} /> </Group> <Group title='Upcoming Tasks'> - <TaskList tasks={tasks} /> + <TaskList tasks={queue} /> </Group> </div> <div className='column'> @@ -61,7 +61,7 @@ const mapStateToProps = state => ({ site: state.system.site, images: state.dashboard.images, files: state.dashboard.files, - tasks: state.task.tasks, + queue: state.queue.queue, }) const mapDispatchToProps = (dispatch, ownProps) => ({ diff --git a/app/client/dashboard/dashboardHeader.component.js b/app/client/dashboard/dashboardHeader.component.js index 701c97a..3d4d31f 100644 --- a/app/client/dashboard/dashboardHeader.component.js +++ b/app/client/dashboard/dashboardHeader.component.js @@ -52,7 +52,6 @@ class DashboardHeader extends Component { const mapStateToProps = state => ({ runner: state.system.runner, - currentTask: state.task.currentTask, site: state.system.site, }) diff --git a/app/client/modules/samplernn/samplernn.actions.js b/app/client/modules/samplernn/samplernn.actions.js index 3386247..5bf8a37 100644 --- a/app/client/modules/samplernn/samplernn.actions.js +++ b/app/client/modules/samplernn/samplernn.actions.js @@ -3,31 +3,25 @@ import types from '../../types' import actions from '../../actions' -// bindActionCreators(actions.folder, dispatch), -// bindActionCreators(actions.file, dispatch), -// bindActionCreators(taskActions, dispatch), -// bindActionCreators(systemActions, dispatch), - export const load_directories = () => (dispatch) => { // load datasets // load directories from server console.log(actions) - actions.folder.index({ module: 'samplernn' }) - .then(folders => { - console.log('got folders') - }) - actions.file.index({ module: 'samplernn' }) - .then(files => { - console.log('got files') - }) - actions.socket.list_directory({ module: 'samplernn', dir: 'results' }) - .then(dirs => { - console.log('got results') - }) - actions.socket.list_directory({ module: 'samplernn', dir: 'datasets' }) - .then(dirs => { - console.log('got datasets') + Promise.all([ + actions.folder.index({ module: 'samplernn' }), + actions.file.index({ module: 'samplernn' }), + actions.task.index({ module: 'samplernn' }), + actions.socket.list_directory({ module: 'samplernn', dir: 'results' }), + actions.socket.list_directory({ module: 'samplernn', dir: 'datasets' }), + ]).then(res => { + console.log(res) + const [folders, files, results, datasets] = res + console.log(folders.length, files.length, results.length, datasets.length) + dispatch({ + type: types.samplernn.init, + data: { folders, files, results, datasets }, }) + }) } export const fetch_url = (url) => (dispatch) => { diff --git a/app/client/modules/samplernn/samplernn.datasets.js b/app/client/modules/samplernn/samplernn.datasets.js index 960c976..f358170 100644 --- a/app/client/modules/samplernn/samplernn.datasets.js +++ b/app/client/modules/samplernn/samplernn.datasets.js @@ -53,10 +53,6 @@ class SampleRNNDatasets extends Component { const { samplernn } = this.props // console.log(samplernn.upload) // sort files?? - const module = { - name: 'samplernn', - datatype: 'audio', - } return ( <div className='app'> <div className='heading'> @@ -70,10 +66,36 @@ class SampleRNNDatasets extends Component { linkFiles fileOptions={this.fileOptions} onPick={this.handlePick} - module={module} folder={samplernn.input.folder} files={samplernn.input.files} /> + {this.renderData()} + </div> + ) + } + renderData(){ + const { samplernn } = this.props + if (samplernn.data === null) { + return + } + return ( + <div class='row params'> + <FileList + title='Folders' + files={samplernn.data.folders} + /> + <FileList + title='Files' + files={samplernn.data.files} + /> + <FileList + title='Datasets' + files={samplernn.data.datasets} + /> + <FileList + title='Results' + files={samplernn.data.results} + /> </div> ) } diff --git a/app/client/modules/samplernn/samplernn.reducer.js b/app/client/modules/samplernn/samplernn.reducer.js index 9ecd492..8d1ed74 100644 --- a/app/client/modules/samplernn/samplernn.reducer.js +++ b/app/client/modules/samplernn/samplernn.reducer.js @@ -15,37 +15,28 @@ const samplernnInitialState = { folder: {}, files: [], }, + data: null, } const samplernnReducer = (state = samplernnInitialState, action) => { switch(action.type) { - case types.socket.connect: - return { - ...state, - } - case types.task.task_begin: + case types.samplernn.init: return { ...state, + data: action.data, } - case types.task.task_finish: + case types.socket.connect: return { ...state, } - case types.folder.index: + case types.task.task_begin: return { ...state, - folders: action.data, - folder: action.data[0], } - case types.folder.update: - return state - - case types.file.index: + case types.task.task_finish: return { ...state, - files: action.data } - case types.file.create: if (state.folder.id === action.data.folder_id) { return { @@ -54,7 +45,6 @@ const samplernnReducer = (state = samplernnInitialState, action) => { } } return state - case types.folder.upload_complete: if (state.folder.id === action.folder) { return { @@ -63,13 +53,6 @@ const samplernnReducer = (state = samplernnInitialState, action) => { } } return state - - case types.system.list_directory: - console.log('list directory', action.data) - return { - ...state, - } - case types.socket.status: return samplernnSocket(state, action.data) default: diff --git a/app/client/task/task.actions.js b/app/client/queue/queue.actions.js index 7ede36d..7ede36d 100644 --- a/app/client/task/task.actions.js +++ b/app/client/queue/queue.actions.js diff --git a/app/client/task/task.reducer.js b/app/client/queue/queue.reducer.js index 12e5184..c3995b1 100644 --- a/app/client/task/task.reducer.js +++ b/app/client/queue/queue.reducer.js @@ -1,20 +1,11 @@ import types from '../types' import moment from 'moment' -let FileSaver = require('file-saver') -const taskInitialState = { +const queueInitialState = { loading: false, error: null, - currentTask: { - id: 1072, - activity: 'train', - module: 'pix2pix', - dataset: 'video/woods_final', - epoch: 87, - epochs: 100, - }, - tasks: [ + queue: [ { id: 1073, activity: 'train', @@ -70,11 +61,11 @@ const taskInitialState = { ], } -const taskReducer = (state = taskInitialState, action) => { +const queueReducer = (state = queueInitialState, action) => { switch(action.type) { default: return state } } -export default taskReducer +export default queueReducer diff --git a/app/client/socket/socket.actions.js b/app/client/socket/socket.actions.js index 574892a..a2162ac 100644 --- a/app/client/socket/socket.actions.js +++ b/app/client/socket/socket.actions.js @@ -1,3 +1,7 @@ -import { list_directory_async } from './socket.system' +import { + list_directory_async, + run_system_command_async +} from './socket.system' export const list_directory = list_directory_async +export const run_system_command = run_system_command_async
\ No newline at end of file diff --git a/app/client/socket/socket.system.js b/app/client/socket/socket.system.js index 11cb44c..ad9e8ac 100644 --- a/app/client/socket/socket.system.js +++ b/app/client/socket/socket.system.js @@ -59,7 +59,10 @@ export function list_directory(opt) { } export function list_directory_async(opt) { - return syscall_async('list_directory', opt) + return syscall_async('list_directory', opt).then(res => res.files) +} +export function run_system_command_async(opt) { + return syscall_async('run_system_command', opt) } export const syscall_async = (tag, payload, ttl=10000) => { @@ -70,6 +73,7 @@ export const syscall_async = (tag, payload, ttl=10000) => { reject('timeout') }, ttl) const cb = (data) => { + if (!data.uuid) return if (data.uuid === uuid) { clearTimeout(timeout) socket.off('system_res', cb) diff --git a/app/client/store.js b/app/client/store.js index 77001d6..256d5f6 100644 --- a/app/client/store.js +++ b/app/client/store.js @@ -10,7 +10,7 @@ import systemReducer from './system/system.reducer' import dashboardReducer from './dashboard/dashboard.reducer' import liveReducer from './live/live.reducer' import datasetReducer from './dataset/dataset.reducer' -import taskReducer from './task/task.reducer' +import queueReducer from './queue/queue.reducer' import { moduleReducer } from './modules/module.reducer' const appReducer = combineReducers({ @@ -18,7 +18,7 @@ const appReducer = combineReducers({ dashboard: dashboardReducer, live: liveReducer, dataset: datasetReducer, - task: taskReducer, + queue: queueReducer, router: routerReducer, module: moduleReducer, }) diff --git a/app/client/types.js b/app/client/types.js index b6593ff..925ba52 100644 --- a/app/client/types.js +++ b/app/client/types.js @@ -75,6 +75,7 @@ export default { fetch_progress: 'FETCH_PROGRESS', }, samplernn: { + init: 'SAMPLERNN_INIT' // queue and train // update checkpoint settings // reset checkpoint settings |
