]> SALOME platform Git repositories - tools/ydefx.git/commitdiff
Salome HOME
Copy job parameters without salome session. V9_4_BR V9_4_0 V9_4_0rc1
authorOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Wed, 16 Oct 2019 14:13:54 +0000 (16:13 +0200)
committerOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Wed, 16 Oct 2019 14:13:54 +0000 (16:13 +0200)
src/cpp/Test/SampleTest.cxx
src/pydefx/parameters.py

index c51fd89bb4f4000109abb0e323a0cd58ea918d3d..3704302baccf6ea9173a893d69d630b7f2a24f0b 100644 (file)
@@ -208,8 +208,6 @@ void SampleTest::params()
 {
   Py_Initialize();
   {
-    try
-    {
     ydefx::JobParametersProxy jpp;
     CPPUNIT_ASSERT(jpp.resource_name() == "localhost");
     CPPUNIT_ASSERT(jpp.job_type() == "yacs_file");
@@ -262,12 +260,53 @@ void SampleTest::params()
     CPPUNIT_ASSERT(jpp.result_directory() == "rd");
     CPPUNIT_ASSERT(jpp.wckey() == "wk");
     CPPUNIT_ASSERT(jpp.work_directory() == "wd");
-    }
-    catch(std::exception& e)
-    {
-      std::cout << e.what();
-      CPPUNIT_FAIL("Unexpected exception!");
-    }
+    // test copy constructor
+    ydefx::JobParametersProxy jpp_2(jpp);
+    CPPUNIT_ASSERT(jpp_2.env_file() == "a");
+    CPPUNIT_ASSERT(jpp_2.exclusive());
+    CPPUNIT_ASSERT(jpp_2.extra_params() == "b");
+    CPPUNIT_ASSERT(jpp_2.job_file() == "c");
+    CPPUNIT_ASSERT(jpp_2.job_name() == "d");
+    CPPUNIT_ASSERT(jpp_2.job_type() == "e");
+    CPPUNIT_ASSERT(jpp_2.local_directory() == "fi");
+    CPPUNIT_ASSERT(jpp_2.maximum_duration() == "dur");
+    CPPUNIT_ASSERT(jpp_2.mem_mb() == 5);
+    CPPUNIT_ASSERT(jpp_2.mem_per_cpu() == 42);
+    CPPUNIT_ASSERT(jpp_2.nb_branches() == 18);
+    CPPUNIT_ASSERT(jpp_2.nb_node() == 15);
+    CPPUNIT_ASSERT(jpp_2.nb_proc() == 13);
+    CPPUNIT_ASSERT(jpp_2.nb_proc_per_node() == 12);
+    CPPUNIT_ASSERT(jpp_2.partition() == "gg");
+    CPPUNIT_ASSERT(jpp_2.pre_command() == "pc");
+    CPPUNIT_ASSERT(jpp_2.queue() == "qq");
+    CPPUNIT_ASSERT(jpp_2.resource_name() == "rn");
+    CPPUNIT_ASSERT(jpp_2.result_directory() == "rd");
+    CPPUNIT_ASSERT(jpp_2.wckey() == "wk");
+    CPPUNIT_ASSERT(jpp_2.work_directory() == "wd");
+    // test copy operator
+    ydefx::JobParametersProxy jpp_3;
+    jpp_3 = jpp;
+    CPPUNIT_ASSERT(jpp_3.env_file() == "a");
+    CPPUNIT_ASSERT(jpp_3.exclusive());
+    CPPUNIT_ASSERT(jpp_3.extra_params() == "b");
+    CPPUNIT_ASSERT(jpp_3.job_file() == "c");
+    CPPUNIT_ASSERT(jpp_3.job_name() == "d");
+    CPPUNIT_ASSERT(jpp_3.job_type() == "e");
+    CPPUNIT_ASSERT(jpp_3.local_directory() == "fi");
+    CPPUNIT_ASSERT(jpp_3.maximum_duration() == "dur");
+    CPPUNIT_ASSERT(jpp_3.mem_mb() == 5);
+    CPPUNIT_ASSERT(jpp_3.mem_per_cpu() == 42);
+    CPPUNIT_ASSERT(jpp_3.nb_branches() == 18);
+    CPPUNIT_ASSERT(jpp_3.nb_node() == 15);
+    CPPUNIT_ASSERT(jpp_3.nb_proc() == 13);
+    CPPUNIT_ASSERT(jpp_3.nb_proc_per_node() == 12);
+    CPPUNIT_ASSERT(jpp_3.partition() == "gg");
+    CPPUNIT_ASSERT(jpp_3.pre_command() == "pc");
+    CPPUNIT_ASSERT(jpp_3.queue() == "qq");
+    CPPUNIT_ASSERT(jpp_3.resource_name() == "rn");
+    CPPUNIT_ASSERT(jpp_3.result_directory() == "rd");
+    CPPUNIT_ASSERT(jpp_3.wckey() == "wk");
+    CPPUNIT_ASSERT(jpp_3.work_directory() == "wd");
   }
   Py_Finalize();
 }
