From 01cda57ffd9edc0a3f53501399c134815232e4b5 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sat, 2 Jun 2018 17:38:24 +0200 Subject: inspect mode for samplernn sanity --- app/client/common/fileList.component.js | 5 +- app/client/modules/samplernn/index.js | 2 + app/client/modules/samplernn/samplernn.actions.js | 11 ++- app/client/modules/samplernn/samplernn.inspect.js | 105 ++++++++++++++++++++++ 4 files changed, 114 insertions(+), 9 deletions(-) create mode 100644 app/client/modules/samplernn/samplernn.inspect.js (limited to 'app/client') diff --git a/app/client/common/fileList.component.js b/app/client/common/fileList.component.js index b4b5430..0b69b62 100644 --- a/app/client/common/fileList.component.js +++ b/app/client/common/fileList.component.js @@ -20,10 +20,9 @@ export const FileList = (props) => { return (
- {files.length + {(files && files.length) ? (title &&

{title}

) :

No files

} -
{(loading || error) && status}
@@ -71,7 +70,7 @@ export const FileRow = (props) => { {fields.has('module') && file.module}
} - {this.props.options && this.props.options(file)} + {props.options && props.options(file)}
) } diff --git a/app/client/modules/samplernn/index.js b/app/client/modules/samplernn/index.js index afb5263..e020c6c 100644 --- a/app/client/modules/samplernn/index.js +++ b/app/client/modules/samplernn/index.js @@ -1,10 +1,12 @@ import { h, Component } from 'preact' import { Route, Link } from 'react-router-dom' import SampleRNNDatasets from './samplernn.datasets' +import SampleRNNInspect from './samplernn.inspect' function router () { return (
+
) diff --git a/app/client/modules/samplernn/samplernn.actions.js b/app/client/modules/samplernn/samplernn.actions.js index becab34..339c347 100644 --- a/app/client/modules/samplernn/samplernn.actions.js +++ b/app/client/modules/samplernn/samplernn.actions.js @@ -35,7 +35,7 @@ export const load_directories = () => (dispatch) => { const fileLookup = unprocessedFiles.reduce((fileLookup, file) => { file.checkpoints = [] if (! file.name) { - file.name = (file.opt || {}).token || 'unloaded' + file.name = (file.opt || {}).token || file.url // fileLookup[(file.name || 'unsorted').split('.')[0]] = file } else { fileLookup[(file.name).split('.')[0]] = file @@ -100,11 +100,10 @@ export const load_directories = () => (dispatch) => { type: types.samplernn.init, data: { folderLookup, - // folders, files, - // checkpoints, - // builtDatasets, - // flatDatasets, - // report + folders, files, + checkpoints, + builtDatasets, + report }, }) if (folders.length) { diff --git a/app/client/modules/samplernn/samplernn.inspect.js b/app/client/modules/samplernn/samplernn.inspect.js new file mode 100644 index 0000000..5009328 --- /dev/null +++ b/app/client/modules/samplernn/samplernn.inspect.js @@ -0,0 +1,105 @@ +import { h, Component } from 'preact' +import { bindActionCreators } from 'redux' +import { connect } from 'react-redux' + +import * as samplernnActions from './samplernn.actions' + +import Dataset from '../../dataset/dataset.component' + +import Group from '../../common/group.component' +import Slider from '../../common/slider.component' +import Select from '../../common/select.component' +import Button from '../../common/button.component' +import { FileList } from '../../common/fileList.component' +import TextInput from '../../common/textInput.component' + +class SampleRNNInspect extends Component { + constructor(props){ + super() + this.fileOptions = this.fileOptions.bind(this) + this.pickFile = this.pickFile.bind(this) + props.actions.load_directories() + } + pickFile(file){ + console.log('pick', file) + } + fileOptions(file){ + // console.log(file) + if (file.activity === 'url' && !file.dataset) { + if (this.props.runner.cpu.status !== 'IDLE') { + return ( +
+ fetching... +
+ ) + } else { + return ( +
this.fetchURL(file.url)}> + fetch +
+ ) + } + } + return ( +
+
this.train(file)}>train
+ {file.epoch == 0 &&
{file.epochs} ep.
} +
+ ) + } + fetchURL(url) { + } + render(){ + const { samplernn } = this.props + // console.log(samplernn.upload) + // sort files?? + return ( +
+
+

SampleRNN (inspect)

+
+ {this.renderData()} +
+ ) + } + renderData(){ + const { samplernn, actions } = this.props + console.log(samplernn) + if (! samplernn.data) return + return ( +
+ + + + +
+ ) + } +} + +const mapStateToProps = state => ({ + samplernn: state.module.samplernn, + runner: state.system.runner, + task: state.task, +}) + +const mapDispatchToProps = (dispatch, ownProps) => ({ + actions: bindActionCreators(samplernnActions, dispatch), +}) + +export default connect(mapStateToProps, mapDispatchToProps)(SampleRNNInspect) -- cgit v1.2.3-70-g09d2