Salome HOME
Work in progress.
authorOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Tue, 4 Feb 2020 13:57:43 +0000 (14:57 +0100)
committerOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Tue, 4 Feb 2020 13:57:43 +0000 (14:57 +0100)
src/pydefx/multijob/executor.py
src/pydefx/multijob/pointeval.py
src/pydefx/multijobstudy.py
src/pydefx/pystudy.py

index 431718302ce981bed14143f120221d4b221b6b84..4d56df0d9f77ab54ad744cd27c6c0417199e0dd8 100644 (file)
@@ -21,7 +21,9 @@ class JobExecutor:
     # Copy the commun files to the root work directory
     params = pydefx.Parameters() # global parameters
     params.loadDict(self.config["params"])
-    # use a fake empty command
+    # use a fake empty command.
+    # Using launcher to copy some files on the remote file system,
+    # without launching a job.
     command = os.path.join(os.getcwd(), "empty.sh")
     open(command, "w").close()
     params.salome_parameters.job_file = command
index 4619d871ba99b9d28773561dfbbbcf37352ce615..c652b269dd5de8e1ce368eca1d467251424aec2f 100644 (file)
@@ -6,6 +6,7 @@ data_file_name = "idefixdata.csv"
 study_module = "idefixstudy.py"
 error_result = "idefixerror.txt"
 value_result = "idefixresult.txt"
+traceback_result = "idefixtraceback.txt"
 
 with open(data_file_name, "r") as f:
   values = f.read()
@@ -23,7 +24,9 @@ try:
   result = _exec(**inputvals)
 except Exception as e:
   error=str(e)
-  traceback.print_exc()
+  os.chdir(old_dir) # back to the current case job directory
+  with open(traceback_result, "w") as f:
+    traceback.print_exc(file=f)
 
 os.chdir(old_dir) # back to the current case job directory
 
index 5a4a98ead9f85c2e2bc522b692b74427ef2d94d2..1d2f9f29fe8576e83cbe629a54de77a75a59b6b1 100644 (file)
@@ -26,6 +26,9 @@ from . import salome_proxy
 
 
 class MultiJobStudy(pystudy.PyStudy):
+  """
+  This study uses one different job for each evaluation.
+  """
   def __init__(self, sampleManager=None, schemaBuilder=None):
     if schemaBuilder is None:
       schemaBuilder = multijobbuilder.MultiJobBuilder()
index 63739268d1534577b99481ad11ff228dbaa65f9c..bf7cf194a2020c15647e77ec150885979e934f41 100644 (file)
@@ -82,8 +82,8 @@ class PyStudy:
     job_string = loadJobString(path)
     launcher = salome_proxy.getLauncher()
     self.job_id = launcher.restoreJob(job_string)
-    if job_id >= 0:
-      salome_params = launcher.getJobParameters(job_id)
+    if self.job_id >= 0:
+      salome_params = launcher.getJobParameters(self.job_id)
       self.params = parameters.Parameters(salome_parameters=salome_params)
       self.getResult()
     return self.job_id
@@ -317,21 +317,10 @@ For further details, see {}/logs directory on {}.""".format(
         raise StudyUseException("Parameter {} not found in the sample.".format(nm))
 
 ### Deprecated!!!!
-def dumpJob(result_directory, jobString):
-  """
-  Save the jobString to a file into result_directory.
-  result_directory is a string representing a path to a directory.
-  jobString is a string representing the serialization of a job.
-  Use loadJobString for reloading the string saved here.
-  """
-  jobDumpPath = os.path.join(result_directory, PyStudy.JOB_DUMP_NAME)
-  with open(jobDumpPath, "w") as f:
-    f.write(job_string)
-
 def loadJobString(result_directory):
   """
   Return the jobString saved by the dumpJob function into a directory.
-  Use dumpJob for saving the string.
+  Use dumpJob for saving the string.
   """
   jobDumpPath = os.path.join(result_directory, PyStudy.JOB_DUMP_NAME)
   with open(jobDumpPath, "r") as f: