]> SALOME platform Git repositories - modules/yacs.git/blob - src/evalyfx_swig/test3.py
Salome HOME
Deleted deprecated code
[modules/yacs.git] / src / evalyfx_swig / test3.py
1 # Copyright (C) 2015-2016  CEA/DEN, EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 # first test using cluster
21
22 import os,getpass
23
24 CatalogResources="""<?xml version="1.0"?>
25 <resources>
26   <machine name="localhost" hostname="dsp0698184" type="single_machine" appliPath="" batchQueue="" userCommands="" protocol="ssh" iprotocol="ssh" workingDirectory="" canLaunchBatchJobs="false" canRunContainers="true" batch="none" mpi="no mpi" userName="" OS="" memInMB="0" CPUFreqMHz="0" nbOfNodes="1" nbOfProcPerNode="4"/>
27   <machine name="athos" hostname="athos" type="cluster" appliPath="/home/H87074/ATHOS_V771/appli_V7_7_1" batchQueue="" userCommands="" protocol="ssh" iprotocol="ssh" workingDirectory="" canLaunchBatchJobs="true" canRunContainers="false" batch="slurm" mpi="no mpi" userName="" OS="" memInMB="0" CPUFreqMHz="0" nbOfNodes="250" nbOfProcPerNode="28"/>
28 </resources>"""
29
30 def buildScheme(fname):
31     import SALOMERuntime
32     import loader
33     SALOMERuntime.RuntimeSALOME.setRuntime()
34     r=SALOMERuntime.getSALOMERuntime()
35     p0=r.createProc("run")
36     #
37     p=r.createBloc("toto")
38     p0.edAddChild(p)
39     #
40     cont=p0.createContainer("MyWonderfulContainer","Salome")
41     td=p0.createType("double","double")
42     n0=r.createScriptNode("Salome","PyScript0")
43     p.edAddChild(n0)
44     q=n0.edAddInputPort("q",td)
45     ep=n0.edAddOutputPort("ep",td)
46     n0.setScript("ep=1./(4.-q)") # <- force division by 0
47     n0.setExecutionMode("remote")
48     n0.setContainer(cont)
49     p0.saveSchema(fname)
50     pass
51
52 fname="test3.xml"
53 import evalyfx
54 session=evalyfx.YACSEvalSession()
55 session.launch()
56 buildScheme(fname)
57 efx=evalyfx.YACSEvalYFX.BuildFromFile(fname)
58 efx.getParams().setStopASAPAfterErrorStatus(False)
59 inps=efx.getFreeInputPorts()
60 assert(len(inps)==1)
61 outps=efx.getFreeOutputPorts()
62 inps[0].setSequenceOfValuesToEval([-7.,2.,3.,5.,6.])
63 efx.lockPortsForEvaluation(inps,outps)
64 #
65 rss=efx.giveResources()
66 rss[0][0].setWantedMachine("athos")
67 cp=rss.getAddParamsForCluster() ; cp.setRemoteWorkingDir(os.path.join("/scratch",getpass.getuser(),"TMP3")) ; cp.setLocalWorkingDir(os.path.join(os.path.expanduser("~"),"TMP52"))
68 cp.setWCKey("P11U50:CARBONES") ; cp.setNbProcs(5) ; cp.setMaxDuration("00:05")
69 assert(not rss.isInteractive())
70 a,b=efx.run(session)
71 print("************",a,b)
72 print efx.getResults()