]> SALOME platform Git repositories - modules/jobmanager.git/commitdiff
Salome HOME
Add possibility to keep default values for memory and time requirements
authorRenaud Barate <renaud.barate@edf.fr>
Tue, 7 Oct 2014 09:46:35 +0000 (11:46 +0200)
committerRenaud Barate <renaud.barate@edf.fr>
Tue, 7 Oct 2014 09:46:35 +0000 (11:46 +0200)
src/engine/BL_Job.hxx
src/genericgui/BL_CreateJobWizard.cxx
src/genericgui/BL_CreateJobWizard.hxx
src/genericgui/BL_JobTab.cxx
src/genericgui/BL_JobTab.hxx
src/genericgui/ResourceRequirementsWizardPage.ui

index 510ee1c1c3555c23f2985fc029df1b65ed8d42aa..646949a550ed7bc3d04ce3b0c54e965292f464eb 100644 (file)
@@ -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;
index 2fe128e23672d00a9709e2e8ab12547cfdf7a10c..353704b2b5bda1fd780abc66fe7157228bd23cdd 100644 (file)
@@ -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()
 {
index d5c004aa0a7c3c1ca28489985d47abc8e2fe128d..757f2193fd0a9a6045833fc58a68620d348a7245 100644 (file)
@@ -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;
index bd44f39546a3bb5e59dd908406f4b0fccdbbeafb..7b673ef41f179796da56649a359f6af684c72d91 100644 (file)
@@ -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("");
index bc953e0257a0fa0e4f5e22244c5d0f0a28b63477..10a3e229010d6ce863359adfe7debfd9e496d6c3 100644 (file)
@@ -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;
 
index 051be21e4be395a827a7ee6030c067ae0e26fe5e..e25a98f7f25883e116de51ad4afedbe3ad3ffb8e 100644 (file)
       <item>
        <layout class="QVBoxLayout" name="verticalLayout_2">
         <item>
-         <widget class="QRadioButton" name="radioButton">
-          <property name="enabled">
-           <bool>false</bool>
-          </property>
+         <widget class="QRadioButton" name="rb_default_time">
           <property name="text">
            <string>Default</string>
           </property>
         <item>
          <layout class="QHBoxLayout" name="horizontalLayout_2">
           <item>
-           <widget class="QRadioButton" name="radioButton_2">
+           <widget class="QRadioButton" name="rb_user_time">
             <property name="text">
              <string/>
             </property>
       <item>
        <layout class="QVBoxLayout" name="verticalLayout_4">
         <item>
-         <widget class="QRadioButton" name="radioButton_3">
-          <property name="enabled">
-           <bool>false</bool>
-          </property>
+         <widget class="QRadioButton" name="rb_default_mem">
           <property name="text">
            <string>Default</string>
           </property>
+          <property name="checked">
+           <bool>true</bool>
+          </property>
           <attribute name="buttonGroup">
            <string notr="true">memoryButtonGroup</string>
           </attribute>
         <item>
          <layout class="QHBoxLayout" name="horizontalLayout_4">
           <item>
-           <widget class="QRadioButton" name="radioButton_4">
+           <widget class="QRadioButton" name="rb_user_mem">
             <property name="text">
              <string/>
             </property>
-            <property name="checked">
-             <bool>true</bool>
-            </property>
             <attribute name="buttonGroup">
              <string notr="true">memoryButtonGroup</string>
             </attribute>