diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/client/common/fileList.component.js | 21 | ||||
| -rw-r--r-- | app/client/dataset/dataset.component.js | 7 | ||||
| -rw-r--r-- | app/client/modules/samplernn/samplernn.actions.js | 95 | ||||
| -rw-r--r-- | app/client/modules/samplernn/samplernn.datasets.js | 11 | ||||
| -rw-r--r-- | app/client/modules/samplernn/samplernn.reducer.js | 22 | ||||
| -rw-r--r-- | app/client/system/system.component.js | 2 | ||||
| -rw-r--r-- | app/client/types.js | 3 |
7 files changed, 120 insertions, 41 deletions
diff --git a/app/client/common/fileList.component.js b/app/client/common/fileList.component.js index 8f7ff5a..ece77ae 100644 --- a/app/client/common/fileList.component.js +++ b/app/client/common/fileList.component.js @@ -11,9 +11,14 @@ class FileList extends Component { super() } render(){ - const { files, linkFiles, title, onClick } = this.props + const { files, linkFiles, title, onClick, className="" } = this.props if (!files.length) return null let fields = this.props.fields || defaultFields + if (typeof fields === 'string') { + fields = new Set(fields.split(' ')) + } else if (!(fields instanceof Set)) { + fields = new Set(fields) + } const fileList = files.map(file => { const size = util.hush_size(file.size) const date = file.created_at @@ -55,9 +60,17 @@ class FileList extends Component { ) }) return ( - <div className='filelist rows'> - {title && <h3>{title}</h3>} - {fileList} + <div className={'rows ' + className}> + <div class='row heading'> + {files.length ? + <h3>{title || Files}</h3> : + <h4>No files</h4>} + <div>{(loading || error) && status}</div> + </div> + + <div className={'filelist rows'}> + {fileList} + </div> </div> ) } diff --git a/app/client/dataset/dataset.component.js b/app/client/dataset/dataset.component.js index e6c1bfd..45f88dc 100644 --- a/app/client/dataset/dataset.component.js +++ b/app/client/dataset/dataset.component.js @@ -100,13 +100,8 @@ class Dataset extends Component { </div> </div> <div className='params col'> - <div class='row heading'> - {files.length ? - <h3>Files</h3> : - <h4>No files</h4>} - <div>{(loading || error) && status}</div> - </div> <FileList + title='Files' files={files} options={fileOptions} onClick={pickFile} diff --git a/app/client/modules/samplernn/samplernn.actions.js b/app/client/modules/samplernn/samplernn.actions.js index 55bd9f3..b9789c7 100644 --- a/app/client/modules/samplernn/samplernn.actions.js +++ b/app/client/modules/samplernn/samplernn.actions.js @@ -4,9 +4,7 @@ import types from '../../types' import actions from '../../actions' export const load_directories = () => (dispatch) => { - // load datasets - // load directories from server - console.log(actions) + // console.log(actions) Promise.all([ actions.folder.index({ module: 'samplernn' }), actions.file.index({ module: 'samplernn' }), @@ -15,26 +13,97 @@ export const load_directories = () => (dispatch) => { actions.socket.list_directory({ module: 'samplernn', dir: 'datasets' }), actions.socket.run_script({ module: 'samplernn', activity: 'report' }) ]).then(res => { - console.log(res) const [folders, files, tasks, results, datasets, report] = res - console.log(datasets) + + const folderLookup = folders.reduce((folderLookup, folder) => { + folderLookup[folder.id] = folder + folder.files = [] + folder.results = [] + return folderLookup + }, { + 'unsorted': { + id: 0, + name: 'unsorted', + files: [], + results: [], + } + }) + + const processedFiles = files.filter(file => file.processed) + const unprocessedFiles = files.filter(file => !file.processed) + const fileLookup = unprocessedFiles.reduce((fileLookup, file) => { + file.checkpoints = [] + if (! file.name) { + file.name = (file.opt || {}).token || 'unloaded' + // fileLookup[(file.name || 'unsorted').split('.')[0]] = file + } else { + fileLookup[(file.name).split('.')[0]] = file + } + folderLookup[file.folder_id] && folderLookup[file.folder_id].files.push(file) + return fileLookup + }, { + unsorted: { + checkpoints: [], + results: [], + } + }) + processedFiles.map(result => { + const pair = result.name.split('.')[0].split('-') + const file = fileLookup[pair[0]] + if (file) { + file.results.push(result) + } else { + folderLookup[file.folder_id] && folderLookup[file.folder_id].results.push(file) + } + result.epoch = result.epoch || pair[1] + }) + folderLookup.unsorted.files.push(fileLookup.unsorted) + + // console.log(datasets) + // const flatDatasets = datasets.filter(s => s.name.match(/(wav|aiff?|flac|mp3)$/) && !s.dir) const builtDatasets = datasets.filter(s => s.dir) - const flatDatasets = datasets.filter(s => s.name.match(/(wav|aiff?|flac|mp3)$/) && !s.dir) - const checkpoints = results.filter(s => s.dir) - console.log(folders.length, files.length, tasks.length, results.length, datasets.length) - console.log(report) + builtDatasets.forEach(dataset => { + const file = fileLookup[dataset.name] || fileLookup.unsorted + file.hasDataset = true + }) + + // exp:coccokit_3-frame_sizes:8,2-n_rnn:2-dataset:coccokit_3 + const checkpoints = results.filter(s => s.dir).map(s => { + const checkpoint = s.name.split('-').map(s => s.split(':')).reduce((a,b) => (a[b[0]] = b[1])&&a, {}) + checkpoint.dir = s + const file = fileLookup[checkpoint.dataset] || fileLookup.unsorted + file.checkpoints.push(checkpoint) + return checkpoint + }) + + // console.log(folders.length, files.length, tasks.length, results.length, datasets.length) + // console.log(report) + report.stdout.split('\n\n').filter(a=>!!a).forEach(data => { + const [ name, ...lines ] = data.split('\n') + const file = fileLookup[name] || fileLookup.unsorted + file.log = lines.map(s => s.split('\t')).map(s => s.split(': ')).reduce((a,b) => (a[b[0]] = b[1])&&a, {}) + }) + dispatch({ type: types.samplernn.init, data: { - folders, files, - checkpoints, - builtDatasets, flatDatasets, - report + folderLookup, + // folders, files, + // checkpoints, + // builtDatasets, + // flatDatasets, + // report }, }) + dispatch({ + type: types.samplernn.set_folder, + folder: folders[0].name, + }) }) } +export const set_folder = (folder) => { types.samplernn.set_folder, folder } + export const fetch_url = (url) => (dispatch) => { console.log(url) actions.task.start_task({ diff --git a/app/client/modules/samplernn/samplernn.datasets.js b/app/client/modules/samplernn/samplernn.datasets.js index 58e6df4..bcc7878 100644 --- a/app/client/modules/samplernn/samplernn.datasets.js +++ b/app/client/modules/samplernn/samplernn.datasets.js @@ -66,15 +66,15 @@ class SampleRNNDatasets extends Component { linkFiles fileOptions={this.fileOptions} onPick={this.handlePick} - folder={samplernn.input.folder} - files={samplernn.input.files} + folder={samplernn.folder} + files={samplernn.folder.files} /> - {this.renderData()} </div> ) } renderData(){ - const { samplernn } = this.props + // {this.renderData()} + const { samplernn, actions } = this.props if (samplernn.data === null) { return } @@ -82,6 +82,9 @@ class SampleRNNDatasets extends Component { <div class='row params'> <FileList title='Folders' + className='folders' + fields='name' + onPick={actions.set_folder} files={samplernn.data.folders} /> <FileList diff --git a/app/client/modules/samplernn/samplernn.reducer.js b/app/client/modules/samplernn/samplernn.reducer.js index 8d1ed74..5e83e98 100644 --- a/app/client/modules/samplernn/samplernn.reducer.js +++ b/app/client/modules/samplernn/samplernn.reducer.js @@ -1,20 +1,10 @@ import types from '../../types' const samplernnInitialState = { - loading: false, + loading: true, error: null, - folder: {}, folders: [], - datasets: [], - results: [], - input: { - folder: {}, - files: [], - }, - output: { - folder: {}, - files: [], - }, + folder: {}, data: null, } @@ -23,6 +13,7 @@ const samplernnReducer = (state = samplernnInitialState, action) => { case types.samplernn.init: return { ...state, + loading: false, data: action.data, } case types.socket.connect: @@ -55,6 +46,13 @@ const samplernnReducer = (state = samplernnInitialState, action) => { return state case types.socket.status: return samplernnSocket(state, action.data) + + case types.samplernn.set_folder: + return { + ...state, + folder: action.folder, + } + default: return state } diff --git a/app/client/system/system.component.js b/app/client/system/system.component.js index b257573..a4bba81 100644 --- a/app/client/system/system.component.js +++ b/app/client/system/system.component.js @@ -7,7 +7,7 @@ import Param from '../common/param.component' import * as systemActions from './system.actions' import * as liveActions from '../live/live.actions' -import * as taskActions from '../task/task.actions' +import * as queueActions from '../queue/queue.actions' const cpu_test_task = { activity: 'cpu', diff --git a/app/client/types.js b/app/client/types.js index 925ba52..092ad8f 100644 --- a/app/client/types.js +++ b/app/client/types.js @@ -75,7 +75,8 @@ export default { fetch_progress: 'FETCH_PROGRESS', }, samplernn: { - init: 'SAMPLERNN_INIT' + init: 'SAMPLERNN_INIT', + set_folder: 'SAMPLERNN_SET_FOLDER', // queue and train // update checkpoint settings // reset checkpoint settings |
