diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-06-05 16:16:24 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-06-05 16:16:24 +0200 |
| commit | b0d534d174def2940287745535726c7e878dcbcc (patch) | |
| tree | 499f8980f2e29bd36833bb943eacd01e9815759e /app | |
| parent | e243e4f65cc2c98724a1cfb4d28ac5f1d1bc0a79 (diff) | |
more sane file naming
Diffstat (limited to 'app')
| -rw-r--r-- | app/client/common/fileList.component.js | 24 | ||||
| -rw-r--r-- | app/client/modules/samplernn/samplernn.datasets.js | 25 | ||||
| -rw-r--r-- | app/client/modules/samplernn/samplernn.reducer.js | 3 | ||||
| -rw-r--r-- | app/client/modules/samplernn/samplernn.tasks.js | 2 | ||||
| -rw-r--r-- | app/client/socket/socket.api.js | 2 | ||||
| -rw-r--r-- | app/client/system/system.actions.js | 30 | ||||
| -rw-r--r-- | app/client/system/system.reducer.js | 2 | ||||
| -rw-r--r-- | app/relay/modules/samplernn.js | 9 | ||||
| -rw-r--r-- | app/server/bridge.js | 7 |
9 files changed, 66 insertions, 38 deletions
diff --git a/app/client/common/fileList.component.js b/app/client/common/fileList.component.js index 7508885..6ecd1fe 100644 --- a/app/client/common/fileList.component.js +++ b/app/client/common/fileList.component.js @@ -74,15 +74,31 @@ export const FileRow = props => { const date = file.date || file.created_at const epoch = file.epoch || file.epochs || 0 + let name; + let key; + if (file.name) { + name = file.name + key = name + } else if (file.url) { + if (file.opt && file.opt.type) { + name = file.opt.type + ': ' + file.opt.title + key = file.opt.token + } + else { + name = file.url.replace(/^https?:\/\//, '') + key = name + } + } + return ( - <div class={className} key={file.name}> + <div class={className} key={key}> {fields.has('name') && <div className="filename" title={file.name || file.url}> {file.persisted === false - ? <span className='unpersisted'>{file.name || file.url}</span> + ? <span className='unpersisted'>{name}</span> : (linkFiles && file.url) - ? <a target='_blank' onClick={(e) => onClick && onClick(file, e)} href={file.url}>{file.name || file.url}</a> - : <span class='link' onClick={(e) => onClick && onClick(file, e)}>{file.name || file.url}</span> + ? <a target='_blank' onClick={(e) => onClick && onClick(file, e)} href={file.url}>{name}</a> + : <span class='link' onClick={(e) => onClick && onClick(file, e)}>{name}</span> } </div> } diff --git a/app/client/modules/samplernn/samplernn.datasets.js b/app/client/modules/samplernn/samplernn.datasets.js index 3d4219e..9ee7618 100644 --- a/app/client/modules/samplernn/samplernn.datasets.js +++ b/app/client/modules/samplernn/samplernn.datasets.js @@ -19,7 +19,6 @@ const samplernnModule = { class SampleRNNDatasets extends Component { constructor(props){ super(props) - this.fileOptions = this.fileOptions.bind(this) this.pickFile = this.pickFile.bind(this) } componentWillMount(){ @@ -37,29 +36,6 @@ class SampleRNNDatasets extends Component { pickFile(file){ console.log('pick', file) } - fileOptions(file){ - if (file.activity === 'url' && !file.dataset) { - if (this.props.runner.cpu.status !== 'IDLE') { - return ( - <div className='gray'> - fetching... - </div> - ) - } else { - return ( - <div className='link' onClick={() => this.fetchURL(file.url)}> - fetch - </div> - ) - } - } - return ( - <div> - <div className='link' onClick={() => this.train(file)}>train</div> - {file.epoch == 0 && <div className='epochs'>{file.epochs} ep.</div>} - </div> - ) - } onDeleteFile(file){ const yes = confirm('Are you sure you want to delete this file?') if (yes) { @@ -116,7 +92,6 @@ class SampleRNNDatasets extends Component { fileListClassName='' rowClassName='input_file' fields={'name date size delete'} - options={this.fileOptions} onClick={onPickFile} onDelete={(file) => this.onDeleteFile(file)} /> diff --git a/app/client/modules/samplernn/samplernn.reducer.js b/app/client/modules/samplernn/samplernn.reducer.js index 5255ca3..fd9dbff 100644 --- a/app/client/modules/samplernn/samplernn.reducer.js +++ b/app/client/modules/samplernn/samplernn.reducer.js @@ -123,6 +123,7 @@ const samplernnReducer = (state = samplernnInitialState, action) => { return state case types.file.update: + console.log('>>>>>>> file update') if (action.data.module === 'samplernn') { let old_dataset; let new_dataset = state.data.datasetLookup[action.data.dataset] @@ -143,6 +144,8 @@ const samplernnReducer = (state = samplernnInitialState, action) => { output: !action.data.generated ? [] : [action.data.id], } } + console.log('old_dataset', old_dataset_update.name) + console.log('new_dataset', new_dataset_update.name) return { ...state, loading: false, diff --git a/app/client/modules/samplernn/samplernn.tasks.js b/app/client/modules/samplernn/samplernn.tasks.js index 21939dd..80585bd 100644 --- a/app/client/modules/samplernn/samplernn.tasks.js +++ b/app/client/modules/samplernn/samplernn.tasks.js @@ -25,7 +25,7 @@ export const fetch_task = (url, file_id, dataset) => dispatch => { const task = { module: 'samplernn', activity: 'fetch', - dataset: name, + dataset: dataset, opt: { url, file_id, diff --git a/app/client/socket/socket.api.js b/app/client/socket/socket.api.js index 99c9248..11783a5 100644 --- a/app/client/socket/socket.api.js +++ b/app/client/socket/socket.api.js @@ -5,6 +5,7 @@ import { socket } from './socket.connection' socket.on('api_res', (data) => { // console.log('system response', data) const type = types[data.datatype] + console.log('api_res', data.type, data.datatype) if (! type) return console.error('socket:api_res bad datatype', data.datatype) switch (data.type) { case 'create': @@ -29,4 +30,3 @@ socket.on('api_res', (data) => { break } }) - diff --git a/app/client/system/system.actions.js b/app/client/system/system.actions.js index 8758715..7831704 100644 --- a/app/client/system/system.actions.js +++ b/app/client/system/system.actions.js @@ -37,3 +37,33 @@ export const enqueue_test_task = (dataset) => dispatch => { } return actions.queue.add_task(task) } + +window.addEventListener('keyDown', e => { + if (e.altKey) { + switch (e.keyCode) { + case 192: // tilde - switch tool + break + case 49: // 1 + break + case 50: // 2 + break + case 51: // 3 + break + case 52: // 4 + break + case 53: // 5 + break + case 54: // 6 + break + case 55: // 7 + break + case 56: // 8 + break + case 57: // 9 + break + case 48: // 0 + break + } + } +}) + diff --git a/app/client/system/system.reducer.js b/app/client/system/system.reducer.js index 961db74..5067acd 100644 --- a/app/client/system/system.reducer.js +++ b/app/client/system/system.reducer.js @@ -179,7 +179,7 @@ const systemReducer = (state = systemInitialState, action) => { if (action.task === 'cpu' || (state.runner.cpu.task && action.task && state.runner.cpu.task.uuid === action.task.uuid)) { processor = 'cpu' } - else if (action.task === 'gpu' || (state.runner.cpu.task && action.task && state.runner.gpu.task.uuid === action.task.uuid)) { + else if (action.task === 'gpu' || (state.runner.gpu.task && action.task && state.runner.gpu.task.uuid === action.task.uuid)) { processor = 'gpu' } else { processor = null diff --git a/app/relay/modules/samplernn.js b/app/relay/modules/samplernn.js index 2dacaa7..73d0a5f 100644 --- a/app/relay/modules/samplernn.js +++ b/app/relay/modules/samplernn.js @@ -13,10 +13,11 @@ const fetch = { listen: (task, line, i) => { // here i need to bridge again... get the filename that comes back from youtube-dl // and tell the cortex that URL -> fn and add the filename! - if ( line.match(/^got fn, /) ) { - let dataset = line.split(' => ')[1].trim() - task.dataset = dataset - return { type: 'progress', action: 'set_dataset', task, } + if ( line.match(/^youtube-dl got fn, /) ) { + let filename = line.split(' => ')[1].trim() + task.dataset = filename.split('.')[0] + task.opt.filename = filename + return { type: 'progress', action: 'resolve_dataset', task, } } return null } diff --git a/app/server/bridge.js b/app/server/bridge.js index 8a6b547..d076b6d 100644 --- a/app/server/bridge.js +++ b/app/server/bridge.js @@ -60,11 +60,14 @@ function bind_relay(socket) { data.task = task client.emit('task_res', data) }) - if (data.type === 'set_dataset' && data.task.opt.file_id) { - db.models.task.update(data.task.opt.file_id, { + if (data.action === 'resolve_dataset' && data.task.opt.file_id) { + console.log(">>>>>>>>>>\n\n\n\n","SOMEONE TRYING TO SET THE DATASET", data.task.opt.file_id, data.task.dataset) + db.models.file.update(data.task.opt.file_id, { dataset: data.task.dataset, }).then(file => { client.emit('api_res', { type: 'update', datatype: 'file', data: file }) + }).catch(err => { + console.error('error setting the dataset', err) }) } } |
