Version: 9.15.0
driver_internal Namespace Reference

Functions

def initializeSALOME ()
 
def SALOMEInitializationNeeded (func)
 
def loadGraph (xmlFileName)
 
def patchGraph (proc, squeezeMemory, initPorts, xmlSchema, loadStateXmlFile, reset, display)
 
def prepareExecution (proc, isStop, dumpErrorFile)
 
def executeGraph (executor, xmlfilename, proc, dump, finalDump, display, shutdown, CPUMemContainerTimeRes, HTopOfThisProcessFile, HTopTimeRes, HTopOfAllServersFile, HTopOfAllServersTimeRes, DirectoriesToMonitor)
 
def EntryFromCoarseEntry (entry)
 
def toDict (args)
 
def reprAfterArgParsing (args)
 
def getArgumentParser ()
 
def mainRun (args, xmlFileName)
 
def parseArgs ()
 

Variables

string DisplayEntryInCMD = "--display"
 
string VerboseEntryInCMD = "--verbose"
 
string VerboseLevelEntryInCMD = "--verbose-level"
 
string StopOnErrorEntryInCMD = "--stop-on-error"
 
string DumpOnErrorEntryInCMD = "--dump-on-error"
 
string DumpEntryInCMD = "--dump"
 
string KernelTraceEntryInCMD = "--kerneltrace"
 
string DumpStateEntryInCMD = "--dump-final"
 
string LoadStateEntryInCMD = "--load-state"
 
string SaveXMLSchemaEntryInCMD = "--save-xml-schema"
 
string ShutdownEntryInCMD = "--shutdown"
 
string ResetEntryInCMD = "--reset"
 
string InitPortEntryInCMD = "--init-port"
 
string DoNotSqueezeEntryInCMD = "--donotsqueeze"
 
string IOREntryInCMD = "--ior-ns"
 
string CPUTimeResOfContainerEntryInCMD = "--cpu-mem-container-time-res"
 
string HTOPFileEntryInCMD = "--htop-of-yacs-engine-process-file"
 
string HTOPServerFileEntryInCMD = "--htop-of-servers"
 
string HTOPFileTimeResEntryInCMD = "--htop-of-yacs-engine-process-time-res"
 
string HTOPServerFileTimeResEntryInCMD = "--htop-of-servers-time-res"
 
string MonitoringDirsEntryInCMD = "--monitoring-dirs-content"
 
string MonitoringDirsResEntryInCMD = "--monitoring-dirs-content-res"
 
string MonitoringDirsTimeResEntryInCMD = "--monitoring-dirs-content-time-res"
 
string ReplayOnErrorEntryInCMD = "--replay-on-error"
 
string ReplayDirInCMD = "--replay-dir"
 
string BigObjDirInCMD = "--bigobj-dir"
 
string BigObjThresInCMD = "--bigobj-thres"
 
string CustomOverridesInCMD = "--activate-custom-overrides"
 
string DisplayKeyInARGS = "display"
 
string VerboseKeyInARGS = "verbose"
 
string VerboseLevelKeyInARGS = "verbose_level"
 
string StopOnErrorKeyInARGS = "stop"
 
string DumpOnErrorKeyInARGS = "dumpErrorFile"
 
string DumpKeyInARGS = "dump"
 
string KernelTraceKeyInARGS = "kerneltrace"
 
string DumpStateKeyInARGS = "finalDump"
 
string LoadStateKeyInARGS = "loadState"
 
string SaveXMLSchemaKeyInARGS = "saveXMLSchema"
 
string ShutdownKeyInARGS = "shutdown"
 
string ResetKeyInARGS = "reset"
 
string InitPortKeyInARGS = "init_port"
 
string DoNotSqueezeKeyInARGS = "donotsqueeze"
 
string IORKeyInARGS = "iorNS"
 
string CPUTimeResOfContainerKeyInARGS = "cpu_mem_container_time_res"
 
string HTOPFileKeyInARGS = "htop_of_yacs_engine_process_file"
 
string HTOPServerFileKeyInARGS = "htop_of_servers"
 
string HTOPFileTimeResKeyInARGS = "htop_of_yacs_engine_process_time_res"
 
string HTOPServerFileTimeResKeyInARGS = "htop_of_servers_time_res"
 
string MonitoringDirsInARGS = "monitoring_dirs_content"
 
string MonitoringDirsResInARGS = "monitoring_dirs_content_res"
 
string MonitoringDirsTimeResInARGS = "monitoring_dirs_content_time_res"
 
string ReplayOnErrorEntryInARGS = "replay_on_error"
 
string ReplayDirInARGS = "replay_dir"
 
string BigObjDirInARGS = "bigobj_dir"
 
string BigObjThresInARGS = "bigobj_thres"
 
string CustomOverridesInARGS = "activate_custom_overrides"
 
list KeyValnARGS
 
 my_runtime_yacs = None
 
 my_ior_ns = None
 
bool my_replay_on_error = False
 
string my_replay_dir = ""
 
 args
 
 xmlFileName
 
 _proc
 
 _shutdown
 
 _dumpFile
 
 _lockFile
 
 _dump_thread
 

Function Documentation

◆ EntryFromCoarseEntry()

def driver_internal.EntryFromCoarseEntry (   entry)

Definition at line 338 of file driver_internal.py.

338 def EntryFromCoarseEntry( entry ):
339  if entry[:2] != "--":
340  raise RuntimeError("Unexpected entry")
341  return entry[2:]
342 
def EntryFromCoarseEntry(entry)

