]> SALOME platform Git repositories - tools/ydefx.git/commitdiff
Salome HOME
Example for slurm without YACS. V9_9_0 V9_9_0a2 V9_9_0rc1 V9_9_0rc2
authorOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Fri, 4 Feb 2022 11:14:20 +0000 (12:14 +0100)
committerOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Fri, 4 Feb 2022 11:14:20 +0000 (12:14 +0100)
src/pyexample/multijob/launch_slurm_light.py [new file with mode: 0755]

diff --git a/src/pyexample/multijob/launch_slurm_light.py b/src/pyexample/multijob/launch_slurm_light.py
new file mode 100755 (executable)
index 0000000..d8a42b6
--- /dev/null
@@ -0,0 +1,41 @@
+"""
+Cet exemple est adapté pour le cas où la fonction _exec lance une ou plusieures
+commandes srun.
+La parallélisation est basée sur multiprocessing, mais la distribution est à la
+charge de la function _exec par l'utilisation de srun.
+Dans cet exemple, on n'utilise ni YACS ni les containers de Salomé.
+"""
+import pydefx
+import os
+
+myParams = pydefx.Parameters()
+myParams.configureResource("gaia")
+myParams.nb_branches = 4
+myParams.salome_parameters.resource_required.nb_proc = 4
+myParams.salome_parameters.result_directory=os.path.join(os.getcwd(),"lightsrun")
+myParams.salome_parameters.work_directory="/scratch/I35256/workingdir/test_srunjob/"
+myParams.salome_parameters.local_directory = os.getcwd()
+myParams.salome_parameters.in_files=["template_jdd.txt", "mysolver.py"]
+
+pyScript = os.path.join(os.getcwd(), "mystudy.py")
+
+myScript = pydefx.PyScript()
+myScript.loadFile(pyScript)
+
+mySample = myScript.CreateEmptySample()
+mydata = {"x":range(10)}
+mySample.setInputValues(mydata)
+
+pydefx_path = os.path.dirname(pydefx.__file__)
+light_executor_path = os.path.join(pydefx_path, "plugins", "lightexecutor.py")
+
+mybuilder = pydefx.slurmbuilder.SlurmBuilder(executor=light_executor_path)
+
+myStudy = pydefx.SlurmStudy(schemaBuilder=mybuilder)
+myStudy.createNewJob(myScript, mySample, myParams)
+myStudy.launch()
+
+myStudy.getJobState()
+myStudy.wait()
+print(myStudy.getResult())
+print(myStudy.sample)