1 // Copyright (C) 2009-2014 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "BL_JobTab.hxx"
21 #include "BL_Traces.hxx"
29 BL::JobTab::JobTab(QWidget *parent, BL::JobsManager_QT * jobs_manager) : QTabWidget(parent)
31 DEBTRACE("Creating BL::JobTab");
33 BL_ASSERT(jobs_manager);
35 _jobs_manager = jobs_manager;
38 createJobSummaryTab();
44 DEBTRACE("Destroying BL::JobTab");
48 BL::JobTab::setModel(QStandardItemModel * model)
50 DEBTRACE("Call setModel BL::JobTab");
57 BL::JobTab::createJobSummaryTab()
59 _summary_tab = new QWidget(this);
61 QLabel * job_name_label = new QLabel("Name:");
62 _job_name_label_value = new QLabel("");
63 QLabel * job_type_label = new QLabel("Type:");
64 _job_type_label_value = new QLabel("");
65 QLabel * job_state_label = new QLabel("State:");
66 _job_state_label_value = new QLabel("");
67 QLabel * job_launcher_label = new QLabel("Launcher Id:");
68 _job_launcher_label_value = new QLabel("");
69 QLabel * job_resource_label = new QLabel("Resource:");
70 _job_resource_label_value = new QLabel("");
71 QLabel * job_jobfile_label = new QLabel("Job File:");
72 _job_jobfile_label_value = new QLabel("");
73 QLabel * job_envfile_label = new QLabel("Env File:");
74 _job_envfile_label_value = new QLabel("");
78 _yacs_dump_state_label = new QLabel("YACS dump state:");
79 _yacs_dump_state_value = new QLabel("");
81 QGroupBox * main_values_box = new QGroupBox("Main values");
82 _main_values_form = new QFormLayout;
83 _main_values_form->insertRow(0, job_name_label, _job_name_label_value);
84 _main_values_form->insertRow(1, job_type_label, _job_type_label_value);
85 _main_values_form->insertRow(2, job_state_label, _job_state_label_value);
86 _main_values_form->insertRow(3, job_launcher_label, _job_launcher_label_value);
87 _main_values_form->insertRow(4, job_resource_label, _job_resource_label_value);
88 _main_values_form->insertRow(5, job_jobfile_label, _job_jobfile_label_value);
89 _main_values_form->insertRow(6, job_envfile_label, _job_envfile_label_value);
90 main_values_box->setLayout(_main_values_form);
92 QLabel * job_nif_label = new QLabel("Number of Input Files:");
93 _job_nif_label_value = new QLabel("");
94 QLabel * job_nof_label = new QLabel("Number of Output Files:");
95 _job_nof_label_value = new QLabel("");
96 QLabel * job_bd_label = new QLabel("Execution directory:");
97 _job_bd_label_value = new QLabel("");
98 QLabel * job_rd_label = new QLabel("Result directory:");
99 _job_rd_label_value = new QLabel("");
101 QLabel * job_mdt_label = new QLabel("Maximum duration:");
102 _job_mdt_label_value = new QLabel("");
103 QLabel * job_req_mem_label = new QLabel("Required memory:");
104 _job_req_mem_label_value = new QLabel("");
105 QLabel * job_nop_label = new QLabel("Number of processors:");
106 _job_nop_label_value = new QLabel("");
107 QLabel * job_excl_label = new QLabel("Exclusive:");
108 _job_excl_label_value = new QLabel("");
110 // Parameters for COORM
111 QLabel * job_lf_label = new QLabel("Launcher file:");
112 _job_lf_label_value = new QLabel("");
113 QLabel * job_la_label = new QLabel("Launcher args:");
114 _job_la_label_value = new QLabel("");
117 _batch_queue_label = new QLabel("Batch queue:");
118 _batch_queue_value = new QLabel("");
119 _ll_jobtype_label = new QLabel("LoadLeveler JobType:");
120 _ll_jobtype_value = new QLabel("");
122 QGroupBox * run_values_box = new QGroupBox("Run values");
123 _run_values_form = new QFormLayout;
124 _run_values_form->insertRow(0, job_nif_label, _job_nif_label_value);
125 _run_values_form->insertRow(1, job_nof_label, _job_nof_label_value);
126 _run_values_form->insertRow(2, job_bd_label, _job_bd_label_value);
127 _run_values_form->insertRow(3, job_rd_label, _job_rd_label_value);
129 // Parameters for COORM
130 _run_values_form->insertRow(4, job_lf_label, _job_lf_label_value);
132 _other_run_values_form = new QFormLayout;
133 _other_run_values_form->insertRow(0, job_mdt_label, _job_mdt_label_value);
134 _other_run_values_form->insertRow(1, job_req_mem_label, _job_req_mem_label_value);
135 _other_run_values_form->insertRow(2, job_nop_label, _job_nop_label_value);
136 _other_run_values_form->insertRow(3, job_excl_label, _job_excl_label_value);
138 // Parameters for COORM
139 _other_run_values_form->insertRow(4, job_la_label, _job_la_label_value);
141 QHBoxLayout * box_layout = new QHBoxLayout();
142 box_layout->addLayout(_run_values_form);
143 box_layout->addLayout(_other_run_values_form);
144 run_values_box->setLayout(box_layout);
146 QVBoxLayout * mainLayout = new QVBoxLayout();
147 mainLayout->addWidget(main_values_box);
148 mainLayout->addWidget(run_values_box);
149 _summary_tab->setLayout(mainLayout);
152 insertTab(0, _summary_tab, "Job Summary");
157 BL::JobTab::createJobFilesTab()
159 _files_tab = new QWidget(this);
161 _input_files_list = new QListWidget(this);
162 _input_files_list->setSelectionMode(QAbstractItemView::NoSelection);
163 QGroupBox * input_files_box = new QGroupBox("Input Files");
164 QVBoxLayout * input_layout = new QVBoxLayout();
165 input_layout->addWidget(_input_files_list);
166 input_files_box->setLayout(input_layout);
168 _output_files_list = new QListWidget(this);
169 _output_files_list->setSelectionMode(QAbstractItemView::NoSelection);
170 QGroupBox * output_files_box = new QGroupBox("Output Files");
171 QVBoxLayout * output_layout = new QVBoxLayout();
172 output_layout->addWidget(_output_files_list);
173 output_files_box->setLayout(output_layout);
175 QVBoxLayout * mainLayout = new QVBoxLayout();
176 mainLayout->addWidget(input_files_box);
177 mainLayout->addWidget(output_files_box);
178 _files_tab->setLayout(mainLayout);
180 insertTab(1, _files_tab, "Job Files");
184 BL::JobTab::job_selected(const QModelIndex & index)
186 DEBTRACE("BL::JobTab::job_selected slot");
187 QStandardItem * item = _model->itemFromIndex(index);
188 QStandardItem * item_name = _model->item(item->row());
191 BL::Job * job = _jobs_manager->getJob(item_name->text().toUtf8().constData());
195 _job_name_label_value->setText(QString::fromUtf8(job->getName().c_str()));
197 if (job->getState() == BL::Job::CREATED)
198 _job_state_label_value->setText("Created");
199 else if (job->getState() == BL::Job::IN_PROCESS)
200 _job_state_label_value->setText("In Process");
201 else if (job->getState() == BL::Job::QUEUED)
202 _job_state_label_value->setText("Queued");
203 else if (job->getState() == BL::Job::RUNNING)
204 _job_state_label_value->setText("Running");
205 else if (job->getState() == BL::Job::PAUSED)
206 _job_state_label_value->setText("Paused");
207 else if (job->getState() == BL::Job::ERROR)
208 _job_state_label_value->setText("Error");
209 else if (job->getState() == BL::Job::FAILED)
210 _job_state_label_value->setText("Failed");
211 else if (job->getState() == BL::Job::NOT_CREATED)
212 _job_state_label_value->setText("Not Created");
214 _job_state_label_value->setText("Finished");
216 _job_launcher_label_value->setText(QVariant(job->getSalomeLauncherId()).toString());
217 _job_jobfile_label_value->setText(QString::fromUtf8(job->getJobFile().c_str()));
218 _job_envfile_label_value->setText(QString::fromUtf8(job->getEnvFile().c_str()));
219 if (job->getType() == BL::Job::YACS_SCHEMA)
220 _job_type_label_value->setText("YACS_Schema");
221 else if (job->getType() == BL::Job::COMMAND)
222 _job_type_label_value->setText("Command");
223 else if (job->getType() == BL::Job::PYTHON_SALOME)
224 _job_type_label_value->setText("Python_Salome");
226 _job_resource_label_value->setText(QString::fromUtf8(job->getResource().c_str()));
228 BL::Job::BatchParam batch_params = job->getBatchParameters();
230 BL::Job::FilesParam files_params = job->getFilesParameters();
231 int nif = files_params.input_files_list.size();
232 _job_nif_label_value->setText(QVariant(nif).toString());
233 int nof = files_params.output_files_list.size();
234 _job_nof_label_value->setText(QVariant(nof).toString());
235 _job_bd_label_value->setText(QString::fromUtf8(batch_params.batch_directory.c_str()));
236 _job_rd_label_value->setText(QString::fromUtf8(files_params.result_directory.c_str()));
238 QString time = (batch_params.maximum_duration == "")? "Default" :
239 batch_params.maximum_duration.c_str();
240 _job_mdt_label_value->setText(time);
241 _job_nop_label_value->setText(QVariant(batch_params.nb_proc).toString());
242 QString exclText = (batch_params.exclusive)? "yes" : "no";
243 _job_excl_label_value->setText(exclText);
245 // Memory requirement
246 long mem_mb = batch_params.mem_limit;
247 ostringstream mem_ss;
252 if (mem_mb % 1024 == 0)
253 mem_ss << mem_mb / 1024 << "GB";
255 mem_ss << mem_mb << "MB";
256 switch (batch_params.mem_req_type)
258 case BL::Job::MEM_PER_NODE:
259 mem_ss << " per node";
261 case BL::Job::MEM_PER_CPU:
262 mem_ss << " per core";
265 throw Exception("Unknown memory requirement, unable to show selected job");
268 _job_req_mem_label_value->setText(QString(mem_ss.str().c_str()));
270 // Parameters for COORM
271 _job_lf_label_value->setText(QString::fromUtf8(batch_params.launcher_file.c_str()));
272 _job_la_label_value->setText(QString::fromUtf8(batch_params.launcher_args.c_str()));
274 _input_files_list->clear();
275 _output_files_list->clear();
276 std::list<std::string>::iterator it;
277 for (it = files_params.input_files_list.begin(); it != files_params.input_files_list.end(); it++)
279 std::string file = *it;
280 _input_files_list->addItem(QString::fromUtf8(file.c_str()));
282 for (it = files_params.output_files_list.begin(); it != files_params.output_files_list.end(); it++)
284 std::string file = *it;
285 _output_files_list->addItem(QString::fromUtf8(file.c_str()));
288 // Specific parameters management
289 if (job->getDumpYACSState() > 0)
291 // Add widget in the layout
292 _yacs_dump_state_value->setText(QVariant(job->getDumpYACSState()).toString());
293 _main_values_form->insertRow(7, _yacs_dump_state_label, _yacs_dump_state_value);
295 if (job->getBatchQueue() != "")
297 _batch_queue_value->setText(QVariant(job->getBatchQueue().c_str()).toString());
298 _other_run_values_form->insertRow(_other_run_values_form->rowCount(), _batch_queue_label, _batch_queue_value);
300 if (job->getLoadLevelerJobType() != "")
302 _ll_jobtype_value->setText(QVariant(job->getLoadLevelerJobType().c_str()).toString());
303 _other_run_values_form->insertRow(_other_run_values_form->rowCount(), _ll_jobtype_label, _ll_jobtype_value);
307 DEBTRACE ("itemFromIndex returns 0 !");
311 BL::JobTab::itemChanged(QStandardItem * item)
313 DEBTRACE("BL::JobTab::itemChanged slot");
315 QStandardItem * item_name = _model->item(item->row());
316 BL::Job * job = _jobs_manager->getJob(item_name->text().toUtf8().constData());
318 if (_job_name_label_value->text() == QString::fromUtf8(job->getName().c_str()))
320 if (job->getState() == BL::Job::CREATED)
321 _job_state_label_value->setText("Created");
322 else if (job->getState() == BL::Job::IN_PROCESS)
323 _job_state_label_value->setText("In Process");
324 else if (job->getState() == BL::Job::QUEUED)
325 _job_state_label_value->setText("Queued");
326 else if (job->getState() == BL::Job::RUNNING)
327 _job_state_label_value->setText("Running");
328 else if (job->getState() == BL::Job::PAUSED)
329 _job_state_label_value->setText("Paused");
330 else if (job->getState() == BL::Job::ERROR)
331 _job_state_label_value->setText("Error");
332 else if (job->getState() == BL::Job::FAILED)
333 _job_state_label_value->setText("Failed");
334 else if (job->getState() == BL::Job::NOT_CREATED)
335 _job_state_label_value->setText("Not Created");
337 _job_state_label_value->setText("Finished");
342 BL::JobTab::reset(QString job_name)
344 if (job_name == _job_name_label_value->text() || job_name == "")
346 _job_name_label_value->setText("");
347 _job_type_label_value->setText("");
348 _job_state_label_value->setText("");
349 _job_launcher_label_value->setText("");
350 _job_resource_label_value->setText("");
351 _job_nif_label_value->setText("");
352 _job_nof_label_value->setText("");
353 _job_bd_label_value->setText("");
354 _job_rd_label_value->setText("");
355 _job_mdt_label_value->setText("");
356 _job_req_mem_label_value->setText("");
357 _job_nop_label_value->setText("");
358 _job_excl_label_value->setText("");
359 _job_jobfile_label_value->setText("");
360 _job_envfile_label_value->setText("");
362 _input_files_list->clear();
363 _output_files_list->clear();
365 _yacs_dump_state_value->setText("");
366 _batch_queue_value->setText("");
367 _ll_jobtype_value->setText("");
369 // Parameters for COORM
370 _job_lf_label_value->setText("");
371 _job_la_label_value->setText("");