Referenced by parseArgs(), and toDict().

◆ executeGraph()

def driver_internal.executeGraph (   executor,
  xmlfilename,
  proc,
  dump,
  finalDump,
  display,
  shutdown,
  CPUMemContainerTimeRes,
  HTopOfThisProcessFile,
  HTopTimeRes,
  HTopOfAllServersFile,
  HTopOfAllServersTimeRes,
  DirectoriesToMonitor 
)
Args:
-----

executor (pilot.ExecutorSwig) : Executor in charge of evaluation.
proc ( SALOMERuntime.SalomeProc ) : YACS Proc instance to be evaluated
xmlfilename (string)
dump (int) : time interval between 2 dump state
finalDump ( string ) : filename containing final result of graph, if any.
display (int) :
shutdown (int) : shutdown level
CPUMemContainerTimeRes (int) : time in second between two measures of CPU/Mem in container processes
HTopOfThisProcessFile (str) : file name (if not empty) containing the result of measure of current process
HTopTimeRes (int) : time in second between two measures of CPU/Mem of current process
HTopOfAllServersFile (str) : file name (if not empty) containing the result of measure of all servers
HTopOfAllServersTimeRes (int) : time in second between two measures of CPU/Mem of any of server

Definition at line 236 of file driver_internal.py.

238  HTopOfAllServersFile, HTopOfAllServersTimeRes, DirectoriesToMonitor):
239  """
240  Args:
241  -----
242 
243  executor (pilot.ExecutorSwig) : Executor in charge of evaluation.
244  proc ( SALOMERuntime.SalomeProc ) : YACS Proc instance to be evaluated
245  xmlfilename (string)
246  dump (int) : time interval between 2 dump state
247  finalDump ( string ) : filename containing final result of graph, if any.
248  display (int) :
249  shutdown (int) : shutdown level
250  CPUMemContainerTimeRes (int) : time in second between two measures of CPU/Mem in container processes
251  HTopOfThisProcessFile (str) : file name (if not empty) containing the result of measure of current process
252  HTopTimeRes (int) : time in second between two measures of CPU/Mem of current process
253  HTopOfAllServersFile (str) : file name (if not empty) containing the result of measure of all servers
254  HTopOfAllServersTimeRes (int) : time in second between two measures of CPU/Mem of any of server
255  """
256  import SALOMERuntime
257  import pilot
258  import os
259  import contextlib
260 
261  class AutoShutdown:
262  def __init__(self, proc, shutdown):
263  self._proc = proc
264  self._shutdown = shutdown
265  def __enter__(self):
266  pass
267 
268  def __exit__(self,exctype, exc, tb):
269  if my_replay_on_error:
270  listOfGrps = []
271  for cont in salome.get_all_containers():
272  listOfGrps += cont.getAllLogFileNameGroups()
273  print("{} {} {}".format( 100*"=", "List of replay sessions of failing usecases" , 100*"="))
274  for igrp,grp in enumerate(listOfGrps):
275  print("{} : {}".format("Group {}".format(igrp)," ".join(grp)))
276  print(300*"=")
277  #
278  if self._shutdown < 999:
279  self._proc.shutdown(self._shutdown)
280  salome.dsm.shutdownScopes()
281  my_runtime_yacs.fini( False )
282 
283  class AutoDumpThread:
284  def __init__(self, proc, dump, xmlfilename):
285  self._dumpFile = "dumpState_{}".format( os.path.basename(xmlfilename) )
286  self._lockFile = "{}.lock".format( os.path.splitext( os.path.basename(xmlfilename) )[0] )
287  def __enter__(self):
288  logging.info(f"Ready to launch thread of state dump with dumpFile = {self._dumpFile} lockFile = {self._lockFile}")
289  self._dump_thread = SALOMERuntime.ThreadDumpState(proc,dump,self._dumpFile,self._lockFile)
290  self._dump_thread.start()
291  def __exit__(self,exctype, exc, tb):
292  self._dump_thread.join()
293 
294  def MonitoringDirectories( DirectoriesToMonitor ):
295  import SALOME_PyNode
296  if len( DirectoriesToMonitor ) > 0:
297  return [ SALOME_PyNode.GenericPythonMonitoringLauncherCtxMgr( SALOME_PyNode.FileSystemMonitoring(timeRes*1000,zeDir,zeDirRes) ) for zeDir,zeDirRes,timeRes in DirectoriesToMonitor ]
298  else:
299  return [ ]
300 
301  def MonitoringThisProcess(HTopOfThisProcessFile,HTopTimeRes):
302  import SALOME_PyNode
303  if HTopOfThisProcessFile:
304  return [ SALOME_PyNode.GenericPythonMonitoringLauncherCtxMgr( SALOME_PyNode.CPUMemoryMonitoring(1000*HTopTimeRes,HTopOfThisProcessFile) ) ]
305  else:
306  return [ ]
307 
308  def MonitoringAllKernelServers(HTopOfAllServersFile, HTopOfAllServersTimeRes):
309  if HTopOfAllServersFile:
310  return [ salome.LogManagerLaunchMonitoringFileCtxMgr( 1000*HTopOfAllServersTimeRes, HTopOfAllServersFile ) ]
311  else:
312  return [ ]
313  #
314  salome.cm.SetDeltaTimeBetweenCPUMemMeasureInMilliSecond( 1000*CPUMemContainerTimeRes )
315  # Start part of context manager instances
316  ctxManagers = [ AutoShutdown(proc,shutdown) ] # the first one must be this one. Because orb.shutdown must be called last !
317  #
318  ctxManagers += MonitoringDirectories( DirectoriesToMonitor ) + MonitoringThisProcess(HTopOfThisProcessFile, HTopTimeRes) + MonitoringAllKernelServers(HTopOfAllServersFile, HTopOfAllServersTimeRes)
319  #
320  if dump != 0:
321  ctxManagers += [ AutoDumpThread(proc,dump,xmlfilename) ]
322  # end of part of context managers
323  with contextlib.ExitStack() as stack:
324  for mgr in ctxManagers:
325  stack.enter_context(mgr)
326  executor.RunPy(proc,display,isPyThread=True,fromscratch=True) # same as RunW but releasing GIL
327  #
328  if proc.getEffectiveState() != pilot.DONE:
329  raise RuntimeError( proc.getErrorReport() )
330  #
331  if display > 0:
332  proc.writeDotInFile("titi")
333  #
334  if finalDump:
335  logging.info(f"Final dump requested : {finalDump}")
336  SALOMERuntime.schemaSaveStateUnsafe( proc, finalDump )
337 

