From: Renaud Barate Date: Tue, 7 Oct 2014 09:46:35 +0000 (+0200) Subject: Add possibility to keep default values for memory and time requirements X-Git-Tag: V7_5_0a1^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3ffbf6ddd698a202e55618100d14debd51b24187;p=modules%2Fjobmanager.git Add possibility to keep default values for memory and time requirements --- diff --git a/src/engine/BL_Job.hxx b/src/engine/BL_Job.hxx index 510ee1c..646949a 100644 --- a/src/engine/BL_Job.hxx +++ b/src/engine/BL_Job.hxx @@ -62,7 +62,7 @@ namespace BL{ { std::string batch_directory; std::string maximum_duration; - unsigned long mem_limit; + long mem_limit; MemReqType mem_req_type; int nb_proc; bool exclusive; diff --git a/src/genericgui/BL_CreateJobWizard.cxx b/src/genericgui/BL_CreateJobWizard.cxx index 2fe128e..353704b 100644 --- a/src/genericgui/BL_CreateJobWizard.cxx +++ b/src/genericgui/BL_CreateJobWizard.cxx @@ -171,11 +171,13 @@ BL::CreateJobWizard::clone(const std::string & name) if (batch_params.maximum_duration == "") { + setField("default_time", true); setField("duration_hour", 0); setField("duration_min", 0); } else { + setField("user_time", true); std::size_t pos = batch_params.maximum_duration.find(":"); std::string hour_str = batch_params.maximum_duration.substr(0, pos); int hour; @@ -190,18 +192,26 @@ BL::CreateJobWizard::clone(const std::string & name) setField("duration_min", min); } - unsigned long long mem_mb = batch_params.mem_limit; - if (mem_mb % 1024 == 0) + long long mem_mb = batch_params.mem_limit; + if (mem_mb < 1) { - setField("mem_value", mem_mb / 1024); - _batch_parameters_page->setMemUnit(BatchParametersPage::GB); + setField("default_mem", true); } else { - setField("mem_value", mem_mb); - _batch_parameters_page->setMemUnit(BatchParametersPage::MB); + setField("user_mem", true); + if (mem_mb % 1024 == 0) + { + setField("mem_value", mem_mb / 1024); + _batch_parameters_page->setMemUnit(BatchParametersPage::GB); + } + else + { + setField("mem_value", mem_mb); + _batch_parameters_page->setMemUnit(BatchParametersPage::MB); + } + _batch_parameters_page->setMemReqType(batch_params.mem_req_type); } - _batch_parameters_page->setMemReqType(batch_params.mem_req_type); BL::Job::FilesParam files_params = job->getFilesParameters(); @@ -275,7 +285,8 @@ BL::CreateJobWizard::end(int result) QString time_hour; QString time_min; - if(field("duration_hour").toInt() == 0 && field("duration_min").toInt() == 0) + if (field("default_time").toBool() || + (field("duration_hour").toInt() == 0 && field("duration_min").toInt() == 0)) { maximum_duration = ""; } @@ -292,20 +303,27 @@ BL::CreateJobWizard::end(int result) maximum_duration = time_hour.toStdString() + ":" + time_min.toStdString(); } - unsigned long mem = field("mem_value").toULongLong(); - BatchParametersPage::MemUnit mem_unit = _batch_parameters_page->getMemUnit(); - switch (mem_unit) + if(field("default_mem").toBool()) { - case BatchParametersPage::MB: - mem_limit = mem; - break; - case BatchParametersPage::GB: - mem_limit = mem * 1024; - break; - default: - throw Exception("Invalid memory unit"); + mem_limit = -1; + } + else + { + unsigned long mem = field("mem_value").toULongLong(); + BatchParametersPage::MemUnit mem_unit = _batch_parameters_page->getMemUnit(); + switch (mem_unit) + { + case BatchParametersPage::MB: + mem_limit = mem; + break; + case BatchParametersPage::GB: + mem_limit = mem * 1024; + break; + default: + throw Exception("Invalid memory unit"); + } + mem_req_type = _batch_parameters_page->getMemReqType(); } - mem_req_type = _batch_parameters_page->getMemReqType(); nb_proc = field("proc_value").toInt(); exclusive = field("exclusive").toBool(); @@ -678,6 +696,10 @@ BatchParametersPage::BatchParametersPage(QWidget * parent, SALOMEServices * salo registerField("mem_value", ui->spin_memory); registerField("proc_value", ui->spin_proc); registerField("exclusive", ui->check_exclusive); + registerField("default_time", ui->rb_default_time); + registerField("user_time", ui->rb_user_time); + registerField("default_mem", ui->rb_default_mem); + registerField("user_mem", ui->rb_user_mem); ui->combo_memory_unit->insertItem(ui->combo_memory_unit->count(), "MB", MB); ui->combo_memory_unit->insertItem(ui->combo_memory_unit->count(), "GB", GB); @@ -687,6 +709,12 @@ BatchParametersPage::BatchParametersPage(QWidget * parent, SALOMEServices * salo "per node", Job::MEM_PER_NODE); ui->combo_memory_req_type->insertItem(ui->combo_memory_req_type->count(), "per core", Job::MEM_PER_CPU); + + connect(ui->spin_duration_hour, SIGNAL(valueChanged(int)), this, SLOT(timeChanged())); + connect(ui->spin_duration_min, SIGNAL(valueChanged(int)), this, SLOT(timeChanged())); + connect(ui->spin_memory, SIGNAL(valueChanged(int)), this, SLOT(memChanged())); + connect(ui->combo_memory_unit, SIGNAL(currentIndexChanged(int)), this, SLOT(memChanged())); + connect(ui->combo_memory_req_type, SIGNAL(currentIndexChanged(int)), this, SLOT(memChanged())); }; BatchParametersPage::~BatchParametersPage() @@ -741,6 +769,21 @@ BatchParametersPage::setMemReqType(Job::MemReqType mem_req_type) ui->combo_memory_req_type->setCurrentIndex(ui->combo_memory_req_type->findData(mem_req_type)); } +void +BatchParametersPage::timeChanged() +{ + if (ui->spin_duration_hour->value() == 0 && ui->spin_duration_min->value() == 0) + ui->rb_default_time->setChecked(true); + else + ui->rb_user_time->setChecked(true); +} + +void +BatchParametersPage::memChanged() +{ + ui->rb_user_mem->setChecked(true); +} + void BatchParametersPage::cleanupPage() { diff --git a/src/genericgui/BL_CreateJobWizard.hxx b/src/genericgui/BL_CreateJobWizard.hxx index d5c004a..757f219 100644 --- a/src/genericgui/BL_CreateJobWizard.hxx +++ b/src/genericgui/BL_CreateJobWizard.hxx @@ -80,7 +80,7 @@ namespace BL{ std::string coorm_batch_directory; std::string maximum_duration; - unsigned long mem_limit; + long mem_limit; BL::Job::MemReqType mem_req_type; int nb_proc; bool exclusive; @@ -173,6 +173,10 @@ namespace BL{ BL::Job::MemReqType getMemReqType() const; void setMemReqType(BL::Job::MemReqType mem_req_type); + public slots: + void timeChanged(); + void memChanged(); + private: Ui::ResourceRequirementsWizardPage * ui; BL::SALOMEServices * _salome_services; diff --git a/src/genericgui/BL_JobTab.cxx b/src/genericgui/BL_JobTab.cxx index bd44f39..7b673ef 100644 --- a/src/genericgui/BL_JobTab.cxx +++ b/src/genericgui/BL_JobTab.cxx @@ -100,8 +100,8 @@ BL::JobTab::createJobSummaryTab() QLabel * job_mdt_label = new QLabel("Maximum duration:"); _job_mdt_label_value = new QLabel(""); - QLabel * job_em_label = new QLabel("Expected memory:"); - _job_em_label_value = new QLabel(""); + QLabel * job_req_mem_label = new QLabel("Required memory:"); + _job_req_mem_label_value = new QLabel(""); QLabel * job_nop_label = new QLabel("Number of processors:"); _job_nop_label_value = new QLabel(""); QLabel * job_excl_label = new QLabel("Exclusive:"); @@ -131,7 +131,7 @@ BL::JobTab::createJobSummaryTab() _other_run_values_form = new QFormLayout; _other_run_values_form->insertRow(0, job_mdt_label, _job_mdt_label_value); - _other_run_values_form->insertRow(1, job_em_label, _job_em_label_value); + _other_run_values_form->insertRow(1, job_req_mem_label, _job_req_mem_label_value); _other_run_values_form->insertRow(2, job_nop_label, _job_nop_label_value); _other_run_values_form->insertRow(3, job_excl_label, _job_excl_label_value); @@ -235,30 +235,37 @@ BL::JobTab::job_selected(const QModelIndex & index) _job_bd_label_value->setText(QString::fromUtf8(batch_params.batch_directory.c_str())); _job_rd_label_value->setText(QString::fromUtf8(files_params.result_directory.c_str())); - _job_mdt_label_value->setText(QString(batch_params.maximum_duration.c_str())); + QString time = (batch_params.maximum_duration == "")? "Default" : + batch_params.maximum_duration.c_str(); + _job_mdt_label_value->setText(time); _job_nop_label_value->setText(QVariant(batch_params.nb_proc).toString()); QString exclText = (batch_params.exclusive)? "yes" : "no"; _job_excl_label_value->setText(exclText); // Memory requirement - unsigned long long mem_mb = batch_params.mem_limit; + long mem_mb = batch_params.mem_limit; ostringstream mem_ss; - if (mem_mb % 1024 == 0) - mem_ss << mem_mb / 1024 << "GB"; + if (mem_mb < 1) + mem_ss << "Default"; else - mem_ss << mem_mb << "MB"; - switch (batch_params.mem_req_type) { - case BL::Job::MEM_PER_NODE: - mem_ss << " per node"; - break; - case BL::Job::MEM_PER_CPU: - mem_ss << " per core"; - break; - default: - throw Exception("Unknown memory requirement, unable to show selected job"); + if (mem_mb % 1024 == 0) + mem_ss << mem_mb / 1024 << "GB"; + else + mem_ss << mem_mb << "MB"; + switch (batch_params.mem_req_type) + { + case BL::Job::MEM_PER_NODE: + mem_ss << " per node"; + break; + case BL::Job::MEM_PER_CPU: + mem_ss << " per core"; + break; + default: + throw Exception("Unknown memory requirement, unable to show selected job"); + } } - _job_em_label_value->setText(QString(mem_ss.str().c_str())); + _job_req_mem_label_value->setText(QString(mem_ss.str().c_str())); // Parameters for COORM _job_lf_label_value->setText(QString::fromUtf8(batch_params.launcher_file.c_str())); @@ -346,7 +353,7 @@ BL::JobTab::reset(QString job_name) _job_bd_label_value->setText(""); _job_rd_label_value->setText(""); _job_mdt_label_value->setText(""); - _job_em_label_value->setText(""); + _job_req_mem_label_value->setText(""); _job_nop_label_value->setText(""); _job_excl_label_value->setText(""); _job_jobfile_label_value->setText(""); diff --git a/src/genericgui/BL_JobTab.hxx b/src/genericgui/BL_JobTab.hxx index bc953e0..10a3e22 100644 --- a/src/genericgui/BL_JobTab.hxx +++ b/src/genericgui/BL_JobTab.hxx @@ -70,7 +70,7 @@ namespace BL QLabel * _job_bd_label_value; QLabel * _job_rd_label_value; QLabel * _job_mdt_label_value; - QLabel * _job_em_label_value; + QLabel * _job_req_mem_label_value; QLabel * _job_nop_label_value; QLabel * _job_excl_label_value; diff --git a/src/genericgui/ResourceRequirementsWizardPage.ui b/src/genericgui/ResourceRequirementsWizardPage.ui index 051be21..e25a98f 100644 --- a/src/genericgui/ResourceRequirementsWizardPage.ui +++ b/src/genericgui/ResourceRequirementsWizardPage.ui @@ -90,10 +90,7 @@ - - - false - + Default @@ -105,7 +102,7 @@ - + @@ -210,13 +207,13 @@ - - - false - + Default + + true + memoryButtonGroup @@ -225,13 +222,10 @@ - + - - true - memoryButtonGroup