Commit d61263cc authored by LIGNEUL CLEMENT's avatar LIGNEUL CLEMENT
Browse files

add progress bar during runs

parent 082984ab
......@@ -6,7 +6,7 @@ Cette application est une interface graphique pour la plateforme [EASEA](http://
Cette application a été conçu et testé sur Ubuntu 20.10
Pour utiliser ce programme il est nécessaire d'avoir installé EASEA (voir http://easea.unistra.fr/index.php/Downloading_EASEA)
Pour utiliser ce programme il est nécessaire d'avoir installé la version la plus récente d'EASEA (voir http://easea.unistra.fr/index.php/Downloading_EASEA)
### Dépendances générales
......
......@@ -129,9 +129,6 @@ export class Compile {
option_layout.addWidget(check_cdas, 2, 0);
option_layout.addWidget(check_memetic, 2, 1);
option_layout.addWidget(check_cmaes, 2, 2);
option_layout.addWidget(misc_label, 3, 0);
option_layout.addWidget(check_v, 4, 0);
option_layout.addWidget(check_tl, 4, 1);
// cuda options if nvcc is installed
const cuda_test = new Pseudo_term('Cuda test');
......@@ -139,6 +136,10 @@ export class Compile {
option_layout.addWidget(check_cuda, 2, 3);
option_layout.addWidget(check_cuda_gp, 2, 4);
}
option_layout.addWidget(misc_label, 3, 0);
option_layout.addWidget(check_v, 4, 0);
option_layout.addWidget(check_tl, 4, 1);
option_layout.setSpacing(15);
......
......@@ -44,7 +44,7 @@ fig.update_layout(
"x": 0.5,
"xanchor": "center",
"yanchor": "top",
},
}
)
fig.update_xaxes(title_text="Generations")
......
......@@ -56,11 +56,11 @@ export class Plot_result {
running_plot.push(run);
run.on('exit', (code) => {
run.on('exit', (code, signal) => {
const index = running_plot.indexOf(run, 0);
if (index > -1) {
if (running_plot.length === 1) {
running_proc.pop();
running_plot.pop();
} else {
running_plot.splice(index, 1);
}
......@@ -73,14 +73,26 @@ export class Plot_result {
this.image_label.setFixedSize(800, 500);
this.btn_widget.show();
} else {
this.image_label.setFixedSize(200, 30);
this.image_label.setText('Error : graph not found');
}
} else {
this.image_label.setFixedSize(200, 30);
this.image_label.setText('This graph can\'t be displayed');
}
if (running_plot.length === 0) {
run_obj.running_label.hide();
run_obj.progress_bar.setValue(run_obj.progress_bar.value() + (100 / (2 * run_obj.batch_size)));
if (running_plot.length === 0 && signal === null) {
run_obj.running_label.setText('Finished');
run_obj.progress_bar.setValue(100);
run_obj.enable_buttons(true);
}
if (signal?.toString() === 'SIGTERM') {
run_obj.enable_buttons(true);
run_obj.running_label.setText('Interrupted');
run_obj.running_label.show();
}
});
}
......@@ -128,7 +140,7 @@ export class Plot_result {
try {
fs.copyFileSync('plotting/fig.svg', path_file);
} catch (e) {
if(e)
if (e)
new Win_alert(e, 'Save Static Plot');
return;
}
......@@ -151,7 +163,7 @@ export class Plot_result {
fs.copyFileSync('plotting/fig.html', path_file);
} catch (e) {
if(e)
if (e)
new Win_alert(e, 'Save Interactive Plot');
return;
}
......@@ -169,9 +181,9 @@ export class Plot_result {
this.image_label.setText('No graph to display');
this.image_label.addEventListener(WidgetEventTypes.MouseButtonDblClick, () => {
if(os.type() === 'Linux'){
if (os.type() === 'Linux') {
spawn('sensible-browser', ['plotting/fig.html']);
} else if (os.type() === 'Darwin'){
} else if (os.type() === 'Darwin') {
spawn('open', ['plotting/fig.html']);
}
})
......
const { QGridLayout } = require("@nodegui/nodegui");
import { QPlainTextEdit, QWidget, QLabel, QPushButton } from '@nodegui/nodegui';
import { spawn } from 'child_process';
import { spawnSync } from 'child_process';
import { running_plot, running_proc, tab_menu } from '.';
import { Win_alert } from './win_alert';
import * as plot_generation from './plot_generation';
import { plot_obj, run_obj } from './index';
import { initial_proc } from './run_tab';
require('child_process').spawn('node', ['--version'], {
env: {
PATH: process.env.PATH
}
});
export class Pseudo_term{
window: QWidget;
text: QPlainTextEdit;
label_text: QLabel;
constructor(label_txt: string){
this.window = new QWidget
this.window.setFixedSize(840,440);
const layout = new QGridLayout();
this.window.setLayout(layout);
this.label_text = new QLabel();
this.label_text.setText(label_txt);
this.text = new QPlainTextEdit();
this.text.setReadOnly(true);
this.text.setFixedSize(800,400);
const reset_btn = new QPushButton();
reset_btn.setText('Clear');
reset_btn.addEventListener('clicked', ()=>{
this.text.clear();
})
layout.addWidget(this.label_text, 0, 0);
layout.addWidget(reset_btn, 0, 1);
layout.addWidget(this.text, 1, 0);
// this.run_command("ls", ["-l"]);
}
compile(command: string, params?: string[], dir?: string) {
var array_params = [];
if(params == undefined){
this.text.insertPlainText('\n$ ' + command + '\n');
// console.log('$ ' + command + '\n');
} else {
var res = '';
for(var i = 0; i < params.length; i++){
if(params[i] != ''){
res = res.concat(params[i], ' ');
array_params.push(params[i]);
}
}
if(command != "nvcc"){
this.text.insertPlainText('\n$ ' + command + ' ' + res + '\n');
// console.log('$ ' + command + ' ' + res + '\n');
}
}
process.env.EZ_PATH = "/usr/local/easena/"
var child = spawn(command, array_params,{
cwd: dir,
env: process.env
});
// child.stdout.pipe(process.stdout);
// handle error in spawn
child.on('error', function(err) {
new Win_alert('' + err);
return 1;
});
// child.stdout.on('data', (data) => {
// // this.text.insertPlainText(data.toString());
// return 1;
// });
child.stderr.on('data', (data) => {
this.text.insertPlainText(data.toString());
});
// if (child.stderr){
// this.text.insertPlainText(child.stderr + '');
// this.text.insertPlainText("\n");
// }
return child;
}
// run shell command and print stdin & stdout in text
// return child process pid or -1 if an error occurs
run_command(command: string, params?: string[], dir?: string) {
var array_params = [];
if(params == undefined){
this.text.insertPlainText('\n$ ' + command + '\n');
// console.log('$ ' + command + '\n');
} else {
var res = '';
for(var i = 0; i < params.length; i++){
if(params[i] != ''){
res = res.concat(params[i], ' ');
array_params.push(params[i]);
}
}
if(command != "nvcc"){
this.text.insertPlainText('\n$ ' + command + ' ' + res + '\n');
// console.log('$ ' + command + ' ' + res + '\n');
}
}
process.env.EZ_PATH = "/usr/local/easena/";
var child = spawnSync(command, array_params,{
cwd: dir,
env: process.env
});
// handle error in spawn
// child.on('error', function(err) {
// var e = new Win_alert('' + err);
// e.execute();
// return 1;
// });
// child.stdout.on('data', (data) => {
// text.insertPlainText(data.toString());
// })
// child.stderr.on('data', (data) => {
// text.insertPlainText(data.toString());
// })
// return 0;
// execute and print result in console
if(command != "nvcc"){
if(child.output){
this.text.insertPlainText(child.output.join(""));
this.text.insertPlainText("\n");
}
}
// if (child.stderr){
// text.insertPlainText(child.stderr.join());
// text.insertPlainText("\n");
// }
if(child.error){
console.log("error detected in run_command")
// text.insertPlainText(child.error);
// text.insertPlainText("\n");
return -1;
} else {
return child;
}
}
run(cmd: string, plot_size: number, params?: string, dir?: string, rank?: number){
var array_params: string[] = [];
if(params == undefined){
this.text.insertPlainText('\n$ ' + cmd + '\n');
// console.log('$ ' + command + '\n');
} else {
// var res = '';
// for(var i = 0; i < params.length; i++){
// if(params[i] != ''){
// res = res.concat(params[i], ' ');
// array_params.push(params[i]);
// }
// }
array_params = params.split(' ');
this.text.insertPlainText('\n$ ' + cmd + ' ' + params + '\n');
// console.log('$ ' + cmd + ' ' + params + '\n');
}
process.env.EZ_PATH = "/usr/local/easena/"
var child = spawn(cmd, array_params, {
cwd: dir,
env: process.env
});
child.on('error', function(err) {
var type = err.toString().split(" ");
if(type[type.length-1] === "ENOENT"){
var message = '\nExecution impossible try to recompile';
if(rank !== undefined){
new Win_alert(err + message, 'Process ' + rank);
} else {
new Win_alert(err + message);
}
} else {
new Win_alert(err + '');
}
running_proc.length = 0;
running_plot.length = 0;
return -1;
});
child.stdout.on('data', (data) => {
if(child.pid === initial_proc.pid)
this.text.insertPlainText(data.toString());
run_obj.running_label.setText('Writing results ...');
run_obj.running_label.show();
plot_generation.parser(data);
// run_obj.running_label.setText('Plotting results ...');
// run_obj.running_label.show();
// plot_obj.update_plot(process.cwd() + '/' + plot_generation.data_csv);
// console.log(process.cwd() + '/' + plot_generation.data_csv);
});
// child.stderr.on('data', (data) => {
// this.text.insertPlainText(data.toString());
// });
child.on('exit', (code)=>{
const index = running_proc.indexOf(child, 0);
if(index > -1){
if(running_proc.length === 1){
running_proc.pop();
} else {
running_proc.splice(index, 1);
}
}
if(code !== 0)
return;
run_obj.running_label.setText('Plotting results ...');
run_obj.running_label.show();
plot_obj.update_plot(process.cwd() + '/plotting/fig.svg', plot_size);
// console.log(process.cwd() + '/' + plot_generation.data_csv);
console.log("child process terminated with code " + code);
run_obj.finished_label.setText('Completed Runs : ' + (run_obj.batch_size - running_proc.length)+ '/' + run_obj.batch_size);
})
running_proc.push(child);
return child;
}
const { QGridLayout } = require("@nodegui/nodegui");
import { QPlainTextEdit, QWidget, QLabel, QPushButton, SystemFont } from '@nodegui/nodegui';
import { spawn } from 'child_process';
import { spawnSync } from 'child_process';
import { running_plot, running_proc, tab_menu } from '.';
import { Win_alert } from './win_alert';
import * as plot_generation from './plot_generation';
import { plot_obj, run_obj } from './index';
import { initial_proc } from './run_tab';
require('child_process').spawn('node', ['--version'], {
env: {
PATH: process.env.PATH
}
});
export class Pseudo_term {
window: QWidget;
text: QPlainTextEdit;
label_text: QLabel;
constructor(label_txt: string) {
this.window = new QWidget
this.window.setFixedSize(840, 440);
const layout = new QGridLayout();
this.window.setLayout(layout);
this.label_text = new QLabel();
this.label_text.setText(label_txt);
this.text = new QPlainTextEdit();
this.text.setReadOnly(true);
this.text.setFixedSize(800, 400);
const reset_btn = new QPushButton();
reset_btn.setText('Clear');
reset_btn.addEventListener('clicked', () => {
this.text.clear();
})
layout.addWidget(this.label_text, 0, 0);
layout.addWidget(reset_btn, 0, 1);
layout.addWidget(this.text, 1, 0);
// this.run_command("ls", ["-l"]);
}
compile(command: string, params?: string[], dir?: string) {
var array_params = [];
if (params == undefined) {
this.text.insertPlainText('\n$ ' + command + '\n');
// console.log('$ ' + command + '\n');
} else {
var res = '';
for (var i = 0; i < params.length; i++) {
if (params[i] != '') {
res = res.concat(params[i], ' ');
array_params.push(params[i]);
}
}
if (command != "nvcc") {
this.text.insertPlainText('\n$ ' + command + ' ' + res + '\n');
// console.log('$ ' + command + ' ' + res + '\n');
}
}
process.env.EZ_PATH = "/usr/local/easena/"
var child = spawn(command, array_params, {
cwd: dir,
env: process.env
});
// child.stdout.pipe(process.stdout);
// handle error in spawn
child.on('error', function(err) {
new Win_alert('' + err);
return 1;
});
// child.stdout.on('data', (data) => {
// // this.text.insertPlainText(data.toString());
// return 1;
// });
child.stderr.on('data', (data) => {
this.text.insertPlainText(data.toString());
});
// if (child.stderr){
// this.text.insertPlainText(child.stderr + '');
// this.text.insertPlainText("\n");
// }
return child;
}
// run shell command and print stdin & stdout in text
// return child process pid or -1 if an error occurs
run_command(command: string, params?: string[], dir?: string) {
var array_params = [];
if (params == undefined) {
this.text.insertPlainText('\n$ ' + command + '\n');
// console.log('$ ' + command + '\n');
} else {
var res = '';
for (var i = 0; i < params.length; i++) {
if (params[i] != '') {
res = res.concat(params[i], ' ');
array_params.push(params[i]);
}
}
if (command != "nvcc") {
this.text.insertPlainText('\n$ ' + command + ' ' + res + '\n');
// console.log('$ ' + command + ' ' + res + '\n');
}
}
process.env.EZ_PATH = "/usr/local/easena/";
var child = spawnSync(command, array_params, {
cwd: dir,
env: process.env
});
// handle error in spawn
// child.on('error', function(err) {
// var e = new Win_alert('' + err);
// e.execute();
// return 1;
// });
// child.stdout.on('data', (data) => {
// text.insertPlainText(data.toString());
// })
// child.stderr.on('data', (data) => {
// text.insertPlainText(data.toString());
// })
// return 0;
// execute and print result in console
if (command != "nvcc") {
if (child.output) {
this.text.insertPlainText(child.output.join(""));
this.text.insertPlainText("\n");
}
}
// if (child.stderr){
// text.insertPlainText(child.stderr.join());
// text.insertPlainText("\n");
// }
if (child.error) {
console.log("error detected in run_command")
// text.insertPlainText(child.error);
// text.insertPlainText("\n");
return -1;
} else {
return child;
}
}
run(cmd: string, plot_size: number, params?: string, dir?: string, rank?: number) {
var array_params: string[] = [];
if (params == undefined) {
this.text.insertPlainText('\n$ ' + cmd + '\n');
// console.log('$ ' + command + '\n');
} else {
// var res = '';
// for(var i = 0; i < params.length; i++){
// if(params[i] != ''){
// res = res.concat(params[i], ' ');
// array_params.push(params[i]);
// }
// }
array_params = params.split(' ');
this.text.insertPlainText('\n$ ' + cmd + ' ' + params + '\n');
// console.log('$ ' + cmd + ' ' + params + '\n');
}
process.env.EZ_PATH = "/usr/local/easena/"
var child = spawn(cmd, array_params, {
cwd: dir,
env: process.env
});
child.on('error', function(err) {
var type = err.toString().split(" ");
if (type[type.length - 1] === "ENOENT") {
var message = '\nExecution impossible try to recompile';
if (rank !== undefined) {
new Win_alert(err + message, 'Process ' + rank);
} else {
new Win_alert(err + message);
}
} else {
new Win_alert(err + '');
}
running_proc.length = 0;
running_plot.length = 0;
return -1;
});
child.stdout.on('data', (data) => {
if (child.pid === initial_proc.pid)
this.text.insertPlainText(data.toString());
run_obj.running_label.setText('Writing results ...');
run_obj.running_label.show();
plot_generation.parser(data);
// run_obj.running_label.setText('Plotting results ...');
// run_obj.running_label.show();
// plot_obj.update_plot(process.cwd() + '/' + plot_generation.data_csv);
// console.log(process.cwd() + '/' + plot_generation.data_csv);
});
// child.stderr.on('data', (data) => {
// this.text.insertPlainText(data.toString());
// });
child.on('exit', (code, signal) => {
const index = running_proc.indexOf(child, 0);
if (index > -1) {
if (running_proc.length === 1) {
running_proc.pop();
} else {
running_proc.splice(index, 1);
}
}
run_obj.progress_bar.setValue(run_obj.progress_bar.value() + (100 / (2 * run_obj.batch_size)));
if (code !== 0)
return;
run_obj.running_label.setText('