Referenced by mainRun().

◆ getArgumentParser()

def driver_internal.getArgumentParser ( )

Definition at line 358 of file driver_internal.py.

358 def getArgumentParser():
359  import KernelBasis
360  import argparse
361  parser = argparse.ArgumentParser()
362  parser.add_argument('xmlfilename',help = "XML file containing YACS schema to be executed")
363  parser.add_argument("-d", DisplayEntryInCMD, dest = DisplayKeyInARGS, type=int, const=1, nargs='?', default=0, help="Display dot files: 0=never to 3=very often")
364  parser.add_argument("-v", VerboseEntryInCMD, dest = VerboseKeyInARGS,help="Produce verbose output", action='store_true')
365  parser.add_argument("-vl", VerboseLevelEntryInCMD, dest = VerboseLevelKeyInARGS, type=str, choices=["ERROR", "WARNING", "INFO", "DEBUG"], default="INFO", help="Specifies level of verbosity")
366  parser.add_argument("-s",StopOnErrorEntryInCMD,dest=StopOnErrorKeyInARGS,help="Stop on first error", action='store_true')
367  parser.add_argument("-e",DumpOnErrorEntryInCMD,dest=DumpOnErrorKeyInARGS, type=str, const='dumpErrorState.xml', default="", nargs='?', help="Stop on first error and dump state")
368  parser.add_argument("-g",DumpEntryInCMD,dest=DumpKeyInARGS, type=int, const=60, default=0, nargs='?', help="dump state")
369  parser.add_argument("-kt", KernelTraceEntryInCMD, dest = KernelTraceKeyInARGS,help="Produce verbose of SALOME/KERNEL", action='store_true')
370  parser.add_argument("-f",DumpStateEntryInCMD, dest =DumpStateKeyInARGS, type=str, const='finalDumpState.xml', default="", nargs='?', help="dump final state")
371  parser.add_argument("-l",LoadStateEntryInCMD, dest=LoadStateKeyInARGS, type=str, default="", help="Load State from a previous partial execution")
372  parser.add_argument("-x",SaveXMLSchemaEntryInCMD, dest=SaveXMLSchemaKeyInARGS, type=str, const="saveSchema.xml", nargs='?', default="", help = "dump xml schema")
373  parser.add_argument("-t",ShutdownEntryInCMD, dest = ShutdownKeyInARGS, type=int , default=3, help="Shutdown the schema: 0=no shutdown to 3=full shutdown")
374  parser.add_argument("-r",ResetEntryInCMD, dest = ResetKeyInARGS, type=int , default = 0, help="Reset the schema before execution: 0=nothing, 1=reset error nodes to ready state")
375  parser.add_argument("-i",InitPortEntryInCMD, dest = InitPortKeyInARGS, type=str, default =[], action='append', help="Initialisation value of a port, specified as bloc.node.port=value. For multiple settings use comma.")
376  parser.add_argument("-z",DoNotSqueezeEntryInCMD, dest = DoNotSqueezeKeyInARGS, help = "Desactivate squeeze memory optimization.", action='store_true')
377  parser.add_argument(CPUTimeResOfContainerEntryInCMD, dest = CPUTimeResOfContainerKeyInARGS, type=int, default = 10, help="Time in second between two measures of CPU/Mem in container processes")
378  parser.add_argument(HTOPFileEntryInCMD, dest = HTOPFileKeyInARGS, type=str, default ="", help="File name (if not empty) containing the result of measure of current process")
379  parser.add_argument(HTOPFileTimeResEntryInCMD, dest = HTOPFileTimeResKeyInARGS, type=int, default = 60, help="Time in second between between two measures of CPU/Mem of current process")
380  parser.add_argument(HTOPServerFileEntryInCMD, dest = HTOPServerFileKeyInARGS, type=str, default ="", help="File name (if not empty) containing the result of measure of all server processes")
381  parser.add_argument(HTOPServerFileTimeResEntryInCMD, dest = HTOPServerFileTimeResKeyInARGS, type=int, default = 30, help="Time in second between between two measures of CPU/Mem of any server process")
382  parser.add_argument(MonitoringDirsEntryInCMD, dest = MonitoringDirsInARGS, nargs='+', type=str, default =[], help="List of directories to be monitored")
383  parser.add_argument(MonitoringDirsResEntryInCMD, dest = MonitoringDirsResInARGS, nargs='+', type=str, default =[], help=f"List of files with result of monitoring of directories to be monitored (see {MonitoringDirsInARGS}). The size of lists are expected to be the same.")
384  parser.add_argument(MonitoringDirsTimeResEntryInCMD, dest = MonitoringDirsTimeResInARGS, nargs='+', type=int, default =[], help=f"List of time resolution (in second) of monitoring of directories to be monitored (see {MonitoringDirsInARGS}). The size of lists are expected to be the same.")
385  parser.add_argument("-w",ReplayOnErrorEntryInCMD,dest=ReplayOnErrorEntryInARGS,help="Mode of execution of YACS where all python execution are wrapped into a subprocess to be able to resist against failure (such as SIGSEV)", action='store_true')
386  parser.add_argument(ReplayDirInCMD, dest=ReplayDirInARGS, type=str, default ="", help="Directory storing replay scenarii if any (see replay-on-error option.")
387  parser.add_argument(BigObjDirInCMD, dest=BigObjDirInARGS, type=str, default ="", help="Directory storing big obj files exchanged between YACS python nodes.")
388  parser.add_argument(BigObjThresInCMD, dest=BigObjThresInARGS, type=int, default = KernelBasis.GetBigObjOnDiskThreshold(), help="Objects whose size exceeds this threshold in bytes will be written inside directory")
389  parser.add_argument(CustomOverridesInCMD, dest=CustomOverridesInARGS, help="Activate custom overrides. These overrides are incarnated by yacs_driver_overrides module that is expected to loadable in current application.", action='store_true')
390  parser.add_argument(IOREntryInCMD, dest = IORKeyInARGS, type=str, default ="", help="file inside which the ior of NS will be stored")
391  parser.add_argument("--options_from_json", dest = "options_from_json", type=str, default ="", help="Json file of options. If defined options in json will override those specified in command line.")
392  return parser
393 