index 4feba18ac5a1128ff658464b29fd0c4172fa3e9a..53b9bd6a7f2144ce4feb1c716c892802184e5c07 100644 (file)
@@ -58,3 +58,41 @@ class Parameters:
   def createTmpResultDirectory(self):
     self.salome_parameters.result_directory = configuration.newResultDirectory(
                                                           tempfile.gettempdir())
+
+  # Specific deep copy function is needed because the default one does not work
+  # for swig objects, when we are in no salome session mode.
+  def __deepcopy__(self, memo):
+    cls = self.__class__
+    newobj = cls.__new__(cls)
+    newobj.nb_branches = self.nb_branches
+    newobj.salome_parameters = salome_proxy.createSalomeParameters()
+    newobj.salome_parameters.job_name = self.salome_parameters.job_name
+    newobj.salome_parameters.job_type = self.salome_parameters.job_type
+    newobj.salome_parameters.job_file = self.salome_parameters.job_file
+    newobj.salome_parameters.pre_command = self.salome_parameters.pre_command
+    newobj.salome_parameters.env_file = self.salome_parameters.env_file
+    newobj.salome_parameters.in_files = list(self.salome_parameters.in_files)
+    newobj.salome_parameters.out_files = list(self.salome_parameters.out_files)
+    newobj.salome_parameters.work_directory = self.salome_parameters.work_directory
+    newobj.salome_parameters.local_directory = self.salome_parameters.local_directory
+    newobj.salome_parameters.result_directory = self.salome_parameters.result_directory
+    newobj.salome_parameters.maximum_duration = self.salome_parameters.maximum_duration
+    newobj.salome_parameters.queue = self.salome_parameters.queue
+    newobj.salome_parameters.partition = self.salome_parameters.partition
+    newobj.salome_parameters.exclusive = self.salome_parameters.exclusive
+    newobj.salome_parameters.mem_per_cpu = self.salome_parameters.mem_per_cpu
+    newobj.salome_parameters.wckey = self.salome_parameters.wckey
+    newobj.salome_parameters.extra_params = self.salome_parameters.extra_params
+    newobj.salome_parameters.specific_parameters = self.salome_parameters.specific_parameters
+    newobj.salome_parameters.resource_required.name = self.salome_parameters.resource_required.name
+    newobj.salome_parameters.resource_required.hostname = self.salome_parameters.resource_required.hostname
+    newobj.salome_parameters.resource_required.can_launch_batch_jobs = self.salome_parameters.resource_required.can_launch_batch_jobs
+    newobj.salome_parameters.resource_required.can_run_containers = self.salome_parameters.resource_required.can_run_containers
+    newobj.salome_parameters.resource_required.OS = self.salome_parameters.resource_required.OS
+    newobj.salome_parameters.resource_required.nb_proc = self.salome_parameters.resource_required.nb_proc
+    newobj.salome_parameters.resource_required.mem_mb = self.salome_parameters.resource_required.mem_mb
+    newobj.salome_parameters.resource_required.cpu_clock = self.salome_parameters.resource_required.cpu_clock
+    newobj.salome_parameters.resource_required.nb_node = self.salome_parameters.resource_required.nb_node
+    newobj.salome_parameters.resource_required.nb_proc_per_node = self.salome_parameters.resource_required.nb_proc_per_node
+
+    return newobj