]> SALOME platform Git repositories - tools/ydefx.git/commitdiff
Salome HOME
WIP
authorAnthony Geay <anthony.geay@edf.fr>
Fri, 6 Jan 2023 08:55:51 +0000 (09:55 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Fri, 6 Jan 2023 08:55:51 +0000 (09:55 +0100)
src/pydefx/mpmcn.py

index 1232c49c257b291b8e00c25adaac7452650c366c..b6a95696917bfe9b1dd7b2a2b777cb20913f178a 100644 (file)
@@ -19,6 +19,8 @@
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 
 import pydefx
+import salome
+salome.salome_init()
 
 myParams = None
 
@@ -62,23 +64,21 @@ def _exec({}):
         self.myScript.loadString(pyScript)
         self.mySample = self.myScript.CreateEmptySample()
         #
-        #print(fArgs)
-        #print(iterable)
-        #
         if not hasattr(iterable[0],"__iter__"):
             iterable = [[elt] for elt in iterable]
         #
-        #print(pyScript)
-        #print({k:v for k,*v in zip(fArgs,*iterable)})
-        #
         self.mySample.setInputValues( {k:v for k,*v in zip(fArgs,*iterable)} )
         #
         self.myStudy.createNewJob(self.myScript, self.mySample, myParams)
         #
         self.myStudy.launch()
         self.myStudy.wait()
+        self.myStudy.getResult()
         #
-        return self.myStudy.getResult()
+        ret = [elt for elt in zip(*[self.myStudy.sample._output[n] for n in self.myStudy.sample.getOutputNames()])]
+        if len(self.myStudy.sample.getOutputNames()) == 1:
+            ret = [elt[0] for elt in ret]
+        return ret
 
     def __enter__(self):
         self.myStudy = pydefx.PyStudy()
@@ -88,6 +88,18 @@ def _exec({}):
         pass
     pass
 
+def getResourcesAbleToLaunchJobs():
+    """
+    Regarding list of Resources in the CatalogResources.xml this method returns those able to launch jobs.
+    Ydefx engine delegate to a job encapsulating itself an execution of YACS graph with driver application.
+    Consequently, the resource to evaluate in parallel the function should one of those returned by this method.
+    """
+    import LifeCycleCORBA
+    params = LifeCycleCORBA.ResourceParameters(can_launch_batch_jobs=True)
+    # ask to resource manager to filter among all resources listed in CatalogResources those able to launch job.
+    return salome.rm.GetFittingResources(params)
+
+
 def init(resultDirectory = "/tmp"):
     """
     :param resourceName: Name of the resource matching one of the ${KERNEL_ROOT_DIR}/share/salome/resources/kernel/CatalogResources.xml
@@ -95,7 +107,16 @@ def init(resultDirectory = "/tmp"):
     """
     global myParams
     myParams = pydefx.Parameters()
+
+    # pour cluster avec 10 noeuds de 28 coeurs chacuns
+    #
+
+    # On positionne la resource qui va lancer le job qui inclu drive
+    # rmyParams.nb_branches = 4
     myParams.configureResource("localhost")
     myParams.createResultDirectory(resultDirectory)
+    myParams.nb_branches = 280
+    myParams.salome_parameters.
+    # myParams.salome_parameters.work_directory = wd
     pass