Referenced by parseArgs().

◆ initializeSALOME()

def driver_internal.initializeSALOME ( )

Definition at line 119 of file driver_internal.py.

119 def initializeSALOME():
120  import SALOMERuntime
121  import KernelBasis
122  global my_runtime_yacs,my_ior_ns,my_runtime_yacs
123  if my_runtime_yacs:
124  return
125  salome.salome_init()
126  if my_replay_on_error:
127  KernelBasis.SetPyExecutionMode("OutOfProcessWithReplay")
128  KernelBasis.SetDirectoryForReplayFiles( my_replay_dir )
129  if my_ior_ns:
130  salome.naming_service.DumpIORInFile( my_ior_ns )
131  flags = SALOMERuntime.RuntimeSALOME.UsePython + SALOMERuntime.RuntimeSALOME.UseCorba + SALOMERuntime.RuntimeSALOME.UseXml + SALOMERuntime.RuntimeSALOME.UseCpp + SALOMERuntime.RuntimeSALOME.UseSalome
132  SALOMERuntime.RuntimeSALOME.setRuntime( flags )
133  my_runtime_yacs = SALOMERuntime.getSALOMERuntime()
134  anIOR = salome.orb.object_to_string ( salome.modulcat )
135  aCatalog = my_runtime_yacs.loadCatalog( "session", anIOR )
136  my_runtime_yacs.addCatalog( aCatalog )
137 

Referenced by SALOMEInitializationNeeded().

◆ loadGraph()

def driver_internal.loadGraph (   xmlFileName)
Args:
-----
xmlFileName : XML file containing YACS schema

Returns
-------

SALOMERuntime.SalomeProc : YACS graph instance

Definition at line 145 of file driver_internal.py.

145 def loadGraph( xmlFileName ):
146  """
147  Args:
148  -----
149  xmlFileName : XML file containing YACS schema
150 
151  Returns
152  -------
153 
154  SALOMERuntime.SalomeProc : YACS graph instance
155  """
156  import loader
157  l=loader.YACSLoader()
158  p=l.load( xmlFileName )
159  return p
160 
def loadGraph(xmlFileName)

Referenced by mainRun().

◆ mainRun()

def driver_internal.mainRun (   args,
  xmlFileName 
)
Args:
-----

args (dict) : options for treatment

Definition at line 394 of file driver_internal.py.

