]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
[bos #35138][EDF] (2023-T1) Specialization of resources in KERNEL. JobParameters...
authorKonstantin Leontev <Konstantin.LEONTEV@opencascade.com>
Fri, 11 Aug 2023 10:41:32 +0000 (11:41 +0100)
committerKonstantin Leontev <Konstantin.LEONTEV@opencascade.com>
Fri, 11 Aug 2023 10:41:32 +0000 (11:41 +0100)
14 files changed:
idl/SALOME_Launcher.idl
src/Launcher/Launcher.cxx
src/Launcher/Launcher.hxx
src/Launcher/Launcher_Job.cxx
src/Launcher/Launcher_Job.hxx
src/Launcher/Launcher_XML_Persistence.cxx
src/Launcher/SALOME_Launcher.cxx
src/Launcher/Test/launcher_use_case.py
src/Launcher/Test/test_launcher.py
src/Launcher_SWIG/Launcher.i
src/Launcher_SWIG/Test/test_swig_launcher.py
src/Launcher_SWIG/test.py
src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py
src/ResourcesManager/ResourcesManager.cxx

index 5193d29b7a96ddac337c58bfcf2a6abb9a0f17ab..95dd67e35f7809571f86f11decbd7c509a608a4a 100644 (file)
@@ -137,7 +137,7 @@ struct JobParameters
       - mem_mb -> Memory expressed in megabytes.
       - nb_proc -> Number of Processors.
   */
-  ResourceParametersContainer resource_required;
+  ResourceParametersJob resource_required;
 
   //!  Name of the batch queue chosen - optional
   string queue;
@@ -150,7 +150,7 @@ struct JobParameters
   //! Specifies if the job must run in exclusive mode (without sharing nodes with other jobs)
   boolean exclusive;
 
-  //! Specifies the memory limit per cpu (exclusive with resource_required.mem_mb)
+  //! Specifies the memory limit per cpu
   unsigned long mem_per_cpu;
 
   //! Workload Characterization Key - mandatory on some clusters
index 63ea28b1c18e038eee280063aea3c923b8255ef7..a9b016610af237f4d1631dfb26c255815498d259 100644 (file)
@@ -493,17 +493,9 @@ Launcher_cpp::getJobParameters(int job_id)
   job_parameters.wckey            = job->getWCKey();
   job_parameters.extra_params     = job->getExtraParams();
 
-  resourceParamsContainer resource_params = job->getResourceRequiredParams();
-  job_parameters.resource_required.name             = resource_params.name;
-  job_parameters.resource_required.hostname         = resource_params.hostname;
-  job_parameters.resource_required.OS               = resource_params.OS;
-  job_parameters.resource_required.nb_proc          = resource_params.nb_proc;
-  job_parameters.resource_required.nb_node          = resource_params.nb_node;
-  job_parameters.resource_required.nb_proc_per_node = resource_params.nb_proc_per_node;
-  job_parameters.resource_required.cpu_clock        = resource_params.cpu_clock;
-  job_parameters.resource_required.mem_mb           = resource_params.mem_mb;
-
-  job_parameters.specific_parameters                = job->getSpecificParameters();
+  job_parameters.resource_required = job->getResourceRequiredParams();
+
+  job_parameters.specific_parameters = job->getSpecificParameters();
 
   return job_parameters;
 }
