The Gaudi Framework  master (37c0b60a)
gaudirun Namespace Reference

Classes

class  ArgProcessor
 
class  FakeModule
 

Functions

def getArgsWithoutProfilerInfo (args)
 
def setLibraryPreload (newpreload)
 
def rationalizepath (path)
 
def getArgsFromQmt (qmtfile)
 
def option_cb (option, opt, value, parser)
 

Variables

list _qmt_tmp_opt_files = []
 
 parser = OptionParser(usage="%prog [options] <opts_file|function_id> ...")
 
 action
 
 help
 
 type
 
 metavar
 
 default
 
 callback
 
 nargs
 
 dest
 
 options = ["process({!r})".format(arg) for arg in args]
 
 tcmalloc
 
 profilerName = opts.profilerName
 
 profilerOutput = opts.profilerOutput or (profilerName + ".output")
 
 profilerExtraOptions = opts.profilerExtraOptions
 
 preload = os.environ.get("LD_PRELOAD", "")
 
 ncpus
 
 old_conf_user_apply
 
 run_info_file
 
 application
 
list argv = []
 
 opts
 
 args = [a for a in sys.argv if a != "-T" and not "--tcmalloc".startswith(a)]
 
 sys_cpus = cpu_count()
 
string s = "Invalid value : --ncpus : only %i cpus available" % sys_cpus
 
string prefix = "// "
 
 level = logging.INFO
 
 with_time
 
 root_logger = logging.getLogger()
 
 sanitizers = os.environ.get("PRELOAD_SANITIZER_LIB", "")
 
list to_load = [libname for libname in opts.preload if libname not in set(preload)]
 
string profilerExecName = ""
 
string igprofPerfOptions = "-d -pp -z -o igprof.pp.gz".split()
 
string profilerOptions = ""
 
 toolname = profilerName.replace("valgrind", "")
 
string outoption = "--log-file"
 
 profilerPath = distutils.spawn.find_executable(profilerExecName)
 
list to_reload = []
 
list arglist = [profilerPath] + profilerOptions.split() + args
 
 output
 
 c = gaudimain()
 
 process
 
 optlines = list(opts.options)
 
dictionary g = {"process": process}
 
dictionary l = {}
 
 _appliedConfigurableUsers_
 
 use_temp_opts
 
 instances
 
 fd
 
 tmpfile
 
 printsequence
 
 retcode = c.run(opts.gdb, opts.ncpus)
 
dictionary run_info = {}
 

Function Documentation

◆ getArgsFromQmt()

def gaudirun.getArgsFromQmt (   qmtfile)
Given a .qmt file, return the command line arguments of the corresponding
test.

Definition at line 88 of file gaudirun.py.

88 def getArgsFromQmt(qmtfile):
89  """
90  Given a .qmt file, return the command line arguments of the corresponding
91  test.
92  """
93  from xml.etree import ElementTree as ET
94 
95  global _qmt_tmp_opt_files
96  # parse the .qmt file and extract args and options
97  qmt = ET.parse(qmtfile)
98  args = [a.text for a in qmt.findall("argument[@name='args']//text")]
99  options = qmt.find("argument[@name='options']/text")
100 
101  if (
102  options is not None and options.text is not None
103  ): # options need to be dumped in a temporary file
104  import re
105  from tempfile import NamedTemporaryFile
106 
107  if re.search(
108  r"from\s+Gaudi.Configuration\s+import\s+\*"
109  r"|from\s+Configurables\s+import",
110  options.text,
111  ):
112  tmp_opts = NamedTemporaryFile(suffix=".py")
113  else:
114  tmp_opts = NamedTemporaryFile(suffix=".opts")
115  tmp_opts.write(options.text.encode("ascii"))
116  tmp_opts.flush()
117  args.append(tmp_opts.name)
118  _qmt_tmp_opt_files.append(tmp_opts)
119 
120  # relative paths in a .qmt are rooted in the qmtest directory, so
121  # - find where the .qmt lives
122  qmtfile = os.path.abspath(qmtfile)
123  if "qmtest" in qmtfile.split(os.path.sep):
124  # this return the path up to the 'qmtest' entry in qmtfile
125  testdir = qmtfile
126  while os.path.basename(testdir) != "qmtest":
127  testdir = os.path.dirname(testdir)
128  else:
129  testdir = "."
130  # - temporarily switch to that directory and rationalize the paths
131  old_cwd = os.getcwd()
132  os.chdir(testdir)
133  args = [rationalizepath(arg) for arg in args]
134  os.chdir(old_cwd)
135 
136  return args
137 
138 
139 # ---------------------------------------------------------------------

◆ getArgsWithoutProfilerInfo()

def gaudirun.getArgsWithoutProfilerInfo (   args)
Remove from the arguments the presence of the profiler and its output in
order to relaunch the script w/o infinite loops.

>>> getArgsWithoutProfilerInfo(['--profilerName', 'igprof', 'myopts.py'])
['myopts.py']

>>> getArgsWithoutProfilerInfo(['--profilerName=igprof', 'myopts.py'])
['myopts.py']

