The Gaudi Framework  v36r1 (3e2fb5a8)
gaudirun Namespace Reference

Classes

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 = ["importOptions(%r)" % f for f in opt_files]
 
 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
 
 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
 
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()
 
list callables = []
 
list opt_files = []
 
 optlines = list(opts.options)
 
dictionary g = {}
 
dictionary l = {}
 
 _appliedConfigurableUsers_
 
 use_temp_opts
 
 config = mergeConfigs(*[invokeConfig(f) for f in callables])
 
 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 90 of file gaudirun.py.

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

◆ 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 19 of file gaudirun.py.

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

◆ 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 185 of file gaudirun.py.

185  def option_cb(option, opt, value, parser):
186  """Add the option line to a list together with its position in the
187  argument list.
188  """
189  parser.values.options.append((len(parser.largs), value))
190 

◆ 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 74 of file gaudirun.py.

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

◆ setLibraryPreload()

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

Definition at line 48 of file gaudirun.py.

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

Variable Documentation

◆ _appliedConfigurableUsers_

gaudirun._appliedConfigurableUsers_
private

Definition at line 563 of file gaudirun.py.

◆ _qmt_tmp_opt_files

list gaudirun._qmt_tmp_opt_files = []
private

Definition at line 87 of file gaudirun.py.

◆ action

gaudirun.action

Definition at line 148 of file gaudirun.py.

◆ application

gaudirun.application

Definition at line 307 of file gaudirun.py.

◆ arglist

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

Definition at line 486 of file gaudirun.py.

◆ args

def gaudirun.args
Initial value:
1 = [
2  a for a in sys.argv
3  if a != '-T' and not '--tcmalloc'.startswith(a)
4  ]

Definition at line 319 of file gaudirun.py.

◆ argv

list gaudirun.argv = []

Definition at line 310 of file gaudirun.py.

◆ c

gaudirun.c = gaudimain()

Definition at line 509 of file gaudirun.py.

◆ callables

list gaudirun.callables = []

Definition at line 513 of file gaudirun.py.

◆ callback

gaudirun.callback

Definition at line 194 of file gaudirun.py.

◆ config

gaudirun.config = mergeConfigs(*[invokeConfig(f) for f in callables])

Definition at line 586 of file gaudirun.py.

◆ default

gaudirun.default

Definition at line 181 of file gaudirun.py.

◆ dest

gaudirun.dest

Definition at line 213 of file gaudirun.py.

◆ fd

gaudirun.fd

Definition at line 597 of file gaudirun.py.

◆ g

dictionary gaudirun.g = {}

Definition at line 552 of file gaudirun.py.

◆ help

gaudirun.help

Definition at line 149 of file gaudirun.py.

◆ igprofPerfOptions

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

Definition at line 414 of file gaudirun.py.

◆ instances

gaudirun.instances

Definition at line 589 of file gaudirun.py.

◆ l

dictionary gaudirun.l = {}

Definition at line 553 of file gaudirun.py.

◆ level

gaudirun.level = logging.INFO

Definition at line 346 of file gaudirun.py.

◆ metavar

gaudirun.metavar

Definition at line 155 of file gaudirun.py.

◆ nargs

gaudirun.nargs

Definition at line 196 of file gaudirun.py.

◆ ncpus

gaudirun.ncpus

Definition at line 303 of file gaudirun.py.

◆ old_conf_user_apply

gaudirun.old_conf_user_apply

Definition at line 305 of file gaudirun.py.

◆ opt_files

list gaudirun.opt_files = []

Definition at line 514 of file gaudirun.py.

◆ options

list gaudirun.options = ["importOptions(%r)" % f for f in opt_files]

Definition at line 297 of file gaudirun.py.

◆ optlines

gaudirun.optlines = list(opts.options)

Definition at line 527 of file gaudirun.py.

◆ opts

gaudirun.opts

Definition at line 319 of file gaudirun.py.

◆ outoption

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

Definition at line 440 of file gaudirun.py.

◆ output

gaudirun.output

Definition at line 506 of file gaudirun.py.

◆ parser

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

Definition at line 144 of file gaudirun.py.

◆ prefix

string gaudirun.prefix = "// "

Definition at line 343 of file gaudirun.py.

◆ preload

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

Definition at line 302 of file gaudirun.py.

◆ printsequence

gaudirun.printsequence

Definition at line 604 of file gaudirun.py.

◆ profilerExecName

string gaudirun.profilerExecName = ""

Definition at line 408 of file gaudirun.py.

◆ profilerExtraOptions

gaudirun.profilerExtraOptions = opts.profilerExtraOptions

Definition at line 301 of file gaudirun.py.

◆ profilerName

gaudirun.profilerName = opts.profilerName

Definition at line 299 of file gaudirun.py.

◆ profilerOptions

string gaudirun.profilerOptions = ""

Definition at line 416 of file gaudirun.py.

◆ profilerOutput

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

Definition at line 300 of file gaudirun.py.

◆ profilerPath

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

Definition at line 463 of file gaudirun.py.

◆ retcode

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

Definition at line 620 of file gaudirun.py.

◆ root_logger

gaudirun.root_logger = logging.getLogger()

Definition at line 350 of file gaudirun.py.

◆ run_info

dictionary gaudirun.run_info = {}

Definition at line 627 of file gaudirun.py.

◆ run_info_file

gaudirun.run_info_file

Definition at line 306 of file gaudirun.py.

◆ s

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

Definition at line 328 of file gaudirun.py.

◆ sanitizers

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

Definition at line 353 of file gaudirun.py.

◆ sys_cpus

gaudirun.sys_cpus = cpu_count()

Definition at line 326 of file gaudirun.py.

◆ tcmalloc

gaudirun.tcmalloc

Definition at line 298 of file gaudirun.py.

◆ tmpfile

gaudirun.tmpfile

Definition at line 597 of file gaudirun.py.

◆ to_load

list gaudirun.to_load
Initial value:
1 = [
2  libname for libname in opts.preload if libname not in set(preload)
3  ]

Definition at line 389 of file gaudirun.py.

◆ to_reload

def gaudirun.to_reload = []

Definition at line 477 of file gaudirun.py.

◆ toolname

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

Definition at line 439 of file gaudirun.py.

◆ type

gaudirun.type

Definition at line 154 of file gaudirun.py.

◆ use_temp_opts

gaudirun.use_temp_opts

Definition at line 583 of file gaudirun.py.

◆ with_time

gaudirun.with_time

Definition at line 349 of file gaudirun.py.

gaudirun.getArgsFromQmt
def getArgsFromQmt(qmtfile)
Definition: gaudirun.py:90
gaudirun.getArgsWithoutProfilerInfo
def getArgsWithoutProfilerInfo(args)
Definition: gaudirun.py:19
gaudirun.option_cb
def option_cb(option, opt, value, parser)
Definition: gaudirun.py:185
gaudirun.setLibraryPreload
def setLibraryPreload(newpreload)
Definition: gaudirun.py:48
gaudirun.rationalizepath
def rationalizepath(path)
Definition: gaudirun.py:74