From 8b01db070b84e6945b178d47ac1b97988c19bb46 Mon Sep 17 00:00:00 2001 From: Ovidiu Mircescu Date: Mon, 14 Mar 2016 15:13:54 +0100 Subject: [PATCH] Add "YACSDriverOptions" to the specific parameters list of a "yacs_file" job. The new parameter "YACSDriverOptions" allows to use any option of the command "driver" when launching a YACS job with SalomeLauncher interface. --- idl/SALOME_Launcher.idl | 2 + src/Launcher/Launcher_Job_YACSFile.cxx | 14 +++- src/Launcher/Launcher_Job_YACSFile.hxx | 1 + src/Launcher/Test/test_launcher.py | 95 ++++++++++++++++++++++++++ 4 files changed, 110 insertions(+), 2 deletions(-) diff --git a/idl/SALOME_Launcher.idl b/idl/SALOME_Launcher.idl index 012c855a4..b98aaf3e3 100644 --- a/idl/SALOME_Launcher.idl +++ b/idl/SALOME_Launcher.idl @@ -153,6 +153,8 @@ struct JobParameters when the job type is "yacs_file". It gives the number of seconds between two updates of the state dump file. There will be no dump file if this parameter is missing or if its value is less than 1. + - YACSDriverOptions : options of the driver command when the job type is + "yacs_file". */ Engines::ParameterList specific_parameters; diff --git a/src/Launcher/Launcher_Job_YACSFile.cxx b/src/Launcher/Launcher_Job_YACSFile.cxx index 7462e8b0c..4d6ff37da 100644 --- a/src/Launcher/Launcher_Job_YACSFile.cxx +++ b/src/Launcher/Launcher_Job_YACSFile.cxx @@ -27,6 +27,7 @@ Launcher::Job_YACSFile::Job_YACSFile() { _job_type = "yacs_file"; _dumpState = -1; + _yacsDriverOptions = ""; } Launcher::Job_YACSFile::~Job_YACSFile() {} @@ -40,9 +41,11 @@ Launcher::Job_YACSFile::setJobFile(const std::string & job_file) void Launcher::Job_YACSFile::addJobTypeSpecificScript(std::ofstream & launch_script_stream) { - launch_script_stream << _resource_definition.AppliPath << "/salome shell -p \"$appli_port\" driver args:-k,\"$appli_port\"," << _job_file_name_complete; + launch_script_stream << _resource_definition.AppliPath << "/salome shell -p \"$appli_port\" -- driver -k\"$appli_port\" " << _job_file_name_complete; if (_dumpState > 0) - launch_script_stream << ",--dump=" << _dumpState; + launch_script_stream << " --dump=" << _dumpState; + if(not _yacsDriverOptions.empty()) + launch_script_stream << " " << _yacsDriverOptions ; launch_script_stream << " > logs/yacs_" << _launch_date << ".log 2>&1" << std::endl; } @@ -59,4 +62,11 @@ Launcher::Job_YACSFile::checkSpecificParameters() if (!(iss >> _dumpState)) throw LauncherException("Specific parameter EnableDumpYACS is not correctly defined: it should be an integer. Value given is " + user_value); } + + it = _specific_parameters.find("YACSDriverOptions"); + if (it != _specific_parameters.end()) + { + // Decode info + _yacsDriverOptions = it->second; + } } diff --git a/src/Launcher/Launcher_Job_YACSFile.hxx b/src/Launcher/Launcher_Job_YACSFile.hxx index 13cab7984..122fcf6ff 100644 --- a/src/Launcher/Launcher_Job_YACSFile.hxx +++ b/src/Launcher/Launcher_Job_YACSFile.hxx @@ -38,6 +38,7 @@ namespace Launcher protected: int _dumpState; + std::string _yacsDriverOptions; }; } diff --git a/src/Launcher/Test/test_launcher.py b/src/Launcher/Test/test_launcher.py index 86d5d61aa..53fe67af5 100755 --- a/src/Launcher/Test/test_launcher.py +++ b/src/Launcher/Test/test_launcher.py @@ -353,6 +353,101 @@ f.close() self.verifyFile(os.path.join(job_params.result_directory, "result.txt"), "expected") + ############################## + # test of yacs job type using "--init_port" driver option + ############################## + def test_yacsopt(self): + yacs_path = os.getenv("YACS_ROOT_DIR", "") + if not os.path.isdir(yacs_path): + self.skipTest("Needs YACS module to run. Please define YACS_ROOT_DIR.") + + case_test_dir = os.path.join(TestCompo.test_dir, "yacs_opt") + os.mkdir(case_test_dir) + + # job script + script_text = """ + + + + + + + + + + + + + + + + + + + + + +""" + yacs_file = "simpleSchema.xml" + job_script_file = os.path.join(case_test_dir, yacs_file) + f = open(job_script_file, "w") + f.write(script_text) + f.close() + + local_result_dir = os.path.join(case_test_dir, "result_yacsopt_job") + job_params = salome.JobParameters() + job_params.job_type = "yacs_file" + job_params.job_file = job_script_file + #job_params.env_file = os.path.join(case_test_dir,env_file) + job_params.out_files = ["result.txt"] + + # define the interval between two YACS schema dumps (3 seconds) + import Engines + job_params.specific_parameters = [Engines.Parameter("YACSDriverOptions", + "-imynode.i=5 -imynode.d=3.7 -imynode.b=False -imynode.s=lili")] + expected_result="i=5,d=3.7,b=False,s=lili" + job_params.resource_required = salome.ResourceParameters() + job_params.resource_required.nb_proc = 1 + + launcher = salome.naming_service.Resolve('/SalomeLauncher') + resManager= salome.lcc.getResourcesManager() + + for resource in self.ressources: + print "Testing yacs job with options on ", resource + job_params.result_directory = local_result_dir + resource + job_params.job_name = "YacsJobOpt_" + resource + job_params.resource_required.name = resource + + # use the working directory of the resource + resParams = resManager.GetResourceDefinition(resource) + wd = os.path.join(resParams.working_directory, + "YacsJobOpt_" + self.suffix) + job_params.work_directory = wd + + job_id = launcher.createJob(job_params) + launcher.launchJob(job_id) + jobState = launcher.getJobState(job_id) + + yacs_dump_success = False + print "Job %d state: %s" % (job_id,jobState) + while jobState != "FINISHED" and jobState != "FAILED" : + time.sleep(5) + jobState = launcher.getJobState(job_id) + print "Job %d state: %s " % (job_id,jobState) + pass + + self.assertEqual(jobState, "FINISHED") + + # getJobResults to default directory (result_directory) + launcher.getJobResults(job_id, "") + self.verifyFile(os.path.join(job_params.result_directory, "result.txt"), + expected_result) + if __name__ == '__main__': # creat study import salome -- 2.39.2