summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/client/dashboard/dashboard.component.js16
-rw-r--r--app/client/modules/samplernn/samplernn.actions.js4
-rw-r--r--app/client/queue/queue.actions.js9
-rw-r--r--app/client/queue/queue.reducer.js87
-rw-r--r--app/client/util/sort.js3
-rw-r--r--app/relay/runner.js17
-rw-r--r--app/server/bridge.js25
7 files changed, 82 insertions, 79 deletions
diff --git a/app/client/dashboard/dashboard.component.js b/app/client/dashboard/dashboard.component.js
index c74c4df..d9aece1 100644
--- a/app/client/dashboard/dashboard.component.js
+++ b/app/client/dashboard/dashboard.component.js
@@ -14,10 +14,12 @@ import { FileList } from '../common/fileList.component'
import Gallery from '../common/gallery.component'
import * as dashboardActions from './dashboard.actions'
+import actions from '../actions'
class Dashboard extends Component {
constructor(props){
super()
+ actions.task.index()
}
componentWillUpdate(nextProps) {
// if (nextProps.opt.checkpoint_name && nextProps.opt.checkpoint_name !== this.props.opt.checkpoint_name) {
@@ -38,20 +40,6 @@ class Dashboard extends Component {
<TaskList tasks={queue} />
</Group>
</div>
- <div className='column'>
- <Group title='Your Datasets'>
- <FileList files={files} />
- </Group>
- <Group title='Results'>
- <FileList files={files} />
- </Group>
- <Group title='Audio Player'>
- <FileList files={files} />
- </Group>
- </div>
- </div>
- <div>
- <Gallery images={images} />
</div>
</div>
)
diff --git a/app/client/modules/samplernn/samplernn.actions.js b/app/client/modules/samplernn/samplernn.actions.js
index a6c8ab8..c196cc5 100644
--- a/app/client/modules/samplernn/samplernn.actions.js
+++ b/app/client/modules/samplernn/samplernn.actions.js
@@ -274,7 +274,7 @@ export const set_folder = (folder) => { types.samplernn.set_folder, folder }
export const fetch_url = (url) => (dispatch) => {
console.log(url)
- actions.task.start_task({
+ return actions.queue.add_task({
activity: 'fetch',
module: 'samplernn',
dataset: 'test',
@@ -295,5 +295,5 @@ export const train_task_now = (dataset, epochs=1) => (dispatch) => {
keep_old_checkpoints: false,
}
}
- return actions.queue.start_task(task)
+ return actions.queue.add_task(task)
} \ No newline at end of file
diff --git a/app/client/queue/queue.actions.js b/app/client/queue/queue.actions.js
index 6e39e71..3450ecc 100644
--- a/app/client/queue/queue.actions.js
+++ b/app/client/queue/queue.actions.js
@@ -1,6 +1,8 @@
import socket from '../socket'
import types from '../types'
+import actions from '../actions'
+
export const start_task = (task, opt={}) => {
socket.task.start_task(task, opt)
return { type: types.task.starting_task, task, ...opt }
@@ -10,3 +12,10 @@ export const stop_task = (task, opt={}) => {
socket.task.stop_task(task, opt)
return { type: types.task.stopping_task, task, ...opt }
}
+
+export const add_task = (new_task) => (dispatch) => {
+ actions.task.create(new_task)
+ .then((task) => {
+ socket.task.add_task(task, opt)
+ })
+} \ No newline at end of file
diff --git a/app/client/queue/queue.reducer.js b/app/client/queue/queue.reducer.js
index c3995b1..02d6943 100644
--- a/app/client/queue/queue.reducer.js
+++ b/app/client/queue/queue.reducer.js
@@ -1,68 +1,45 @@
import types from '../types'
+import * as util from '../util'
import moment from 'moment'
const queueInitialState = {
loading: false,
error: null,
-
- queue: [
- {
- id: 1073,
- activity: 'train',
- module: 'samplernn',
- dataset: 'bobby_brown_-_every_little_step',
- epochs: 6,
- },
- {
- id: 1073,
- activity: 'train',
- module: 'pix2pix',
- checkpoint: 'lyra_voice_layers',
- dataset: 'audio/lyra_improv',
- epochs: 30,
- },
- {
- id: 1073,
- activity: 'train',
- module: 'pix2pix',
- checkpoint: 'lyra_melody_lines',
- dataset: 'audio/lyra_improv',
- epochs: 30,
- },
- {
- id: 1073,
- activity: 'train',
- module: 'pix2pix',
- checkpoint: 'ensemble_chords',
- dataset: 'audio/lyra_improv',
- epochs: 30,
- },
- {
- id: 1073,
- activity: 'generate',
- module: 'samplernn',
- dataset: 'coccoglass3',
- opt: { time: 5, count: 6 },
- },
- {
- id: 1073,
- activity: 'train',
- module: 'pix2pix',
- dataset: 'video/woods_green',
- epochs: 100,
- },
- {
- id: 1073,
- activity: 'train',
- module: 'samplernn',
- dataset: 'bobby_brown_-_every_little_step',
- epochs: 6,
- },
- ],
+ tasks: {},
+ queue: [],
+ completed: [],
}
+const dateSort = util.sort.orderByFn('date desc')
+const prioritySort = util.sort.orderByFn('priority asc')
+
const queueReducer = (state = queueInitialState, action) => {
switch(action.type) {
+ case types.task.create:
+ return {
+ ...state,
+ tasks: {
+ ...state.tasks,
+ [action.data.id]: action.data,
+ },
+ queue: state.queue.concat([action.data]),
+ }
+ case types.task.index:
+ console.log(action.data)
+ return {
+ ...state,
+ tasks: action.data.reduce((a,b) => (a[b.id] = b, a), {}),
+ queue: action.data
+ .filter(a => !a.completed)
+ .map(dateSort.mapFn)
+ .sort(dateSort.sortFn)
+ .map(pair => pair[1].id),
+ completed: action.data
+ .filter(a => a.completed)
+ .map(prioritySort.mapFn)
+ .sort(prioritySort.sortFn)
+ .map(pair => pair[1].id),
+ }
default:
return state
}
diff --git a/app/client/util/sort.js b/app/client/util/sort.js
index 78f17a0..4c07a96 100644
--- a/app/client/util/sort.js
+++ b/app/client/util/sort.js
@@ -22,6 +22,9 @@ export const orderByFn = (s='name asc') => {
mapFn = a => [+new Date(a.date || a.created_at), a]
sortFn = numericSort[direction]
break
+ case 'priority':
+ mapFn = a => [parseInt(a.priority) || parseInt(a.id) || 1000, a]
+ sortFn = numericSort[direction]
case 'name':
default:
mapFn = a => [a.name || "", a]
diff --git a/app/relay/runner.js b/app/relay/runner.js
index a8e26af..1a72025 100644
--- a/app/relay/runner.js
+++ b/app/relay/runner.js
@@ -196,7 +196,7 @@ export function run_task_with_activity(task, module, activity, preempt, watch) {
if (interpreter.gpu && state.current_gpu_task.status !== 'IDLE') {
if (preempt) {
console.log('preempting currently running GPU task')
- terminate(state.current_gpu_task.subprocess)
+ terminate(state.current_gpu_task)
} else {
console.log('already running GPU task :(', state.current_gpu_task.pid)
return { type: 'error', error: 'task already running on gpu' }
@@ -204,7 +204,7 @@ export function run_task_with_activity(task, module, activity, preempt, watch) {
} else if (!interpreter.gpu && state.current_cpu_task.status !== 'IDLE') {
if (preempt) {
console.log('preempting currently running CPU task')
- terminate(state.current_cpu_task.subprocess)
+ terminate(state.current_cpu_task)
} else {
console.log('already running CPU task :(')
return { type: 'error', error: 'task already running on cpu' }
@@ -290,19 +290,20 @@ export function run_next_task(){
export function stop_task(task){
if (!task) return
if (state.current_cpu_task.task.uuid === task.uuid) {
- terminate(state.current_cpu_task.subprocess)
+ terminate(state.current_cpu_task)
return { status: 'ok' }
} else if (state.current_gpu_task.task.uuid === task.uuid) {
- terminate(state.current_gpu_task.subprocess)
+ terminate(state.current_gpu_task)
return { status: 'ok' }
}
return { error: 'no such task' }
}
-export function terminate(subprocess){
- if (!subprocess) {
+export function terminate(task){
+ if (!task || !task.subprocess) {
return
}
- console.log('kill pid', subprocess.pid)
- kill(subprocess.pid)
+ console.log('kill pid', task.subprocess.pid)
+ task.preempted = true
+ kill(task.subprocess.pid)
} \ No newline at end of file
diff --git a/app/server/bridge.js b/app/server/bridge.js
index bbe0e26..ef586ac 100644
--- a/app/server/bridge.js
+++ b/app/server/bridge.js
@@ -1,5 +1,6 @@
import { server, io } from './site'
import * as proxy from './proxy'
+import * as db from './db'
let relay_connected = false
@@ -27,15 +28,18 @@ function bind_relay(socket) {
relay_connected = true
client.emit('system_res', { type: 'relay_connected' })
+ // responses from a live process
socket.on('res', data => {
// console.log('Received response', data.cmd)
client.emit('res', data)
})
+ // status messages from a live process
socket.on('status', data => {
client.emit('status', data)
})
+ // responses to system calls
socket.on('system_res', data => {
if (process.env.CACHE_SYSCALLS) {
const id = make_server_id(data)
@@ -44,10 +48,31 @@ function bind_relay(socket) {
client.emit('system_res', data)
})
+ // messages related to queuing and tasks
socket.on('task_res', data => {
client.emit('task_res', data)
})
+ // // data responses from the server, telling us that files, folders, etc were created
+ // socket.on('data_res', data => {
+ // if (EXPRESS_CONNECTS_TO_RELAY) return
+ // switch (data.type) {
+ // case 'file_create':
+ // // certain files should be persisted in the database...
+ // db.models.file.create(data.data).then(file => {
+ // client.emit('data_res', {
+ // type: 'file_create',
+ // data: file,
+ // })
+ // })
+ // break
+ // default:
+ // client.emit('data_res', data)
+ // break
+ // }
+ // })
+
+ // image frames generated by pix2pix
socket.on('frame', (data) => {
client.volatile.emit('frame', data)
})