From: Ovidiu Mircescu Date: Tue, 4 Feb 2020 13:57:43 +0000 (+0100) Subject: Work in progress. X-Git-Tag: V9_7_0b1~1^2~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fddf812fa0bc4e573ddb41fbe02f06010e56f82f;p=tools%2Fydefx.git Work in progress. --- diff --git a/src/pydefx/multijob/executor.py b/src/pydefx/multijob/executor.py index 4317183..4d56df0 100644 --- a/src/pydefx/multijob/executor.py +++ b/src/pydefx/multijob/executor.py @@ -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 diff --git a/src/pydefx/multijob/pointeval.py b/src/pydefx/multijob/pointeval.py index 4619d87..c652b26 100644 --- a/src/pydefx/multijob/pointeval.py +++ b/src/pydefx/multijob/pointeval.py @@ -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 diff --git a/src/pydefx/multijobstudy.py b/src/pydefx/multijobstudy.py index 5a4a98e..1d2f9f2 100644 --- a/src/pydefx/multijobstudy.py +++ b/src/pydefx/multijobstudy.py @@ -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() diff --git a/src/pydefx/pystudy.py b/src/pydefx/pystudy.py index 6373926..bf7cf19 100644 --- a/src/pydefx/pystudy.py +++ b/src/pydefx/pystudy.py @@ -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 a the string. + Use dumpJob for saving the string. """ jobDumpPath = os.path.join(result_directory, PyStudy.JOB_DUMP_NAME) with open(jobDumpPath, "r") as f: