From: Ovidiu Mircescu Date: Tue, 20 Sep 2022 15:58:35 +0000 (+0200) Subject: Fix order of outputs in c++ mode. X-Git-Tag: V9_10_0b1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c425aac936cbfa9b8a289ce2814c63e5d02b8a7c;p=tools%2Fydefx.git Fix order of outputs in c++ mode. --- diff --git a/src/cpp/PyStudyFunction.cxx b/src/cpp/PyStudyFunction.cxx index 03ab8b6..6c4dc4c 100644 --- a/src/cpp/PyStudyFunction.cxx +++ b/src/cpp/PyStudyFunction.cxx @@ -149,4 +149,13 @@ std::list PyStudyFunction::datafiles()const return std::list(); } +py2cpp::PyPtr PyStudyFunction::createEmptySample()const +{ + py2cpp::PyPtr sample; + py2cpp::PyFunction fnCreateEmptySample; + fnCreateEmptySample.loadExp(_pyObject, "CreateEmptySample"); + sample = fnCreateEmptySample(); + return sample; +} + } diff --git a/src/cpp/PyStudyFunction.hxx b/src/cpp/PyStudyFunction.hxx index 17ae27d..6b45416 100644 --- a/src/cpp/PyStudyFunction.hxx +++ b/src/cpp/PyStudyFunction.hxx @@ -40,6 +40,7 @@ public: virtual std::string errors()const; virtual bool isValid()const; virtual std::list datafiles()const; + py2cpp::PyPtr createEmptySample()const; friend PyObject * py2cpp::toPy(const PyStudyFunction& jp); private: py2cpp::PyPtr _pyObject; diff --git a/src/cpp/SamplePyConversions.hxx b/src/cpp/SamplePyConversions.hxx index b720bbd..8fdeca3 100644 --- a/src/cpp/SamplePyConversions.hxx +++ b/src/cpp/SamplePyConversions.hxx @@ -86,14 +86,6 @@ YDEFX_EXPORT py2cpp::ConversionCheck outputFromPy(PyObject* obj, Sample& template YDEFX_EXPORT py2cpp::ConversionCheck errorsFromPy(PyObject* obj, Sample& sample); -/*! - * A python sample object is created and it contains input and output names of - * variables. It also contains input values, but output values and errors are - * not copied. - */ -template -YDEFX_EXPORT py2cpp::PyPtr createPySample(const Sample& sample); - /*! * Fetch output values and errors from the python objet. * The c++ sample should already contain the names of variables when this @@ -355,21 +347,6 @@ YDEFX_EXPORT py2cpp::ConversionCheck errorsFromPy(PyObject* obj, Sample& return check; } -template -YDEFX_EXPORT py2cpp::PyPtr createPySample(const Sample& sample) -{ - py2cpp::PyFunction sampleConstructor; - sampleConstructor.loadExp("pydefx", "Sample"); - py2cpp::PyPtr result = sampleConstructor(sample.allInputNames(), - sample.allOutputNames()); - - py2cpp::PyFunction setInputValues; - setInputValues.loadExp(result, "setInputValues"); - setInputValues(inputToPy(sample)); - - return result; -} - template YDEFX_EXPORT py2cpp::ConversionCheck fetchResults(const py2cpp::PyPtr& obj, Sample& sample) { diff --git a/src/cpp/TMonoPyJob.hxx b/src/cpp/TMonoPyJob.hxx index 54753d8..8d50f63 100644 --- a/src/cpp/TMonoPyJob.hxx +++ b/src/cpp/TMonoPyJob.hxx @@ -41,7 +41,11 @@ public: { try { - py2cpp::PyPtr pySample = createPySample(sample); + py2cpp::PyPtr pySample = fnScript.createEmptySample(); + py2cpp::PyFunction setInputValues; + setInputValues.loadExp(pySample, "setInputValues"); + setInputValues(inputToPy(_sample)); + py2cpp::PyFunction pyFn; pyFn.loadExp(_pyStudy, "createNewJob"); pyFn(fnScript, pySample, params); diff --git a/src/cpp/TPyStudyJob.hxx b/src/cpp/TPyStudyJob.hxx index 02e3e80..0922d45 100644 --- a/src/cpp/TPyStudyJob.hxx +++ b/src/cpp/TPyStudyJob.hxx @@ -99,7 +99,11 @@ private: { try { - py2cpp::PyPtr pySample = createPySample(_sample); + py2cpp::PyPtr pySample = fnScript.createEmptySample(); + py2cpp::PyFunction setInputValues; + setInputValues.loadExp(pySample, "setInputValues"); + setInputValues(inputToPy(_sample)); + py2cpp::PyFunction pyFn; pyFn.loadExp(_pyStudy, "createNewJob"); pyFn(fnScript, pySample, params); diff --git a/src/pyexample/multijob/launch_multi.py b/src/pyexample/multijob/launch_multi.py index 2fa057f..95fdc64 100755 --- a/src/pyexample/multijob/launch_multi.py +++ b/src/pyexample/multijob/launch_multi.py @@ -2,7 +2,7 @@ import pydefx import os myParams = pydefx.Parameters() -myParams.configureResource("eole") +myParams.configureResource("gaia") #myParams.createResultDirectory("/tmp") myParams.nb_branches = 4 myParams.salome_parameters.resource_required.nb_proc = 1