From: barate Date: Wed, 3 Apr 2013 08:52:40 +0000 (+0000) Subject: Integrate developments from N. Toukourou at INRIA (OAR and CooRM support) X-Git-Tag: V7_2_0~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f7004ae8bd78104ea3649c580e82d5cea97f5ee5;p=modules%2Fjobmanager.git Integrate developments from N. Toukourou at INRIA (OAR and CooRM support) --- diff --git a/src/engine/BL_Job.cxx b/src/engine/BL_Job.cxx index 231ee19..b179ba6 100644 --- a/src/engine/BL_Job.cxx +++ b/src/engine/BL_Job.cxx @@ -37,6 +37,10 @@ BL::Job::Job() _salome_launcher_id = -1; _dump_yacs_state = 0; _ll_jobtype = ""; + + // Parameters for COORM + _batch_params.launcher_file = ""; + _batch_params.launcher_args = ""; } BL::Job::Job(const std::string & name) @@ -57,6 +61,10 @@ BL::Job::Job(const std::string & name) _salome_launcher_id = -1; _dump_yacs_state = 0; _ll_jobtype = ""; + + // Parameters for COORM + _batch_params.launcher_file = ""; + _batch_params.launcher_args = ""; } BL::Job::~Job() @@ -146,6 +154,10 @@ BL::Job::setBatchParameters(BL::Job::BatchParam & param) _batch_params.maximum_duration = param.maximum_duration; _batch_params.expected_memory = param.expected_memory; _batch_params.nb_proc = param.nb_proc; + + // Parameters for COORM + _batch_params.launcher_file = param.launcher_file; + _batch_params.launcher_args = param.launcher_args; } BL::Job::BatchParam & diff --git a/src/engine/BL_Job.hxx b/src/engine/BL_Job.hxx index cb3af3a..576ee8c 100644 --- a/src/engine/BL_Job.hxx +++ b/src/engine/BL_Job.hxx @@ -62,6 +62,10 @@ namespace BL{ std::string maximum_duration; std::string expected_memory; int nb_proc; + + // Parameters for COORM + std::string launcher_file; + std::string launcher_args; }; void setBatchParameters(BL::Job::BatchParam & param); BL::Job::BatchParam & getBatchParameters(); diff --git a/src/engine/BL_JobsManager.cxx b/src/engine/BL_JobsManager.cxx index eeb9e2f..9a7ab78 100644 --- a/src/engine/BL_JobsManager.cxx +++ b/src/engine/BL_JobsManager.cxx @@ -297,7 +297,20 @@ BL::JobsManager::refresh_jobs_thread(void * object_ptr) else if (result_job != "") { if (object->_observer) + { object->_observer->sendEvent("refresh_job", "Ok", job->getName(), result_job); + + // get assigned hostnames when the job will start + if (result_job == "RUNNING") + { + std::string assigned_hostnames = object->_salome_services->get_assigned_hostnames(job); + if (assigned_hostnames != "") + { + // sent event "get_assigned_hostnames" + object->_observer->sendEvent("get_assigned_hostnames", "Ok", job->getName(), assigned_hostnames); + } + } + } } } } diff --git a/src/engine/BL_SALOMEServices.cxx b/src/engine/BL_SALOMEServices.cxx index 3c97ee6..f237f44 100644 --- a/src/engine/BL_SALOMEServices.cxx +++ b/src/engine/BL_SALOMEServices.cxx @@ -331,6 +331,10 @@ BL::SALOMEServices::create_job(BL::Job * job) memory = memory * 1024; job_parameters->resource_required.mem_mb = memory; + // Parameters for COORM + job_parameters->launcher_file = CORBA::string_dup(cpp_batch_params.launcher_file.c_str()); + job_parameters->launcher_args = CORBA::string_dup(cpp_batch_params.launcher_args.c_str()); + // Create Job try { @@ -471,6 +475,31 @@ BL::SALOMEServices::get_results_job(BL::Job * job) return ret; } +// Get names or ids of hosts assigned to the job +std::string +BL::SALOMEServices::get_assigned_hostnames(BL::Job * job) +{ + std::string ret = ""; + + try + { + CORBA::String_var result = _salome_launcher->getAssignedHostnames(job->getSalomeLauncherId()); + ret = result.in(); + } + catch (const SALOME::SALOME_Exception & ex) + { + DEBMSG("SALOME Exception in get_assigned_hostnames !"); + ret = ex.details.text.in(); + } + catch (const CORBA::SystemException& ex) + { + DEBMSG("Receive SALOME System Exception: " << ex); + DEBMSG("Check SALOME servers..."); + ret = "SALOME System Exception - see logs"; + } + return ret; +} + std::string BL::SALOMEServices::save_jobs(const std::string & file_name) { @@ -597,6 +626,11 @@ BL::SALOMEServices::get_new_job(int job_number) std::ostringstream mem_stream; mem_stream << job_parameters->resource_required.mem_mb << "mb"; batch_param.expected_memory = mem_stream.str(); + + // Parameters for COORM + batch_param.launcher_file = job_parameters->launcher_file.in(); + batch_param.launcher_args = job_parameters->launcher_args.in(); + job_return->setBatchParameters(batch_param); job_return->setResource(job_parameters->resource_required.name.in()); diff --git a/src/engine/BL_SALOMEServices.hxx b/src/engine/BL_SALOMEServices.hxx index 4dbb8ed..66995bb 100644 --- a/src/engine/BL_SALOMEServices.hxx +++ b/src/engine/BL_SALOMEServices.hxx @@ -89,6 +89,7 @@ namespace BL{ std::string delete_job(BL::Job * job); std::string stop_job(BL::Job * job); std::string get_results_job(BL::Job * job); + std::string get_assigned_hostnames(BL::Job * job); // Get names or ids of hosts assigned to the job BL::Job * get_new_job(int job_number); diff --git a/src/genericgui/BL_CreateJobWizard.cxx b/src/genericgui/BL_CreateJobWizard.cxx index 84df31c..a065efb 100644 --- a/src/genericgui/BL_CreateJobWizard.cxx +++ b/src/genericgui/BL_CreateJobWizard.cxx @@ -45,10 +45,18 @@ BL::CreateJobWizard::CreateJobWizard(BL::JobsManager_QT * jobs_manager, BL::SALO python_salome_file = ""; env_file = ""; batch_directory = ""; + + // For COORM + coorm_batch_directory = ""; + maximum_duration = ""; expected_memory = ""; nb_proc = 1; + // Parameters for COORM + launcher_file = ""; + launcher_args = ""; + result_directory = ""; resource_choosed = ""; @@ -65,6 +73,10 @@ BL::CreateJobWizard::CreateJobWizard(BL::JobsManager_QT * jobs_manager, BL::SALO setPage(Page_JobName, _job_name_page); setPage(Page_BatchParameters, new BL::BatchParametersPage(this, salome_services)); + + // For COORM + setPage(Page_COORM_BatchParameters, new BL::COORM_BatchParametersPage(this, salome_services)); + setPage(Page_Files, new BL::FilesPage(this)); setPage(Page_Resource, new BL::ResourcePage(this, salome_services)); setPage(Page_Conclusion, new BL::ConclusionPage(this)); @@ -125,8 +137,22 @@ BL::CreateJobWizard::clone(const std::string & name) setField("env_PythonSalome_file", QString(job->getEnvFile().c_str())); } + + // For COORM BL::Job::BatchParam batch_params = job->getBatchParameters(); - setField("batch_directory", QString(batch_params.batch_directory.c_str())); + BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(job->getResource().c_str()); + std::string batch = resource_descr.batch.c_str(); + if (batch == "coorm") + { + setField("coorm_batch_directory", QString(batch_params.batch_directory.c_str())); + setField("launcher_file", QString(batch_params.launcher_file.c_str())); + setField("launcher_args", QString(batch_params.launcher_args.c_str())); + } + else + { + setField("batch_directory", QString(batch_params.batch_directory.c_str())); + } + QString proc_value; proc_value.setNum(batch_params.nb_proc); setField("proc_value", proc_value); @@ -222,6 +248,16 @@ BL::CreateJobWizard::end(int result) QString f_batch_directory = field("batch_directory").toString(); batch_directory = f_batch_directory.toStdString(); + // For COORM + QString f_coorm_batch_directory = field("coorm_batch_directory").toString(); + coorm_batch_directory = f_coorm_batch_directory.toStdString(); + + // For COORM + QString f_launcher_file = field("launcher_file").toString(); + launcher_file = f_launcher_file.toStdString(); + QString f_launcher_args = field("launcher_args").toString(); + launcher_args = f_launcher_args.toStdString(); + QString time_hour; QString time_min; if(field("duration_hour").toInt() == 0 && field("duration_min").toInt() == 0) @@ -721,6 +757,122 @@ BL::BatchParametersPage::nextId() const return BL::CreateJobWizard::Page_Files; } +BL::COORM_BatchParametersPage::COORM_BatchParametersPage(QWidget * parent, BL::SALOMEServices * salome_services) +: QWizardPage(parent) +{ + setTitle("Enter COORM Parameters"); + resource_choosed = ""; + + _salome_services = salome_services; + + QLabel *label = new QLabel("In this step you define the parameters for COORM"); + label->setWordWrap(true); + QVBoxLayout * main_layout = new QVBoxLayout; + main_layout->addWidget(label); + + // coorm_batch_directory + QLabel * label_directory = new QLabel("Remote work directory: "); + QLineEdit * line_directory = new QLineEdit(this); + registerField("coorm_batch_directory", line_directory); + + // launcher_file + QPushButton * launcher_file_button = new QPushButton(tr("Choose a launcher file")); + connect(launcher_file_button, SIGNAL(clicked()), this, SLOT(choose_launcher_file())); + _launcher_file_text = new QLineEdit(this); + _launcher_file_text->setText(""); + registerField("launcher_file", _launcher_file_text); + _launcher_file_text->setReadOnly(true); + + // launcher_args + QLabel * launcher_args_label = new QLabel("Launcher args:"); + QLineEdit * launcher_args_text = new QLineEdit(this); + registerField("launcher_args", launcher_args_text); + + QGridLayout * layout = new QGridLayout; + layout->addWidget(label_directory, 0, 0); + layout->addWidget(line_directory, 0, 1); + layout->addWidget(launcher_file_button, 1, 0); + layout->addWidget(_launcher_file_text, 1, 1); + layout->addWidget(launcher_args_label, 2, 0); + layout->addWidget(launcher_args_text, 2, 1); + + main_layout->insertLayout(-1, layout); + + setLayout(main_layout); +}; + +BL::COORM_BatchParametersPage::~COORM_BatchParametersPage() +{} + +bool +BL::COORM_BatchParametersPage::validatePage() +{ + QString coorm_batch_directory = field("coorm_batch_directory").toString(); + if (coorm_batch_directory == "") + { + QMessageBox::warning(NULL, "Batch Directory Error", "Please enter a batch directory"); + return false; + } + + QString launcher_file = field("launcher_file").toString(); + if (launcher_file == "") + { + QMessageBox::warning(NULL, "Launcher File Error", "Please enter a launcher file"); + return false; + } + + return true; +} + +int +BL::COORM_BatchParametersPage::nextId() const +{ + return BL::CreateJobWizard::Page_Files; +} + +void +BL::COORM_BatchParametersPage::choose_launcher_file() +{ + QString launcher_file = QFileDialog::getOpenFileName(this, + tr("Open launcher files"), "", + tr("Py (*.py);;All Files (*)")); + _launcher_file_text->setReadOnly(false); + _launcher_file_text->setText(launcher_file); + _launcher_file_text->setReadOnly(true); +} + +void BL::COORM_BatchParametersPage::cleanupPage() +{} + +void +BL::COORM_BatchParametersPage::initializePage() +{ + QString f_resource_choosed = field("resource_choosed").toString(); + if (f_resource_choosed != resource_choosed) + { + resource_choosed = f_resource_choosed; + // If choosed resource has a working_directory set + // Generates a default remote working directory + BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(resource_choosed.toStdString()); + QString res_work_dir = resource_descr.working_directory.c_str(); + if (res_work_dir != "") + { + time_t rawtime; + time(&rawtime); + std::string launch_date = ctime(&rawtime); + for (int i = 0; i < launch_date.size(); i++) + if (launch_date[i] == '/' || + launch_date[i] == '-' || + launch_date[i] == ':' || + launch_date[i] == ' ') + launch_date[i] = '_'; + launch_date.erase(--launch_date.end()); // Last caracter is a \n + QString date = launch_date.c_str(); + setField("coorm_batch_directory", res_work_dir + "/" + date); + } + } +} + BL::FilesPage::FilesPage(BL::CreateJobWizard * parent) : QWizardPage(parent) { @@ -989,6 +1141,18 @@ BL::ResourcePage::initializePage() _ll_label->show(); _ll_value->show(); } + + // Initialize resource_choosed with first resource in resource list + if (field("resource_choosed").toString() == "") + { + std::list resource_list = _salome_services->getResourceList(true); + std::list::iterator it = resource_list.begin(); + if (it != resource_list.end()) + { + QString first_resource((*it).c_str()); + setField("resource_choosed", first_resource); + } + } } bool @@ -1044,7 +1208,16 @@ BL::ResourcePage::itemSelected(QListWidgetItem * item) int BL::ResourcePage::nextId() const { - return BL::CreateJobWizard::Page_BatchParameters; + BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(_resource_choosed->text().toStdString()); + std::string batch = resource_descr.batch.c_str(); + if (batch == "coorm") + { + return BL::CreateJobWizard::Page_COORM_BatchParameters; + } + else + { + return BL::CreateJobWizard::Page_BatchParameters; + } } BL::PythonSalomeMainPage::PythonSalomeMainPage(QWidget * parent) diff --git a/src/genericgui/BL_CreateJobWizard.hxx b/src/genericgui/BL_CreateJobWizard.hxx index e34c6d7..a509604 100644 --- a/src/genericgui/BL_CreateJobWizard.hxx +++ b/src/genericgui/BL_CreateJobWizard.hxx @@ -69,10 +69,18 @@ namespace BL{ std::string env_file; std::string batch_directory; - std::string maximum_duration; + + // For COORM + std::string coorm_batch_directory; + + std::string maximum_duration; std::string expected_memory; int nb_proc; + // Parameters for COORM + std::string launcher_file; + std::string launcher_args; + std::string result_directory; std::list input_files_list; std::list output_files_list; @@ -90,6 +98,7 @@ namespace BL{ Page_Command_Main_Definitions, Page_PythonSalome_Main_Definitions, Page_BatchParameters, + Page_COORM_BatchParameters, Page_Files, Page_Resource, Page_Conclusion}; @@ -152,6 +161,29 @@ namespace BL{ QString resource_choosed; }; + // For COORM + class COORM_BatchParametersPage: public QWizardPage + { + Q_OBJECT + + public: + COORM_BatchParametersPage(QWidget * parent, BL::SALOMEServices * salome_services); + virtual ~COORM_BatchParametersPage(); + + virtual bool validatePage(); + virtual int nextId() const; + virtual void cleanupPage(); + virtual void initializePage(); + + public slots: + void choose_launcher_file(); + + private: + BL::SALOMEServices * _salome_services; + QLineEdit * _launcher_file_text; + QString resource_choosed; + }; + class FilesPage: public QWizardPage { Q_OBJECT diff --git a/src/genericgui/BL_JobTab.cxx b/src/genericgui/BL_JobTab.cxx index 75e1b87..7fa6322 100644 --- a/src/genericgui/BL_JobTab.cxx +++ b/src/genericgui/BL_JobTab.cxx @@ -103,6 +103,12 @@ BL::JobTab::createJobSummaryTab() QLabel * job_nop_label = new QLabel("Number of processors:"); _job_nop_label_value = new QLabel(""); + // Parameters for COORM + QLabel * job_lf_label = new QLabel("Launcher file:"); + _job_lf_label_value = new QLabel(""); + QLabel * job_la_label = new QLabel("Launcher args:"); + _job_la_label_value = new QLabel(""); + // Specific values _batch_queue_label = new QLabel("Batch queue:"); _batch_queue_value = new QLabel(""); @@ -115,10 +121,18 @@ BL::JobTab::createJobSummaryTab() _run_values_form->insertRow(1, job_nof_label, _job_nof_label_value); _run_values_form->insertRow(2, job_bd_label, _job_bd_label_value); _run_values_form->insertRow(3, job_rd_label, _job_rd_label_value); + + // Parameters for COORM + _run_values_form->insertRow(4, job_lf_label, _job_lf_label_value); + _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(2, job_nop_label, _job_nop_label_value); + + // Parameters for COORM + _other_run_values_form->insertRow(3, job_la_label, _job_la_label_value); + QHBoxLayout * box_layout = new QHBoxLayout(); box_layout->addLayout(_run_values_form); box_layout->addLayout(_other_run_values_form); @@ -220,6 +234,10 @@ BL::JobTab::job_selected(const QModelIndex & index) _job_em_label_value->setText(QString(batch_params.expected_memory.c_str())); _job_nop_label_value->setText(QVariant(batch_params.nb_proc).toString()); + // Parameters for COORM + _job_lf_label_value->setText(QString(batch_params.launcher_file.c_str())); + _job_la_label_value->setText(QString(batch_params.launcher_args.c_str())); + _input_files_list->clear(); _output_files_list->clear(); std::list::iterator it; @@ -313,5 +331,9 @@ BL::JobTab::reset(QString job_name) _yacs_dump_state_value->setText(""); _batch_queue_value->setText(""); _ll_jobtype_value->setText(""); + + // Parameters for COORM + _job_lf_label_value->setText(""); + _job_la_label_value->setText(""); } } diff --git a/src/genericgui/BL_JobTab.hxx b/src/genericgui/BL_JobTab.hxx index 77b8eb2..3f9226b 100644 --- a/src/genericgui/BL_JobTab.hxx +++ b/src/genericgui/BL_JobTab.hxx @@ -83,6 +83,10 @@ namespace BL QListWidget * _input_files_list; QListWidget * _output_files_list; + + // Parameters for COORM + QLabel * _job_lf_label_value; + QLabel * _job_la_label_value; }; } diff --git a/src/genericgui/BL_JobsManager_QT.cxx b/src/genericgui/BL_JobsManager_QT.cxx index 9b53f94..74820cc 100644 --- a/src/genericgui/BL_JobsManager_QT.cxx +++ b/src/genericgui/BL_JobsManager_QT.cxx @@ -19,6 +19,12 @@ #include "BL_JobsManager_QT.hxx" #include "BL_GenericGui.hxx" +#include + +using namespace std; + +// To tokenize a string +static void Tokenize(const std::string& str, std::vector& tokens, const std::string& delimiters = " "); BL::JobManagerEvent::JobManagerEvent(const std::string & action_i, const std::string & event_name_i, @@ -288,10 +294,25 @@ BL::JobsManager_QT::create_job_with_wizard(BL::CreateJobWizard & wizard) // For all jobs new_job->setEnvFile(wizard.env_file); BL::Job::BatchParam param; - param.batch_directory = wizard.batch_directory; + + // For COORM + if (wizard.coorm_batch_directory != "") + { + param.batch_directory = wizard.coorm_batch_directory; + } + else if (wizard.batch_directory != "") + { + param.batch_directory = wizard.batch_directory; + } + param.maximum_duration = wizard.maximum_duration; param.expected_memory = wizard.expected_memory; param.nb_proc = wizard.nb_proc; + + // Parameters for COORM + param.launcher_file = wizard.launcher_file; + param.launcher_args = wizard.launcher_args; + new_job->setBatchParameters(param); BL::Job::FilesParam files_params; files_params.result_directory = wizard.result_directory; @@ -447,6 +468,33 @@ BL::JobsManager_QT::event(QEvent * e) write_error_text(" ***\n"); } } + else if (event->action == "get_assigned_hostnames") + { + if (event->event_name == "Ok") + { + QString str((event->job_name).c_str()); + + vector hostnames; + + Tokenize(event->data, hostnames, "+"); + + vector::iterator it; + + write_normal_text("Job " + str + " assigned hostnames are :\n"); + + for (it = hostnames.begin(); it < hostnames.end(); it++) + { + vector hostname; + Tokenize(*it, hostname, "."); + QString assigned_hostname(hostname[0].c_str()); + write_normal_text("+ " + assigned_hostname + "\n"); + } + } + else + { + // Do nothing in case the batch manager does not support this + } + } else if (event->action == "save_jobs") { if (event->event_name == "Error") @@ -522,3 +570,22 @@ BL::JobsManager_QT::write_error_text(const QString & text) _log->setTextCursor(cursor); _log->setReadOnly(true); } + +// To tokenize a string +void Tokenize(const std::string& str, std::vector& tokens, const std::string& delimiters) +{ + // Skip delimiters at beginning. + string::size_type lastPos = str.find_first_not_of(delimiters, 0); + // Find first "non-delimiter". + string::size_type pos = str.find_first_of(delimiters, lastPos); + + while (string::npos != pos || string::npos != lastPos) + { + // Found a token, add it to the vector. + tokens.push_back(str.substr(lastPos, pos - lastPos)); + // Skip delimiters. Note the "not_of" + lastPos = str.find_first_not_of(delimiters, pos); + // Find next "non-delimiter" + pos = str.find_first_of(delimiters, lastPos); + } +} diff --git a/src/genericgui/JM_EditSalomeResource.cxx b/src/genericgui/JM_EditSalomeResource.cxx index 1f96849..c78e1f6 100644 --- a/src/genericgui/JM_EditSalomeResource.cxx +++ b/src/genericgui/JM_EditSalomeResource.cxx @@ -140,6 +140,8 @@ JM::EditSalomeResource::EditSalomeResource(QWidget *parent, BL::SALOMEServices * _batch_line->addItem("slurm"); _batch_line->addItem("ll"); _batch_line->addItem("vishnu"); + _batch_line->addItem("oar"); + _batch_line->addItem("coorm"); _batch_line->setCurrentIndex(-1); QLabel * mpiImpl_label = new QLabel("MPI impl:"); @@ -264,6 +266,10 @@ JM::EditSalomeResource::get_infos() _batch_line->setCurrentIndex(6); else if (batch == "vishnu") _batch_line->setCurrentIndex(7); + else if (batch == "oar") + _batch_line->setCurrentIndex(8); + else if (batch == "coorm") + _batch_line->setCurrentIndex(9); else _batch_line->setCurrentIndex(-1);