394 def mainRun( args, xmlFileName):
395  """
396  Args:
397  -----
398 
399  args (dict) : options for treatment
400 
401  """
402  global my_ior_ns,my_replay_on_error,my_replay_dir
403  from salome_utils import positionVerbosityOfLoggerRegardingState,setVerboseLevel,setVerbose,KernelLogLevelToLogging
404  #
405  iorNS = args[IORKeyInARGS]
406  #
407  if iorNS:
408  my_ior_ns = iorNS
409  #
410  if args[ReplayOnErrorEntryInARGS]:
411  my_replay_on_error = True
412  my_replay_dir = args[ReplayDirInARGS]
413  #
414  if args[VerboseKeyInARGS]:
415  setVerbose( args[ KernelTraceKeyInARGS ] )
416  setVerboseLevel( KernelLogLevelToLogging[ args[VerboseLevelKeyInARGS] ] )
417  positionVerbosityOfLoggerRegardingState()
418  logging.info( reprAfterArgParsing(args) )
419  #
420  proc = loadGraph( xmlFileName )
421  # work around a bug in Executor::Run when there are no tasks to launch.
422  if len(proc.getChildren()) == 0 :
423  return
424  #
425  patchGraph( proc, not args[DoNotSqueezeKeyInARGS], args[InitPortKeyInARGS], args[SaveXMLSchemaKeyInARGS], args[LoadStateKeyInARGS], args[ResetKeyInARGS], args[DisplayKeyInARGS])
426  executor = prepareExecution( proc, args[StopOnErrorKeyInARGS], args[DumpOnErrorKeyInARGS])
427  # proxy parameters management
428  if args[ BigObjDirInARGS ]:
429  salome.cm.SetBigObjOnDiskDirectory( args[ BigObjDirInARGS ] )
430  salome.cm.SetBigObjOnDiskThreshold( args[ BigObjThresInARGS ] )
431  # overrides
432  if args[ CustomOverridesInARGS ]:
433  try:
434  import yacs_driver_overrides
435  import pylauncher
436  allresources = pylauncher.RetrieveRMCppSingleton()# pylauncher.ResourcesManager_cpp singleton representing all resources (pylauncher.ResourceDefinition_cpp) devoted for the computation.
437  yacs_driver_overrides.customize( salome.cm, allresources )
438  except:
439  raise RuntimeError("Overrides have be requested to be triggered by the user but module is not available")
440  #
441  executeGraph( executor, xmlFileName, proc, args[DumpKeyInARGS], args[DumpStateKeyInARGS], args[DisplayKeyInARGS], args[ShutdownKeyInARGS], args[CPUTimeResOfContainerKeyInARGS],
442  args[HTOPFileKeyInARGS], args[HTOPFileTimeResKeyInARGS],
443  args[HTOPServerFileKeyInARGS], args[HTOPServerFileTimeResKeyInARGS], [(dirToMonitor,resFile,timeRes) for dirToMonitor,resFile,timeRes in zip(args[MonitoringDirsInARGS],args[MonitoringDirsResInARGS],args[MonitoringDirsTimeResInARGS])] )
444 
def patchGraph(proc, squeezeMemory, initPorts, xmlSchema, loadStateXmlFile, reset, display)
def reprAfterArgParsing(args)
def prepareExecution(proc, isStop, dumpErrorFile)
def executeGraph(executor, xmlfilename, proc, dump, finalDump, display, shutdown, CPUMemContainerTimeRes, HTopOfThisProcessFile, HTopTimeRes, HTopOfAllServersFile, HTopOfAllServersTimeRes, DirectoriesToMonitor)
def mainRun(args, xmlFileName)

References executeGraph(), loadGraph(), patchGraph(), prepareExecution(), and reprAfterArgParsing().

◆ parseArgs()

def driver_internal.parseArgs ( )
Returns
-------

- args (dict) : dictionnary containing all args taken into account. If json, the params in json will override entries
- xmlFileName (str) : XML YACS schema

Definition at line 445 of file driver_internal.py.

445 def parseArgs():
446  """
447  Returns
448  -------
449 
450  - args (dict) : dictionnary containing all args taken into account. If json, the params in json will override entries
451  - xmlFileName (str) : XML YACS schema
452 
453  """
454  import json
455  parser = getArgumentParser()
456  args = parser.parse_args()
457  iorNS = args.iorNS
458  xmlFileName = args.xmlfilename
459  optionFromJSon = args.options_from_json
460  args = toDict( args )
461  if optionFromJSon:
462  # in case of Json overrides
463  with open( optionFromJSon ) as f:
464  opts_from_json = json.load( f )
465  for k,v in opts_from_json.items():
466  if k != EntryFromCoarseEntry(IOREntryInCMD) or v:# for IOR if v is null -> do not override
467  args[k] = v
468  # change key of args from entryCMD to KeyInARGS
469  args = {key:args[EntryFromCoarseEntry(entry)] for entry,key in KeyValnARGS}
470  return args, xmlFileName
471 

References EntryFromCoarseEntry(), getArgumentParser(), and toDict().

◆ patchGraph()

def driver_internal.patchGraph (   proc,
  squeezeMemory,
  initPorts,
  xmlSchema,
  loadStateXmlFile,
  reset,
  display 
)
Args:
-----

proc ( SALOMERuntime.SalomeProc ) : YACS Proc instance to be evaluated
squeezeMemory ( bool ) : squeezememory to be activated
initPorts (list<string>) : list of bloc.node.port=value.
xmlSchema (string) :
loadStateXmlFile (string) : file if any of state to be loaded inside proc
reset (int) : 
display (int) :

Definition at line 161 of file driver_internal.py.

