From: Ovidiu Mircescu Date: Fri, 4 Feb 2022 11:14:20 +0000 (+0100) Subject: Example for slurm without YACS. X-Git-Tag: V9_9_0rc2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=983f8221c1f103defeb4bf852da38736684581c2;p=tools%2Fydefx.git Example for slurm without YACS. --- diff --git a/src/pyexample/multijob/launch_slurm_light.py b/src/pyexample/multijob/launch_slurm_light.py new file mode 100755 index 0000000..d8a42b6 --- /dev/null +++ b/src/pyexample/multijob/launch_slurm_light.py @@ -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)