]> SALOME platform Git repositories - tools/ydefx.git/commitdiff
Salome HOME
Cleaning source code. omu/multijob
authorOvidiu MIRCESCU <ovidiu.mircescu@edf.fr>
Fri, 4 Dec 2020 12:58:42 +0000 (13:58 +0100)
committerOvidiu MIRCESCU <ovidiu.mircescu@edf.fr>
Fri, 4 Dec 2020 12:58:42 +0000 (13:58 +0100)
12 files changed:
src/cpp/PyStudyJob.hxx
src/cpp/TPyStudyJob.hxx
src/cpp/Test/CTestTestfileInstall.cmake
src/cpp/Test/PyTestMain.cxx
src/pydefx/multijobstudy.py
src/pydefx/plugins/jobexecutor.py
src/pydefx/plugins/lightexecutor.py
src/pydefx/plugins/localexecutor.py
src/pydefx/plugins/mainjob.py
src/pydefx/plugins/srunexecutor.py
src/pydefx/slurmstudy.py
src/pyexample/multijob/jobstudy.py

index 9daf91d5e91431a2891b67b5d3c9e39473d0f657..622ece2a8c35ea99b37b9b1c46e1f4addfd19072 100644 (file)
@@ -27,7 +27,7 @@ class PyStudyJob : public Job
 {
 public:
   PyStudyJob(const std::string& pymodule_name, const std::string& pyclass_name);
-  PyStudyJob(py2cpp::PyPtr& pyStudyObj); 
+  PyStudyJob(py2cpp::PyPtr& pyStudyObj);
   PyStudyJob();
   virtual ~PyStudyJob();
   virtual std::string state();
index 57270c549f4fd4d90e32cabbcc8c5a21e3fddd0a..4b4182db065abcdd5b74a019b146b8ea27f1d1a5 100644 (file)
@@ -37,21 +37,6 @@ public:
   , _sample(sample)
   {
     createNewJob(fnScript, params);
-    /*if(_lastError.empty()) // no errors during parent construction
-    {
-      try
-      {
-        py2cpp::PyPtr pySample = createPySample(sample);
-        py2cpp::PyFunction pyFn;
-        pyFn.loadExp(_pyStudy, "createNewJob");
-        pyFn(fnScript, pySample, params);
-      }
-      catch(std::exception& e)
-      {
-        _lastError = "An error occured while creating the job.\n";
-        _lastError += e.what();
-      }
-    }*/
   }
 
   TPyStudyJob(py2cpp::PyPtr& pyStudyObj,
@@ -84,7 +69,7 @@ public:
       }
     }
   }
-  
+
   virtual ~TPyStudyJob(){}
   virtual bool fetch()
   {
index 10fede5de116c6fb15d9c179a1e2edb5921f555c..2917d4147a9f6ddd86e3691f184a84d1d4f18677 100644 (file)
 #
 
 SET(TEST_NAME ${COMPONENT_NAME}_SampleTest)
-ADD_TEST(${TEST_NAME} python ${SALOME_TEST_DRIVER} ${TIMEOUT} ./SampleTest)
+ADD_TEST(${TEST_NAME} ${SALOME_TEST_DRIVER} ${TIMEOUT} ./SampleTest)
 SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES
                                   LABELS "${COMPONENT_NAME}"
                     )
 
 SET(TEST_NAME ${COMPONENT_NAME}_StudyGeneralTest)
-ADD_TEST(${TEST_NAME} python ${SALOME_TEST_DRIVER} ${TIMEOUT} ./StudyGeneralTest)
+ADD_TEST(${TEST_NAME} ${SALOME_TEST_DRIVER} ${TIMEOUT} ./StudyGeneralTest)
 SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES
                                   LABELS "${COMPONENT_NAME}"
                     )
 
 SET(TEST_NAME ${COMPONENT_NAME}_StudyRestartTest)
-ADD_TEST(${TEST_NAME} python ${SALOME_TEST_DRIVER} ${TIMEOUT} ./StudyRestartTest)
+ADD_TEST(${TEST_NAME} ${SALOME_TEST_DRIVER} ${TIMEOUT} ./StudyRestartTest)
 SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES
                                   LABELS "${COMPONENT_NAME}"
                     )