161 def patchGraph( proc, squeezeMemory, initPorts, xmlSchema, loadStateXmlFile, reset, display):
162  """
163  Args:
164  -----
165 
166  proc ( SALOMERuntime.SalomeProc ) : YACS Proc instance to be evaluated
167  squeezeMemory ( bool ) : squeezememory to be activated
168  initPorts (list<string>) : list of bloc.node.port=value.
169  xmlSchema (string) :
170  loadStateXmlFile (string) : file if any of state to be loaded inside proc
171  reset (int) :
172  display (int) :
173  """
174  import SALOMERuntime
175  import loader
176  import pilot
177  def parse_init_port(input):
178  """
179  Returns
180  -------
181  node, port, value
182  """
183  node_port, value = input.split("=")
184  nodePortSpl = node_port.split(".")
185  port = nodePortSpl[-1]
186  node = ".".join( nodePortSpl[:-1] )
187  return node,port,value
188 
189  if squeezeMemory:
190  logging.info("SqueezeMemory requested -> update proc")
191  allNodes = proc.getAllRecursiveNodes()
192  for node in allNodes:
193  if isinstance(node,SALOMERuntime.PythonNode):
194  node.setSqueezeStatus( True )
195  #
196  for initPort in initPorts:
197  node,port,value = parse_init_port(initPort)
198  init_state = proc.setInPortValue(node, port, value)
199  if init_state != value:
200  raise RuntimeError(f"Error on initialization of {initPort}")
201  #
202  if xmlSchema:
203  SALOMERuntime.VisitorSaveSalomeSchemaUnsafe(proc,xmlSchema)
204  pass
205  #
206  info = pilot.LinkInfo( pilot.LinkInfo.ALL_DONT_STOP )
207  proc.checkConsistency(info)
208  if info.areWarningsOrErrors():
209  raise RuntimeError( info.getGlobalRepr() )
210  #
211  if loadStateXmlFile:
212  loader.loadState( proc, loadStateXmlFile )
213  if reset > 0:
214  proc.resetState(reset)
215  proc.exUpdateState()
216  #
217  if display > 0:
218  proc.writeDotInFile("toto")
219 
220 @SALOMEInitializationNeeded
bool parse_init_port(const std::string &input, std::string &node, std::string &port, std::string &value)
Definition: driver.cxx:294

References parse_init_port().

Referenced by mainRun().

◆ prepareExecution()

def driver_internal.prepareExecution (   proc,
  isStop,
  dumpErrorFile 
)
Returns
-------

pilot.ExecutorSwig : Instance of executor

Definition at line 221 of file driver_internal.py.

221 def prepareExecution(proc, isStop, dumpErrorFile):
222  """
223  Returns
224  -------
225 
226  pilot.ExecutorSwig : Instance of executor
227  """
228  import pilot
229  ex=pilot.ExecutorSwig()
230  if isStop:
231  logging.info(f"Stop has been activated with {dumpErrorFile}")
232  ex.setStopOnError( dumpErrorFile!="", dumpErrorFile )
233  return ex
234 
235 @SALOMEInitializationNeeded

Referenced by mainRun().

◆ reprAfterArgParsing()

def driver_internal.reprAfterArgParsing (   args)
Args:
-----

args (argparse.Namespace) : instance after parsing

Definition at line 349 of file driver_internal.py.

349 def reprAfterArgParsing( args ):
350  """
351  Args:
352  -----
353 
354  args (argparse.Namespace) : instance after parsing
355  """
356  return "\n".join( [ f"{EntryFromCoarseEntry(entry)} : {args[key]}" for entry,key in KeyValnARGS ] )
357 

Referenced by mainRun().

◆ SALOMEInitializationNeeded()

def driver_internal.SALOMEInitializationNeeded (   func)

Definition at line 138 of file driver_internal.py.

139  def decaratedFunc(*args,**kwargs):
141  return func(*args,**kwargs)
142  return decaratedFunc
143 
144 @SALOMEInitializationNeeded
def SALOMEInitializationNeeded(func)

References initializeSALOME().

◆ toDict()

def driver_internal.toDict (   args)
Convert argparse.Namespace to dict

Definition at line 343 of file driver_internal.py.

343 def toDict( args ):
344  """
345  Convert argparse.Namespace to dict
346  """
347  return {EntryFromCoarseEntry(entry):getattr(args,key) for entry,key in KeyValnARGS}
348 

References EntryFromCoarseEntry().

Referenced by parseArgs().

Variable Documentation

◆ _dump_thread

driver_internal._dump_thread
private

Definition at line 289 of file driver_internal.py.

◆ _dumpFile

driver_internal._dumpFile
private

Definition at line 285 of file driver_internal.py.

◆ _lockFile

driver_internal._lockFile
private

Definition at line 286 of file driver_internal.py.

◆ _proc

◆ _shutdown

driver_internal._shutdown
private

Definition at line 264 of file driver_internal.py.

◆ args

◆ BigObjDirInARGS

string driver_internal.BigObjDirInARGS = "bigobj_dir"

Definition at line 78 of file driver_internal.py.

◆ BigObjDirInCMD

string driver_internal.BigObjDirInCMD = "--bigobj-dir"

Definition at line 49 of file driver_internal.py.

◆ BigObjThresInARGS

string driver_internal.BigObjThresInARGS = "bigobj_thres"

Definition at line 79 of file driver_internal.py.

◆ BigObjThresInCMD

string driver_internal.BigObjThresInCMD = "--bigobj-thres"

Definition at line 50 of file driver_internal.py.

◆ CPUTimeResOfContainerEntryInCMD

string driver_internal.CPUTimeResOfContainerEntryInCMD = "--cpu-mem-container-time-res"

Definition at line 39 of file driver_internal.py.

◆ CPUTimeResOfContainerKeyInARGS

string driver_internal.CPUTimeResOfContainerKeyInARGS = "cpu_mem_container_time_res"

Definition at line 68 of file driver_internal.py.

◆ CustomOverridesInARGS

string driver_internal.CustomOverridesInARGS = "activate_custom_overrides"

Definition at line 80 of file driver_internal.py.

◆ CustomOverridesInCMD

string driver_internal.CustomOverridesInCMD = "--activate-custom-overrides"

Definition at line 51 of file driver_internal.py.

◆ DisplayEntryInCMD

string driver_internal.DisplayEntryInCMD = "--display"

Definition at line 24 of file driver_internal.py.

◆ DisplayKeyInARGS

string driver_internal.DisplayKeyInARGS = "display"

