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_em_label = new QLabel("Expected memory:");
104 _job_em_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_em_label, _job_em_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().toStdString());
195 _job_name_label_value->setText(QString(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(job->getJobFile().c_str()));
218 _job_envfile_label_value->setText(QString(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(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(batch_params.batch_directory.c_str()));
236 _job_rd_label_value->setText(QString(files_params.result_directory.c_str()));
238 _job_mdt_label_value->setText(QString(batch_params.maximum_duration.c_str()));
239 _job_nop_label_value->setText(QVariant(batch_params.nb_proc).toString());
240 QString exclText = (batch_params.exclusive)? "yes" : "no";
241 _job_excl_label_value->setText(exclText);
243 // Memory requirement
244 unsigned long long mem_mb = batch_params.mem_limit;
245 ostringstream mem_ss;
246 if (mem_mb % 1024 == 0)
247 mem_ss << mem_mb / 1024 << "GB";
249 mem_ss << mem_mb << "MB";
250 switch (batch_params.mem_req_type)
252 case BL::Job::MEM_PER_NODE:
253 mem_ss << " per node";
255 case BL::Job::MEM_PER_CPU:
256 mem_ss << " per core";
259 throw Exception("Unknown memory requirement, unable to show selected job");
261 _job_em_label_value->setText(QString(mem_ss.str().c_str()));
263 // Parameters for COORM
264 _job_lf_label_value->setText(QString(batch_params.launcher_file.c_str()));
265 _job_la_label_value->setText(QString(batch_params.launcher_args.c_str()));
267 _input_files_list->clear();
268 _output_files_list->clear();
269 std::list<std::string>::iterator it;
270 for (it = files_params.input_files_list.begin(); it != files_params.input_files_list.end(); it++)
272 std::string file = *it;
273 _input_files_list->addItem(QString(file.c_str()));
275 for (it = files_params.output_files_list.begin(); it != files_params.output_files_list.end(); it++)
277 std::string file = *it;
278 _output_files_list->addItem(QString(file.c_str()));
281 // Specific parameters management
282 if (job->getDumpYACSState() > 0)
284 // Add widget in the layout
285 _yacs_dump_state_value->setText(QVariant(job->getDumpYACSState()).toString());
286 _main_values_form->insertRow(7, _yacs_dump_state_label, _yacs_dump_state_value);
288 if (job->getBatchQueue() != "")
290 _batch_queue_value->setText(QVariant(job->getBatchQueue().c_str()).toString());
291 _other_run_values_form->insertRow(_other_run_values_form->rowCount(), _batch_queue_label, _batch_queue_value);
293 if (job->getLoadLevelerJobType() != "")
295 _ll_jobtype_value->setText(QVariant(job->getLoadLevelerJobType().c_str()).toString());
296 _other_run_values_form->insertRow(_other_run_values_form->rowCount(), _ll_jobtype_label, _ll_jobtype_value);
300 DEBTRACE ("itemFromIndex returns 0 !");
304 BL::JobTab::itemChanged(QStandardItem * item)
306 DEBTRACE("BL::JobTab::itemChanged slot");
308 QStandardItem * item_name = _model->item(item->row());
309 BL::Job * job = _jobs_manager->getJob(item_name->text().toStdString());
311 if (_job_name_label_value->text() == QString(job->getName().c_str()))
313 if (job->getState() == BL::Job::CREATED)
314 _job_state_label_value->setText("Created");
315 else if (job->getState() == BL::Job::IN_PROCESS)
316 _job_state_label_value->setText("In Process");
317 else if (job->getState() == BL::Job::QUEUED)
318 _job_state_label_value->setText("Queued");
319 else if (job->getState() == BL::Job::RUNNING)
320 _job_state_label_value->setText("Running");
321 else if (job->getState() == BL::Job::PAUSED)
322 _job_state_label_value->setText("Paused");
323 else if (job->getState() == BL::Job::ERROR)
324 _job_state_label_value->setText("Error");
325 else if (job->getState() == BL::Job::FAILED)
326 _job_state_label_value->setText("Failed");
327 else if (job->getState() == BL::Job::NOT_CREATED)
328 _job_state_label_value->setText("Not Created");
330 _job_state_label_value->setText("Finished");
335 BL::JobTab::reset(QString job_name)
337 if (job_name == _job_name_label_value->text() || job_name == "")
339 _job_name_label_value->setText("");
340 _job_type_label_value->setText("");
341 _job_state_label_value->setText("");
342 _job_launcher_label_value->setText("");
343 _job_resource_label_value->setText("");
344 _job_nif_label_value->setText("");
345 _job_nof_label_value->setText("");
346 _job_bd_label_value->setText("");
347 _job_rd_label_value->setText("");
348 _job_mdt_label_value->setText("");
349 _job_em_label_value->setText("");
350 _job_nop_label_value->setText("");
351 _job_excl_label_value->setText("");
352 _job_jobfile_label_value->setText("");
353 _job_envfile_label_value->setText("");
355 _input_files_list->clear();
356 _output_files_list->clear();
358 _yacs_dump_state_value->setText("");
359 _batch_queue_value->setText("");
360 _ll_jobtype_value->setText("");
362 // Parameters for COORM
363 _job_lf_label_value->setText("");
364 _job_la_label_value->setText("");