import { h, Component } from 'preact' import { bindActionCreators } from 'redux' import { connect } from 'react-redux' import * as util from '../../util' import * as samplernnActions from './samplernn.actions' import DatasetForm from '../../dataset/dataset.form' import { FileList, FileRow } from '../../common/fileList.component' class SampleRNNDatasets extends Component { constructor(props){ super() this.fileOptions = this.fileOptions.bind(this) this.pickFile = this.pickFile.bind(this) let id = props.match.params.id || localStorage.getItem('samplernn.last_id') if (! id && props.location.pathname.match(/\/new\//)) { id = 'new' } else if (id) { localStorage.setItem('samplernn.last_id', id) } if (id && (! props.samplernn.folder || props.samplernn.folder.id !== id)) { props.actions.load_directories(id) } } pickFile(file){ console.log('pick', file) } fileOptions(file){ if (file.activity === 'url' && !file.dataset) { if (this.props.runner.cpu.status !== 'IDLE') { return (
fetching...
) } else { return (
this.fetchURL(file.url)}> fetch
) } } return (
this.train(file)}>train
{file.epoch == 0 &&
{file.epochs} ep.
}
) } render(){ const { samplernn } = this.props const folder = samplernn.folder if (!folder.name) return const { mapFn, sortFn } = util.sort.orderByFn('date desc') const datasets = folder.datasets.map(mapFn).sort(sortFn).map(pair => { const dataset = pair[1] return (
{!!dataset.input.length && }
{dataset.isBuilt ? 'cached' : ''}
{!!dataset.checkpoints.length && }
{!!dataset.output.length && }
) }) return (
input
checkpoint
output
{datasets}
) } } const mapStateToProps = state => ({ samplernn: state.module.samplernn, runner: state.system.runner, task: state.task, }) const mapDispatchToProps = (dispatch, ownProps) => ({ actions: bindActionCreators(samplernnActions, dispatch), }) export default connect(mapStateToProps, mapDispatchToProps)(SampleRNNDatasets)