diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-06-20 12:58:45 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-06-20 12:58:45 +0200 |
| commit | f37392fe477d4656e12c4d5d18b4344d2c5ae8d6 (patch) | |
| tree | 2bbf820a3372c301cab7d809b72146446a3bf9aa /app | |
| parent | d13f1cf7ea9853a0afc9baba2a7019369dbd934d (diff) | |
listing sequences..
Diffstat (limited to 'app')
| -rw-r--r-- | app/client/modules/pix2pixhd/pix2pixhd.actions.js | 23 | ||||
| -rw-r--r-- | app/client/modules/pix2pixhd/views/pix2pixhd.results.js | 2 | ||||
| -rw-r--r-- | app/client/socket/socket.actions.js | 3 | ||||
| -rw-r--r-- | app/client/types.js | 2 | ||||
| -rw-r--r-- | app/relay/remote.js | 10 | ||||
| -rw-r--r-- | app/relay/runner.js | 40 |
6 files changed, 56 insertions, 24 deletions
diff --git a/app/client/modules/pix2pixhd/pix2pixhd.actions.js b/app/client/modules/pix2pixhd/pix2pixhd.actions.js index 1ee4886..1b22616 100644 --- a/app/client/modules/pix2pixhd/pix2pixhd.actions.js +++ b/app/client/modules/pix2pixhd/pix2pixhd.actions.js @@ -135,3 +135,26 @@ export const load_directories = (id) => (dispatch) => { console.error(e) }) } + +export const load_results = (id) => (dispatch) => { + console.log('hi') + const module = pix2pixhdModule.name + util.allProgress([ + actions.file.index({ module, generated: true }), + actions.socket.list_sequences({ module, dir: 'results' }), + actions.socket.list_directory({ module, dir: 'renders' }), + ], (percent, i, n) => { + console.log('pix2pixhd load progress', i, n) + dispatch({ type: types.app.load_progress, progress: { i, n }}) + }).then(res => { + const [files, results, renders] = res //, datasets, results, output, datasetUsage, lossReport] = res + console.log(files, results, renders) + dispatch({ + type: types.pix2pixhd.load_results, + results: { + results, + renders, + } + }) + }) +}
\ No newline at end of file diff --git a/app/client/modules/pix2pixhd/views/pix2pixhd.results.js b/app/client/modules/pix2pixhd/views/pix2pixhd.results.js index dcbbfad..cf0bdf7 100644 --- a/app/client/modules/pix2pixhd/views/pix2pixhd.results.js +++ b/app/client/modules/pix2pixhd/views/pix2pixhd.results.js @@ -13,7 +13,7 @@ import { FileList, FileRow } from '../../../common/fileList.component' class Pix2pixHDResults extends Component { constructor(props){ super() - // if (!props.pix2pixhd.data) props.actions.load_directories() + if (!props.pix2pixhd.results) props.actions.load_results() } render(){ if (this.props.pix2pixhd.loading) return <Loading progress={this.props.pix2pixhd.progress} /> diff --git a/app/client/socket/socket.actions.js b/app/client/socket/socket.actions.js index 38c1b7f..e15dda2 100644 --- a/app/client/socket/socket.actions.js +++ b/app/client/socket/socket.actions.js @@ -10,6 +10,9 @@ export function disk_usage(opt) { export function list_directory(opt) { return syscall_async('list_directory', opt).then(res => res.files) } +export function list_sequences(opt) { + return syscall_async('list_sequences', opt).then(res => res.sequences) +} export function run_script(opt) { return syscall_async('run_script', opt) } diff --git a/app/client/types.js b/app/client/types.js index 8021a0e..e710248 100644 --- a/app/client/types.js +++ b/app/client/types.js @@ -105,7 +105,7 @@ export default { 'init', 'set_folder' ]), pix2pixhd: with_type('pix2pixhd', [ - 'init', 'set_folder' + 'init', 'set_folder', 'load_results' ]), pix2wav: with_type('pix2wav', [ 'init', 'set_folder' diff --git a/app/relay/remote.js b/app/relay/remote.js index 79fdcfc..cf941b1 100644 --- a/app/relay/remote.js +++ b/app/relay/remote.js @@ -115,6 +115,16 @@ remote.on('system', (data) => { }) }) break + case 'list_sequences': + runner.list_sequences(data.payload, sequences => { + remote.emit('system_res', { + type: 'list_sequences', + dir: data.payload, + uuid: data.uuid, + sequences, + }) + }) + break case 'upload_file': runner.upload_file(data.payload, (error, stdout, stderr) => { remote.emit('system_res', { diff --git a/app/relay/runner.js b/app/relay/runner.js index 361fecc..06fa85e 100644 --- a/app/relay/runner.js +++ b/app/relay/runner.js @@ -121,31 +121,31 @@ export function build_params(module, activity, task) { } } -export function run_system_command(cmd, cb) { - console.log('running system command:', cmd.cmd) - switch(cmd.cmd) { +export function run_system_command(opt, cb) { + console.log('running system command:', opt.cmd) + switch(opt.cmd) { case 'nvidia-smi': case 'uptime': case 'w': - execFile(cmd.cmd, [], cb) + execFile(opt.cmd, [], cb) break case 'ps': - execFile(cmd.cmd, ['au'], cb) + execFile('ps', ['au'], cb) break case 'df': execFile('df', ['-h'], cb) break case 'ls': - list_directory(cmd, cb) + list_directory(opt, cb) break case 'du': - disk_usage(cmd, cb) + disk_usage(opt, cb) break case 'list_sequences': - list_sequences(cmd, cb) + list_sequences(opt, cb) break case 'dir_to_video': - dir_to_video(cmd, cb) + dir_to_video(opt, cb) break default: cb({ error: 'no such command' }) @@ -161,8 +161,7 @@ export function module_dir(opt, dir){ if (!module) { return null } - const dir = path.join(module.cwd, dir.replace(/\.\.?\//g, '')) - return dir + return path.join(module.cwd, dir.replace(/\.\.?\//g, '')) } export function list_directory(opt, cb) { @@ -194,6 +193,7 @@ export function list_directory(opt, cb) { // list the contents of a directory of sequences export function list_sequences(opt, cb) { list_directory(opt, (files, root_dir) => { + // console.log(files, root_dir) const sequencePromises = files.filter(d => !!d.dir).map(f => { return list_sequence(opt, f, root_dir) }) @@ -213,17 +213,14 @@ export function list_sequence(opt, f, root_dir) { } readdir(path.join(root_dir, f.name)).then(files => { const middle_file = files[Math.floor(files.length/2)] - const filePromises = [] - filePromises.push(stat_promise(path.join(root_dir, f.name, middle_file))) - sequence.count = files.length - return Promise.all(filePromises) - }).then(stats => { - if (stats.length) { - sequence.frame = { - prefix: middle_file.split('_')[0] - size: stat.size, - } + sequence.frame = { + prefix: middle_file.split('_')[0], } + sequence.count = files.length + // console.log(sequence.count) + return stat_promise(path.join(root_dir, f.name, middle_file)) + }).then(stat => { + sequence.frame.size = stat.size resolve(sequence) }).catch(err => reject(err)) }) @@ -244,7 +241,6 @@ export function dir_to_video(opt, db) { // output: the path (in renders/) that contains the video // run the dir to video script with CWD as the directory and first input as ../renders plus the directory name // list the file in renders... - cb([]) execFile('./bin/dir_to_video.pl', params, { cwd: module.cwd, }, cb) |