>>> getArgsWithoutProfilerInfo(['--profilerName', 'igprof', '--profilerExtraOptions', 'a b c', 'myopts.py'])
['myopts.py']

>>> getArgsWithoutProfilerInfo(['--profilerName', 'igprof', '--options', 'a b c', 'myopts.py'])
['--options', 'a b c', 'myopts.py']

Definition at line 18 of file gaudirun.py.

19  """
20  Remove from the arguments the presence of the profiler and its output in
21  order to relaunch the script w/o infinite loops.
22 
23  >>> getArgsWithoutProfilerInfo(['--profilerName', 'igprof', 'myopts.py'])
24  ['myopts.py']
25 
26  >>> getArgsWithoutProfilerInfo(['--profilerName=igprof', 'myopts.py'])
27  ['myopts.py']
28 
29  >>> getArgsWithoutProfilerInfo(['--profilerName', 'igprof', '--profilerExtraOptions', 'a b c', 'myopts.py'])
30  ['myopts.py']
31 
32  >>> getArgsWithoutProfilerInfo(['--profilerName', 'igprof', '--options', 'a b c', 'myopts.py'])
33  ['--options', 'a b c', 'myopts.py']
34  """
35  newargs = []
36  args = list(args) # make a temp copy
37  while args:
38  o = args.pop(0)
39  if o.startswith("--profile"):
40  if "=" not in o:
41  args.pop(0)
42  else:
43  newargs.append(o)
44  return newargs
45 
46 

◆ option_cb()

def gaudirun.option_cb (   option,
  opt,
  value,
  parser 
)
Add the option line to a list together with its position in the
argument list.

Definition at line 193 of file gaudirun.py.

193  def option_cb(option, opt, value, parser):
194  """Add the option line to a list together with its position in the
195  argument list.
196  """
197  parser.values.options.append((len(parser.largs), value))
198 

◆ rationalizepath()

def gaudirun.rationalizepath (   path)
Convert the given path to a real path if the pointed file exists, otherwise
just normalize it.

Definition at line 72 of file gaudirun.py.

72 def rationalizepath(path):
73  """
74  Convert the given path to a real path if the pointed file exists, otherwise
75  just normalize it.
76  """
77  path = os.path.normpath(os.path.expandvars(path))
78  if os.path.exists(path):
79  path = os.path.realpath(path)
80  return path
81 
82 
83 # variable used to keep alive the temporary option files extracted
84 # from the .qmt

◆ setLibraryPreload()

def gaudirun.setLibraryPreload (   newpreload)
Adds  a list of libraries to LD_PRELOAD

Definition at line 47 of file gaudirun.py.

47 def setLibraryPreload(newpreload):
48  """Adds a list of libraries to LD_PRELOAD"""
49  preload = os.environ.get("LD_PRELOAD", "")
50  if preload:
51  preload = preload.replace(" ", ":").split(":")
52  else:
53  preload = []
54 
55  for libname in set(preload).intersection(newpreload):
56  logging.warning(
57  "Ignoring preload of library %s because it is " "already in LD_PRELOAD.",
58  libname,
59  )
60 
61  to_load = [libname for libname in newpreload if libname not in set(preload)]
62 
63  if to_load:
64  preload += to_load
65  preload = ":".join(preload)
66  os.environ["LD_PRELOAD"] = preload
67  logging.info("Setting LD_PRELOAD='%s'", preload)
68 
69  return to_load
70 
71 

Variable Documentation

◆ _appliedConfigurableUsers_

gaudirun._appliedConfigurableUsers_
private

Definition at line 594 of file gaudirun.py.

◆ _qmt_tmp_opt_files

list gaudirun._qmt_tmp_opt_files = []
private

Definition at line 85 of file gaudirun.py.

◆ action

gaudirun.action

Definition at line 153 of file gaudirun.py.

◆ application

gaudirun.application

Definition at line 323 of file gaudirun.py.

◆ arglist

list gaudirun.arglist = [profilerPath] + profilerOptions.split() + args

Definition at line 501 of file gaudirun.py.

◆ args

def gaudirun.args = [a for a in sys.argv if a != "-T" and not "--tcmalloc".startswith(a)]

Definition at line 336 of file gaudirun.py.

◆ argv

list gaudirun.argv = []

Definition at line 327 of file gaudirun.py.

◆ c

gaudirun.c = gaudimain()

Definition at line 525 of file gaudirun.py.

◆ callback

gaudirun.callback

Definition at line 202 of file gaudirun.py.

◆ default

gaudirun.default

Definition at line 188 of file gaudirun.py.

◆ dest

gaudirun.dest

Definition at line 224 of file gaudirun.py.

◆ fd

gaudirun.fd

Definition at line 630 of file gaudirun.py.

◆ g

dictionary gaudirun.g = {"process": process}

Definition at line 582 of file gaudirun.py.

◆ help

gaudirun.help

Definition at line 154 of file gaudirun.py.

◆ igprofPerfOptions

string gaudirun.igprofPerfOptions = "-d -pp -z -o igprof.pp.gz".split()

