diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-06-02 13:02:47 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-06-02 13:02:47 +0200 |
| commit | a6a529a5757417906f6df60ca7557fac3a380966 (patch) | |
| tree | 2791fccff9c24035da59106fb7bfcdefd444186a /app/client/modules/samplernn/samplernn.actions.js | |
| parent | 4d6835094db8d3171d2ba42967a1dff9e622055a (diff) | |
work out data relationships for samplernn
Diffstat (limited to 'app/client/modules/samplernn/samplernn.actions.js')
| -rw-r--r-- | app/client/modules/samplernn/samplernn.actions.js | 95 |
1 files changed, 82 insertions, 13 deletions
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({ |