index b5f960e43dabae58e7e478615e67e3b7d16532c3..1cb33780b0a598bd080ca202f2848cca8971c8b2 100644 (file)
@@ -48,7 +48,7 @@ int main(int argc, char* argv[])
 
   // ---  Add a listener that collects test result
   CPPUNIT_NS::TestResultCollector result;
-  controller.addListener( &result );        
+  controller.addListener( &result );
 
   // ---  Add a listener that print dots as test run.
 #ifdef WIN32
@@ -56,7 +56,7 @@ int main(int argc, char* argv[])
 #else
   CPPUNIT_NS::BriefTestProgressListener progress;
 #endif
-  controller.addListener( &progress );      
+  controller.addListener( &progress );
 
   // ---  Get the top level suite from the registry
 
@@ -74,7 +74,7 @@ int main(int argc, char* argv[])
   testFile.open("test.log", std::ios::out | std::ios::app);
   testFile << "------ Idefix test log:" << std::endl;
   CPPUNIT_NS::CompilerOutputter outputter( &result, testFile );
-  outputter.write(); 
+  outputter.write();
 
   // ---  Run the tests.
 
index f46ac531f2272d85994338237fc4a3bba07afa28..b6c39e0aa552dd47c6a1cc140cb37a5427fe4a46 100644 (file)
@@ -47,7 +47,7 @@ class MultiJobStudy(pystudy.PyStudy):
     # set the parameters of the local job
     self.params.salome_parameters.resource_required.name = "localhost"
     self.params.salome_parameters.job_type = "command_salome" #"python_salome"
-    
+
     self.params.salome_parameters.work_directory = main_job_work_dir
     self.params.createTmpResultDirectory()
     result_directory = self.params.salome_parameters.result_directory
index 0fdfab12b5d1ae665906ea40903b581cd78161d5..cde7f6e5e9463bb9726d4d42a2d823d4332af865 100644 (file)
@@ -51,7 +51,7 @@ class JobExecutor:
       error = str(e)
       traceback.print_exc()
     return error, out_values
-  
+
   def prepare(self, idx, point, context):
     """
     Define local and remote work directory.
@@ -84,10 +84,10 @@ class JobExecutor:
     salome_parameters.out_files = ["idefixresult.txt", "idefixerror.txt"]
     salome_parameters.work_directory = point_remote_dir
     salome_parameters.result_directory = context.local_dir
-  
+
   def noRunFound(self, idx, point, context):
     return True
-  
+
   def runjob(self, idx, point, context):
     """
     Create, launch and wait for the end of the job.
index 22f32a998ece36f5883fec79f7b122f956a66e76..d5b30c4aca7242e35b8c27ad03730f31b2d38a6f 100644 (file)
@@ -1,4 +1,3 @@
-#import pydefx
 import os
 import pickle
 import time
@@ -28,25 +27,14 @@ class JobExecutor:
     error = None
     out_values = None
     studymodule=self.config["studymodule"]
-    #studymodule += ".py"
-    #with open(studymodule, "r") as study_file:
-      #study_string = study_file.read()
-    #try:
-      #exec(study_string)
-      #out_values = _exec(**inputvals)
-    #except Exception as e:
-      #error=str(e) 
-      #traceback.print_exc()
-    # another way:
     import importlib
     try:
       idefixstudy=importlib.import_module(studymodule)
       out_values=idefixstudy._exec(**point)
     except Exception as e:
-      error=str(e) 
+      error=str(e)
       traceback.print_exc()
     return error, out_values
-  
 
 def createExecutor(config):
   return JobExecutor(config)
index 7a0cf46ce07c6d453ee0a412b68fceb8f5a50fc4..8111c3cd6799223e800965367d724c84347138f6 100644 (file)
@@ -1,4 +1,3 @@
-#import pydefx
 import os
 import pickle
 import time
@@ -7,7 +6,6 @@ import subprocess
 
 class Context:
   def __init__(self):
