From a4f6d0e9afa4993437e3031aaa4771f268ce4d99 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 5 Sep 2018 13:28:55 +0200 Subject: app --- app/client/common/index.js | 3 +- app/client/common/numberInput.component.js | 2 +- app/client/common/taskList.component.js | 61 ++++++++++++++++++++++ app/client/dashboard/dashboard.component.js | 4 +- app/client/dashboard/tasklist.component.js | 61 ---------------------- app/client/modules/pix2pixhd/pix2pixhd.tasks.js | 6 ++- .../modules/pix2pixhd/views/pix2pixhd.train.js | 19 +++++-- 7 files changed, 86 insertions(+), 70 deletions(-) create mode 100644 app/client/common/taskList.component.js delete mode 100644 app/client/dashboard/tasklist.component.js (limited to 'app/client') diff --git a/app/client/common/index.js b/app/client/common/index.js index eeb8bfc..13b3189 100644 --- a/app/client/common/index.js +++ b/app/client/common/index.js @@ -17,6 +17,7 @@ import Select from './select.component' import SelectGroup from './selectGroup.component' import Slider from './slider.component' import TextInput from './textInput.component' +import TaskList from './taskList.component' import * as Views from './views' export { @@ -27,5 +28,5 @@ export { Group, ParamGroup, Param, TextInput, NumberInput, Slider, Select, SelectGroup, Button, Checkbox, - CurrentTask, + CurrentTask, TaskList, } \ No newline at end of file diff --git a/app/client/common/numberInput.component.js b/app/client/common/numberInput.component.js index 43f9878..53fbf45 100644 --- a/app/client/common/numberInput.component.js +++ b/app/client/common/numberInput.component.js @@ -13,7 +13,7 @@ class NumberInput extends Component { changed: true, }) this.props.onInput && this.props.onInput(e.target.value, e.target.name) - this.props.onChange && this.props.onInput(e.target.name, e.target.value) + this.props.onChange && this.props.onChange(e.target.name, e.target.value) } handleKeydown(e){ if (e.keyCode === 13) { diff --git a/app/client/common/taskList.component.js b/app/client/common/taskList.component.js new file mode 100644 index 0000000..f6383e0 --- /dev/null +++ b/app/client/common/taskList.component.js @@ -0,0 +1,61 @@ +import { h, Component } from 'preact' +import { bindActionCreators } from 'redux' +import { connect } from 'react-redux' +import { Link } from 'react-router-dom'; +import util from '../util' + +import actions from '../actions' + +class TaskList extends Component { + constructor(props){ + super() + } + render(){ + const { title, tasks } = this.props + let time = 0 + const { mapFn, sortFn } = util.sort.orderByFn(this.props.sort || 'date desc') + const taskList = tasks.map(mapFn).sort(sortFn).map(pair => { + const task = pair[1] + const { dataset } = task + let dataset_link; + if (task.folder_id) { + const href = '/' + task.module + + '/' + (task.module === 'samplernn' ? 'datasets' : 'sequences') + + '/' + task.folder_id + '/' + dataset_link = {dataset} + } else { + dataset_link = dataset + } + return ( +
+
{task.activity} {task.module}
+
{dataset_link}
+
{util.get_age(task.updated_at)}
+
+ this.handleDestroy(task)}>x +
+
+ ) + }) + return ( +
+ {taskList} +
+ ) + } + handleDestroy(task) { + const yes = confirm('Are you sure you want to delete this task?') + if (yes) { + actions.task.destroy(task) + } + } +} + +const mapStateToProps = state => ({ +}) + +const mapDispatchToProps = (dispatch, ownProps) => ({ + // actions: bindActionCreators(liveActions, dispatch) +}) + +export default connect(mapStateToProps, mapDispatchToProps)(TaskList) diff --git a/app/client/dashboard/dashboard.component.js b/app/client/dashboard/dashboard.component.js index 0c15f99..cbfdd33 100644 --- a/app/client/dashboard/dashboard.component.js +++ b/app/client/dashboard/dashboard.component.js @@ -10,9 +10,7 @@ import Select from '../common/select.component' import Button from '../common/button.component' import DashboardHeader from './dashboardheader.component' -import TaskList from './tasklist.component' -import { Loading, FolderList, FileList } from '../common' -import Gallery from '../common/gallery.component' +import { Loading, FolderList, FileList, TaskList, Gallery } from '../common' import * as dashboardActions from './dashboard.actions' import * as audioPlayerActions from '../common/audioPlayer/audioPlayer.actions' diff --git a/app/client/dashboard/tasklist.component.js b/app/client/dashboard/tasklist.component.js deleted file mode 100644 index 3de6efe..0000000 --- a/app/client/dashboard/tasklist.component.js +++ /dev/null @@ -1,61 +0,0 @@ -import { h, Component } from 'preact' -import { bindActionCreators } from 'redux' -import { connect } from 'react-redux' -import { Link } from 'react-router-dom'; -import util from '../util' - -import actions from '../actions' - -class TaskList extends Component { - constructor(props){ - super() - } - render(){ - const { title, tasks } = this.props - let time = 0 - const { mapFn, sortFn } = util.sort.orderByFn('date desc') - const taskList = tasks.map(mapFn).sort(sortFn).map(pair => { - const task = pair[1] - const { dataset } = task - let dataset_link; - if (task.folder_id) { - const href = '/' + task.module + - '/' + (task.module === 'samplernn' ? 'datasets' : 'sequences') + - '/' + task.folder_id + '/' - dataset_link = {dataset} - } else { - dataset_link = dataset - } - return ( -
-
{task.activity} {task.module}
-
{dataset_link}
-
{util.get_age(task.updated_at)}
-
- this.handleDestroy(task)}>x -
-
- ) - }) - return ( -
- {taskList} -
- ) - } - handleDestroy(task) { - const yes = confirm('Are you sure you want to delete this task?') - if (yes) { - actions.task.destroy(task) - } - } -} - -const mapStateToProps = state => ({ -}) - -const mapDispatchToProps = (dispatch, ownProps) => ({ - // actions: bindActionCreators(liveActions, dispatch) -}) - -export default connect(mapStateToProps, mapDispatchToProps)(TaskList) diff --git a/app/client/modules/pix2pixhd/pix2pixhd.tasks.js b/app/client/modules/pix2pixhd/pix2pixhd.tasks.js index bd51f2b..412f066 100644 --- a/app/client/modules/pix2pixhd/pix2pixhd.tasks.js +++ b/app/client/modules/pix2pixhd/pix2pixhd.tasks.js @@ -26,13 +26,17 @@ export const train_task = (dataset, folder_id, epochs=1) => dispatch => { const task = { module: module.name, activity: 'train', - dataset: dataset.name, + dataset: dataset.name || dataset, epoch: 0, epochs: epochs, opt: { folder_id: folder_id, } } + if (!task.dataset) { + console.error("train task: no dataset specified") + return + } console.log(task) return actions.queue.add_task(task) } diff --git a/app/client/modules/pix2pixhd/views/pix2pixhd.train.js b/app/client/modules/pix2pixhd/views/pix2pixhd.train.js index ace93e4..b029eab 100644 --- a/app/client/modules/pix2pixhd/views/pix2pixhd.train.js +++ b/app/client/modules/pix2pixhd/views/pix2pixhd.train.js @@ -64,6 +64,10 @@ class Pix2PixHDTrain extends Component { console.log('name', name, 'value', value) this.setState({ [name]: value }) } + interrupt(){ + this.props.actions.queue.stop_task('gpu') + } + render(){ if (this.props.pix2pixhd.loading) { return @@ -89,9 +93,9 @@ class Pix2PixHDTrain extends Component { } }).filter(n => !!n && !!n.options.length).sort((a,b) => a.name.localeCompare(b.name)) - console.log('state', this.props.pix2pixhd.data.epochs) + // console.log('state', this.props.pix2pixhd.data.epochs) // console.log(this.state.checkpoint_name, this.state.epoch) - + console.log(queue) return (
@@ -160,12 +164,20 @@ class Pix2PixHDTrain extends Component { onClick={() => this.props.remote.clear_recursive_task(this.state.checkpoint_name)} /> + + +
{!!queue.queue.length && - queue.tasks[id])} /> + queue.tasks[id])} sort="date asc" /> }
@@ -176,6 +188,7 @@ class Pix2PixHDTrain extends Component { const mapStateToProps = state => ({ pix2pixhd: state.module.pix2pixhd, + runner: state.system.runner, queue: state.queue, }) -- cgit v1.2.3-70-g09d2