Definition at line 53 of file driver_internal.py.

◆ DoNotSqueezeEntryInCMD

string driver_internal.DoNotSqueezeEntryInCMD = "--donotsqueeze"

Definition at line 37 of file driver_internal.py.

◆ DoNotSqueezeKeyInARGS

string driver_internal.DoNotSqueezeKeyInARGS = "donotsqueeze"

Definition at line 66 of file driver_internal.py.

◆ DumpEntryInCMD

string driver_internal.DumpEntryInCMD = "--dump"

Definition at line 29 of file driver_internal.py.

◆ DumpKeyInARGS

string driver_internal.DumpKeyInARGS = "dump"

Definition at line 58 of file driver_internal.py.

◆ DumpOnErrorEntryInCMD

string driver_internal.DumpOnErrorEntryInCMD = "--dump-on-error"

Definition at line 28 of file driver_internal.py.

◆ DumpOnErrorKeyInARGS

string driver_internal.DumpOnErrorKeyInARGS = "dumpErrorFile"

Definition at line 57 of file driver_internal.py.

◆ DumpStateEntryInCMD

string driver_internal.DumpStateEntryInCMD = "--dump-final"

Definition at line 31 of file driver_internal.py.

◆ DumpStateKeyInARGS

string driver_internal.DumpStateKeyInARGS = "finalDump"

Definition at line 60 of file driver_internal.py.

◆ HTOPFileEntryInCMD

string driver_internal.HTOPFileEntryInCMD = "--htop-of-yacs-engine-process-file"

Definition at line 40 of file driver_internal.py.

◆ HTOPFileKeyInARGS

string driver_internal.HTOPFileKeyInARGS = "htop_of_yacs_engine_process_file"

Definition at line 69 of file driver_internal.py.

◆ HTOPFileTimeResEntryInCMD

string driver_internal.HTOPFileTimeResEntryInCMD = "--htop-of-yacs-engine-process-time-res"

Definition at line 42 of file driver_internal.py.

◆ HTOPFileTimeResKeyInARGS

string driver_internal.HTOPFileTimeResKeyInARGS = "htop_of_yacs_engine_process_time_res"

Definition at line 71 of file driver_internal.py.

◆ HTOPServerFileEntryInCMD

string driver_internal.HTOPServerFileEntryInCMD = "--htop-of-servers"

Definition at line 41 of file driver_internal.py.

◆ HTOPServerFileKeyInARGS

string driver_internal.HTOPServerFileKeyInARGS = "htop_of_servers"

Definition at line 70 of file driver_internal.py.

◆ HTOPServerFileTimeResEntryInCMD

string driver_internal.HTOPServerFileTimeResEntryInCMD = "--htop-of-servers-time-res"

Definition at line 43 of file driver_internal.py.

◆ HTOPServerFileTimeResKeyInARGS

string driver_internal.HTOPServerFileTimeResKeyInARGS = "htop_of_servers_time_res"

Definition at line 72 of file driver_internal.py.

◆ InitPortEntryInCMD

string driver_internal.InitPortEntryInCMD = "--init-port"

Definition at line 36 of file driver_internal.py.

◆ InitPortKeyInARGS

string driver_internal.InitPortKeyInARGS = "init_port"

Definition at line 65 of file driver_internal.py.

◆ IOREntryInCMD

string driver_internal.IOREntryInCMD = "--ior-ns"

Definition at line 38 of file driver_internal.py.

◆ IORKeyInARGS

string driver_internal.IORKeyInARGS = "iorNS"

Definition at line 67 of file driver_internal.py.

◆ KernelTraceEntryInCMD

string driver_internal.KernelTraceEntryInCMD = "--kerneltrace"

Definition at line 30 of file driver_internal.py.

◆ KernelTraceKeyInARGS

string driver_internal.KernelTraceKeyInARGS = "kerneltrace"

Definition at line 59 of file driver_internal.py.

◆ KeyValnARGS

list driver_internal.KeyValnARGS
Initial value:
1 = [(DisplayEntryInCMD,DisplayKeyInARGS),
2  (VerboseEntryInCMD,VerboseKeyInARGS),
3  (VerboseLevelEntryInCMD,VerboseLevelKeyInARGS),
4  (StopOnErrorEntryInCMD,StopOnErrorKeyInARGS),
5  (DumpOnErrorEntryInCMD,DumpOnErrorKeyInARGS),
6  (DumpEntryInCMD,DumpKeyInARGS),
7  (KernelTraceEntryInCMD,KernelTraceKeyInARGS),
8  (DumpStateEntryInCMD,DumpStateKeyInARGS),
9  (LoadStateEntryInCMD,LoadStateKeyInARGS),
10  (SaveXMLSchemaEntryInCMD,SaveXMLSchemaKeyInARGS),
11  (ShutdownEntryInCMD,ShutdownKeyInARGS),
12  (ResetEntryInCMD,ResetKeyInARGS),
13  (InitPortEntryInCMD,InitPortKeyInARGS),
14  (DoNotSqueezeEntryInCMD,DoNotSqueezeKeyInARGS),
15  (CPUTimeResOfContainerEntryInCMD,CPUTimeResOfContainerKeyInARGS),
16  (HTOPFileEntryInCMD,HTOPFileKeyInARGS),
17  (HTOPFileTimeResEntryInCMD,HTOPFileTimeResKeyInARGS),
18  (HTOPServerFileEntryInCMD,HTOPServerFileKeyInARGS),
19  (HTOPServerFileTimeResEntryInCMD,HTOPServerFileTimeResKeyInARGS),
20  (MonitoringDirsEntryInCMD,MonitoringDirsInARGS),
21  (MonitoringDirsResEntryInCMD,MonitoringDirsResInARGS),
22  (MonitoringDirsTimeResEntryInCMD,MonitoringDirsTimeResInARGS),
23  (ReplayOnErrorEntryInCMD,ReplayOnErrorEntryInARGS),
24  (ReplayDirInCMD,ReplayDirInARGS),
25  (BigObjDirInCMD,BigObjDirInARGS),
26  (BigObjThresInCMD,BigObjThresInARGS),
27  (CustomOverridesInCMD,CustomOverridesInARGS),
28  (IOREntryInCMD,IORKeyInARGS)]