-    #self.launcher = pydefx.salome_proxy.getLauncher() # getLauncher()
     pass
 
 class JobExecutor:
@@ -37,7 +35,7 @@ class JobExecutor:
       error = str(e)
       traceback.print_exc()
     return error, out_values
-  
+
   def prepare(self, idx, point, context):
     """
     Define local and remote work directory.
@@ -55,21 +53,14 @@ class JobExecutor:
       # explicit dict convertion is needed for compatibility between python versions
       f.write(repr(dict(point)))
 
-  
   def noRunFound(self, idx, point, context):
     return True
-  
+
   def runjob(self, idx, point, context):
     """
     Create, launch and wait for the end of the job.
     """
-    # srun
-    #ntasks = self.config["tasksPerEval"]
     pointeval = os.path.join(os.getcwd(), "pointeval.py")
-    #command = "srun --ntasks={} --nodes=1 --chdir={} {} ".format(
-                                                             #str(ntasks),
-                                                             #context.local_dir,
-                                                             #pointeval)
     return_code = subprocess.check_call(pointeval, shell=True, cwd=context.local_dir)
 
   def getResult(self, context):
index b9cfe3f7ea22fe1c1a077f431662e3739df61d45..deaeecb3bba0f47a44b5046621c32ca7946b3b74 100644 (file)
@@ -31,7 +31,7 @@ class TerminateJob:
       self.manager.addResult(idx, in_values, out_values, error)
     except Exception as e:
       traceback.print_exc()
-  
+
 if __name__ == '__main__':
   with open("idefixconfig.json", "r") as f:
     config = json.load(f)
index a779c92c50610bd67f14e37007e1f3eb102a4d3f..a679b0fe424a803088f4603385ff9348b647f582 100644 (file)
@@ -1,4 +1,3 @@
-#import pydefx
 import os
 import pickle
 import time
@@ -15,7 +14,7 @@ class JobExecutor:
     self.config = config
 
   def initialize(self):
-    """ 
+    """
     Execute prescript.
     """
     pointeval = os.path.join(os.getcwd(), "pointeval.py")
@@ -36,7 +35,7 @@ class JobExecutor:
       error = str(e)
       traceback.print_exc()
     return error, out_values
-  
+
   def prepare(self, idx, point, context):
     """
     Define local and remote work directory.
@@ -54,10 +53,9 @@ class JobExecutor:
       # explicit dict convertion is needed for compatibility between python versions
       f.write(repr(dict(point)))
 
-  
   def noRunFound(self, idx, point, context):
     return True
-  
+
   def runjob(self, idx, point, context):
     """
     Create, launch and wait for the end of the job.
index 3daf48c03d59926a743648d662da0ea2984901d0..156dda72b25e172487db738bec8c950d85c6da56 100644 (file)
@@ -41,7 +41,7 @@ class SlurmStudy(pystudy.PyStudy):
       os.makedirs(main_job_work_dir)
     # set the parameters of the local job
     self.params.salome_parameters.job_type = self.jobType()
-    
+
     result_directory = self.params.salome_parameters.result_directory
     # export sample to result_directory
     inputFiles = self.sampleManager.prepareRun(self.sample, result_directory)
index 6da5d388c785aca2c4901ef848a4499260e3acc4..5902ef7ddff490bb5d187bcbe3060fc93f2b6aee 100644 (file)
@@ -6,19 +6,19 @@ import time
 def _exec(n):
   # get the job parameters
   salome_parameters = pydefx.configuration.loadJobConfig()
-  
+
   launcher = pydefx.salome_proxy.getLauncher() # CORBA or not CORBA
-  
+
   # have a different working directory for each computation
   resource = salome_parameters.resource_required.name
   default_wd = pydefx.configuration.defaultWorkingDir(resource)
   new_wd = os.path.join(default_wd, "myjob_"+str(n))
   salome_parameters.work_directory = new_wd
-  
+
   # create and launch the job
   job_id = launcher.createJob(salome_parameters)
   launcher.launchJob(job_id)
-  
+
   # wait for the end of the job
   jobState = launcher.getJobState(job_id)
   while jobState != "FINISHED" and jobState != "FAILED" :