The Gaudi Framework  v32r2 (46d42edc)
gaudirun Namespace Reference

Classes

class  FakeModule
 

Functions

def getArgsWithoutoProfilerInfo (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> ...")
 
 action
 
 help
 
 type
 
 metavar
 
 default
 
 callback
 
 nargs
 
 dest
 
 options = ["importOptions(%r)" % f for f 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
 
 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()
 
 sanitizer = 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()
 
 optlines = list(opts.options)
 
dictionary g = {}
 
dictionary l = {}
 
 _appliedConfigurableUsers_
 
 use_temp_opts
 
 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 80 of file gaudirun.py.

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

◆ getArgsWithoutoProfilerInfo()

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

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

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

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

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

Definition at line 9 of file gaudirun.py.

10  """
11  Remove from the arguments the presence of the profiler and its output in
12  order to relaunch the script w/o infinite loops.
13 
14  >>> getArgsWithoutoProfilerInfo(['--profilerName', 'igprof', 'myopts.py'])
15  ['myopts.py']
16 
17  >>> getArgsWithoutoProfilerInfo(['--profilerName=igprof', 'myopts.py'])
18  ['myopts.py']
19 
20  >>> getArgsWithoutoProfilerInfo(['--profilerName', 'igprof', '--profilerExtraOptions', 'a b c', 'myopts.py'])
21  ['myopts.py']
22 
23  >>> getArgsWithoutoProfilerInfo(['--profilerName', 'igprof', '--options', 'a b c', 'myopts.py'])
24  ['--options', 'a b c', 'myopts.py']
25  """
26  newargs = []
27  args = list(args) # make a temp copy
28  while args:
29  o = args.pop(0)
30  if o.startswith('--profile'):
31  if '=' not in o:
32  args.pop(0)
33  else:
34  newargs.append(o)
35  return newargs
36 
37 
def getArgsWithoutoProfilerInfo(args)
Definition: gaudirun.py:9

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

175  def option_cb(option, opt, value, parser):
176  """Add the option line to a list together with its position in the
177  argument list.
178  """
179  parser.values.options.append((len(parser.largs), value))
180 
def option_cb(option, opt, value, parser)
Definition: gaudirun.py:175

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

64 def rationalizepath(path):
65  '''
66  Convert the given path to a real path if the pointed file exists, otherwise
67  just normalize it.
68  '''
69  path = os.path.normpath(os.path.expandvars(path))
70  if os.path.exists(path):
71  path = os.path.realpath(path)
72  return path
73 
74 
75 # variable used to keep alive the temporary option files extracted
76 # from the .qmt
def rationalizepath(path)
Definition: gaudirun.py:64

◆ setLibraryPreload()

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

Definition at line 38 of file gaudirun.py.

38 def setLibraryPreload(newpreload):
39  ''' Adds a list of libraries to LD_PRELOAD '''
40  preload = os.environ.get("LD_PRELOAD", "")
41  if preload:
42  preload = preload.replace(" ", ":").split(":")
43  else:
44  preload = []
45 
46  for libname in set(preload).intersection(newpreload):
47  logging.warning(
48  "Ignoring preload of library %s because it is "
49  "already in LD_PRELOAD.", libname)
50 
51  to_load = [
52  libname for libname in newpreload if libname not in set(preload)
53  ]
54 
55  if to_load:
56  preload += to_load
57  preload = ":".join(preload)
58  os.environ["LD_PRELOAD"] = preload
59  logging.info("Setting LD_PRELOAD='%s'", preload)
60 
61  return to_load
62 
63 
def setLibraryPreload(newpreload)
Definition: gaudirun.py:38

Variable Documentation

◆ _appliedConfigurableUsers_

gaudirun._appliedConfigurableUsers_
private

Definition at line 533 of file gaudirun.py.

◆ _qmt_tmp_opt_files

list gaudirun._qmt_tmp_opt_files = []
private

Definition at line 77 of file gaudirun.py.

◆ action

gaudirun.action

Definition at line 138 of file gaudirun.py.

◆ application

gaudirun.application

Definition at line 297 of file gaudirun.py.

◆ arglist

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

Definition at line 466 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 309 of file gaudirun.py.

◆ argv

list gaudirun.argv = []

Definition at line 300 of file gaudirun.py.

◆ c

gaudirun.c = gaudimain()

Definition at line 489 of file gaudirun.py.

◆ callback

gaudirun.callback

Definition at line 184 of file gaudirun.py.

◆ default

gaudirun.default

Definition at line 171 of file gaudirun.py.

◆ dest

gaudirun.dest

Definition at line 203 of file gaudirun.py.

◆ fd

gaudirun.fd

Definition at line 561 of file gaudirun.py.

◆ g

dictionary gaudirun.g = {}

Definition at line 522 of file gaudirun.py.

◆ help

gaudirun.help

Definition at line 139 of file gaudirun.py.

◆ igprofPerfOptions

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

Definition at line 394 of file gaudirun.py.

◆ l

dictionary gaudirun.l = {}

Definition at line 523 of file gaudirun.py.

◆ level

gaudirun.level = logging.INFO

Definition at line 336 of file gaudirun.py.

◆ metavar

gaudirun.metavar

Definition at line 145 of file gaudirun.py.

◆ nargs

gaudirun.nargs

Definition at line 186 of file gaudirun.py.

◆ ncpus

gaudirun.ncpus

Definition at line 293 of file gaudirun.py.

◆ old_conf_user_apply

gaudirun.old_conf_user_apply

Definition at line 295 of file gaudirun.py.

◆ options

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

Definition at line 287 of file gaudirun.py.

◆ optlines

gaudirun.optlines = list(opts.options)

Definition at line 497 of file gaudirun.py.

◆ opts

gaudirun.opts

Definition at line 309 of file gaudirun.py.

◆ outoption

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

Definition at line 420 of file gaudirun.py.

◆ output

gaudirun.output

Definition at line 486 of file gaudirun.py.

◆ parser

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

Definition at line 134 of file gaudirun.py.

◆ prefix

string gaudirun.prefix = "// "

Definition at line 333 of file gaudirun.py.

◆ preload

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

Definition at line 292 of file gaudirun.py.

◆ printsequence

gaudirun.printsequence

Definition at line 568 of file gaudirun.py.

◆ profilerExecName

string gaudirun.profilerExecName = ""

Definition at line 388 of file gaudirun.py.

◆ profilerExtraOptions

gaudirun.profilerExtraOptions = opts.profilerExtraOptions

Definition at line 291 of file gaudirun.py.

◆ profilerName

gaudirun.profilerName = opts.profilerName

Definition at line 289 of file gaudirun.py.

◆ profilerOptions

string gaudirun.profilerOptions = ""

Definition at line 396 of file gaudirun.py.

◆ profilerOutput

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

Definition at line 290 of file gaudirun.py.

◆ profilerPath

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

Definition at line 443 of file gaudirun.py.

◆ retcode

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

Definition at line 584 of file gaudirun.py.

◆ root_logger

gaudirun.root_logger = logging.getLogger()

Definition at line 340 of file gaudirun.py.

◆ run_info

dictionary gaudirun.run_info = {}

Definition at line 591 of file gaudirun.py.

◆ run_info_file

gaudirun.run_info_file

Definition at line 296 of file gaudirun.py.

◆ s

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

Definition at line 318 of file gaudirun.py.

◆ sanitizer

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

Definition at line 343 of file gaudirun.py.

◆ sys_cpus

gaudirun.sys_cpus = cpu_count()

Definition at line 316 of file gaudirun.py.

◆ tcmalloc

gaudirun.tcmalloc

Definition at line 288 of file gaudirun.py.

◆ tmpfile

gaudirun.tmpfile

Definition at line 561 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 369 of file gaudirun.py.

◆ to_reload

def gaudirun.to_reload = []

Definition at line 457 of file gaudirun.py.

◆ toolname

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

Definition at line 419 of file gaudirun.py.

◆ type

gaudirun.type

Definition at line 144 of file gaudirun.py.

◆ use_temp_opts

gaudirun.use_temp_opts

Definition at line 553 of file gaudirun.py.

◆ with_time

gaudirun.with_time

Definition at line 339 of file gaudirun.py.