Definition at line 82 of file driver_internal.py.

◆ LoadStateEntryInCMD

string driver_internal.LoadStateEntryInCMD = "--load-state"

Definition at line 32 of file driver_internal.py.

◆ LoadStateKeyInARGS

string driver_internal.LoadStateKeyInARGS = "loadState"

Definition at line 61 of file driver_internal.py.

◆ MonitoringDirsEntryInCMD

string driver_internal.MonitoringDirsEntryInCMD = "--monitoring-dirs-content"

Definition at line 44 of file driver_internal.py.

◆ MonitoringDirsInARGS

string driver_internal.MonitoringDirsInARGS = "monitoring_dirs_content"

Definition at line 73 of file driver_internal.py.

◆ MonitoringDirsResEntryInCMD

string driver_internal.MonitoringDirsResEntryInCMD = "--monitoring-dirs-content-res"

Definition at line 45 of file driver_internal.py.

◆ MonitoringDirsResInARGS

string driver_internal.MonitoringDirsResInARGS = "monitoring_dirs_content_res"

Definition at line 74 of file driver_internal.py.

◆ MonitoringDirsTimeResEntryInCMD

string driver_internal.MonitoringDirsTimeResEntryInCMD = "--monitoring-dirs-content-time-res"

Definition at line 46 of file driver_internal.py.

◆ MonitoringDirsTimeResInARGS

string driver_internal.MonitoringDirsTimeResInARGS = "monitoring_dirs_content_time_res"

Definition at line 75 of file driver_internal.py.

◆ my_ior_ns

driver_internal.my_ior_ns = None

Definition at line 113 of file driver_internal.py.

◆ my_replay_dir

string driver_internal.my_replay_dir = ""

Definition at line 117 of file driver_internal.py.

◆ my_replay_on_error

bool driver_internal.my_replay_on_error = False

Definition at line 115 of file driver_internal.py.

◆ my_runtime_yacs

driver_internal.my_runtime_yacs = None

Definition at line 111 of file driver_internal.py.

◆ ReplayDirInARGS

string driver_internal.ReplayDirInARGS = "replay_dir"

Definition at line 77 of file driver_internal.py.

◆ ReplayDirInCMD

string driver_internal.ReplayDirInCMD = "--replay-dir"

Definition at line 48 of file driver_internal.py.

◆ ReplayOnErrorEntryInARGS

string driver_internal.ReplayOnErrorEntryInARGS = "replay_on_error"

Definition at line 76 of file driver_internal.py.

◆ ReplayOnErrorEntryInCMD

string driver_internal.ReplayOnErrorEntryInCMD = "--replay-on-error"

Definition at line 47 of file driver_internal.py.

◆ ResetEntryInCMD

string driver_internal.ResetEntryInCMD = "--reset"

Definition at line 35 of file driver_internal.py.

◆ ResetKeyInARGS

string driver_internal.ResetKeyInARGS = "reset"

Definition at line 64 of file driver_internal.py.

◆ SaveXMLSchemaEntryInCMD

string driver_internal.SaveXMLSchemaEntryInCMD = "--save-xml-schema"

Definition at line 33 of file driver_internal.py.

◆ SaveXMLSchemaKeyInARGS

string driver_internal.SaveXMLSchemaKeyInARGS = "saveXMLSchema"

Definition at line 62 of file driver_internal.py.

◆ ShutdownEntryInCMD

string driver_internal.ShutdownEntryInCMD = "--shutdown"

Definition at line 34 of file driver_internal.py.

◆ ShutdownKeyInARGS

string driver_internal.ShutdownKeyInARGS = "shutdown"

Definition at line 63 of file driver_internal.py.

◆ StopOnErrorEntryInCMD

string driver_internal.StopOnErrorEntryInCMD = "--stop-on-error"

Definition at line 27 of file driver_internal.py.

◆ StopOnErrorKeyInARGS

string driver_internal.StopOnErrorKeyInARGS = "stop"

Definition at line 56 of file driver_internal.py.

◆ VerboseEntryInCMD

string driver_internal.VerboseEntryInCMD = "--verbose"

Definition at line 25 of file driver_internal.py.

◆ VerboseKeyInARGS

string driver_internal.VerboseKeyInARGS = "verbose"

Definition at line 54 of file driver_internal.py.

◆ VerboseLevelEntryInCMD

string driver_internal.VerboseLevelEntryInCMD = "--verbose-level"

Definition at line 26 of file driver_internal.py.

◆ VerboseLevelKeyInARGS

string driver_internal.VerboseLevelKeyInARGS = "verbose_level"

Definition at line 55 of file driver_internal.py.

◆ xmlFileName

driver_internal.xmlFileName

Definition at line 473 of file driver_internal.py.