ATLAS Offline Software
trfArgClasses.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 
6 
7 import argparse
8 import bz2
9 import copy
10 import glob
11 import os
12 import re
13 import subprocess
14 import uuid
15 
16 import logging
17 msg = logging.getLogger(__name__)
18 
19 import PyJobTransforms.trfExceptions as trfExceptions
20 
21 from PyJobTransforms.trfFileUtils import athFileInterestingKeys, AthenaLiteFileInfo, NTUPEntries, HISTEntries, PHYSVALEntries, PRWEntries, urlType, ROOTGetSize
22 from PyJobTransforms.trfUtils import call
23 from PyJobTransforms.trfExeStepTools import commonExecutorStepName
24 from PyJobTransforms.trfExitCodes import trfExit as trfExit
25 from PyJobTransforms.trfDecorators import timelimited
26 from PyJobTransforms.trfAMI import getAMIClient
27 
28 
29 
32  def __init__(self, genclass, *args, **kwargs):
33  msg.debug('Initialised class %s with args=%s; kwargs=%s', genclass, args, kwargs)
34  self._genclass = genclass
35  self._args = args
36  self._kwargs = kwargs
37 
38  def __call__(self, valueString=None):
39  msg.debug('Called class %s with value=%s; args=%s; kwargs=%s', self._genclass, valueString, self._args, self._kwargs)
40 
41  # Wrap this step in our own try/except because if this goes wrong we want to see the exception
42  # instead of having it masked by the argparse module
43  try:
44  # Passing None suppresses the value passed to the constructor, thus the constructor's own
45  # default value is used - generally this will match the default value for the underlying
46  # python object
47  if valueString is None:
48  obj = self._genclass(*self._args, **self._kwargs)
49  else:
50  obj = self._genclass(valueString, *self._args, **self._kwargs)
51  except Exception as e:
52  msg.fatal('Got this exception raised when calling object factory: {0}'.format(e))
53  raise
54  return obj
55 
56  def __str__(self):
57  return 'argFactory for {0}, args {1}, kwargs {2}'.format(self._genclass, self._args, self._kwargs)
58 
59 
60 
61 class argAction(argparse.Action):
62  def __init__(self, factory, option_strings, dest, **kwargs):
63  self._factory = factory
64  super().__init__(option_strings, dest, **kwargs)
65 
66  def __call__(self, parser, namespace, values, option_string=None):
67  msg.debug('Called action for factory=%s; values=%s', self._factory, values)
68 
69  # call the factory for each value
70  if isinstance(values, list):
71  if not values:
72  # in case of empty list, run factory on None to get the default
73  setattr(namespace, self.dest, [self._factory(None)])
74  else:
75  setattr(namespace, self.dest, [self._factory(v) for v in values])
76  else:
77  setattr(namespace, self.dest, self._factory(values))
78 
79 
80 
84  def __init__(self, genclass, *args, **kwargs):
85  msg.debug('Initialised action class %s with args=%s; kwargs=%s', genclass, args, kwargs)
86  self._factory = argFactory(genclass, *args, **kwargs)
87 
88  @property
89  def factory(self):
90  return self._factory
91 
92  def __call__(self, option_strings, dest, **kwargs):
93  return argAction(self._factory, option_strings, dest, **kwargs)
94 
95  def __str__(self):
96  return 'argActionFactory for {0}'.format(self._factory)
97 
98 
99 
103 
104 
109  def __init__(self, value = None, runarg = True, name = None):
110  self._runarg = runarg
111  self._name = name
112 
113 
118  self.value = value
119 
120 
122  @property
123  def value(self):
124  return self._value
125 
126 
128  @value.setter
129  def value(self, value):
130  self._value = value
131 
132 
133  @property
134  def isRunarg(self):
135  return self._runarg
136 
137 
138  @property
139  def name(self):
140  return self._name
141 
142 
143  @name.setter
144  def name(self, value):
145  self._name = value
146 
147  @property
149  desc = {'type' : None}
150  return desc
151 
152 
153  def __str__(self):
154  return '{0}: Value {1} (isRunArg={2})'.format(self.__class__.__name__, self._value, self._runarg)
155 
156 
157  def __repr__(self):
158  return repr(self.value)
159 
160 
161  def __eq__(self,other):
162  return self.value == other.value
163 
164  def __nq__(self, other):
165  return self.value != other.value
166 
167  def __lt__(self, other):
168  return self.value < other.value
169 
170  def __gt__(self, other):
171  return self.value > other.value
172 
173 
175 
176 
182  def __init__(self, value = None, runarg = True, name = None, choices = None):
183  self._choices = choices
184  super(argString, self).__init__(value = value, runarg = runarg, name=name)
185 
186 
188  @property
189  def value(self):
190  return self._value
191 
192 
194  @value.setter
195  def value(self, value):
196  if value is None:
197  # For strings, None maps to ''
198  self._value = ''
199  else:
200  # Call string converter - should work for everything...
201  self._value = str(value)
202  if self._choices:
203  if self._value not in self._choices:
204  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CHOICES_FAIL'), 'Converted argument {0} for {1} did not match any valid choice: {2}'.format(value, self._name, self._choices))
205 
206 
208  def choices(self):
209  return self._choices
210 
211  # prodsysDescription: human readable from of type plus possible values
212  @property
214  desc = {'type' : 'str'}
215  if self._choices:
216  desc['choices'] = self._choices
217  return desc
218 
219 
220  def __str__(self):
221  return self.value
222 
223 
224 
226 
227 
229  @property
230  def value(self):
231  return self._value
232 
233 
236  @value.setter
237  def value(self, value):
238  if value is None:
239  # For ints None maps to 0
240  self._value = 0
241  else:
242  if isinstance(value, int):
243  self._value = value
244  else:
245 
246  try:
247  self._value = int(value)
248  except ValueError as e:
249  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
250  'Failed to convert value {0} to int: {1}'.format(value, e))
251 
252  # prodsysDescription: human readable from of type plus possible values
253  @property
255  desc = {'type' : 'int'}
256  return desc
257 
258 
259 
260 
262 
263 
267  def __init__(self, value=None, min=None, max=None, runarg=True, name=None):
268  self._min = min
269  self._max = max
270  super(argFloat, self).__init__(value = value, runarg = runarg, name=name)
271 
272 
274  @property
275  def value(self):
276  return self._value
277 
278  @property
280  desc = {'type' : 'float'}
281  if self._min:
282  desc['min'] = self._min
283  if self._max:
284  desc['max'] = self._max
285  return desc
286 
287 
292  @value.setter
293  def value(self, value=None):
294  # Default value will be 0.0 or self._min (if defined)
295  if value is None:
296  if self._min is not None:
297  self._value = self._min
298  else:
299  self._value = 0.0
300  else:
301  try:
302  if isinstance(value, float):
303  self._value = value
304  else:
305  self._value = float(value)
306  except ValueError:
307  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
308  'Failed to convert %s to a float' % str(value))
309 
310  if (self._min is not None and self.value < self._min) or (self._max is not None and self._value > self._max):
311  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_OUT_OF_RANGE'),
312  'argFloat value out of range: %g is not between %s and %s' %
313  (self.value, self._min, self._max))
314 
315 
316 
318 
319 
321  @property
322  def value(self):
323  return self._value
324 
325 
330  @value.setter
331  def value(self, value):
332  # Default value matches the python bool() constructor
333  if value is None:
334  self._value = False
335  else:
336  if isinstance(value, bool):
337  self._value = value
338  else:
339  self._value = strToBool(value)
340 
341  # prodsysDescription: human readable from of type plus possible values
342  @property
344  desc = {'type' : 'bool'}
345  return desc
346 
347 
349 
350 
356  def __init__(self, value = [], supressEmptyStrings = True, splitter=',', runarg=True, name=None):
357  self._splitter = splitter
358  self._supressEmptyStrings = supressEmptyStrings
359 
360  super(argList, self).__init__(value = value, runarg = runarg, name=name)
361 
362 
364  @property
365  def value(self):
366  return self._value
367 
368  # prodsysDescription: human readable from of type plus possible values
369  @property
371  desc = {'type' : 'list', 'listtype': 'str'}
372  if self._supressEmptyStrings:
373  desc['supress Empty Strings'] = self._supressEmptyStrings
374  return desc
375 
376 
377 
379  @value.setter
380  def value(self, value):
381  if isinstance(value, (list, tuple)):
382  self._value = list(value)
383  elif value is None:
384  self._value = []
385  return
386  else:
387  try:
388  if self._supressEmptyStrings:
389  self._value = [ v for v in value.split(self._splitter) if v != '' ]
390  else:
391  self._value = value.split(self._splitter)
392  except AttributeError:
393  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
394  'Failed to convert %s to a list' % str(value))
395 
396 
398  def append(self, addme):
399  self._value.append(addme)
400 
401 
404  def __str__(self):
405  return " ".join(self._value)
406 
407 
409  def __repr__(self):
410  return '[' + ','.join([ repr(s) for s in self._value ]) + ']'
411 
412 
413 
415 
417  @property
418  def value(self):
419  return self._value
420 
421 
422 
426  @value.setter
427  def value(self, value):
428  if isinstance(value, list):
429  for v in value:
430  if not isinstance(v, int):
431  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_ERROR'),
432  'Illegal value {0} in list of ints'.format(v))
433  self._value = value
434  elif value is None:
435  self._value = []
436  return
437  else:
438  try:
439  if self._supressEmptyStrings:
440  self._value = [ v for v in value.split(self._splitter) if v != '' ]
441  else:
442  self._value = value.split(self._splitter)
443  self._value = [ int(el) for el in self._value ]
444  except (AttributeError, ValueError):
445  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
446  'Failed to convert %s to a list of ints' % str(value))
447 
448  def __str__(self):
449  return " ".join([ str(el) for el in self._value ])
450 
451  @property
453  desc = {'type' : 'list', 'listtype' : 'int'}
454  return desc
455 
456 
457 # Special list which stores k:v pairs, where the value is an float (used for AthenaMP merge target size)
459 
465  def __init__(self, value = {}, supressEmptyStrings = True, splitter=',', kvsplitter=":", runarg=True, name=None):
466  self._splitter = splitter
467  self._kvsplitter = kvsplitter
468  self._supressEmptyStrings = supressEmptyStrings
469 
470  super(argList, self).__init__(value = value, runarg = runarg, name=name)
471 
472 
474  @property
475  def value(self):
476  return self._value
477 
478 
483  @value.setter
484  def value(self, value):
485  if isinstance(value, dict):
486  for k, v in value.items():
487  if not isinstance(k, str):
488  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_ERROR'),
489  'Illegal key argument type {0} in dictionary for argKeyFloatValueList'.format(k))
490  if not isinstance(v, float):
491  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_ERROR'),
492  'Illegal value argument type {0} in dictionary for argKeyFloatValueList'.format(v))
493  self._value = value
494  elif value is None:
495  self._value = {}
496  return
497  else:
498  self._value = {}
499  try:
500  if self._supressEmptyStrings:
501  kvlist = [ v for v in value.split(self._splitter) if v != '' ]
502  else:
503  kvlist = value.split(self._splitter)
504  for item in kvlist:
505  k, v = item.split(self._kvsplitter, 1)
506  self._value[k] = float(v)
507  except (AttributeError, ValueError):
508  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
509  'Failed to convert {0} to a dictionary of string:int values'.format(value))
510 
511  def __str__(self):
512  return str(self._value)
513 
514  @property
516  desc = {'type' : 'list', 'listtype' : 'str:float'}
517  return desc
518 
519 
520 
522 class argFile(argList):
523 
524 
544  def __init__(self, value=list(), type=None, subtype=None, io = 'output', splitter=',', runarg=True, guid=None,
545  multipleOK = None, name=None, executor=list(), mergeTargetSize=-1, auxiliaryFile=False):
546  # Set these values before invoking super().__init__ to make sure they can be
547  # accessed in our setter
548  self._dataset = None
549  self._urlType = None
550  self._type = type
551  self._subtype = subtype
552  self._guid = guid
553  self._mergeTargetSize = mergeTargetSize
554  self._auxiliaryFile = auxiliaryFile
555  self._originalName = None
556 
557  # User setter to get valid value check
558  self.io = io
559 
560  self._exe = executor
561 
562 
569 
570  self._metadataKeys = {'file_size': self._getSize,
571  'integrity': self._getIntegrity,
572  'file_guid': self._generateGUID,
573  '_exists': self._exists,
574  }
575  self._fileMetadata = {}
576  if multipleOK is None:
577  if self._io == 'input':
578  self._multipleOK = True
579  else:
580  self._multipleOK = False
581  else:
582  self._multipleOK = multipleOK
583 
584 
585  super(argFile, self).__init__(value=value, splitter=splitter, runarg=runarg, name=name)
586 
587 
588 
590  @property
591  def value(self):
592  return self._value
593 
594 
596  @value.setter
597  def value(self, value):
598  self.valueSetter(value)
599 
600 
602  @property
603  def multipleOK(self):
604  return self._multipleOK
605 
606 
607  @multipleOK.setter
608  def multipleOK(self, value):
609  self._multipleOK = value
610 
611 
612  @property
613  def mergeTargetSize(self):
614  return self._mergeTargetSize
615 
616 
617  @mergeTargetSize.setter
618  def mergeTargetSize(self, value):
619  if value is None:
620  self._mergeTargetSize = 0
621  else:
622  self._mergeTargetSize = value
623 
624  @property
626  if isinstance(self._type, dict):
627  if self._type=={}:
628  desc = {'type' : 'file', 'subtype' : "NONE" }
629  else:
630  desc = {'type' : 'file', 'subtype' : dict((str(k).upper(), str(v).upper()) for (k,v) in self._type.items())}
631  else:
632  desc = {'type' : 'file', 'subtype' : str(self._type).upper()}
633  desc['multiple'] = self._multipleOK
634  return desc
635 
636 
637  @property
638  def executor(self):
639  return self._exe
640 
641 
645  def valueSetter(self, value):
646 
647  if isinstance(value, (list, tuple)):
648  if len(value) > 0 and isinstance(value[0], dict): # Tier-0 style expanded argument with metadata
649  self._value=[]
650  for myfile in value:
651  try:
652  self._value.append(myfile['lfn'])
653  self._resetMetadata(files = [myfile['lfn']])
654  except KeyError:
655  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
656  'Filename (key "lfn") not found in Tier-0 file dictionary: {0}'.format(myfile))
657  for k, v in myfile.items():
658  if k == 'guid':
659  self._setMetadata([myfile['lfn']], {'file_guid': v})
660  elif k == 'events':
661  self._setMetadata([myfile['lfn']], {'nentries': v})
662  elif k == 'checksum':
663  self._setMetadata([myfile['lfn']], {'checksum': v})
664  elif k == 'dsn':
665  if not self._dataset:
666  self.dataset = v
667  elif self.dataset != v:
668  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_DATASET'),
669  'Inconsistent dataset names in Tier-0 dictionary: {0} != {1}'.format(self.dataset, v))
670  else:
671  self._value = list(value)
672  self._getDatasetFromFilename(reset = False)
673  self._resetMetadata()
674  elif value is None:
675  self._value = []
676  return
677  else:
678  try:
679  if value.lower().startswith('lfn'):
680  # Resolve physical filename using pool file catalog.
681  from PyUtils.PoolFile import file_name
682  protocol, pfn = file_name(value)
683  self._value = [pfn]
684  self._getDatasetFromFilename(reset = False)
685  self._resetMetadata()
686  else:
687  self._value = value.split(self._splitter)
688  self._getDatasetFromFilename(reset = False)
689  self._resetMetadata()
690  except (AttributeError, TypeError):
691  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
692  'Failed to convert %s to a list' % str(value))
693 
694 
695  deDuplicatedValue = []
696  for fname in self._value:
697  if fname not in deDuplicatedValue:
698  deDuplicatedValue.append(fname)
699  else:
700  msg.warning("Removing duplicated file {0} from file list".format(fname))
701  if len(self._value) != len(deDuplicatedValue):
702  self._value = deDuplicatedValue
703  msg.warning('File list after duplicate removal: {0}'.format(self._value))
704 
705  # Find our URL type (if we actually have files!)
706  # At the moment this is assumed to be the same for all files in this instance
707  # although in principle one could mix different access methods in the one input file type
708  if len(self._value) > 0:
709  self._urlType = urlType(self._value[0])
710  else:
711  self._urlType = None
712 
713 
714  if self._io == 'input':
715 
719  if self._urlType == 'posix':
720  msg.debug('Found POSIX filesystem input - activating globbing')
721  newValue = []
722  for filename in self._value:
723  # Simple case
724  globbedFiles = glob.glob(filename)
725  if len(globbedFiles) == 0: # No files globbed for this 'filename' argument.
726  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_INPUT_FILE_ERROR'),
727  'Input file argument {0} globbed to NO input files - probably the file(s) are missing'.format(filename))
728 
729  globbedFiles.sort()
730  newValue.extend(globbedFiles)
731 
732  self._value = newValue
733  msg.debug ('File input is globbed to %s' % self._value)
734 
735  elif self._urlType == 'root':
736  msg.debug('Found root filesystem input - activating globbing')
737  newValue = []
738  for filename in self._value:
739  if str(filename).startswith("root"):
740  msg.debug('Found input file name starting with "root," setting XRD_RUNFORKHANDLER=1, which enables fork handlers for xrootd in direct I/O')
741  os.environ["XRD_RUNFORKHANDLER"] = "1"
742  if str(filename).startswith("https") or str(filename).startswith("davs") or not(str(filename).endswith('/')) and '*' not in filename and '?' not in filename:
743  msg.debug('Seems that only one file was given: {0}'.format(filename))
744  newValue.extend(([filename]))
745  else:
746  # Hopefully this recognised wildcards...
747  path = filename
748  fileMask = ''
749  if '*' in filename or '?' in filename:
750  msg.debug('Split input into path for listdir() and a filemask to select available files.')
751  path = filename[0:filename.rfind('/')+1]
752  msg.debug('path: {0}'.format(path))
753  fileMask = filename[filename.rfind('/')+1:len(filename)]
754  msg.debug('Will select according to: {0}'.format(fileMask))
755 
756  cmd = ['/afs/cern.ch/project/eos/installation/atlas/bin/eos.select' ]
757  if not os.access ('/afs/cern.ch/project/eos/installation/atlas/bin/eos.select', os.X_OK ):
758  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_INPUT_FILE_ERROR'),
759  'No execute access to "eos.select" - could not glob EOS input files.')
760 
761  cmd.extend(['ls'])
762  cmd.extend([path])
763 
764  myFiles = []
765  try:
766  proc = subprocess.Popen(args = cmd,bufsize = 1, shell = False, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
767  rc = proc.wait()
768  output = proc.stdout.readlines()
769  if rc!=0:
770  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_INPUT_FILE_ERROR'),
771  'EOS list command ("{0!s}") failed: rc {1}, output {2}'.format(cmd, rc, output))
772  msg.debug("eos returned: {0}".format(output))
773  for line in output:
774  if "root" in line:
775  myFiles += [str(path)+str(line.rstrip('\n'))]
776 
777  patt = re.compile(fileMask.replace('*','.*').replace('?','.'))
778  for srmFile in myFiles:
779  if fileMask != '':
780  if(patt.search(srmFile)) is not None:
781  #if fnmatch.fnmatch(srmFile, fileMask):
782  msg.debug('match: ',srmFile)
783  newValue.extend(([srmFile]))
784  else:
785  newValue.extend(([srmFile]))
786 
787  msg.debug('Selected files: ', newValue)
788  except (AttributeError, TypeError, OSError):
789  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_RUNTIME_ERROR'),
790  'Failed to convert %s to a list' % str(value))
791  if len(self._value) > 0 and len(newValue) == 0:
792  # Woops - no files!
793  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_INPUT_FILE_ERROR'),
794  'Input file argument(s) {0!s} globbed to NO input files - ls command failed')
795  self._value = newValue
796  msg.debug ('File input is globbed to %s' % self._value)
797  # Check if multiple outputs are ok for this object
798  elif self._multipleOK is False and len(self._value) > 1:
799  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_OUTPUT_FILE_ERROR'),
800  'Multiple file arguments are not supported for {0} (was given: {1}'.format(self, self._value))
801 
802  @property
803  def io(self):
804  return (self._io)
805 
806  @io.setter
807  def io(self, value):
808  if value not in ('input', 'output', 'temporary'):
809  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_RUNTIME_ERROR'),
810  'File arguments must be specified as input, output or temporary - got {0}'.format(value))
811  self._io = value
812 
813  @property
814  def dataset(self):
815  return self._dataset
816 
817  @dataset.setter
818  def dataset(self, value):
819  self._dataset = value
820 
821  @property
822  def orignalName(self):
823  return self._originalName
824 
825  @orignalName.setter
826  def originalName(self, value):
827  self._originalName = value
828 
829  @property
830  def type(self):
831  return self._type
832 
833  @type.setter
834  def type(self, value):
835  self._type = value
836 
837  @property
838  def subtype(self):
839  return self._subtype
840 
841  @subtype.setter
842  def subtype(self, value):
843  self._subtype = value
844 
845 
846  @property
847  def name(self):
848  return self._name
849 
850 
854  @name.setter
855  def name(self, value):
856  self._name = value
857  m = re.match(r'(input|output|tmp.)([A-Za-z0-9_]+?)(File)?$', value)
858  if m:
859  msg.debug("ArgFile name setter matched this: {0}".format(m.groups()))
860  if self._type is None:
861  dtype = m.group(2).split('_', 1)[0]
862  # But DRAW/DESD/DAOD are really just RAW, ESD, AOD in format
863  if re.match(r'D(RAW|ESD|AOD)', dtype):
864  dtype = dtype[1:]
865  msg.debug("Autoset data type to {0}".format(dtype))
866  self._type = dtype
867  if self._subtype is None:
868  msg.debug("Autoset data subtype to {0}".format(m.group(2)))
869  self._subtype = m.group(2)
870  else:
871  msg.debug("ArgFile name setter did not match against '{0}'".format(value))
872 
873  @property
874  def auxiliaryFile(self):
875  return self._auxiliaryFile
876 
877 
879  @property
880  def metadata(self):
881  self.getMetadata()
882  return self._fileMetadata
883 
884 
885  @property
886  def nentries(self):
887  return self.getnentries()
888 
889 
890  def getnentries(self, fast=False):
891  totalEvents = 0
892  for fname in self._value:
893  events = self.getSingleMetadata(fname=fname, metadataKey='nentries', populate = not fast)
894  if events is None:
895  msg.debug('Got events=None for file {0} - returning None for this instance'.format(fname))
896  return None
897  if events == 'UNDEFINED':
898  msg.debug('Got events=UNDEFINED for file {0} - returning UNDEFINED for this instance'.format(fname))
899  return 'UNDEFINED'
900  if not isinstance(events, int):
901  msg.warning('Got unexpected events metadata for file {0}: {1!s} - returning None for this instance'.format(fname, events))
902  return None
903  totalEvents += events
904 
905  return totalEvents
906 
907 
908 
913  def _resetMetadata(self, files=[]):
914  if files == [] or '_fileMetadata' not in dir(self):
915  self._fileMetadata = {}
916  for fname in self.value:
917  self._fileMetadata[fname] = {}
918  else:
919  for fname in files:
920  if fname in self.value:
921  self._fileMetadata[fname] = {}
922  elif fname in self._fileMetadata:
923  del self._fileMetadata[fname]
924  msg.debug('Metadata dictionary now {0}'.format(self._fileMetadata))
925 
926  # If we have the special guid option, then manually try to set GUIDs we find
927  if self._guid is not None:
928  msg.debug('Now trying to set file GUID metadata using {0}'.format(self._guid))
929  for fname, guid in self._guid.items():
930  if fname in self._value:
931  self._fileMetadata[fname]['file_guid'] = guid
932  else:
933  msg.warning('Explicit GUID {0} was passed for file {1}, but this file is not a member of this instance'.format(guid, fname))
934 
935 
941  def getMetadata(self, files = None, metadataKeys = None, maskMetadataKeys = None, populate = True, flush = False):
942  # Normalise the files and keys parameter
943  if files is None:
944  files = self._value
945  elif isinstance(files, str):
946  files = (files,)
947  msg.debug('getMetadata will examine these files: {0!s}'.format(files))
948 
949  if metadataKeys is None:
950  metadataKeys = list(self._metadataKeys)
951  elif isinstance(metadataKeys, str):
952  metadataKeys = [metadataKeys,]
953  if maskMetadataKeys is not None:
954  metadataKeys = [k for k in metadataKeys if k not in maskMetadataKeys]
955  msg.debug('getMetadata will retrieve these keys: {0!s}'.format(metadataKeys))
956 
957  if flush is True:
958  msg.debug('Flushing cached metadata values')
959  self._resetMetadata()
960 
961  if populate is True:
962  msg.debug('Checking metadata values')
963  self._readMetadata(files, metadataKeys)
964 
965  metadata = {}
966  for fname in files:
967  metadata[fname] = {}
968  for mdkey in metadataKeys:
969  try:
970  metadata[fname][mdkey] = self._fileMetadata[fname][mdkey]
971  except KeyError:
972  # This should not happen, unless we skipped populating
973  if populate:
974  msg.error('Did not find metadata key {0!s} for file {1!s} - setting to None'.format(mdkey, fname))
975  metadata[fname][mdkey] = None
976  return metadata
977 
978 
985  def getSingleMetadata(self, fname, metadataKey, populate = True, flush = False):
986  if not (isinstance(fname, str) and isinstance(metadataKey, str)):
987  raise trfExceptions.TransformInternalException(trfExit.nameToCode('TRF_INTERNAL'),
988  'Illegal call to getSingleMetadata function: {0!s} {1!s}'.format(fname, metadataKey))
989  md = self.getMetadata(files = fname, metadataKeys = metadataKey, populate = populate, flush = flush)
990  return md[fname][metadataKey]
991 
992 
993 
996  def _readMetadata(self, files, metadataKeys):
997  msg.debug('Retrieving metadata keys {1!s} for files {0!s}'.format(files, metadataKeys))
998  for fname in files:
999  if fname not in self._fileMetadata:
1000  self._fileMetadata[fname] = {}
1001  for fname in files:
1002  # Always try for a simple existence test first before producing misleading error messages
1003  # from metadata populator functions
1004  if '_exists' not in self._fileMetadata[fname]:
1005  self._metadataKeys['_exists'](files)
1006  if self._fileMetadata[fname]['_exists'] is False:
1007  # N.B. A log ERROR message has printed by the existence test, so do not repeat that news here
1008  for key in metadataKeys:
1009  if key != '_exists':
1010  self._fileMetadata[fname][key] = None
1011  else:
1012  # OK, file seems to exist at least...
1013  for key in metadataKeys:
1014  if key not in self._metadataKeys:
1015  msg.debug('Metadata key {0} is unknown for {1}'.format(key, self.__class__.__name__))
1016  self._fileMetadata[fname][key] = 'UNDEFINED'
1017  else:
1018  if key in self._fileMetadata[fname]:
1019  msg.debug('Found cached value for {0}:{1} = {2!s}'.format(fname, key, self._fileMetadata[fname][key]))
1020  else:
1021  msg.debug('No cached value for {0}:{1}. Calling generator function {2} ({3})'.format(fname, key, self._metadataKeys[key].__name__, self._metadataKeys[key]))
1022  try:
1023  # For efficiency call this routine with all files we have
1024  msg.info("Metadata generator called to obtain {0} for {1}".format(key, files))
1025  self._metadataKeys[key](files)
1027  msg.error('Calling {0!s} raised an exception: {1!s}'.format(self._metadataKeys[key].__name__, e))
1028  if key not in self._fileMetadata[fname]:
1029  msg.warning('Call to function {0} for {1} file {2} failed to populate metadata key {3}'.format(self._metadataKeys[key].__name__, self.__class__.__name__, fname, key))
1030  self._fileMetadata[fname][key] = None
1031  msg.debug('Now have {0}:{1} = {2!s}'.format(fname, key, self._fileMetadata[fname][key]))
1032 
1033 
1034 
1044  def _setMetadata(self, files=None, metadataKeys={}):
1045  if files is None:
1046  files = self._value
1047  for fname in files:
1048  if fname not in self._fileMetadata:
1049  self._fileMetadata[fname] = {}
1050  for k, v in metadataKeys.items():
1051  msg.debug('Manualy setting {0} for file {1} to {2}'.format(k, fname, v))
1052  self._fileMetadata[fname][k] = v
1053 
1054 
1055 
1061  def isCached(self, files = None, metadataKeys = None):
1062  msg.debug('Testing for cached values for files {0} and keys {1}'.format(files, metadataKeys))
1063  if files is None:
1064  files = self._value
1065  elif isinstance(files, str):
1066  files = (files,)
1067  if metadataKeys is None:
1068  metadataKeys = list(self._metadataKeys)
1069  elif isinstance(metadataKeys, str):
1070  metadataKeys = (metadataKeys,)
1071 
1072  isCachedFlag = True
1073  for fname in files:
1074  for key in metadataKeys:
1075  if key not in self._fileMetadata[fname]:
1076  isCachedFlag = False
1077  break
1078  if isCachedFlag is False:
1079  break
1080 
1081  return isCachedFlag
1082 
1083 
1089  def _getDatasetFromFilename(self, reset = False):
1090  if reset:
1091  self._dataset = None
1092  newValue = []
1093  for filename in self._value:
1094  if filename.find('#') > -1:
1095  (dataset, fname) = filename.split('#', 1)
1096  newValue.append(fname)
1097  msg.debug('Current dataset: {0}; New dataset {1}'.format(self._dataset, dataset))
1098  if self._dataset and (self._dataset != dataset):
1099  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_DATASET'),
1100  'Found inconsistent dataset assignment in argFile setup: %s != %s' % (self._dataset, dataset))
1101  self._dataset = dataset
1102  if len(newValue) == 0:
1103  return
1104  elif len(newValue) != len (self._value):
1105  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_DATASET'),
1106  'Found partial dataset assignment in argFile setup from {0} (dsn#lfn notation must be uniform for all inputs)'.format(self._value))
1107  self._value = newValue
1108 
1109 
1113  def _getSize(self, files):
1114  for fname in files:
1115  if self._urlType == 'posix':
1116  try:
1117  self._fileMetadata[fname]['size'] = os.stat(fname).st_size
1118  except OSError as e:
1119  msg.error('Got exception {0!s} raised while stating file {1}'.format(e, fname))
1120  self._fileMetadata[fname]['size'] = None
1121  else:
1122  # OK, let's see if ROOT can do it...
1123  msg.debug('Calling ROOT TFile.GetSize({0})'.format(fname))
1124  self._fileMetadata[fname]['size'] = ROOTGetSize(fname)
1125 
1126 
1127 
1131  def _getIntegrity(self, files):
1132  for fname in files:
1133  is_binary = False
1134  with open(fname) as f:
1135  try:
1136  while True:
1137  chunk = len(f.read(1024*1024))
1138  msg.debug('Read {0} bytes from {1}'.format(chunk, fname))
1139  if chunk == 0:
1140  break
1141  self._fileMetadata[fname]['integrity'] = True
1142  except OSError as e:
1143  msg.error('Got exception {0!s} raised while checking integrity of file {1}'.format(e, fname))
1144  self._fileMetadata[fname]['integrity'] = False
1145  except UnicodeDecodeError:
1146  msg.debug('Problem reading file as unicode, attempting with binary')
1147  is_binary = True
1148  if is_binary:
1149  with open(fname,'rb') as f:
1150  try:
1151  while True:
1152  chunk = len(f.read(1024*1024))
1153  msg.debug('Read {0} bytes from {1}'.format(chunk, fname))
1154  if chunk == 0:
1155  break
1156  self._fileMetadata[fname]['integrity'] = True
1157  except OSError as e:
1158  msg.error('Got exception {0!s} raised while checking integrity of file {1}'.format(e, fname))
1159  self._fileMetadata[fname]['integrity'] = False
1160 
1161 
1165  def _generateGUID(self, files):
1166  for fname in files:
1167  msg.debug('Generating a GUID for file {0}'.format(fname))
1168  self._fileMetadata[fname]['file_guid'] = str(uuid.uuid4()).upper()
1169 
1170 
1171 
1176  def _exists(self, files):
1177  msg.debug('Testing existance for {0}'.format(files))
1178  for fname in files:
1179  if self._urlType == 'posix':
1180  try:
1181  size = os.stat(fname).st_size
1182  self._fileMetadata[fname]['file_size'] = size
1183  self._fileMetadata[fname]['_exists'] = True
1184  msg.debug('POSIX file {0} exists'.format(fname))
1185  except OSError as e:
1186  msg.error('Got exception {0!s} raised while stating file {1} - probably it does not exist'.format(e, fname))
1187  self._fileMetadata[fname]['_exists'] = False
1188  else:
1189  # OK, let's see if ROOT can do it...
1190  msg.debug('Calling ROOT TFile.GetSize({0})'.format(fname))
1191  size = ROOTGetSize(fname)
1192  if size is None:
1193  self._fileMetadata[fname]['_exists'] = False
1194  msg.error('Non-POSIX file {0} could not be opened - probably it does not exist'.format(fname))
1195  else:
1196  msg.debug('Non-POSIX file {0} exists'.format(fname))
1197  self._fileMetadata[fname]['file_size'] = size
1198  self._fileMetadata[fname]['_exists'] = True
1199 
1200 
1201  def __str__(self):
1202  return "{0}={1} (Type {2}, Dataset {3}, IO {4})".format(self.name, self.value, self.type, self.dataset, self.io)
1203 
1204 
1205 
1209  def _mergeArgs(self, argdict, copyArgs=None):
1210  if copyArgs:
1211  myargdict = {}
1212  for arg in copyArgs:
1213  if arg in argdict:
1214  myargdict[arg] = copy.copy(argdict[arg])
1215 
1216  else:
1217  myargdict = copy.copy(argdict)
1218  # Never do event count checks for self merging
1219  myargdict['checkEventCount'] = argSubstepBool('False', runarg=False)
1220  newopts = []
1221  if 'athenaopts' in myargdict:
1222  # Need to ensure that "nprocs" is not passed to merger
1223  # and prevent multiple '--threads' options when there are multiple sub-steps in 'athenopts'
1224  for subStep in myargdict['athenaopts'].value:
1225  hasNprocs = False
1226  hasNthreads = False
1227  for opt in myargdict['athenaopts'].value[subStep]:
1228  if opt.startswith('--nprocs'):
1229  hasNprocs = True
1230  continue
1231  # Keep at least one '--threads'
1232  elif opt.startswith('--threads'):
1233  hasNthreads = True
1234  if opt in newopts:
1235  continue
1236  newopts.append(opt)
1237  # If we have hybrid MP+MT job make sure --threads is not passed to merger
1238  if hasNprocs and hasNthreads:
1239  tmpopts = []
1240  for opt in newopts:
1241  if opt.startswith('--threads'):
1242  continue
1243  tmpopts.append(opt)
1244  newopts = tmpopts
1245  myargdict['athenaopts'] = argSubstepList(newopts, runarg=False)
1246  return myargdict
1247 
1248 
1250  def __init__(self, value=list(), io = 'output', type=None, splitter=',', runarg=True, multipleOK=None, name=None):
1251  super(argYODAFile, self).__init__(value=value, io=io, type=type, splitter=splitter, runarg=runarg, multipleOK=multipleOK,
1252  name=name)
1253 
1254  self._metadataKeys.update({
1255  'nentries': self._getNumberOfEvents,
1256  'lheSumOfPosWeights': self._getWeightedEvents,
1257  'lheSumOfNegWeights': 0,
1258  })
1259 
1260  def _getNumberOfEvents(self, files):
1261  msg.debug('Retrieving event count for LHE file {0}'.format(files))
1262  import tarfile
1263  for fname in files:
1264  # Attempt to treat this as a pileup reweighting file
1265  try :
1266  tar = tarfile.open(fname, "r:gz")
1267  lhecount = 0
1268  for untar in tar.getmembers():
1269  fileTXT = tar.extractfile(untar)
1270  if fileTXT is not None :
1271  lines = fileTXT.read().decode("utf-8")
1272  lhecount = lines.count('/event')
1273 
1274  self._fileMetadata[fname]['nentries'] = lhecount
1275  except Exception:
1276  msg.debug('Entries is set to None - event count undefined for this LHE')
1277  self._fileMetadata[fname]['nentries'] = -1
1278 
1279  def _getWeightedEvents(self, files):
1280  msg.debug('Retrieving weight count for LHE file {0}'.format(files))
1281  import tarfile
1282  import re
1283 
1284  for fname in files:
1285  weightPos = 0
1286  weightNeg = 0
1287  try :
1288  tar = tarfile.open(fname, "r:gz")
1289  for untar in tar.getmembers():
1290  fileTXT = tar.extractfile(untar)
1291  next = False
1292  if fileTXT is not None :
1293  for line in fileTXT :
1294  line = line.decode("utf-8")
1295  if next :
1296  try :
1297  w = float(re.sub(' +',' ',line).split(" ")[2])
1298  if w > 0 : weightPos += w
1299  else : weightNeg += abs(w)
1300  except Exception:
1301  pass
1302  next = False
1303  if "<event" in line :
1304  next = True
1305 
1306  self._fileMetadata[fname]['lheSumOfPosWeights'] = weightPos
1307  self._fileMetadata[fname]['lheSumOfNegWeights'] = weightNeg
1308  except Exception:
1309  msg.debug('Entries is set to None - negative fraction count undefined for this LHE')
1310  self._fileMetadata[fname]['lheSumOfPosWeights'] = -1
1311  self._fileMetadata[fname]['lheSumOfNegWeights'] = -1
1312 
1313 
1316  def __init__(self, value = list(), type=None, subtype=None, io = 'output', splitter=',', runarg=True, multipleOK = None,
1317  name=None, executor=list(), mergeTargetSize=-1, auxiliaryFile=False):
1318  super(argAthenaFile, self).__init__(value=value, subtype=subtype, io=io, type=type, splitter=splitter, runarg=runarg,
1319  multipleOK=multipleOK, name=name, executor=executor, mergeTargetSize=mergeTargetSize,
1320  auxiliaryFile=auxiliaryFile)
1321 
1322  # Extra metadata known for athena files:
1323  for key in athFileInterestingKeys:
1324  self._metadataKeys[key] = self._getAthInfo
1325 
1326 
1327  def _callAthInfo(self, files, doAllFiles, retrieveKeys):
1328  if doAllFiles:
1329  myFiles = self._value
1330  else:
1331  myFiles = files
1332  msg.debug('Will retrieve metadata info for {0!s}'.format(myFiles))
1333  aftype = 'POOL'
1334  if self._type.upper() in ('BS', 'RAW'):
1335  aftype = 'BS'
1336  elif self._type.upper() in ('TAG'):
1337  aftype = 'TAG'
1338 
1339  # N.B. Could parallelise here
1340  for fname in myFiles:
1341  athFileMetadata = AthenaLiteFileInfo(fname, aftype, retrieveKeys=retrieveKeys)
1342  if athFileMetadata is None:
1343  raise trfExceptions.TransformMetadataException(trfExit.nameToCode('TRF_METADATA_CALL_FAIL'), 'Call to AthenaLiteFileInfo failed')
1344  msg.debug('Setting metadata for file {0} to {1}'.format(fname, athFileMetadata[fname]))
1345  self._fileMetadata[fname].update(athFileMetadata[fname])
1346 
1347 
1348  def _getAthInfo(self, files):
1349  self._callAthInfo(files, doAllFiles = True, retrieveKeys=athFileInterestingKeys)
1350 
1351  @property
1353  desc=super(argAthenaFile, self).prodsysDescription
1354  return desc
1355 
1356 
1357 
1359 
1360  integrityFunction = "returnIntegrityOfBSFile"
1361 
1362  def _getIntegrity(self, files):
1363  for fname in files:
1364  try:
1365  rc=call(["AtlListBSEvents", "-c", fname], logger=msg, message="Report by AtlListBSEvents: ", timeout=600)
1367  return False
1368  if rc==0:
1369  self._fileMetadata[fname]['integrity'] = True
1370  else:
1371  self._fileMetadata[fname]['integrity'] = False
1372 
1373  @property
1375  desc=super(argBSFile, self).prodsysDescription
1376  return desc
1377 
1378 
1385  def selfMerge(self, output, inputs, counter=0, argdict={}):
1386  msg.debug('selfMerge attempted for {0} -> {1} with {2} (index {3})'.format(inputs, output, argdict, counter))
1387 
1388  # First do a little sanity check
1389  for fname in inputs:
1390  if fname not in self._value:
1391  raise trfExceptions.TransformMergeException(trfExit.nameToCode('TRF_FILEMERGE_PROBLEM'),
1392  "File {0} is not part of this agument: {1}".format(fname, self))
1393 
1394  from PyJobTransforms.trfExe import bsMergeExecutor, executorConfig
1395 
1396 
1397  myargdict = self._mergeArgs(argdict)
1398  myargdict['maskEmptyInputs'] = argBool(True)
1399  myargdict['allowRename'] = argBool(True)
1400  myargdict['emptyStubFile'] = argString(inputs[0])
1401 
1402  # We need a athenaExecutor to do the merge
1403  # N.B. We never hybrid merge AthenaMP outputs as this would prevent further merging in another
1404  # task (hybrid merged files cannot be further bybrid merged)
1405  myDataDictionary = {'BS_MRG_INPUT' : argBSFile(inputs, type=self.type, io='input'),
1406  'BS_MRG_OUTPUT' : argBSFile(output, type=self.type, io='output')}
1407  myMergeConf = executorConfig(myargdict, myDataDictionary)
1408  myMerger = bsMergeExecutor(name='BSMergeAthenaMP{0}{1}'.format(self._subtype, counter), conf=myMergeConf, exe = 'file_merging',
1409  inData=set(['BS_MRG_INPUT']), outData=set(['BS_MRG_OUTPUT']))
1410  myMerger.doAll(input=set(['BS_MRG_INPUT']), output=set(['BS_MRG_OUTPUT']))
1411 
1412  # OK, if we got to here with no exceptions, we're good shape
1413  # Now update our own list of files to reflect the merge
1414  for fname in inputs:
1415  self._value.remove(fname)
1416  self._value.append(output)
1417 
1418  msg.debug('Post self-merge files are: {0}'.format(self._value))
1419  self._resetMetadata(inputs + [output])
1420  return myMerger
1421 
1422 
1423 
1426 
1427  integrityFunction = "returnIntegrityOfPOOLFile"
1428 
1429  # trfValidateRootFile is written in an odd way, so timelimit it here.
1430  @timelimited()
1431  def _getIntegrity(self, files):
1432  for fname in files:
1433  from PyJobTransforms.trfValidateRootFile import checkFile
1434  rc=checkFile(fileName=fname, the_type='event', requireTree=False)
1435  if rc==0:
1436  self._fileMetadata[fname]['integrity'] = True
1437  else:
1438  self._fileMetadata[fname]['integrity'] = False
1439 
1440  @property
1442  desc=super(argPOOLFile, self).prodsysDescription
1443  return desc
1444 
1445 
1450  def selfMerge(self, output, inputs, counter=0, argdict={}):
1451  msg.debug('selfMerge attempted for {0} -> {1} with {2}'.format(inputs, output, argdict))
1452 
1453  # First do a little sanity check
1454  for fname in inputs:
1455  if fname not in self._value:
1456  raise trfExceptions.TransformMergeException(trfExit.nameToCode('TRF_FILEMERGE_PROBLEM'),
1457  "File {0} is not part of this agument: {1}".format(fname, self))
1458 
1459  from PyJobTransforms.trfExe import athenaExecutor, executorConfig
1460 
1461 
1462  myargdict = self._mergeArgs(argdict)
1463 
1464  # We need a athenaExecutor to do the merge
1465  # N.B. We never hybrid merge AthenaMP outputs as this would prevent further merging in another
1466  # task (hybrid merged files cannot be further bybrid merged)
1467  myDataDictionary = {'POOL_MRG_INPUT' : argPOOLFile(inputs, type=self.type, io='input'),
1468  'POOL_MRG_OUTPUT' : argPOOLFile(output, type=self.type, io='output')}
1469  myMergeConf = executorConfig(myargdict, myDataDictionary)
1470  myMerger = athenaExecutor(name='POOLMergeAthenaMP{0}{1}'.format(self._subtype, counter), conf=myMergeConf,
1471  skeletonCA = 'RecJobTransforms.MergePool_Skeleton',
1472  inData=set(['POOL_MRG_INPUT']), outData=set(['POOL_MRG_OUTPUT']),
1473  disableMT=True, disableMP=True)
1474  myMerger.doAll(input=set(['POOL_MRG_INPUT']), output=set(['POOL_MRG_OUTPUT']))
1475 
1476  # OK, if we got to here with no exceptions, we're good shape
1477  # Now update our own list of files to reflect the merge
1478  for fname in inputs:
1479  self._value.remove(fname)
1480  self._value.append(output)
1481 
1482  msg.debug('Post self-merge files are: {0}'.format(self._value))
1483  self._resetMetadata(inputs + [output])
1484  return myMerger
1485 
1487 
1488  integrityFunction = "returnIntegrityOfPOOLFile"
1489 
1490 
1491  def selfMerge(self, output, inputs, counter=0, argdict={}):
1492  msg.debug('selfMerge attempted for {0} -> {1} with {2}'.format(inputs, output, argdict))
1493 
1494  # First do a little sanity check
1495  for fname in inputs:
1496  if fname not in self._value:
1497  raise trfExceptions.TransformMergeException(trfExit.nameToCode('TRF_FILEMERGE_PROBLEM'),
1498  "File {0} is not part of this agument: {1}".format(fname, self))
1499 
1500 
1501  mySubstepName = 'HITSMergeAthenaMP{0}'.format(counter)
1502  myargdict = self._mergeArgs(argdict)
1503 
1504  from PyJobTransforms.trfExe import athenaExecutor, executorConfig
1505  myDataDictionary = {'HITS' : argHITSFile(inputs, type=self.type, io='input'),
1506  'HITS_MRG' : argHITSFile(output, type=self.type, io='output')}
1507  myMergeConf = executorConfig(myargdict, myDataDictionary)
1508  myMerger = athenaExecutor(name = mySubstepName,
1509  skeletonCA = 'SimuJobTransforms.HITSMerge_Skeleton',
1510  conf=myMergeConf,
1511  inData=set(['HITS']), outData=set(['HITS_MRG']),
1512  disableMT=True, disableMP=True)
1513  myMerger.doAll(input=set(['HITS']), output=set(['HITS_MRG']))
1514 
1515  # OK, if we got to here with no exceptions, we're good shape
1516  # Now update our own list of files to reflect the merge
1517  for fname in inputs:
1518  self._value.remove(fname)
1519  self._value.append(output)
1520 
1521  msg.debug('Post self-merge files are: {0}'.format(self._value))
1522  self._resetMetadata(inputs + [output])
1523  return myMerger
1524 
1525 
1527 
1528  integrityFunction = "returnIntegrityOfPOOLFile"
1529 
1530 
1531  def selfMerge(self, output, inputs, counter=0, argdict={}):
1532  msg.debug('selfMerge attempted for {0} -> {1} with {2}'.format(inputs, output, argdict))
1533 
1534  # First do a little sanity check
1535  for fname in inputs:
1536  if fname not in self._value:
1537  raise trfExceptions.TransformMergeException(trfExit.nameToCode('TRF_FILEMERGE_PROBLEM'),
1538  "File {0} is not part of this agument: {1}".format(fname, self))
1539 
1540 
1541  mySubstepName = 'EVNT_TRMergeAthenaMP{0}'.format(counter)
1542  myargdict = self._mergeArgs(argdict)
1543 
1544  from PyJobTransforms.trfExe import athenaExecutor, executorConfig
1545  myDataDictionary = {'EVNT_TR' : argEVNT_TRFile(inputs, type=self.type, io='input'),
1546  'EVNT_TR_MRG' : argEVNT_TRFile(output, type=self.type, io='output')}
1547  myMergeConf = executorConfig(myargdict, myDataDictionary)
1548  myMerger = athenaExecutor(name = mySubstepName, skeletonFile = 'SimuJobTransforms/skeleton.EVNT_TRMerge.py',
1549  conf=myMergeConf,
1550  inData=set(['EVNT_TR']), outData=set(['EVNT_TR_MRG']),
1551  disableMT=True, disableMP=True)
1552  myMerger.doAll(input=set(['EVNT_TR']), output=set(['EVNT_TR_MRG']))
1553 
1554  # OK, if we got to here with no exceptions, we're good shape
1555  # Now update our own list of files to reflect the merge
1556  for fname in inputs:
1557  self._value.remove(fname)
1558  self._value.append(output)
1559 
1560  msg.debug('Post self-merge files are: {0}'.format(self._value))
1561  self._resetMetadata(inputs + [output])
1562  return myMerger
1563 
1564 
1566 
1567  integrityFunction = "returnIntegrityOfPOOLFile"
1568 
1569 
1570  def selfMerge(self, output, inputs, counter=0, argdict={}):
1571  msg.debug('selfMerge attempted for {0} -> {1} with {2}'.format(inputs, output, argdict))
1572 
1573  # First do a little sanity check
1574  for fname in inputs:
1575  if fname not in self._value:
1576  raise trfExceptions.TransformMergeException(trfExit.nameToCode('TRF_FILEMERGE_PROBLEM'),
1577  "File {0} is not part of this agument: {1}".format(fname, self))
1578 
1579 
1580  myargdict = self._mergeArgs(argdict)
1581 
1582  from PyJobTransforms.trfExe import athenaExecutor, executorConfig
1583  myDataDictionary = {'RDO' : argHITSFile(inputs, type=self.type, io='input'),
1584  'RDO_MRG' : argHITSFile(output, type=self.type, io='output')}
1585  myMergeConf = executorConfig(myargdict, myDataDictionary)
1586  myMerger = athenaExecutor(name = 'RDOMergeAthenaMP{0}'.format(counter),
1587  skeletonCA = 'SimuJobTransforms.RDOMerge_Skeleton',
1588  conf=myMergeConf,
1589  inData=set(['RDO']), outData=set(['RDO_MRG']),
1590  disableMT=True, disableMP=True)
1591  myMerger.doAll(input=set(['RDO']), output=set(['RDO_MRG']))
1592 
1593  # OK, if we got to here with no exceptions, we're good shape
1594  # Now update our own list of files to reflect the merge
1595  for fname in inputs:
1596  self._value.remove(fname)
1597  self._value.append(output)
1598 
1599  msg.debug('Post self-merge files are: {0}'.format(self._value))
1600  self._resetMetadata(inputs + [output])
1601  return myMerger
1602 
1604 
1605  integrityFunction = "returnIntegrityOfPOOLFile"
1606 
1607 
1608  def selfMerge(self, output, inputs, counter=0, argdict={}):
1609  msg.debug('selfMerge attempted for {0} -> {1} with {2}'.format(inputs, output, argdict))
1610 
1611  # First do a little sanity check
1612  for fname in inputs:
1613  if fname not in self._value:
1614  raise trfExceptions.TransformMergeException(trfExit.nameToCode('TRF_FILEMERGE_PROBLEM'),
1615  "File {0} is not part of this agument: {1}".format(fname, self))
1616 
1617 
1618  mySubstepName = 'EVNTMergeAthenaMP{0}'.format(counter)
1619  myargdict = self._mergeArgs(argdict)
1620 
1621  from PyJobTransforms.trfExe import athenaExecutor, executorConfig
1622  myDataDictionary = {'EVNT' : argEVNTFile(inputs, type=self.type, io='input'),
1623  'EVNT_MRG' : argEVNTFile(output, type=self.type, io='output')}
1624  myMergeConf = executorConfig(myargdict, myDataDictionary)
1625  myMerger = athenaExecutor(name = mySubstepName, skeletonCA = 'EvgenJobTransforms.EVNTMerge_Skeleton',
1626  conf=myMergeConf,
1627  inData=set(['EVNT']), outData=set(['EVNT_MRG']),
1628  disableMT=True, disableMP=True)
1629  myMerger.doAll(input=set(['EVNT']), output=set(['EVNT_MRG']))
1630 
1631  # OK, if we got to here with no exceptions, we're good shape
1632  # Now update our own list of files to reflect the merge
1633  for fname in inputs:
1634  self._value.remove(fname)
1635  self._value.append(output)
1636 
1637  msg.debug('Post self-merge files are: {0}'.format(self._value))
1638  self._resetMetadata(inputs + [output])
1639  return myMerger
1640 
1641 
1642 
1644 
1645  integrityFunction = "returnIntegrityOfHISTFile"
1646 
1647  def __init__(self, value=list(), io = 'output', type=None, subtype=None, splitter=',', runarg=True, countable=True, multipleOK = None,
1648  name=None, auxiliaryFile=False):
1649  super(argHISTFile, self).__init__(value=value, io=io, type=type, subtype=subtype, splitter=splitter, runarg=runarg, multipleOK=multipleOK,
1650  name=name, auxiliaryFile=auxiliaryFile)
1651 
1652  # Make events optional for HISTs (can be useful for HIST_AOD, HIST_ESD before hist merging)
1653  if countable:
1654  self._metadataKeys.update({
1655  'nentries': self._getNumberOfEvents
1656  })
1657 
1658 
1659  def _getIntegrity(self, files):
1660  for fname in files:
1661  self._fileMetadata[fname]['integrity'] = 'UNDEFINED'
1662 
1663 
1664  def _getNumberOfEvents(self, files):
1665  for fname in files:
1666  try:
1667  self._fileMetadata[fname]['nentries'] = HISTEntries(fname)
1669  msg.error('Timeout counting events for {0}'.format(fname))
1670 
1671  @property
1673  desc=super(argHISTFile, self).prodsysDescription
1674  return desc
1675 
1676 
1677 
1680 
1681  integrityFunction = "returnIntegrityOfNTUPFile"
1682 
1683 
1686  def __init__(self, value=list(), io = 'output', type=None, subtype=None, splitter=',', treeNames=None, runarg=True, multipleOK = None,
1687  name=None, mergeTargetSize=-1, auxiliaryFile=False):
1688  super(argNTUPFile, self).__init__(value=value, io=io, type=type, subtype=subtype, splitter=splitter, runarg=runarg, multipleOK=multipleOK,
1689  name=name, mergeTargetSize=mergeTargetSize, auxiliaryFile=auxiliaryFile)
1690  self._treeNames=treeNames
1691 
1692  self._metadataKeys.update({
1693  'nentries': self._getNumberOfEvents,
1694  'file_guid': self._generateGUID,
1695  'integrity': self._getIntegrity,
1696  })
1697 
1698  if name and 'NTUP_PILEUP' in name:
1699  self._metadataKeys.update({
1700  'sumOfWeights': self._getNumberOfEvents,
1701  })
1702 
1703  def _getNumberOfEvents(self, files):
1704  msg.debug('Retrieving event count for NTUP files {0}'.format(files))
1705  if self._treeNames is None:
1706  for fname in files:
1707  # Attempt to treat this as a pileup reweighting file
1708  myPRWEntries = PRWEntries(fileName=fname)
1709  if myPRWEntries is not None:
1710  self._fileMetadata[fname]['nentries'] = myPRWEntries
1711  if self.name and 'NTUP_PILEUP' in self.name:
1712  myPRWEntries = PRWEntries(fileName=fname, integral=True)
1713  self._fileMetadata[fname]['sumOfWeights'] = myPRWEntries
1714  else:
1715  # Attempt to treat this as a PHYSVAL file
1716  myPHYSVALEntries = PHYSVALEntries(fileName=fname)
1717  if myPHYSVALEntries is not None:
1718  self._fileMetadata[fname]['nentries'] = myPHYSVALEntries
1719  if self.name and 'NTUP_PHYSVAL' in self.name:
1720  myPHYSVALEntries = PHYSVALEntries(fileName=fname, integral=True)
1721  self._fileMetadata[fname]['sumOfWeights'] = myPHYSVALEntries
1722  else:
1723  msg.debug('treeNames is set to None - event count undefined for this NTUP')
1724  self._fileMetadata[fname]['nentries'] = 'UNDEFINED'
1725  else:
1726  for fname in files:
1727  try:
1728  self._fileMetadata[fname]['nentries'] = NTUPEntries(fileName=fname, treeNames=self._treeNames)
1730  msg.error('Timeout counting events for {0}'.format(fname))
1731 
1732 
1733  def _getIntegrity(self, files):
1734  for fname in files:
1735  from PyJobTransforms.trfValidateRootFile import checkFile
1736  rc=checkFile(fileName=fname, the_type='basket', requireTree=False)
1737  if rc==0:
1738  self._fileMetadata[fname]['integrity'] = True
1739  else:
1740  self._fileMetadata[fname]['integrity'] = False
1741 
1742 
1743  def selfMerge(self, output, inputs, counter=0, argdict={}):
1744  msg.debug('selfMerge attempted for {0} -> {1} with {2}'.format(inputs, output, argdict))
1745 
1746  # First do a little sanity check
1747  for fname in inputs:
1748  if fname not in self._value:
1749  raise trfExceptions.TransformMergeException(trfExit.nameToCode('TRF_FILEMERGE_PROBLEM'),
1750  "File {0} is not part of this agument: {1}".format(fname, self))
1751 
1752  from PyJobTransforms.trfExe import NTUPMergeExecutor, executorConfig
1753 
1754 
1755  myargdict = self._mergeArgs(argdict)
1756 
1757  # We need a NTUPMergeExecutor to do the merge
1758  myDataDictionary = {'NTUP_MRG_INPUT' : argNTUPFile(inputs, type=self.type, io='input'),
1759  'NYUP_MRG_OUTPUT' : argNTUPFile(output, type=self.type, io='output')}
1760  myMergeConf = executorConfig(myargdict, myDataDictionary)
1761  myMerger = NTUPMergeExecutor(name='NTUPMergeAthenaMP{0}{1}'.format(self._subtype, counter), conf=myMergeConf,
1762  inData=set(['NTUP_MRG_INPUT']), outData=set(['NTUP_MRG_OUTPUT']))
1763  myMerger.doAll(input=set(['NTUP_MRG_INPUT']), output=set(['NYUP_MRG_OUTPUT']))
1764 
1765  # OK, if we got to here with no exceptions, we're good shape
1766  # Now update our own list of files to reflect the merge
1767  for fname in inputs:
1768  self._value.remove(fname)
1769  self._value.append(output)
1770 
1771  msg.debug('Post self-merge files are: {0}'.format(self._value))
1772  self._resetMetadata(inputs + [output])
1773  return myMerger
1774 
1775  @property
1777  desc=super(argNTUPFile, self).prodsysDescription
1778  return desc
1779 
1780 
1781 
1782 
1784  def _getIntegrity(self, files):
1785  for fname in files:
1786  # bz2 only supports 'with' from python 2.7
1787  try:
1788  f = bz2.BZ2File(fname, 'r')
1789  while True:
1790  chunk = len(f.read(1024*1024))
1791  msg.debug('Read {0} bytes from {1}'.format(chunk, fname))
1792  if chunk == 0:
1793  break
1794  self._fileMetadata[fname]['integrity'] = True
1795  f.close()
1796  except OSError as e:
1797  msg.error('Got exception {0!s} raised while checking integrity of file {1}'.format(e, fname))
1798  self._fileMetadata[fname]['integrity'] = False
1799 
1800 
1801  @property
1803  desc=super(argBZ2File, self).prodsysDescription
1804  return desc
1805 
1806 
1807 
1809  def __init__(self, value=list(), io = 'output', type=None, splitter=',', runarg=True, multipleOK=None, name=None):
1810  super(argFTKIPFile, self).__init__(value=value, io=io, type=type, splitter=splitter, runarg=runarg, multipleOK=multipleOK,
1811  name=name)
1812  self._metadataKeys.update({
1813  'nentries': self._getNumberOfEvents
1814  })
1815 
1816  def _getNumberOfEvents(self, files):
1817  for fname in files:
1818  try:
1819  eventCount = 0
1820  f = bz2.BZ2File(fname, 'r')
1821  for line in f:
1822  if line.startswith('F'):
1823  eventCount += 1
1824  self._fileMetadata[fname]['nentries'] = eventCount
1825  except OSError as e:
1826  msg.error('Event count for file {0} failed: {1!s}'.format(fname, e))
1827  self._fileMetadata[fname]['nentries'] = None
1828 
1829  @property
1831  desc=super(argFTKIPFile, self).prodsysDescription
1832  return desc
1833 
1834 
1837  def __init__(self, value=list(), io = 'output', type='txt_evt', splitter=',', runarg=True, multipleOK=None, name=None):
1838  super(argHepEvtAsciiFile, self).__init__(value=value, io=io, type=type, splitter=splitter, runarg=runarg,
1839  multipleOK=multipleOK, name=name)
1840  self._metadataKeys.update({
1841  'nentries': self._getNumberOfEvents
1842  })
1843 
1844  def _getNumberOfEvents(self, files):
1845  for fname in files:
1846  try:
1847  eventCount = 0
1848  import tarfile
1849  tar = tarfile.open(fname, "r:gz")
1850  for untar in tar.getmembers():
1851  fileTXT = tar.extractfile(untar)
1852  if fileTXT is not None :
1853  lines = fileTXT.read().decode("utf-8")
1854  # lines contains the entire file, so we just count the number of event markers
1855  eventCount = lines.count('E ')
1856  self._fileMetadata[fname]['nentries'] = eventCount
1857  except OSError as e:
1858  msg.error('Event count for file {0} failed: {1!s}'.format(fname, e))
1859  self._fileMetadata[fname]['nentries'] = 'UNDEFINED'
1860 
1861 
1863  def __init__(self, value=list(), io = 'output', type=None, splitter=',', runarg=True, multipleOK=None, name=None):
1864  super(argLHEFile, self).__init__(value=value, io=io, type=type, splitter=splitter, runarg=runarg, multipleOK=multipleOK,
1865  name=name)
1866 
1867  self._metadataKeys.update({
1868  'nentries': self._getNumberOfEvents,
1869  'lheSumOfPosWeights': self._getWeightedEvents,
1870  'lheSumOfNegWeights': 0,
1871  })
1872 
1873  def _getNumberOfEvents(self, files):
1874  msg.debug('Retrieving event count for LHE file {0}'.format(files))
1875  import tarfile
1876  for fname in files:
1877  # Decompress this as we read
1878  try :
1879  tar = tarfile.open(fname, "r:gz")
1880  lhecount = 0
1881  for untar in tar.getmembers():
1882  fileTXT = tar.extractfile(untar)
1883  if fileTXT is not None :
1884  lines = fileTXT.read().decode("utf-8")
1885  lhecount = lines.count('/event')
1886 
1887  self._fileMetadata[fname]['nentries'] = lhecount
1888  except Exception:
1889  msg.debug('Entries is set to None - event count undefined for this LHE')
1890  self._fileMetadata[fname]['nentries'] = 'UNDEFINED'
1891 
1892  def _getWeightedEvents(self, files):
1893  msg.debug('Retrieving weight count for LHE file {0}'.format(files))
1894  import tarfile
1895  import re
1896 
1897  for fname in files:
1898  weightPos = 0
1899  weightNeg = 0
1900  try :
1901  tar = tarfile.open(fname, "r:gz")
1902  for untar in tar.getmembers():
1903  fileTXT = tar.extractfile(untar)
1904  next = False
1905  if fileTXT is not None :
1906  lines = fileTXT.readlines()
1907  for line in lines :
1908  if next :
1909  try :
1910  w = float(re.sub(' +',' ',line).split(" ")[2])
1911  if w > 0 : weightPos += w
1912  else : weightNeg += abs(w)
1913  except Exception:
1914  pass
1915  next = False
1916  if "<event" in line :
1917  next = True
1918 
1919  self._fileMetadata[fname]['lheSumOfPosWeights'] = weightPos
1920  self._fileMetadata[fname]['lheSumOfNegWeights'] = weightNeg
1921  except Exception:
1922  msg.debug('Entries is set to None - negative fraction count undefined for this LHE')
1923  self._fileMetadata[fname]['lheSumOfPosWeights'] = 'UNDEFINED'
1924  self._fileMetadata[fname]['lheSumOfNegWeights'] = 'UNDEFINED'
1925 
1926 
1931 
1932 
1935  def __init__(self, value = None, runarg = True, name = None, defaultSubstep = 'all', separator = ':'):
1936  self._defaultSubstep = defaultSubstep
1937  self._separator = separator
1938  super(argSubstep, self).__init__(value, runarg, name)
1939 
1940  # Reset getter
1941  @property
1942  def value(self):
1943  return self._value
1944 
1945  # The default setter for sustep class
1946  @value.setter
1947  def value(self, value):
1948  msg.debug('Attempting to set argSubstep from {0!s} (type {1}'.format(value, type(value)))
1949  if value is None:
1950  self._value = {}
1951  elif isinstance(value, str):
1952  self._value = dict(self._parseStringAsSubstep(value))
1953  elif isinstance(value, (list, tuple)):
1954  # This is a list of strings to parse, so we go through them one by one
1955  self._value = {}
1956  for item in value:
1957  if not isinstance(item, str):
1958  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Failed to convert list item {0!s} to substep (should be a string)'.format(item))
1959  self._value.update(dict(self._parseStringAsSubstep(item)))
1960  elif isinstance(value, dict):
1961  self._value = value
1962  else:
1963  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Setter value {0!s} (type {1}) for substep argument cannot be parsed'.format(value, type(value)))
1964 
1965 
1966 
1971  def _parseStringAsSubstep(self, string):
1972  subStepMatch = re.match(r'([a-zA-Z0-9,]+)' + self._separator + r'(.*)', string)
1973  subStepList = []
1974  if subStepMatch:
1975  subStep = subStepMatch.group(1).split(',')
1976  subStepValue = subStepMatch.group(2)
1977  else:
1978  subStep = [self._defaultSubstep]
1979  subStepValue = string
1980  msg.debug('Parsed {0} as substep {1}, argument {2}'.format(string, subStep, subStepValue))
1981  for step in subStep:
1982  subStepList.append((step, subStepValue))
1983  return subStepList
1984 
1985 
1986 
1991  def returnMyValue(self, name=None, substep=None, first=False, exe=None):
1992  if exe:
1993  name = exe.name
1994  substep = exe.substep
1995  first = exe.conf.firstExecutor
1996 
1997  name = commonExecutorStepName(name)
1998 
1999  value = None
2000 
2001  if name in self._value:
2002  value = self._value[name]
2003  elif substep in self._value:
2004  value = self._value[substep]
2005  elif first and 'first' in self._value:
2006  value = self._value['first']
2007  elif 'default' in self._value:
2008  value = self._value['default']
2009 
2010 
2018  if 'all' in self._value:
2019  if value is None:
2020  value = self._value['all']
2021  elif isinstance(value, list):
2022  value = self._value['all'] + value
2023 
2024  msg.debug('From substep argument {myvalue} picked value "{value}" for {name}, {substep}, first={first}'.format(myvalue=self._value, value=value, name=name, substep=substep, first=first))
2025 
2026  return value
2027 
2028  @property
2030  desc = {'type': 'substep', 'substeptype': 'str', 'separator': self._separator,
2031  'default': self._defaultSubstep}
2032  return desc
2033 
2034 
2041 
2042 
2045  def __init__(self, value = None, runarg = True, name = None, defaultSubstep = 'all', splitter = None, separator=':'):
2046  self._splitter = splitter
2047  super(argSubstepList, self).__init__(value, runarg, name, defaultSubstep, separator)
2048 
2049 
2050  # Reset getter
2051  @property
2052  def value(self):
2053  return self._value
2054 
2055  @property
2057  desc = {'type': 'substep', 'substeptype': 'list', 'listtype': 'str',
2058  'separator': self._separator,
2059  'default': self._defaultSubstep}
2060  return desc
2061  @value.setter
2062  def value(self, value):
2063  msg.debug('Attempting to set argSubstep from {0!s} (type {1}'.format(value, type(value)))
2064  if value is None:
2065  self._value = {}
2066  elif isinstance(value, str):
2067  self._value = dict(self._parseStringAsSubstep(value))
2068  elif isinstance(value, (list, tuple)):
2069  # This is a list of strings to parse
2070  self._value = {}
2071  for item in value:
2072  if not isinstance(item, str):
2073  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Failed to convert list item {0!s} to substep (should be a string)'.format(item))
2074  subStepList = self._parseStringAsSubstep(item)
2075  for subStep in subStepList:
2076  if subStep[0] in self._value:
2077  self._value[subStep[0]].extend(subStep[1])
2078  else:
2079  self._value[subStep[0]] = subStep[1]
2080  elif isinstance(value, dict):
2081  for k, v in value.items():
2082  if not isinstance(k, str):
2083  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Dictionary key {0!s} for substep is not a string'.format(k))
2084  if not isinstance(v, list):
2085  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Dictionary value {0!s} for substep is not a list'.format(v))
2086  self._value = value
2087  else:
2088  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Setter value {0!s} (type {1}) for substep argument cannot be parsed'.format(value, type(value)))
2089 
2090 
2092  def _parseStringAsSubstep(self, value):
2093  subStepList = super(argSubstepList, self)._parseStringAsSubstep(value)
2094  if self._splitter:
2095  subStepList = [(s[0], s[1].split(self._splitter)) for s in subStepList]
2096  else:
2097  subStepList = [(s[0], [s[1]]) for s in subStepList]
2098  return subStepList
2099 
2100 
2102 
2103  # Reset getter
2104  @property
2105  def value(self):
2106  return self._value
2107 
2108  @property
2110  desc = {'type': 'substep', 'substeptype': 'str', 'separator': self._separator,
2111  'default': self._defaultSubstep}
2112  return desc
2113 
2114  @value.setter
2115  def value(self, value):
2116  msg.debug('Attempting to set argSubstep from {0!s} (type {1}'.format(value, type(value)))
2117  if value is None:
2118  self._value = {}
2119  elif isinstance(value, str):
2120  subStepList = self._parseStringAsSubstep(value)
2121  self._value = dict([(subStep[0], subStep[1]) for subStep in subStepList])
2122  elif isinstance(value, (list, tuple)):
2123  # This is a list of strings to parse
2124  self._value = {}
2125  for item in value:
2126  if not isinstance(item, str):
2127  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Failed to convert list item {0!s} to substep (should be a string)'.format(item))
2128  subStepList = self._parseStringAsSubstep(item)
2129  for subStep in subStepList:
2130  self._value[subStep[0]] = subStep[1]
2131  elif isinstance(value, dict):
2132  for k, v in value.items():
2133  if not isinstance(k, str):
2134  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Dictionary key {0!s} for substep is not a string'.format(k))
2135  if not isinstance(v, str):
2136  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Dictionary value {0!s} for substep is not a string'.format(v))
2137  self._value = value
2138  else:
2139  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Setter value {0!s} (type {1}) for substep argument cannot be parsed'.format(value, type(value)))
2140 
2141 
2143 
2144  # Reset getter
2145  @property
2146  def value(self):
2147  return self._value
2148 
2149  @property
2151  desc = {'type': 'substep', 'substeptype': 'bool', 'separator': self._separator,
2152  'default': self._defaultSubstep}
2153  return desc
2154 
2155  @value.setter
2156  def value(self, value):
2157  msg.debug('Attempting to set argSubstep from {0!s} (type {1})'.format(value, type(value)))
2158  if value is None:
2159  self._value = {self._defaultSubstep: True}
2160  elif isinstance(value, bool):
2161  self._value = {self._defaultSubstep: value}
2162  elif isinstance(value, str):
2163  subStepList = self._parseStringAsSubstep(value)
2164  self._value = dict([(subStep[0], strToBool(subStep[1])) for subStep in subStepList])
2165  elif isinstance(value, (list, tuple)):
2166  # This is a list of strings to parse
2167  self._value = {}
2168  for item in value:
2169  if not isinstance(item, str):
2170  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Failed to convert list item {0!s} to substep (should be a string)'.format(item))
2171  subStepList = self._parseStringAsSubstep(item)
2172  for subStep in subStepList:
2173  self._value[subStep[0]] = strToBool(subStep[1])
2174  elif isinstance(value, dict):
2175  for k, v in value.items():
2176  if not isinstance(k, str):
2177  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Dictionary key {0!s} for substep is not a string'.format(k))
2178  if not isinstance(v, bool):
2179  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Dictionary value {0!s} for substep is not a bool'.format(v))
2180  self._value = value
2181  else:
2182  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Setter value {0!s} (type {1}) for substep argument cannot be parsed'.format(value, type(value)))
2183 
2184 
2185 
2187 
2188  # Reset getter
2189  @property
2190  def value(self):
2191  return self._value
2192 
2193  @property
2195  desc = {'type': 'substep', 'substeptype': 'int', 'separator': self._separator,
2196  'default': self._defaultSubstep}
2197  return desc
2198 
2199  @value.setter
2200  def value(self, value):
2201  msg.debug('Attempting to set argSubstep from {0!s} (type {1}'.format(value, type(value)))
2202  try:
2203  if value is None:
2204  self._value = {}
2205  elif isinstance(value, int):
2206  self._value = {self._defaultSubstep: value}
2207  elif isinstance(value, str):
2208  subStepList = self._parseStringAsSubstep(value)
2209  self._value = dict([(subStep[0], int(subStep[1])) for subStep in subStepList])
2210  elif isinstance(value, (list, tuple)):
2211  # This is a list of strings to parse
2212  self._value = {}
2213  for item in value:
2214  if not isinstance(item, str):
2215  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Failed to convert list item {0!s} to substep (should be a string)'.format(item))
2216  subStepList = self._parseStringAsSubstep(item)
2217  for subStep in subStepList:
2218  self._value[subStep[0]] = int(subStep[1])
2219  elif isinstance(value, dict):
2220  for k, v in value.items():
2221  if not isinstance(k, str):
2222  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Dictionary key {0!s} for substep is not a string'.format(k))
2223  if not isinstance(v, int):
2224  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Dictionary value {0!s} for substep is not an int'.format(v))
2225  self._value = value
2226  else:
2227  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Setter value {0!s} (type {1}) for substep argument cannot be parsed'.format(value, type(value)))
2228  except ValueError:
2229  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Failed to convert substep value {0} to int'.format(value))
2230 
2231 
2232 
2233 
2235 
2236  def __init__(self, value=None, min=None, max=None, runarg=True, name=None):
2237  self._min = min
2238  self._max = max
2239  super(argSubstepFloat, self).__init__(value = value, runarg = runarg, name=name)
2240 
2241  @property
2243  desc = {'type': 'substep', 'substeptype': 'float', 'separator': self._separator,
2244  'default': self._defaultSubstep}
2245  if self._min:
2246  desc['min'] = self._min
2247  if self._max:
2248  desc['max'] = self._max
2249  return desc
2250 
2251 
2252  # Reset getter
2253  @property
2254  def value(self):
2255  return self._value
2256 
2257  @value.setter
2258  def value(self, value):
2259  msg.debug('Attempting to set argSubstep from {0!s} (type {1}'.format(value, type(value)))
2260  try:
2261  if value is None:
2262  self._value = {}
2263  elif isinstance(value, float):
2264  self._value = {self._defaultSubstep: value}
2265  elif isinstance(value, str):
2266  subStepList = self._parseStringAsSubstep(value)
2267  self._value = dict([(subStep[0], float(subStep[1])) for subStep in subStepList])
2268  elif isinstance(value, (list, tuple)):
2269  # This is a list of strings to parse
2270  self._value = {}
2271  for item in value:
2272  if not isinstance(item, str):
2273  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2274  'Failed to convert list item {0!s} to substep (should be a string)'.format(item))
2275  subStepList = self._parseStringAsSubstep(item)
2276  for subStep in subStepList:
2277  self._value[subStep[0]] = float(subStep[1])
2278  elif isinstance(value, dict):
2279  for k, v in value.items():
2280  if not isinstance(k, str):
2281  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2282  'Dictionary key {0!s} for substep is not a string'.format(k))
2283  if not isinstance(v, float):
2284  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2285  'Dictionary value {0!s} for substep is not an float'.format(v))
2286  self._value = value
2287  else:
2288  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2289  'Setter value {0!s} (type {1}) for substep argument cannot be parsed'.format(value, type(value)))
2290  # Now do min/max checks
2291  for my_float in self._value.values():
2292  if (self._min is not None and my_float < self._min) or (self._max is not None and my_float > self._max):
2293  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_OUT_OF_RANGE'),
2294  'argFloat value out of range: {0} is not between {1} and {2}'.format(my_float, self._min, self._max))
2295  except ValueError as e:
2296  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2297  'Failed to convert substep value {0} to float: {1}'.format(value, e))
2298 
2299 
2300 
2302  # This singleton is where we define some aliases for common production
2303  # usecases of steering.
2304  # "no" - a convenience null option for production managers, does nothing
2305  # "doRDO_TRIG" - run split trigger for Reco_tf and friends
2306  # "doOverlay" - run event overlay on presampled RDOs instead of standard HITtoRDO digitization
2307  # "doFCtoDAOD" - run the FastChain transform, including the Derivation step, to process data from EVNT to DAOD
2308  # "afterburn" - run the B decay afterburner for event generation
2309  # "doRAWtoALL" - (deprecated) produce all DESDs and AODs directly from bytestream
2310  # "doTRIGtoALL" - (deprecated) produce AODs directly from trigger RDOs
2311  steeringAlises = {
2312  'no': {},
2313  'doRDO_TRIG': {'RAWtoALL': [('in', '-', 'RDO'), ('in', '+', 'RDO_TRIG'), ('in', '-', 'BS')]},
2314  'doOverlay': {'HITtoRDO': [('in', '-', 'HITS'), ('out', '-', 'RDO'), ('out', '-', 'RDO_FILT')],
2315  'Overlay': [('in', '+', ('HITS', 'RDO_BKG')), ('out', '+', 'RDO')]},
2316  'doFCtoDAOD': {'Derivation': [('in', '-', 'EVNT')]},
2317  'afterburn': {'generate': [('out', '-', 'EVNT')]},
2318  'doRAWtoALL': {},
2319  'doTRIGtoALL': {}
2320  }
2321 
2322  # Reset getter
2323  @property
2324  def value(self):
2325  return self._value
2326 
2327  # This argument gets dumped in a special way, using an alias directly
2328  # instead of the expanded value
2329  @property
2330  def dumpvalue(self):
2331  return self._dumpvalue
2332 
2333  @property
2335  desc = {'type': 'substep', 'substeptype': 'steering', 'listtype': 'str', 'separator': self._separator,
2336  'default': self._defaultSubstep}
2337  return desc
2338 
2339 
2342  @value.setter
2343  def value(self, value):
2344  msg.debug('Attempting to set argSubstepSteering from {0!s} (type {1})'.format(value, type(value)))
2345  if value is None:
2346  self._value = {}
2347  self._dumpvalue = [""]
2348  elif isinstance(value, dict):
2349  # OK, this should be the direct setable dictionary - but do a check of that
2350  for k, v in value.items():
2351  if not isinstance(k, str) or not isinstance(v, list):
2352  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2353  'Failed to convert dict {0!s} to argSubstepSteering'.format(value))
2354  for subv in v:
2355  if not isinstance(subv, (list, tuple)) or len(subv) != 3 or subv[0] not in ('in', 'out') or subv[1] not in ('+', '-'):
2356  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2357  'Failed to convert dict {0!s} to argSubstepSteering'.format(value))
2358  self._value = value
2359  # Note we are a little careful here to never reset the dumpvalue - this is
2360  # because when processing the _list_ of steering arguments down to a single
2361  # multi-valued argument we re-call value() with an expanded diectionary and
2362  # one can nievely reset dumpvalue by mistake
2363  self._dumpvalue = getattr(self, "_dumpvalue", value)
2364  elif isinstance(value, (str, list, tuple)):
2365  if isinstance(value, str):
2366  value = [value,]
2367  self._dumpvalue = getattr(self, "_dumpvalue", value)
2368  # Now we have a list of strings to parse
2369  self._value = {}
2370  for item in value:
2371  if not isinstance(item, str):
2372  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2373  'Failed to convert list item {0!s} to substep (should be a string)'.format(item))
2374  if item in argSubstepSteering.steeringAlises:
2375  msg.debug("Found value {0} in steeringAlises ({1})".format(item, argSubstepSteering.steeringAlises[item]))
2376  for substep, steerlist in argSubstepSteering.steeringAlises[item].items():
2377  if substep in self._value:
2378  self._value[substep].extend(steerlist)
2379  else:
2380  self._value[substep] = steerlist
2381  else:
2382  subStepList = self._parseStringAsSubstep(item)
2383  self._value.update(dict([(subStep[0], self._parseSteeringString(subStep[1])) for subStep in subStepList]))
2384  else:
2385  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2386  'Setter value {0!s} (type {1}) for substep argument cannot be parsed'.format(value, type(value)))
2387 
2388  def _parseSetterString(self, string):
2389  if string in argSubstepSteering.steeringAlises:
2390  return argSubstepSteering.steeringAlises[string]
2391 
2392  def _parseSteeringString(self, ivalue):
2393  retvalue = []
2394  for subvalue in ivalue.split(','):
2395  matchedParts = re.match(r'(in|out)(\+|\-)([A-Z_]+)$', subvalue)
2396  if not matchedParts:
2397  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2398  'Failed to convert string {0!s} to argSubstepSteering'.format(subvalue))
2399  retvalue.append((matchedParts.group(1), matchedParts.group(2), matchedParts.group(3)))
2400  return retvalue
2401 
2402 
2403 
2405  @property
2406  def value(self):
2407  return self._value
2408 
2409  @value.setter
2410  def value(self, value):
2411  msg.debug('Attempting to set argSubstepConditions from {0!s} (type {1}'.format(value, type(value)))
2412  # super().value = value workaround:
2413  super(self.__class__, self.__class__).value.fset(self, value)
2414 
2415  current = None
2416  for k, v in self._value.items():
2417  if "CurrentMC" == v:
2418  if current is None:
2419  current = self._amiLookUp(getAMIClient())
2420  self._value[k] = current
2421 
2422  def _amiLookUp(self, client):
2423  cmd = "COMAGetGlobalTagNameByCurrentState --state=CurrentMC"
2424  return str(client.execute(cmd, format = 'dom_object').get_rows().pop()['globalTag'])
2425 
2426  @property
2428  desc = {'type': 'substep', 'substeptype': 'str', 'separator': self._separator,
2429  'default': self._defaultSubstep}
2430  return desc
2431 
2432 
2433 class trfArgParser(argparse.ArgumentParser):
2434 
2435 
2440  def __init__(self, *args, **kwargs):
2441  self._helpString = {}
2442  self._argClass = {}
2443  self._argGroups = {}
2444  self._argKeyGroups = {}
2445  self._argAlias = {}
2446  super(trfArgParser, self).__init__(*args, **kwargs)
2447 
2448  def add_argument(self, *args, **kwargs):
2449  argName = args[0].lstrip('-')
2450  msg.debug('Found arg name {0}'.format(argName))
2451 
2452  # Ban arguments with hyphens as they cause trouble in signature files and then
2453  # AMI tag definitions because of the auto-translation to underscores in argparse
2454  if '-' in argName:
2455  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_ERROR'),
2456  'Transform arguments may not use hyphens (use camelCase or underscore')
2457 
2458  # Prevent a crash if this argument already exists (there are valid use cases for 'grabbing' an
2459  # argument, so this is DEBUG, not WARNING)
2460  if argName in self._argClass:
2461  msg.debug('Double definition of argument {0} - ignored'.format(argName))
2462  return
2463 
2464  # if there is a help function defined for the argument then populate the helpString dict
2465  if 'help' in kwargs:
2466  self._helpString[argName] = kwargs['help'] # if the help option is present for the argument then put it into the helpString dict key = argument name, value = help
2467  else:
2468  self._helpString[argName] = None
2469  if 'action' in kwargs and 'factory' in dir(kwargs['action']):
2470  self._argClass[argName] = kwargs['action'].factory
2471  elif 'type' in kwargs:
2472  self._argClass[argName] = kwargs['type']
2473  else:
2474  self._argClass[argName] = None
2475 
2476  # Remove kwargs which are not understood by ArgumentParser.add_argument()
2477  strippedArgs = {}
2478  for arg in ('group',):
2479  if arg in kwargs:
2480  strippedArgs[arg] = kwargs.pop(arg)
2481 
2482  # Setup aliases
2483  if len(args) > 1:
2484  for i in range(1, len(args)):
2485  argAlias = args[i].lstrip('-')
2486  msg.debug('Adding an alias of {0}: {1}'.format(argName, argAlias))
2487  self._argAlias[argAlias] = argName
2488 
2489  # Optinally add an argument to an argparse argument group
2490  if 'group' in strippedArgs:
2491  if strippedArgs['group'] in self._argGroups:
2492  msg.debug('Adding argument to group {0}: ({1}; {2})'.format(strippedArgs['group'], args, kwargs))
2493  self._argGroups[strippedArgs['group']].add_argument(*args, **kwargs)
2494  self._argKeyGroups[argName] = strippedArgs['group']
2495  else:
2496  msg.warning('Argument group {0} not defined - adding argument to main parser'.format(strippedArgs['group']))
2497  msg.debug('Adding argument: ({0}; {1})'.format(args, kwargs))
2498  super(trfArgParser, self).add_argument(*args, **kwargs)
2499  else:
2500  msg.debug('Adding argument: ({0}; {1})'.format(args, kwargs))
2501  super(trfArgParser, self).add_argument(*args, **kwargs)
2502 
2503  @property
2504  def getProdsysDesc(self):
2505  desc = {}
2506  for name, argClass in self._argClass.items():
2507  msg.debug('Detected the local variable {0}'.format(name))
2508  if argClass is not None:
2509  desc[name] = argClass().prodsysDescription
2510  if name in self._helpString:
2511  desc[name].update({'help': self._helpString[name]})
2512  if name in self._argKeyGroups:
2513  desc[name].update({'group':self._argKeyGroups[name]})
2514  return desc
2515 
2516 
2517  def defineArgGroup(self, *args):
2518  # Get an argparse group
2519  if args[0] in self._argGroups:
2520  msg.warning('Argument group %s already exists', args[0])
2521  return
2522  self._argGroups[args[0]] = self.add_argument_group(*args)
2523 
2524 
2525  def getHelpString(self, argument):
2526  try:
2527  return(self._helpString[argument])
2528  except KeyError:
2529  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_KEY_ERROR'), 'no help string available for argument %s' %argument)
2530  return None
2531 
2532 
2534  def dumpArgs(self):
2535  keyArray = [ '--' + str(key) for key in self._helpString if key not in ('h', 'verbose', 'loglevel', 'dumpargs', 'argdict') ]
2536  keyArray.sort()
2537  print('ListOfDefaultPositionalKeys={0}'.format(keyArray))
2538 
2539 
2540  @property
2541  def allArgs(self):
2542  return list(self._helpString)
2543 
2544  # @brief parsing helper
2545  def _parse_list_helper(self, value):
2546  # We build on the value[0] instance as this contains the correct metadata
2547  # and object references for this instance (shallow copying can
2548  # mess up object references and deepcopy thows exceptions!)
2549  newValueObj = value[0]
2550  msg.debug('Started with: %s = %s', type(newValueObj), newValueObj)
2551  if isinstance(value[0], argSubstep):
2552  # Make sure you do not have a reference to the original value - this is a deeper copy
2553  newValues = dictSubstepMerge(value[0].value, {})
2554  elif isinstance(value[0], list):
2555  if len(value) == 1:
2556  return self._parse_list_helper(value[0])
2557  msg.debug('Handling a list of arguments for key')
2558  newValues = []
2559  for v in value:
2560  processedValueObj, processedValues = self._parse_list_helper(v)
2561  processedValueObj.value = processedValues
2562  newValues.append(processedValueObj)
2563  newValueObj = newValues
2564  return newValueObj, newValues
2565  elif isinstance(value[0].value, list):
2566  newValues = value[0].value
2567  elif isinstance(value[0].value, dict):
2568  newValues = value[0].value
2569  else:
2570  newValues = [value[0].value,]
2571  for valueObj in value[1:]:
2572  msg.debug('Value Object: %s = %s', type(valueObj), valueObj)
2573  if isinstance(value[0], argSubstep):
2574  # Special merger for lists attached to substeps
2575  newValues = dictSubstepMerge(newValues, valueObj.value)
2576  elif isinstance(valueObj.value, list):
2577  # General lists are concatenated
2578  newValues.extend(valueObj.value)
2579  elif isinstance(valueObj.value, dict):
2580  # General dictionaries are merged
2581  newValues.update(valueObj.value)
2582  else:
2583  newValues.append(valueObj.value)
2584  return newValueObj, newValues
2585 
2586 
2591  def parse_args(self, args = None, namespace = None):
2592  if namespace:
2593  super(trfArgParser, self).parse_args(args = args, namespace = namespace)
2594  else:
2595  namespace = super(trfArgParser, self).parse_args(args = args)
2596  for k, v in namespace.__dict__.items():
2597  msg.debug('Treating key %s (%s)', k, v)
2598  if isinstance(v, list):
2599  newValueObj, newValues = self._parse_list_helper(v)
2600  if not isinstance(newValueObj, list):
2601  newValueObj.value = newValues
2602  namespace.__dict__[k] = newValueObj
2603  msg.debug('Set to %s', newValues)
2604 
2605  return namespace
2606 
2607 
2608 
2609 def strToBool(string):
2610  try:
2611  msg.debug("converting string {string} to boolean".format(string = string))
2612  if string.lower() == 'false':
2613  return False
2614  elif string.lower() == 'true':
2615  return True
2616  else:
2617  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Failed to convert value {0} to bool'.format(string))
2618  except AttributeError:
2619  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Failed to convert value {0} to bool'.format(string))
2620 
2621 
2630 def dictSubstepMerge(dict1, dict2):
2631  mergeDict = {}
2632  allKeys = set(dict1) | set(dict2)
2633  # Find the value type - lists are special...
2634  listType = False
2635  if len(dict1) > 0:
2636  if isinstance(list(dict1.values())[0], list):
2637  listType = True
2638  elif len(dict2) > 0:
2639  if isinstance(list(dict2.values())[0], list):
2640  listType = True
2641  if listType:
2642  for key in allKeys:
2643  mergeDict[key] = dict1.get(key, []) + dict2.get(key, [])
2644  else:
2645  for key in allKeys:
2646  if key in dict1 and key in dict2:
2647  # Don't really know what to do if these clash...
2648  if dict1[key] != dict2[key]:
2649  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2650  'Merging substep arguments found clashing values for substep {0}: {1}!={2}'.format(key, dict1[key], dict2[key]))
2651  mergeDict[key] = dict1[key]
2652  elif key in dict1:
2653  mergeDict[key] = dict1[key]
2654  else:
2655  mergeDict[key] = dict2[key]
2656 
2657  return mergeDict
2658 
2659 
python.trfArgClasses.argument.__nq__
def __nq__(self, other)
Definition: trfArgClasses.py:164
python.trfDecorators.timelimited
def timelimited(timeout=None, retry=1, timefactor=1.5, sleeptime=10, defaultrc=None)
Definition: trfDecorators.py:140
python.trfArgClasses.argFile._auxiliaryFile
_auxiliaryFile
Definition: trfArgClasses.py:553
python.trfArgClasses.argActionFactory.__call__
def __call__(self, option_strings, dest, **kwargs)
Definition: trfArgClasses.py:92
python.trfFileUtils.PHYSVALEntries
def PHYSVALEntries(fileName, integral=False)
Determines number of entries in NTUP_PHYSVAL file.
Definition: trfFileUtils.py:249
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
AtlasMcWeight::decode
double decode(number_type binnedWeight)
Convert weight from unsigned to double.
Definition: AtlasMcWeight.cxx:32
python.trfArgClasses.argPOOLFile._getIntegrity
def _getIntegrity(self, files)
File integrity checker.
Definition: trfArgClasses.py:1431
python.trfArgClasses.argFile.__init__
def __init__(self, value=list(), type=None, subtype=None, io='output', splitter=',', runarg=True, guid=None, multipleOK=None, name=None, executor=list(), mergeTargetSize=-1, auxiliaryFile=False)
Initialise an argFile.
Definition: trfArgClasses.py:544
python.trfArgClasses.argNTUPFile._getNumberOfEvents
def _getNumberOfEvents(self, files)
Definition: trfArgClasses.py:1703
python.trfArgClasses.argSubstep.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:2029
python.trfArgClasses.argFTKIPFile._getNumberOfEvents
def _getNumberOfEvents(self, files)
Definition: trfArgClasses.py:1816
python.trfArgClasses.argFile.isCached
def isCached(self, files=None, metadataKeys=None)
Test if certain metadata elements are already cached.
Definition: trfArgClasses.py:1061
python.trfArgClasses.argSubstepFloat.__init__
def __init__(self, value=None, min=None, max=None, runarg=True, name=None)
argSubstep constructor
Definition: trfArgClasses.py:2236
python.trfFileUtils.ROOTGetSize
def ROOTGetSize(filename)
Get the size of a file via ROOT's TFile.
Definition: trfFileUtils.py:285
python.trfArgClasses.argSubstepConditions._amiLookUp
def _amiLookUp(self, client)
Definition: trfArgClasses.py:2422
python.trfArgClasses.argFile._readMetadata
def _readMetadata(self, files, metadataKeys)
Check metadata is in the cache or generate it if it's missing.
Definition: trfArgClasses.py:996
PyJobTransforms.trfAMI
Utilities for configuration of transforms via AMI tags.
python.trfArgClasses.argBZ2File._getIntegrity
def _getIntegrity(self, files)
File integrity checker.
Definition: trfArgClasses.py:1784
python.trfArgClasses.argPOOLFile
POOL file class.
Definition: trfArgClasses.py:1425
python.trfArgClasses.argHISTFile
Data quality histogram file class.
Definition: trfArgClasses.py:1643
python.trfArgClasses.argument.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:148
vtune_athena.format
format
Definition: vtune_athena.py:14
python.trfArgClasses.argument._value
_value
Definition: trfArgClasses.py:130
python.trfArgClasses.argNTUPFile
NTUP (plain ROOT) file class.
Definition: trfArgClasses.py:1679
python.trfArgClasses.trfArgParser
Definition: trfArgClasses.py:2433
python.trfArgClasses.trfArgParser.getHelpString
def getHelpString(self, argument)
Return the help string for a given argument.
Definition: trfArgClasses.py:2525
python.trfArgClasses.argFactory.__init__
def __init__(self, genclass, *args, **kwargs)
Definition: trfArgClasses.py:32
python.trfArgClasses.argument.name
def name(self)
Name getter.
Definition: trfArgClasses.py:139
python.trfArgClasses.argHITSFile
Definition: trfArgClasses.py:1486
python.trfArgClasses.argRDOFile
Definition: trfArgClasses.py:1565
python.trfArgClasses.argSubstep._separator
_separator
Definition: trfArgClasses.py:1937
python.trfArgClasses.argString.choices
def choices(self)
Choices getter.
Definition: trfArgClasses.py:208
python.trfArgClasses.trfArgParser._argGroups
_argGroups
Definition: trfArgClasses.py:2443
python.trfArgClasses.trfArgParser.parse_args
def parse_args(self, args=None, namespace=None)
Call argument_parser parse_args, then concatenate values.
Definition: trfArgClasses.py:2591
python.trfArgClasses.argFloat.__init__
def __init__(self, value=None, min=None, max=None, runarg=True, name=None)
Float argument constructor.
Definition: trfArgClasses.py:267
python.trfArgClasses.argSubstep._defaultSubstep
_defaultSubstep
Definition: trfArgClasses.py:1936
python.trfArgClasses.argSubstepInt.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:2194
python.trfArgClasses.argAction.__call__
def __call__(self, parser, namespace, values, option_string=None)
Definition: trfArgClasses.py:66
python.trfArgClasses.argEVNT_TRFile.selfMerge
def selfMerge(self, output, inputs, counter=0, argdict={})
Method which can be used to merge EVNT_TR files.
Definition: trfArgClasses.py:1531
python.trfExceptions.TransformArgException
Group of argument based exceptions.
Definition: trfExceptions.py:38
python.trfArgClasses.argIntList.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:452
python.trfArgClasses.argSubstepFloat._max
_max
Definition: trfArgClasses.py:2238
python.trfArgClasses.argument.isRunarg
def isRunarg(self)
Return runarg status.
Definition: trfArgClasses.py:134
python.trfArgClasses.argSubstepBool.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:2150
python.trfArgClasses.argString.__str__
def __str__(self)
Definition: trfArgClasses.py:220
python.trfArgClasses.argList.__init__
def __init__(self, value=[], supressEmptyStrings=True, splitter=',', runarg=True, name=None)
List of string arguments.
Definition: trfArgClasses.py:356
python.trfArgClasses.argFile._multipleOK
_multipleOK
Definition: trfArgClasses.py:577
python.trfArgClasses.argYODAFile._getWeightedEvents
def _getWeightedEvents(self, files)
Definition: trfArgClasses.py:1279
python.trfArgClasses.argLHEFile
LHE ASCII file.
Definition: trfArgClasses.py:1862
python.trfArgClasses.argYODAFile._getNumberOfEvents
def _getNumberOfEvents(self, files)
Definition: trfArgClasses.py:1260
python.trfAMI.getAMIClient
def getAMIClient(endpoints=['atlas-replica', 'atlas'])
Get an AMI client.
Definition: trfAMI.py:222
python.trfArgClasses.trfArgParser.__init__
def __init__(self, *args, **kwargs)
Subclassing argparse.
Definition: trfArgClasses.py:2440
python.trfArgClasses.argument._runarg
_runarg
Definition: trfArgClasses.py:110
python.trfArgClasses.argNTUPFile.__init__
def __init__(self, value=list(), io='output', type=None, subtype=None, splitter=',', treeNames=None, runarg=True, multipleOK=None, name=None, mergeTargetSize=-1, auxiliaryFile=False)
Definition: trfArgClasses.py:1686
python.trfArgClasses.argFile._getDatasetFromFilename
def _getDatasetFromFilename(self, reset=False)
Look for dataset name in dataset::filename Tier0 convention.
Definition: trfArgClasses.py:1089
python.trfArgClasses.argFile.mergeTargetSize
def mergeTargetSize(self)
mergeTargeSize value getter
Definition: trfArgClasses.py:613
python.trfArgClasses.argFTKIPFile.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:1830
python.trfArgClasses.argFactory._genclass
_genclass
Definition: trfArgClasses.py:34
python.trfArgClasses.argument.__repr__
def __repr__(self)
Repr conversion of our value.
Definition: trfArgClasses.py:157
python.trfArgClasses.argEVNTFile
Definition: trfArgClasses.py:1603
python.trfArgClasses.argFile._mergeArgs
def _mergeArgs(self, argdict, copyArgs=None)
Utility to strip arguments which should not be passed to the selfMerge methods of our child classes.
Definition: trfArgClasses.py:1209
python.trfArgClasses.argFile.__str__
def __str__(self)
String representation of a file argument.
Definition: trfArgClasses.py:1201
python.trfArgClasses.argSubstep.returnMyValue
def returnMyValue(self, name=None, substep=None, first=False, exe=None)
Return the value of this substep arg for an executor with the given parameters.
Definition: trfArgClasses.py:1991
upper
int upper(int c)
Definition: LArBadChannelParser.cxx:49
python.trfArgClasses.argFile.originalName
def originalName(self, value)
Definition: trfArgClasses.py:826
python.trfArgClasses.argBZ2File.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:1802
python.trfArgClasses.argActionFactory.__init__
def __init__(self, genclass, *args, **kwargs)
Definition: trfArgClasses.py:84
python.trfArgClasses.trfArgParser._helpString
_helpString
Definition: trfArgClasses.py:2441
python.trfArgClasses.argHepEvtAsciiFile._getNumberOfEvents
def _getNumberOfEvents(self, files)
Definition: trfArgClasses.py:1844
python.trfArgClasses.argFile._exists
def _exists(self, files)
Try to determine if a file actually exists...
Definition: trfArgClasses.py:1176
python.trfArgClasses.argLHEFile._getWeightedEvents
def _getWeightedEvents(self, files)
Definition: trfArgClasses.py:1892
python.trfArgClasses.argHepEvtAsciiFile
HEP ASCII file.
Definition: trfArgClasses.py:1836
python.trfArgClasses.argHISTFile._getNumberOfEvents
def _getNumberOfEvents(self, files)
Definition: trfArgClasses.py:1664
python.trfArgClasses.argSubstepBool
Boolean substep argument.
Definition: trfArgClasses.py:2142
PyJobTransforms.trfExitCodes
Module for transform exit codes.
python.trfArgClasses.argFloat
Float type argument.
Definition: trfArgClasses.py:261
python.trfArgClasses.argBZ2File
TarBZ filetype.
Definition: trfArgClasses.py:1783
python.trfArgClasses.argSubstepString.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:2109
python.trfArgClasses.trfArgParser.getProdsysDesc
def getProdsysDesc(self)
Definition: trfArgClasses.py:2504
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
python.trfArgClasses.trfArgParser.allArgs
def allArgs(self)
Getter for argument list.
Definition: trfArgClasses.py:2541
python.trfArgClasses.argSubstepList._splitter
_splitter
Definition: trfArgClasses.py:2046
python.trfArgClasses.argAction.__init__
def __init__(self, factory, option_strings, dest, **kwargs)
Definition: trfArgClasses.py:62
python.trfArgClasses.argument.__init__
def __init__(self, value=None, runarg=True, name=None)
Initialise argument class.
Definition: trfArgClasses.py:109
python.Bindings.values
values
Definition: Control/AthenaPython/python/Bindings.py:805
python.trfArgClasses.argEVNT_TRFile
Definition: trfArgClasses.py:1526
python.trfArgClasses.argFile._type
_type
Definition: trfArgClasses.py:549
python.trfArgClasses.argList.__str__
def __str__(self)
String conversion.
Definition: trfArgClasses.py:404
python.trfArgClasses.argList
List of string arguments.
Definition: trfArgClasses.py:348
python.trfArgClasses.argFactory
Factory class used to generate argument class instances for argparse.
Definition: trfArgClasses.py:31
python.trfArgClasses.argFile.valueSetter
def valueSetter(self, value)
Set the argFile value, but allow parameters here.
Definition: trfArgClasses.py:645
python.trfArgClasses.argFile._fileMetadata
_fileMetadata
Definition: trfArgClasses.py:574
python.trfArgClasses.argument.__str__
def __str__(self)
String conversion of our value.
Definition: trfArgClasses.py:153
PixelModuleFeMask_create_db.remove
string remove
Definition: PixelModuleFeMask_create_db.py:83
physics_parameters.file_name
string file_name
Definition: physics_parameters.py:32
python.trfArgClasses.argFTKIPFile.__init__
def __init__(self, value=list(), io='output', type=None, splitter=',', runarg=True, multipleOK=None, name=None)
Definition: trfArgClasses.py:1809
python.trfArgClasses.argString._choices
_choices
Definition: trfArgClasses.py:183
python.trfArgClasses.argHISTFile.__init__
def __init__(self, value=list(), io='output', type=None, subtype=None, splitter=',', runarg=True, countable=True, multipleOK=None, name=None, auxiliaryFile=False)
Definition: trfArgClasses.py:1647
python.trfArgClasses.argFile._getIntegrity
def _getIntegrity(self, files)
File integrity checker.
Definition: trfArgClasses.py:1131
python.trfUtils.call
def call(args, bufsize=0, executable=None, stdin=None, preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0, message="", logger=msg, loglevel=None, timeout=None, retry=2, timefactor=1.5, sleeptime=10)
Definition: trfUtils.py:155
python.trfArgClasses.argAction
Definition: trfArgClasses.py:61
python.trfArgClasses.trfArgParser._argAlias
_argAlias
Definition: trfArgClasses.py:2445
python.trfArgClasses.argAthenaFile.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:1352
python.trfArgClasses.argActionFactory.__str__
def __str__(self)
Definition: trfArgClasses.py:95
python.trfArgClasses.argNTUPFile._treeNames
_treeNames
Definition: trfArgClasses.py:1689
python.trfArgClasses.trfArgParser._parse_list_helper
def _parse_list_helper(self, value)
Definition: trfArgClasses.py:2545
python.trfExceptions.TransformMergeException
Base class for file merging exceptions.
Definition: trfExceptions.py:66
python.trfArgClasses.argFile.nentries
def nentries(self)
Return total number of events in all constituent files.
Definition: trfArgClasses.py:886
python.trfArgClasses.argSubstepList._parseStringAsSubstep
def _parseStringAsSubstep(self, value)
Specialist parser for lists, which applies the splitter string, if defined.
Definition: trfArgClasses.py:2092
python.trfArgClasses.argLHEFile._getNumberOfEvents
def _getNumberOfEvents(self, files)
Definition: trfArgClasses.py:1873
python.trfArgClasses.argFile._resetMetadata
def _resetMetadata(self, files=[])
Resets all metadata files in this instance.
Definition: trfArgClasses.py:913
python.trfArgClasses.argKeyFloatValueList._kvsplitter
_kvsplitter
Definition: trfArgClasses.py:467
python.trfArgClasses.argFloat._min
_min
Definition: trfArgClasses.py:268
python.trfArgClasses.argBool
Boolean type argument.
Definition: trfArgClasses.py:317
python.trfFileUtils.PRWEntries
def PRWEntries(fileName, integral=False)
Determines number of entries in PRW file.
Definition: trfFileUtils.py:206
python.trfFileUtils.NTUPEntries
def NTUPEntries(fileName, treeNames)
Determines number of entries in NTUP file with given tree names.
Definition: trfFileUtils.py:153
python.trfArgClasses.argFile._mergeTargetSize
_mergeTargetSize
Definition: trfArgClasses.py:552
python.trfArgClasses.argEVNTFile.selfMerge
def selfMerge(self, output, inputs, counter=0, argdict={})
Method which can be used to merge EVNT files.
Definition: trfArgClasses.py:1608
python.trfArgClasses.argFile.multipleOK
def multipleOK(self)
multipleOK getter
Definition: trfArgClasses.py:603
PyJobTransforms.trfFileUtils
Transform utilities to deal with files.
python.LArMinBiasAlgConfig.int
int
Definition: LArMinBiasAlgConfig.py:59
python.trfArgClasses.argLHEFile.__init__
def __init__(self, value=list(), io='output', type=None, splitter=',', runarg=True, multipleOK=None, name=None)
Definition: trfArgClasses.py:1863
python.trfArgClasses.argBSFile
ByteStream file class.
Definition: trfArgClasses.py:1358
python.trfArgClasses.argFile._guid
_guid
Definition: trfArgClasses.py:551
python.trfArgClasses.argFactory._kwargs
_kwargs
Definition: trfArgClasses.py:36
python.trfArgClasses.argSubstepSteering._dumpvalue
_dumpvalue
Definition: trfArgClasses.py:2347
python.trfArgClasses.argString
String type argument.
Definition: trfArgClasses.py:174
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
python.trfArgClasses.argActionFactory
Factory class used to generate argparse actions, actions should be used when arguments are used witho...
Definition: trfArgClasses.py:83
python.trfArgClasses.argFile.subtype
def subtype(self)
Definition: trfArgClasses.py:838
PyAthena::repr
std::string repr(PyObject *o)
returns the string representation of a python object equivalent of calling repr(o) in python
Definition: PyAthenaUtils.cxx:106
python.trfArgClasses.argSubstepList
Argument class for substep lists, suitable for preExec/postExec.
Definition: trfArgClasses.py:2040
python.trfArgClasses.argYODAFile.__init__
def __init__(self, value=list(), io='output', type=None, splitter=',', runarg=True, multipleOK=None, name=None)
Definition: trfArgClasses.py:1250
python.trfArgClasses.argSubstepString
String substep argument.
Definition: trfArgClasses.py:2101
python.trfExceptions.TransformInternalException
Transform internal errors.
Definition: trfExceptions.py:74
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
python.trfArgClasses.trfArgParser._argKeyGroups
_argKeyGroups
Definition: trfArgClasses.py:2444
python.trfArgClasses.argSubstepFloat._min
_min
Definition: trfArgClasses.py:2237
python.trfArgClasses.argList._supressEmptyStrings
_supressEmptyStrings
Definition: trfArgClasses.py:358
python.trfArgClasses.argSubstepSteering.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:2334
python.trfArgClasses.argSubstepList.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:2056
python.trfArgClasses.argument.value
value
Definition: trfArgClasses.py:118
python.trfArgClasses.argList.append
def append(self, addme)
Append a value to the list.
Definition: trfArgClasses.py:398
python.trfArgClasses.trfArgParser.dumpArgs
def dumpArgs(self)
Return a list of all arguments understood by this transform in prodsys style.
Definition: trfArgClasses.py:2534
python.trfArgClasses.argSubstepSteering.dumpvalue
def dumpvalue(self)
Definition: trfArgClasses.py:2330
checkFile
Definition: checkFile.py:1
python.trfArgClasses.argAthenaFile._getAthInfo
def _getAthInfo(self, files)
Small wrapper which sets the standard options for doAllFiles and retrieveKeys.
Definition: trfArgClasses.py:1348
python.trfArgClasses.argSubstepSteering._parseSteeringString
def _parseSteeringString(self, ivalue)
Definition: trfArgClasses.py:2392
beamspotman.dir
string dir
Definition: beamspotman.py:623
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
python.trfArgClasses.argList.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:370
python.trfArgClasses.argList._splitter
_splitter
Definition: trfArgClasses.py:357
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
python.trfExceptions.TransformTimeoutException
Exception used by time limited executions.
Definition: trfExceptions.py:78
python.trfArgClasses.argAthenaFile
Athena file class.
Definition: trfArgClasses.py:1315
python.trfArgClasses.argFile._dataset
_dataset
Definition: trfArgClasses.py:547
python.trfArgClasses.argHepEvtAsciiFile.__init__
def __init__(self, value=list(), io='output', type='txt_evt', splitter=',', runarg=True, multipleOK=None, name=None)
Definition: trfArgClasses.py:1837
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.trfArgClasses.argFile._setMetadata
def _setMetadata(self, files=None, metadataKeys={})
Set metadata values into the cache.
Definition: trfArgClasses.py:1044
python.trfArgClasses.argFile.getSingleMetadata
def getSingleMetadata(self, fname, metadataKey, populate=True, flush=False)
Convenience function to extract a single metadata key for a single file.
Definition: trfArgClasses.py:985
python.trfFileUtils.AthenaLiteFileInfo
def AthenaLiteFileInfo(filename, filetype, retrieveKeys=athFileInterestingKeys)
New lightweight interface to getting a single file's metadata.
Definition: trfFileUtils.py:23
python.trfArgClasses.argRDOFile.selfMerge
def selfMerge(self, output, inputs, counter=0, argdict={})
Method which can be used to merge RDO files.
Definition: trfArgClasses.py:1570
python.trfArgClasses.argFile._exe
_exe
Definition: trfArgClasses.py:559
python.trfArgClasses.argFloat.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:279
python.trfArgClasses.argFile
File argument class.
Definition: trfArgClasses.py:522
python.trfExceptions.TransformMetadataException
Exception used by metadata functions.
Definition: trfExceptions.py:82
python.trfArgClasses.argFile.io
io
Definition: trfArgClasses.py:557
python.trfArgClasses.argFile.metadata
def metadata(self)
Returns the whole kit and kaboodle...
Definition: trfArgClasses.py:880
python.trfArgClasses.argPOOLFile.selfMerge
def selfMerge(self, output, inputs, counter=0, argdict={})
Method which can be used to merge files of this type.
Definition: trfArgClasses.py:1450
python.trfArgClasses.argFile._getSize
def _getSize(self, files)
Determines the size of files.
Definition: trfArgClasses.py:1113
python.trfFileUtils.urlType
def urlType(filename)
Return the LAN access type for a file URL.
Definition: trfFileUtils.py:316
TrigJetMonitorAlgorithm.items
items
Definition: TrigJetMonitorAlgorithm.py:71
python.trfArgClasses.argActionFactory.factory
def factory(self)
Definition: trfArgClasses.py:89
python.trfExeStepTools.commonExecutorStepName
def commonExecutorStepName(name)
Definition: trfExeStepTools.py:7
python.trfArgClasses.argFile.getnentries
def getnentries(self, fast=False)
Explicit getter, offering fast switch.
Definition: trfArgClasses.py:890
python.trfArgClasses.argNTUPFile.selfMerge
def selfMerge(self, output, inputs, counter=0, argdict={})
Definition: trfArgClasses.py:1743
python.trfArgClasses.argFile._generateGUID
def _generateGUID(self, files)
Generate a GUID on demand - no intrinsic for this file type
Definition: trfArgClasses.py:1165
python.trfArgClasses.argSubstep.__init__
def __init__(self, value=None, runarg=True, name=None, defaultSubstep='all', separator=':')
argSubstep constructor
Definition: trfArgClasses.py:1935
python.trfArgClasses.argFile.orignalName
def orignalName(self)
Definition: trfArgClasses.py:822
python.trfArgClasses.argSubstep._parseStringAsSubstep
def _parseStringAsSubstep(self, string)
Parse a string for substep:value format.
Definition: trfArgClasses.py:1971
PyJobTransforms.trfExe
Transform execution functions.
python.trfArgClasses.argFile.executor
def executor(self)
Executor status getter.
Definition: trfArgClasses.py:638
Trk::open
@ open
Definition: BinningType.h:40
python.trfArgClasses.argFile.type
def type(self)
Definition: trfArgClasses.py:830
python.trfArgClasses.argKeyFloatValueList.__init__
def __init__(self, value={}, supressEmptyStrings=True, splitter=',', kvsplitter=":", runarg=True, name=None)
Dictionary of key value arguments, where the values are floats.
Definition: trfArgClasses.py:465
ActsTrk::detail::MakeDerivedVariant::extend
constexpr std::variant< Args..., T > extend(const std::variant< Args... > &, const T &)
Definition: MakeDerivedVariant.h:17
python.trfArgClasses.argFile._originalName
_originalName
Definition: trfArgClasses.py:554
python.trfArgClasses.argSubstepSteering
Special argument class to hold steering information.
Definition: trfArgClasses.py:2301
python.trfArgClasses.argSubstepFloat.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:2242
python.trfArgClasses.argSubstepFloat
Float substep argument.
Definition: trfArgClasses.py:2234
python.trfArgClasses.argNTUPFile.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:1776
python.trfArgClasses.argFTKIPFile
Class which defines a special input file format used in FTK simulation
Definition: trfArgClasses.py:1808
python.trfArgClasses.argHITSFile.selfMerge
def selfMerge(self, output, inputs, counter=0, argdict={})
Method which can be used to merge HITS files.
Definition: trfArgClasses.py:1491
python.trfArgClasses.argPOOLFile.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:1441
PyJobTransforms.trfUtils
Transform utility functions.
python.trfArgClasses.argKeyFloatValueList
Definition: trfArgClasses.py:458
python.trfArgClasses.argAthenaFile.__init__
def __init__(self, value=list(), type=None, subtype=None, io='output', splitter=',', runarg=True, multipleOK=None, name=None, executor=list(), mergeTargetSize=-1, auxiliaryFile=False)
Definition: trfArgClasses.py:1316
python.trfArgClasses.argSubstepConditions
Substep class for conditionsTag.
Definition: trfArgClasses.py:2404
python.trfArgClasses.dictSubstepMerge
def dictSubstepMerge(dict1, dict2)
special dictionary merger which is used for substep type arguments
Definition: trfArgClasses.py:2630
python.trfArgClasses.argument.__lt__
def __lt__(self, other)
Definition: trfArgClasses.py:167
python.trfArgClasses.argHISTFile._getIntegrity
def _getIntegrity(self, files)
There is no integrity check for HIST files - return 'UNDEFINED'.
Definition: trfArgClasses.py:1659
python.trfArgClasses.argFile.name
def name(self)
Name getter.
Definition: trfArgClasses.py:847
python.trfArgClasses.argFile.dataset
dataset
Definition: trfArgClasses.py:666
python.trfArgClasses.argSubstepList.__init__
def __init__(self, value=None, runarg=True, name=None, defaultSubstep='all', splitter=None, separator=':')
argSubstepList constructor
Definition: trfArgClasses.py:2045
python.trfArgClasses.argFile._urlType
_urlType
Definition: trfArgClasses.py:548
python.trfArgClasses.argument.__eq__
def __eq__(self, other)
Comparison is based on value attribute.
Definition: trfArgClasses.py:161
python.trfArgClasses.argFloat._max
_max
Definition: trfArgClasses.py:269
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567
python.trfArgClasses.argSubstep
Base class for substep arguments.
Definition: trfArgClasses.py:1930
python.trfArgClasses.argYODAFile
Definition: trfArgClasses.py:1249
python.trfArgClasses.argSubstepSteering._parseSetterString
def _parseSetterString(self, string)
Definition: trfArgClasses.py:2388
python.trfArgClasses.argSubstepConditions.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:2427
python.trfArgClasses.argument._name
_name
Definition: trfArgClasses.py:111
python.trfArgClasses.argFactory.__str__
def __str__(self)
Definition: trfArgClasses.py:56
python.trfArgClasses.argFile._subtype
_subtype
Definition: trfArgClasses.py:550
pickleTool.object
object
Definition: pickleTool.py:30
python.trfArgClasses.argFile.getMetadata
def getMetadata(self, files=None, metadataKeys=None, maskMetadataKeys=None, populate=True, flush=False)
Return specific keys for specific files.
Definition: trfArgClasses.py:941
str
Definition: BTagTrackIpAccessor.cxx:11
python.trfArgClasses.trfArgParser._argClass
_argClass
Definition: trfArgClasses.py:2442
python.trfArgClasses.argFactory._args
_args
Definition: trfArgClasses.py:35
python.trfArgClasses.argIntList
List of int arguments.
Definition: trfArgClasses.py:414
python.trfArgClasses.argKeyFloatValueList.__str__
def __str__(self)
String conversion.
Definition: trfArgClasses.py:511
python.trfArgClasses.argIntList.__str__
def __str__(self)
String conversion.
Definition: trfArgClasses.py:448
python.trfArgClasses.argFile.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:625
python.trfArgClasses.trfArgParser.defineArgGroup
def defineArgGroup(self, *args)
Define an argparse argument group for the main parser to use.
Definition: trfArgClasses.py:2517
python.trfArgClasses.argString.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:213
python.trfArgClasses.trfArgParser.add_argument
def add_argument(self, *args, **kwargs)
Definition: trfArgClasses.py:2448
python.trfArgClasses.argBSFile.selfMerge
def selfMerge(self, output, inputs, counter=0, argdict={})
Method which can be used to merge files of this type.
Definition: trfArgClasses.py:1385
python.trfFileUtils.HISTEntries
def HISTEntries(fileName)
Determines number of events in a HIST file.
Definition: trfFileUtils.py:55
python.trfArgClasses.argument.__gt__
def __gt__(self, other)
Definition: trfArgClasses.py:170
python.trfArgClasses.argSubstepInt
Int substep argument.
Definition: trfArgClasses.py:2186
python.trfArgClasses.argBSFile.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:1374
python.trfArgClasses.argFile._metadataKeys
_metadataKeys
Definition: trfArgClasses.py:569
python.trfArgClasses.argBool.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:343
python.trfArgClasses.strToBool
def strToBool(string)
Small utility to convert a string value to a boolean.
Definition: trfArgClasses.py:2609
python.trfArgClasses.argList.__repr__
def __repr__(self)
Repr conversion.
Definition: trfArgClasses.py:409
python.trfArgClasses.argNTUPFile._getIntegrity
def _getIntegrity(self, files)
File integrity checker.
Definition: trfArgClasses.py:1733
python.trfArgClasses.argHISTFile.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:1672
python.trfArgClasses.argAthenaFile._callAthInfo
def _callAthInfo(self, files, doAllFiles, retrieveKeys)
Workhorse which actually calls Meta Reader.
Definition: trfArgClasses.py:1327
python.trfArgClasses.argInt.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:254
python.trfArgClasses.argInt
Int type argument.
Definition: trfArgClasses.py:225
python.trfArgClasses.argString.__init__
def __init__(self, value=None, runarg=True, name=None, choices=None)
Class initialisation.
Definition: trfArgClasses.py:182
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
python.trfArgClasses.argFile.auxiliaryFile
def auxiliaryFile(self)
Definition: trfArgClasses.py:874
python.trfArgClasses.argFactory.__call__
def __call__(self, valueString=None)
Definition: trfArgClasses.py:38
python.trfArgClasses.argBSFile._getIntegrity
def _getIntegrity(self, files)
File integrity checker.
Definition: trfArgClasses.py:1362
python.trfArgClasses.argument
Basic argument class holding a value which can be get and set.
Definition: trfArgClasses.py:102
python.trfArgClasses.argActionFactory._factory
_factory
Definition: trfArgClasses.py:86
python.trfArgClasses.argFile._io
_io
Input file globbing and expansion.
Definition: trfArgClasses.py:576
python.trfArgClasses.argAction._factory
_factory
Definition: trfArgClasses.py:63
python.LArMinBiasAlgConfig.float
float
Definition: LArMinBiasAlgConfig.py:65
python.trfArgClasses.argKeyFloatValueList.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:515