Definition at line 429 of file gaudirun.py.

◆ instances

gaudirun.instances

Definition at line 622 of file gaudirun.py.

◆ l

dictionary gaudirun.l = {}

Definition at line 583 of file gaudirun.py.

◆ level

gaudirun.level = logging.INFO

Definition at line 364 of file gaudirun.py.

◆ metavar

gaudirun.metavar

Definition at line 161 of file gaudirun.py.

◆ nargs

gaudirun.nargs

Definition at line 204 of file gaudirun.py.

◆ ncpus

gaudirun.ncpus

Definition at line 319 of file gaudirun.py.

◆ old_conf_user_apply

gaudirun.old_conf_user_apply

Definition at line 321 of file gaudirun.py.

◆ options

list gaudirun.options = ["process({!r})".format(arg) for arg in args]

Definition at line 313 of file gaudirun.py.

◆ optlines

gaudirun.optlines = list(opts.options)

Definition at line 556 of file gaudirun.py.

◆ opts

gaudirun.opts

Definition at line 336 of file gaudirun.py.

◆ outoption

string gaudirun.outoption = "--log-file"

Definition at line 455 of file gaudirun.py.

◆ output

gaudirun.output

Definition at line 521 of file gaudirun.py.

◆ parser

gaudirun.parser = OptionParser(usage="%prog [options] <opts_file|function_id> ...")

Definition at line 149 of file gaudirun.py.

◆ prefix

string gaudirun.prefix = "// "

Definition at line 361 of file gaudirun.py.

◆ preload

string gaudirun.preload = os.environ.get("LD_PRELOAD", "")

Definition at line 318 of file gaudirun.py.

◆ printsequence

gaudirun.printsequence

Definition at line 637 of file gaudirun.py.

◆ process

gaudirun.process

Definition at line 548 of file gaudirun.py.

◆ profilerExecName

string gaudirun.profilerExecName = ""

Definition at line 423 of file gaudirun.py.

◆ profilerExtraOptions

gaudirun.profilerExtraOptions = opts.profilerExtraOptions

Definition at line 317 of file gaudirun.py.

◆ profilerName

gaudirun.profilerName = opts.profilerName

Definition at line 315 of file gaudirun.py.

◆ profilerOptions

string gaudirun.profilerOptions = ""

Definition at line 431 of file gaudirun.py.

◆ profilerOutput

gaudirun.profilerOutput = opts.profilerOutput or (profilerName + ".output")

Definition at line 316 of file gaudirun.py.

◆ profilerPath

gaudirun.profilerPath = distutils.spawn.find_executable(profilerExecName)

Definition at line 477 of file gaudirun.py.

◆ retcode

gaudirun.retcode = c.run(opts.gdb, opts.ncpus)

Definition at line 651 of file gaudirun.py.

◆ root_logger

gaudirun.root_logger = logging.getLogger()

Definition at line 368 of file gaudirun.py.

◆ run_info

dictionary gaudirun.run_info = {}

Definition at line 659 of file gaudirun.py.

◆ run_info_file

gaudirun.run_info_file

Definition at line 322 of file gaudirun.py.

◆ s

string gaudirun.s = "Invalid value : --ncpus : only %i cpus available" % sys_cpus

Definition at line 346 of file gaudirun.py.

◆ sanitizers

gaudirun.sanitizers = os.environ.get("PRELOAD_SANITIZER_LIB", "")

Definition at line 371 of file gaudirun.py.

◆ sys_cpus

gaudirun.sys_cpus = cpu_count()

Definition at line 344 of file gaudirun.py.

◆ tcmalloc

gaudirun.tcmalloc

Definition at line 314 of file gaudirun.py.

◆ tmpfile

gaudirun.tmpfile

Definition at line 630 of file gaudirun.py.

◆ to_load

list gaudirun.to_load = [libname for libname in opts.preload if libname not in set(preload)]

Definition at line 409 of file gaudirun.py.

◆ to_reload

def gaudirun.to_reload = []

Definition at line 492 of file gaudirun.py.

◆ toolname

gaudirun.toolname = profilerName.replace("valgrind", "")

Definition at line 454 of file gaudirun.py.

◆ type

gaudirun.type

Definition at line 160 of file gaudirun.py.

◆ use_temp_opts

gaudirun.use_temp_opts

Definition at line 616 of file gaudirun.py.

◆ with_time

gaudirun.with_time

Definition at line 367 of file gaudirun.py.

gaudirun.getArgsFromQmt
def getArgsFromQmt(qmtfile)
Definition: gaudirun.py:88
gaudirun.getArgsWithoutProfilerInfo
def getArgsWithoutProfilerInfo(args)
Definition: gaudirun.py:18
gaudirun.option_cb
def option_cb(option, opt, value, parser)
Definition: gaudirun.py:193
gaudirun.setLibraryPreload
def setLibraryPreload(newpreload)
Definition: gaudirun.py:47
gaudirun.rationalizepath
def rationalizepath(path)
Definition: gaudirun.py:72