summaryrefslogtreecommitdiff
path: root/app/client
diff options
context:
space:
mode:
Diffstat (limited to 'app/client')
-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
5 files changed, 48 insertions, 71 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]