@@ -548,15 +540,15 @@ Launcher_cpp::createJobWithFile(const std::string xmlExecuteFile,
   for(size_t i=0; i < job_params.OutputFile.size();i++)
     new_job->add_out_file(job_params.OutputFile[i]);
 
-  resourceParamsContainer p;
+  resourceParamsJob p;
   p.hostname = clusterName;
   p.name = "";
-  p.OS = "";
-  p.nb_proc = job_params.NbOfProcesses;
-  p.nb_node = 0;
-  p.nb_proc_per_node = 0;
-  p.cpu_clock = 0;
-  p.mem_mb = 0;
+  // p.OS = "";
+  // p.nb_proc = job_params.NbOfProcesses;
+  // p.nb_node = 0;
+  // p.nb_proc_per_node = 0;
+  // p.cpu_clock = 0;
+  // p.mem_mb = 0;
   new_job->setResourceRequiredParams(p);
 
   createJob(new_job.get());
@@ -862,12 +854,12 @@ Launcher_cpp::getBatchManager(Launcher::Job * job)
 
   // Select a resource for the job
   std::vector<std::string> ResourceList;
-  resourceParamsContainer params = job->getResourceRequiredParams();
+  resourceParamsJob params = job->getResourceRequiredParams();
   // Consider only resources that can launch batch jobs
 
   try
   {
-    ResourceList = _ResManager->GetFittingResourcesContainer(params);
+    ResourceList = _ResManager->GetFittingResourcesJob(params);
   }
   catch(const ResourcesException &ex)
   {
index 5f767194f510ee42b1c0e448ff2a079561199213..d71e75508b884175c6747109d3ed1d5e51bf29ea 100644 (file)
@@ -51,7 +51,7 @@ struct LAUNCHER_EXPORT JobParameters_cpp
   std::string local_directory;
   std::string result_directory;
   std::string maximum_duration;
-  resourceParamsContainer resource_required;
+  resourceParamsJob resource_required;
   std::string queue;
   std::string partition;
   bool exclusive;
index 20d1b92ddc84cebbdd5805908c8c103c77a93f59..aa3256d441a19e3849756e018a229ef703aca46d 100644 (file)
@@ -315,7 +315,7 @@ Launcher::Job::setLauncherArgs(const std::string & launcher_args)
 }
 
 void
-Launcher::Job::setResourceRequiredParams(const resourceParamsContainer& resource_required_params)
+Launcher::Job::setResourceRequiredParams(const resourceParamsJob& resource_required_params)
 {
   checkResourceRequiredParams(resource_required_params);
   _resource_required_params = resource_required_params;
@@ -422,7 +422,7 @@ Launcher::Job::getLauncherArgs() const
         return _launcher_args;
 }
 
-resourceParamsContainer
+resourceParamsJob
 Launcher::Job::getResourceRequiredParams() const
 {
   return _resource_required_params;
@@ -527,7 +527,7 @@ Launcher::Job::checkMaximumDuration(const std::string & maximum_duration)
 }
 
 void
-Launcher::Job::checkResourceRequiredParams(const resourceParamsContainer& resource_required_params)
+Launcher::Job::checkResourceRequiredParams(const resourceParamsJob& resource_required_params)
 {
   // TODO: check if we need this check for a job:
   // nb_proc has be to > 0
index 134f18e1c6a4c0e453f442d795e932c8c1446365..9a99fd55678a741359fe606cea0d40b90f2e8d3c 100644 (file)
@@ -71,7 +71,7 @@ namespace Launcher
       void add_in_file(const std::string & file);
       void add_out_file(const std::string & file);
       void setMaximumDuration(const std::string & maximum_duration);
-      void setResourceRequiredParams(const resourceParamsContainer & resource_required_params);
+      void setResourceRequiredParams(const resourceParamsJob& resource_required_params);
       void setQueue(const std::string & queue);
       void setPartition(const std::string & partition);
       void setEnvFile(const std::string & env_file);
@@ -94,7 +94,7 @@ namespace Launcher
       const std::list<std::string> & get_in_files() const;
       const std::list<std::string> & get_out_files() const;
       std::string getMaximumDuration() const;
-      resourceParamsContainer getResourceRequiredParams() const;
+      resourceParamsJob getResourceRequiredParams() const;
       std::string getQueue() const;
       std::string getPartition() const;
       std::string getEnvFile() const;
@@ -119,7 +119,7 @@ namespace Launcher
 
       // Checks
       void checkMaximumDuration(const std::string & maximum_duration);
-      void checkResourceRequiredParams(const resourceParamsContainer & resource_required_params);
+      void checkResourceRequiredParams(const resourceParamsJob& resource_required_params);
 
       // Helps
       long convertMaximumDuration(const std::string & maximum_duration);
@@ -157,7 +157,7 @@ namespace Launcher
       std::map<std::string, std::string> _specific_parameters;
       std::string _maximum_duration;
       long _maximum_duration_in_second;
-      resourceParamsContainer _resource_required_params;
+      resourceParamsJob _resource_required_params;
       std::string _queue;
       std::string _partition;
       bool _exclusive;
index a76a776af832c5b0e4b350003c865a52b3d720df..02d8590f96479c1ec3434154b7c3bb24db353161 100644 (file)
@@ -175,7 +175,7 @@ XML_Persistence::addJobToXmlDocument(xmlNodePtr root_node, const Job & job)
   }
 
   // Resource part
-  resourceParamsContainer resource_params = job.getResourceRequiredParams();
+  const resourceParamsJob resource_params = job.getResourceRequiredParams();
   xmlNodePtr res_node = addNode(node, "resource_params", "");
   addNode(res_node, "name", resource_params.name);
   if (!resource_params.hostname.empty())
@@ -394,7 +394,7 @@ XML_Persistence::parseUserNode(Job * new_job, xmlNodePtr user_node)
 void
 XML_Persistence::parseResourceNode(Job * new_job, xmlNodePtr res_node)
 {
-  resourceParamsContainer p;
+  resourceParamsJob p;
   xmlNodePtr current_node = xmlFirstElementChild(res_node);
   while (current_node != NULL)
   {
@@ -403,20 +403,20 @@ XML_Persistence::parseResourceNode(Job * new_job, xmlNodePtr res_node)
       p.name = getNodeContent(current_node);
     else if (node_name == "hostname")
       p.hostname = getNodeContent(current_node);
-    else if (node_name == "OS")
-      p.OS = getNodeContent(current_node);
-    else if (node_name == "nb_proc")
-      p.nb_proc = getNumericalNodeContent<long>(current_node);
-    else if (node_name == "nb_node")
-      p.nb_node = getNumericalNodeContent<long>(current_node);
-    else if (node_name == "nb_proc_per_node")
-      p.nb_proc_per_node = getNumericalNodeContent<long>(current_node);
-    else if (node_name == "cpu_clock")
-      p.cpu_clock = getNumericalNodeContent<long>(current_node);
-    else if (node_name == "mem_mb")
-      p.mem_mb = getNumericalNodeContent<long>(current_node);
-    else if (node_name == "mem_per_cpu")
-      new_job->setMemPerCpu(getNumericalNodeContent<long>(current_node));
+    // else if (node_name == "OS")
+    //   p.OS = getNodeContent(current_node);
+    // else if (node_name == "nb_proc")
+    //   p.nb_proc = getNumericalNodeContent<long>(current_node);
+    // else if (node_name == "nb_node")
+    //   p.nb_node = getNumericalNodeContent<long>(current_node);
+    // else if (node_name == "nb_proc_per_node")
+    //   p.nb_proc_per_node = getNumericalNodeContent<long>(current_node);
+    // else if (node_name == "cpu_clock")
+    //   p.cpu_clock = getNumericalNodeContent<long>(current_node);
+    // else if (node_name == "mem_mb")
+    //   p.mem_mb = getNumericalNodeContent<long>(current_node);
+    // else if (node_name == "mem_per_cpu")
+    //   new_job->setMemPerCpu(getNumericalNodeContent<long>(current_node));
     else
       throw LauncherException(string("invalid node \"") + node_name + "\"");
     current_node = xmlNextElementSibling(current_node);
index 6b876147fe83de374ce20fc03f3a624e0512c7f1..7b0d1fc1dfc26f91122e68885f73d9e2b26d37a8 100644 (file)
@@ -628,7 +628,7 @@ SALOME_Launcher::JobParameters_CORBA2CPP(
   result.result_directory = job_parameters.result_directory.in();
   result.maximum_duration = job_parameters.maximum_duration.in();
 
-  result.resource_required = resourceParametersContainer_CORBAtoCPP(job_parameters.resource_required);
+  result.resource_required = resourceParametersJob_CORBAtoCPP(job_parameters.resource_required);
 
   result.queue = job_parameters.queue.in();
   result.partition = job_parameters.partition.in();
@@ -677,7 +677,7 @@ SALOME_Launcher::JobParameters_CPP2CORBA(const JobParameters_cpp& job_parameters
   result->result_directory = CORBA::string_dup(job_parameters.result_directory.c_str());
   result->maximum_duration = CORBA::string_dup(job_parameters.maximum_duration.c_str());
 
-  result->resource_required = resourceParametersContainer_CPPtoCORBA(job_parameters.resource_required);
+  result->resource_required = resourceParametersJob_CPPtoCORBA(job_parameters.resource_required);
 
   result->queue = CORBA::string_dup(job_parameters.queue.c_str());
   result->partition = CORBA::string_dup(job_parameters.partition.c_str());
index f18316739380acaad2944477bd6feaae83977bd0..73ae2918164f8fff970d1d898d0342273cf2cc72 100644 (file)
@@ -31,9 +31,8 @@ if __name__ == '__main__':
   salome.salome_init()
   launcher = salome.naming_service.Resolve('/SalomeLauncher')
   job_params = salome.JobParameters()
-  job_params.resource_required = salome.ResourceParametersContainer()
+  job_params.resource_required = salome.ResourceParametersJob()
   job_params.resource_required.name = "localhost"
-  job_params.resource_required.nb_proc = 1 # slurm: --ntasks
 
   job_params.job_type = "command"
   #cwd = os.getcwd()
index 5ed629dca97d2b2df041492c5b49709d1e98d976..0649c495d39cef5b7587bdb098cc14111c683e82 100755 (executable)
@@ -82,8 +82,7 @@ class TestCompo(unittest.TestCase):
   def create_JobParameters(self):
     job_params = salome.JobParameters()
     job_params.wckey="P11N0:SALOME" #needed by edf clusters
-    job_params.resource_required = salome.ResourceParametersContainer()
-    job_params.resource_required.nb_proc = 1
+    job_params.resource_required = salome.ResourceParametersJob()
     return job_params
 
   ##############################
index e1c39af053ccadbf4210a4f701887f9e63585920..ec3c4dc52f15348e0f9897eecc28bf2f1c7686f3 100644 (file)
@@ -112,7 +112,7 @@ public:
   std::string local_directory;
   std::string result_directory;
   std::string maximum_duration;
-  resourceParamsContainer resource_required;
+  resourceParamsJob resource_required;
   std::string queue;
   std::string partition;
   bool exclusive;
index 9f54d5b4851578985d41dc1648f003ea029c7283..20ba2d9a05d5b7f4453fc6beccf03792155c9077 100755 (executable)
@@ -52,7 +52,7 @@ def createJobParameters():
   return jp
 
 def createResourceParameters():
-  return pylauncher.resourceParamsContainer()
+  return pylauncher.resourceParamsJob()
 
 # Test of SalomeLauncher.
 # This test should be run in the salome environment, using "salome shell".
@@ -77,7 +77,7 @@ class TestCompo(unittest.TestCase):
     # Get the list of possible ressources
     ressource_param = createResourceParameters()
     rm = createResourcesManager()
-    cls.ressources = rm.GetFittingResourcesContainer(ressource_param)
+    cls.ressources = rm.GetFittingResourcesJob(ressource_param)
 
   def verifyFile(self, path, content):
     try:
@@ -91,7 +91,6 @@ class TestCompo(unittest.TestCase):
   def create_JobParameters(self):
     job_params = createJobParameters()
     job_params.wckey="P11U5:CARBONES" #needed by edf clusters
-    job_params.resource_required.nb_proc = 1
     return job_params
 
   ##############################
index 64f5ac8d6143e55c03bdf6c21d8acd2856163fbf..c85fb5a7bc3cf238dcc62ee93191676c1b9f009c 100644 (file)
@@ -24,10 +24,9 @@ jp.job_type = "command"
 jp.job_file = "/home/I35256/salome/scripts/job_sh/script.sh"
 jp.work_directory = "/tmp/wd"
 jp.result_directory = "/tmp/rd"
-rp = pylauncher.resourceParamsContainer()
+rp = pylauncher.resourceParamsJob()
 rp.name="localhost"
 rp.hostname="localhost"
-rp.nb_proc = 1
 jp.resource_required = rp
 launcher = pylauncher.Launcher_cpp()
 # no catalog. localhost is defined anyway
index 2a59505ae8774f26a02e64e3aec12f32df8f2ca1..303f0ab8df6f15df285d236d5e968f677f5a3ec3 100644 (file)
@@ -60,6 +60,14 @@ class ResourceParametersContainer(Engines.ResourceParametersContainer):
     Engines.ResourceParametersContainer.__init__(self, name, hostname,
                                         policy, resList,
                                         OS, componentList, nb_proc, mem_mb, cpu_clock, nb_node, nb_proc_per_node)
+    
+class ResourceParametersJob(Engines.ResourceParametersJob):
+  def __init__(self, name="", hostname="",
+               policy="", resList = None):
+    if resList is None:
+      resList = []
+    Engines.ResourceParametersJob.__init__(self, name, hostname,
+                                        policy, resList)
 
 class JobParameters (Engines.JobParameters):
   def __init__(self, job_name="", job_type="", job_file="", pre_command="", env_file="", in_files=None, out_files=None,
@@ -74,7 +82,7 @@ class JobParameters (Engines.JobParameters):
     if specific_parameters is None:
       specific_parameters = []
     if resource_required is None:
-      resource_required = ResourceParametersContainer()
+      resource_required = ResourceParametersJob()
     Engines.JobParameters.__init__(self, job_name, job_type, job_file, pre_command, env_file, in_files, out_files,
                                          work_directory, local_directory, result_directory, maximum_duration,
                                          resource_required, queue, partition, exclusive, mem_per_cpu,
index d9b9b75128847938ef0fedf45a0107a7208244ce..e1ae2676eb8065b032483e5e35a2aeb36d109cd9 100644 (file)
@@ -139,6 +139,17 @@ namespace
     // }
   }
 
+  template<typename T> ResourceList GetAllResources(const T& resources)
+  {
+    ResourceList result;
+    for (const auto& res : resources)
+    {
+      result.push_back(res.first);
+    }
+
+    return result;
+  }
+
   template<typename T> ResourceList GetResourcesByHostname(const std::string& hostnameIn, const T& resourceList)
   {
     if (hostnameIn.empty())
@@ -338,6 +349,12 @@ ResourceList ResourcesManager_cpp::GetFittingResourcesJob(const resourceParamsJo
     throw ResourcesException("Resource name was not found in resource list! Requested name: " + params.name);
   }
 
+  if (params.hostname.empty())
+  {
+    // Use all available resources
+    return GetAllResources(_resourcesListJob);
+  }
+
   // Step 3
   ResourceList result = GetResourcesByHostname(params.hostname, _resourcesListJob);