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, 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  myEntries = PRWEntries(fileName=fname)
1709  if myEntries is not None:
1710  self._fileMetadata[fname]['nentries'] = myEntries
1711  if self.name and 'NTUP_PILEUP' in self.name:
1712  myEntries = PRWEntries(fileName=fname, integral=True)
1713  self._fileMetadata[fname]['sumOfWeights'] = myEntries
1714  else:
1715  msg.debug('treeNames is set to None - event count undefined for this NTUP')
1716  self._fileMetadata[fname]['nentries'] = 'UNDEFINED'
1717  else:
1718  for fname in files:
1719  try:
1720  self._fileMetadata[fname]['nentries'] = NTUPEntries(fileName=fname, treeNames=self._treeNames)
1722  msg.error('Timeout counting events for {0}'.format(fname))
1723 
1724 
1725  def _getIntegrity(self, files):
1726  for fname in files:
1727  from PyJobTransforms.trfValidateRootFile import checkFile
1728  rc=checkFile(fileName=fname, the_type='basket', requireTree=False)
1729  if rc==0:
1730  self._fileMetadata[fname]['integrity'] = True
1731  else:
1732  self._fileMetadata[fname]['integrity'] = False
1733 
1734 
1735  def selfMerge(self, output, inputs, counter=0, argdict={}):
1736  msg.debug('selfMerge attempted for {0} -> {1} with {2}'.format(inputs, output, argdict))
1737 
1738  # First do a little sanity check
1739  for fname in inputs:
1740  if fname not in self._value:
1741  raise trfExceptions.TransformMergeException(trfExit.nameToCode('TRF_FILEMERGE_PROBLEM'),
1742  "File {0} is not part of this agument: {1}".format(fname, self))
1743 
1744  from PyJobTransforms.trfExe import NTUPMergeExecutor, executorConfig
1745 
1746 
1747  myargdict = self._mergeArgs(argdict)
1748 
1749  # We need a NTUPMergeExecutor to do the merge
1750  myDataDictionary = {'NTUP_MRG_INPUT' : argNTUPFile(inputs, type=self.type, io='input'),
1751  'NYUP_MRG_OUTPUT' : argNTUPFile(output, type=self.type, io='output')}
1752  myMergeConf = executorConfig(myargdict, myDataDictionary)
1753  myMerger = NTUPMergeExecutor(name='NTUPMergeAthenaMP{0}{1}'.format(self._subtype, counter), conf=myMergeConf,
1754  inData=set(['NTUP_MRG_INPUT']), outData=set(['NTUP_MRG_OUTPUT']))
1755  myMerger.doAll(input=set(['NTUP_MRG_INPUT']), output=set(['NYUP_MRG_OUTPUT']))
1756 
1757  # OK, if we got to here with no exceptions, we're good shape
1758  # Now update our own list of files to reflect the merge
1759  for fname in inputs:
1760  self._value.remove(fname)
1761  self._value.append(output)
1762 
1763  msg.debug('Post self-merge files are: {0}'.format(self._value))
1764  self._resetMetadata(inputs + [output])
1765  return myMerger
1766 
1767  @property
1769  desc=super(argNTUPFile, self).prodsysDescription
1770  return desc
1771 
1772 
1773 
1774 
1776  def _getIntegrity(self, files):
1777  for fname in files:
1778  # bz2 only supports 'with' from python 2.7
1779  try:
1780  f = bz2.BZ2File(fname, 'r')
1781  while True:
1782  chunk = len(f.read(1024*1024))
1783  msg.debug('Read {0} bytes from {1}'.format(chunk, fname))
1784  if chunk == 0:
1785  break
1786  self._fileMetadata[fname]['integrity'] = True
1787  f.close()
1788  except OSError as e:
1789  msg.error('Got exception {0!s} raised while checking integrity of file {1}'.format(e, fname))
1790  self._fileMetadata[fname]['integrity'] = False
1791 
1792 
1793  @property
1795  desc=super(argBZ2File, self).prodsysDescription
1796  return desc
1797 
1798 
1799 
1801  def __init__(self, value=list(), io = 'output', type=None, splitter=',', runarg=True, multipleOK=None, name=None):
1802  super(argFTKIPFile, self).__init__(value=value, io=io, type=type, splitter=splitter, runarg=runarg, multipleOK=multipleOK,
1803  name=name)
1804  self._metadataKeys.update({
1805  'nentries': self._getNumberOfEvents
1806  })
1807 
1808  def _getNumberOfEvents(self, files):
1809  for fname in files:
1810  try:
1811  eventCount = 0
1812  f = bz2.BZ2File(fname, 'r')
1813  for line in f:
1814  if line.startswith('F'):
1815  eventCount += 1
1816  self._fileMetadata[fname]['nentries'] = eventCount
1817  except OSError as e:
1818  msg.error('Event count for file {0} failed: {1!s}'.format(fname, e))
1819  self._fileMetadata[fname]['nentries'] = None
1820 
1821  @property
1823  desc=super(argFTKIPFile, self).prodsysDescription
1824  return desc
1825 
1826 
1829  def __init__(self, value=list(), io = 'output', type='txt_evt', splitter=',', runarg=True, multipleOK=None, name=None):
1830  super(argHepEvtAsciiFile, self).__init__(value=value, io=io, type=type, splitter=splitter, runarg=runarg,
1831  multipleOK=multipleOK, name=name)
1832  self._metadataKeys.update({
1833  'nentries': self._getNumberOfEvents
1834  })
1835 
1836  def _getNumberOfEvents(self, files):
1837  for fname in files:
1838  try:
1839  eventCount = 0
1840  f = open(fname, 'r')
1841  for line in f:
1842  if len(line.split(" "))==3:
1843  eventCount += 1
1844  self._fileMetadata[fname]['nentries'] = eventCount
1845  except OSError as e:
1846  msg.error('Event count for file {0} failed: {1!s}'.format(fname, e))
1847  self._fileMetadata[fname]['nentries'] = None
1848 
1849 
1851  def __init__(self, value=list(), io = 'output', type=None, splitter=',', runarg=True, multipleOK=None, name=None):
1852  super(argLHEFile, self).__init__(value=value, io=io, type=type, splitter=splitter, runarg=runarg, multipleOK=multipleOK,
1853  name=name)
1854 
1855  self._metadataKeys.update({
1856  'nentries': self._getNumberOfEvents,
1857  'lheSumOfPosWeights': self._getWeightedEvents,
1858  'lheSumOfNegWeights': 0,
1859  })
1860 
1861  def _getNumberOfEvents(self, files):
1862  msg.debug('Retrieving event count for LHE file {0}'.format(files))
1863  import tarfile
1864  for fname in files:
1865  # Attempt to treat this as a pileup reweighting file
1866  try :
1867  tar = tarfile.open(fname, "r:gz")
1868  lhecount = 0
1869  for untar in tar.getmembers():
1870  fileTXT = tar.extractfile(untar)
1871  if fileTXT is not None :
1872  lines = fileTXT.read().decode("utf-8")
1873  lhecount = lines.count('/event')
1874 
1875  self._fileMetadata[fname]['nentries'] = lhecount
1876  except Exception:
1877  msg.debug('Entries is set to None - event count undefined for this LHE')
1878  self._fileMetadata[fname]['nentries'] = 'UNDEFINED'
1879 
1880  def _getWeightedEvents(self, files):
1881  msg.debug('Retrieving weight count for LHE file {0}'.format(files))
1882  import tarfile
1883  import re
1884 
1885  for fname in files:
1886  weightPos = 0
1887  weightNeg = 0
1888  try :
1889  tar = tarfile.open(fname, "r:gz")
1890  for untar in tar.getmembers():
1891  fileTXT = tar.extractfile(untar)
1892  next = False
1893  if fileTXT is not None :
1894  lines = fileTXT.readlines()
1895  for line in lines :
1896  if next :
1897  try :
1898  w = float(re.sub(' +',' ',line).split(" ")[2])
1899  if w > 0 : weightPos += w
1900  else : weightNeg += abs(w)
1901  except Exception:
1902  pass
1903  next = False
1904  if "<event" in line :
1905  next = True
1906 
1907  self._fileMetadata[fname]['lheSumOfPosWeights'] = weightPos
1908  self._fileMetadata[fname]['lheSumOfNegWeights'] = weightNeg
1909  except Exception:
1910  msg.debug('Entries is set to None - negative fraction count undefined for this LHE')
1911  self._fileMetadata[fname]['lheSumOfPosWeights'] = 'UNDEFINED'
1912  self._fileMetadata[fname]['lheSumOfNegWeights'] = 'UNDEFINED'
1913 
1914 
1919 
1920 
1923  def __init__(self, value = None, runarg = True, name = None, defaultSubstep = 'all', separator = ':'):
1924  self._defaultSubstep = defaultSubstep
1925  self._separator = separator
1926  super(argSubstep, self).__init__(value, runarg, name)
1927 
1928  # Reset getter
1929  @property
1930  def value(self):
1931  return self._value
1932 
1933  # The default setter for sustep class
1934  @value.setter
1935  def value(self, value):
1936  msg.debug('Attempting to set argSubstep from {0!s} (type {1}'.format(value, type(value)))
1937  if value is None:
1938  self._value = {}
1939  elif isinstance(value, str):
1940  self._value = dict(self._parseStringAsSubstep(value))
1941  elif isinstance(value, (list, tuple)):
1942  # This is a list of strings to parse, so we go through them one by one
1943  self._value = {}
1944  for item in value:
1945  if not isinstance(item, str):
1946  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Failed to convert list item {0!s} to substep (should be a string)'.format(item))
1947  self._value.update(dict(self._parseStringAsSubstep(item)))
1948  elif isinstance(value, dict):
1949  self._value = value
1950  else:
1951  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)))
1952 
1953 
1954 
1959  def _parseStringAsSubstep(self, string):
1960  subStepMatch = re.match(r'([a-zA-Z0-9,]+)' + self._separator + r'(.*)', string)
1961  subStepList = []
1962  if subStepMatch:
1963  subStep = subStepMatch.group(1).split(',')
1964  subStepValue = subStepMatch.group(2)
1965  else:
1966  subStep = [self._defaultSubstep]
1967  subStepValue = string
1968  msg.debug('Parsed {0} as substep {1}, argument {2}'.format(string, subStep, subStepValue))
1969  for step in subStep:
1970  subStepList.append((step, subStepValue))
1971  return subStepList
1972 
1973 
1974 
1979  def returnMyValue(self, name=None, substep=None, first=False, exe=None):
1980  if exe:
1981  name = exe.name
1982  substep = exe.substep
1983  first = exe.conf.firstExecutor
1984 
1985  name = commonExecutorStepName(name)
1986 
1987  value = None
1988 
1989  if name in self._value:
1990  value = self._value[name]
1991  elif substep in self._value:
1992  value = self._value[substep]
1993  elif first and 'first' in self._value:
1994  value = self._value['first']
1995  elif 'default' in self._value:
1996  value = self._value['default']
1997 
1998 
2006  if 'all' in self._value:
2007  if value is None:
2008  value = self._value['all']
2009  elif isinstance(value, list):
2010  value = self._value['all'] + value
2011 
2012  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))
2013 
2014  return value
2015 
2016  @property
2018  desc = {'type': 'substep', 'substeptype': 'str', 'separator': self._separator,
2019  'default': self._defaultSubstep}
2020  return desc
2021 
2022 
2029 
2030 
2033  def __init__(self, value = None, runarg = True, name = None, defaultSubstep = 'all', splitter = None, separator=':'):
2034  self._splitter = splitter
2035  super(argSubstepList, self).__init__(value, runarg, name, defaultSubstep, separator)
2036 
2037 
2038  # Reset getter
2039  @property
2040  def value(self):
2041  return self._value
2042 
2043  @property
2045  desc = {'type': 'substep', 'substeptype': 'list', 'listtype': 'str',
2046  'separator': self._separator,
2047  'default': self._defaultSubstep}
2048  return desc
2049  @value.setter
2050  def value(self, value):
2051  msg.debug('Attempting to set argSubstep from {0!s} (type {1}'.format(value, type(value)))
2052  if value is None:
2053  self._value = {}
2054  elif isinstance(value, str):
2055  self._value = dict(self._parseStringAsSubstep(value))
2056  elif isinstance(value, (list, tuple)):
2057  # This is a list of strings to parse
2058  self._value = {}
2059  for item in value:
2060  if not isinstance(item, str):
2061  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Failed to convert list item {0!s} to substep (should be a string)'.format(item))
2062  subStepList = self._parseStringAsSubstep(item)
2063  for subStep in subStepList:
2064  if subStep[0] in self._value:
2065  self._value[subStep[0]].extend(subStep[1])
2066  else:
2067  self._value[subStep[0]] = subStep[1]
2068  elif isinstance(value, dict):
2069  for k, v in value.items():
2070  if not isinstance(k, str):
2071  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Dictionary key {0!s} for substep is not a string'.format(k))
2072  if not isinstance(v, list):
2073  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Dictionary value {0!s} for substep is not a list'.format(v))
2074  self._value = value
2075  else:
2076  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)))
2077 
2078 
2080  def _parseStringAsSubstep(self, value):
2081  subStepList = super(argSubstepList, self)._parseStringAsSubstep(value)
2082  if self._splitter:
2083  subStepList = [(s[0], s[1].split(self._splitter)) for s in subStepList]
2084  else:
2085  subStepList = [(s[0], [s[1]]) for s in subStepList]
2086  return subStepList
2087 
2088 
2090 
2091  # Reset getter
2092  @property
2093  def value(self):
2094  return self._value
2095 
2096  @property
2098  desc = {'type': 'substep', 'substeptype': 'str', 'separator': self._separator,
2099  'default': self._defaultSubstep}
2100  return desc
2101 
2102  @value.setter
2103  def value(self, value):
2104  msg.debug('Attempting to set argSubstep from {0!s} (type {1}'.format(value, type(value)))
2105  if value is None:
2106  self._value = {}
2107  elif isinstance(value, str):
2108  subStepList = self._parseStringAsSubstep(value)
2109  self._value = dict([(subStep[0], subStep[1]) for subStep in subStepList])
2110  elif isinstance(value, (list, tuple)):
2111  # This is a list of strings to parse
2112  self._value = {}
2113  for item in value:
2114  if not isinstance(item, str):
2115  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Failed to convert list item {0!s} to substep (should be a string)'.format(item))
2116  subStepList = self._parseStringAsSubstep(item)
2117  for subStep in subStepList:
2118  self._value[subStep[0]] = subStep[1]
2119  elif isinstance(value, dict):
2120  for k, v in value.items():
2121  if not isinstance(k, str):
2122  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Dictionary key {0!s} for substep is not a string'.format(k))
2123  if not isinstance(v, str):
2124  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Dictionary value {0!s} for substep is not a string'.format(v))
2125  self._value = value
2126  else:
2127  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)))
2128 
2129 
2131 
2132  # Reset getter
2133  @property
2134  def value(self):
2135  return self._value
2136 
2137  @property
2139  desc = {'type': 'substep', 'substeptype': 'bool', 'separator': self._separator,
2140  'default': self._defaultSubstep}
2141  return desc
2142 
2143  @value.setter
2144  def value(self, value):
2145  msg.debug('Attempting to set argSubstep from {0!s} (type {1})'.format(value, type(value)))
2146  if value is None:
2147  self._value = {self._defaultSubstep: True}
2148  elif isinstance(value, bool):
2149  self._value = {self._defaultSubstep: value}
2150  elif isinstance(value, str):
2151  subStepList = self._parseStringAsSubstep(value)
2152  self._value = dict([(subStep[0], strToBool(subStep[1])) for subStep in subStepList])
2153  elif isinstance(value, (list, tuple)):
2154  # This is a list of strings to parse
2155  self._value = {}
2156  for item in value:
2157  if not isinstance(item, str):
2158  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Failed to convert list item {0!s} to substep (should be a string)'.format(item))
2159  subStepList = self._parseStringAsSubstep(item)
2160  for subStep in subStepList:
2161  self._value[subStep[0]] = strToBool(subStep[1])
2162  elif isinstance(value, dict):
2163  for k, v in value.items():
2164  if not isinstance(k, str):
2165  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Dictionary key {0!s} for substep is not a string'.format(k))
2166  if not isinstance(v, bool):
2167  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Dictionary value {0!s} for substep is not a bool'.format(v))
2168  self._value = value
2169  else:
2170  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)))
2171 
2172 
2173 
2175 
2176  # Reset getter
2177  @property
2178  def value(self):
2179  return self._value
2180 
2181  @property
2183  desc = {'type': 'substep', 'substeptype': 'int', 'separator': self._separator,
2184  'default': self._defaultSubstep}
2185  return desc
2186 
2187  @value.setter
2188  def value(self, value):
2189  msg.debug('Attempting to set argSubstep from {0!s} (type {1}'.format(value, type(value)))
2190  try:
2191  if value is None:
2192  self._value = {}
2193  elif isinstance(value, int):
2194  self._value = {self._defaultSubstep: value}
2195  elif isinstance(value, str):
2196  subStepList = self._parseStringAsSubstep(value)
2197  self._value = dict([(subStep[0], int(subStep[1])) for subStep in subStepList])
2198  elif isinstance(value, (list, tuple)):
2199  # This is a list of strings to parse
2200  self._value = {}
2201  for item in value:
2202  if not isinstance(item, str):
2203  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Failed to convert list item {0!s} to substep (should be a string)'.format(item))
2204  subStepList = self._parseStringAsSubstep(item)
2205  for subStep in subStepList:
2206  self._value[subStep[0]] = int(subStep[1])
2207  elif isinstance(value, dict):
2208  for k, v in value.items():
2209  if not isinstance(k, str):
2210  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Dictionary key {0!s} for substep is not a string'.format(k))
2211  if not isinstance(v, int):
2212  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Dictionary value {0!s} for substep is not an int'.format(v))
2213  self._value = value
2214  else:
2215  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)))
2216  except ValueError:
2217  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Failed to convert substep value {0} to int'.format(value))
2218 
2219 
2220 
2221 
2223 
2224  def __init__(self, value=None, min=None, max=None, runarg=True, name=None):
2225  self._min = min
2226  self._max = max
2227  super(argSubstepFloat, self).__init__(value = value, runarg = runarg, name=name)
2228 
2229  @property
2231  desc = {'type': 'substep', 'substeptype': 'float', 'separator': self._separator,
2232  'default': self._defaultSubstep}
2233  if self._min:
2234  desc['min'] = self._min
2235  if self._max:
2236  desc['max'] = self._max
2237  return desc
2238 
2239 
2240  # Reset getter
2241  @property
2242  def value(self):
2243  return self._value
2244 
2245  @value.setter
2246  def value(self, value):
2247  msg.debug('Attempting to set argSubstep from {0!s} (type {1}'.format(value, type(value)))
2248  try:
2249  if value is None:
2250  self._value = {}
2251  elif isinstance(value, float):
2252  self._value = {self._defaultSubstep: value}
2253  elif isinstance(value, str):
2254  subStepList = self._parseStringAsSubstep(value)
2255  self._value = dict([(subStep[0], float(subStep[1])) for subStep in subStepList])
2256  elif isinstance(value, (list, tuple)):
2257  # This is a list of strings to parse
2258  self._value = {}
2259  for item in value:
2260  if not isinstance(item, str):
2261  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2262  'Failed to convert list item {0!s} to substep (should be a string)'.format(item))
2263  subStepList = self._parseStringAsSubstep(item)
2264  for subStep in subStepList:
2265  self._value[subStep[0]] = float(subStep[1])
2266  elif isinstance(value, dict):
2267  for k, v in value.items():
2268  if not isinstance(k, str):
2269  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2270  'Dictionary key {0!s} for substep is not a string'.format(k))
2271  if not isinstance(v, float):
2272  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2273  'Dictionary value {0!s} for substep is not an float'.format(v))
2274  self._value = value
2275  else:
2276  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2277  'Setter value {0!s} (type {1}) for substep argument cannot be parsed'.format(value, type(value)))
2278  # Now do min/max checks
2279  for my_float in self._value.values():
2280  if (self._min is not None and my_float < self._min) or (self._max is not None and my_float > self._max):
2281  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_OUT_OF_RANGE'),
2282  'argFloat value out of range: {0} is not between {1} and {2}'.format(my_float, self._min, self._max))
2283  except ValueError as e:
2284  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2285  'Failed to convert substep value {0} to float: {1}'.format(value, e))
2286 
2287 
2288 
2290  # This singleton is where we define some aliases for common production
2291  # usecases of steering.
2292  # "no" - a convenience null option for production managers, does nothing
2293  # "doRDO_TRIG" - run split trigger for Reco_tf and friends
2294  # "doOverlay" - run event overlay on presampled RDOs instead of standard HITtoRDO digitization
2295  # "doFCwOverlay" - run FastChain with MC-overlay (EVNTtoRDOwOverlay) instead of standard PU digitization (EVNTtoRDO)
2296  # "afterburn" - run the B decay afterburner for event generation
2297  # "doRAWtoALL" - (deprecated) produce all DESDs and AODs directly from bytestream
2298  # "doTRIGtoALL" - (deprecated) produce AODs directly from trigger RDOs
2299  steeringAlises = {
2300  'no': {},
2301  'doRDO_TRIG': {'RAWtoALL': [('in', '-', 'RDO'), ('in', '+', 'RDO_TRIG'), ('in', '-', 'BS')]},
2302  'doOverlay': {'HITtoRDO': [('in', '-', 'HITS'), ('out', '-', 'RDO'), ('out', '-', 'RDO_FILT')],
2303  'Overlay': [('in', '+', ('HITS', 'RDO_BKG')), ('out', '+', 'RDO')]},
2304  'doFCwOverlay': {'EVNTtoRDO': [('in', '-', 'EVNT'), ('out', '-', 'RDO')],
2305  'EVNTtoRDOwOverlay': [('in', '+', ('EVNT', 'RDO_BKG')), ('out', '+', 'RDO'), ('out', '+', 'RDO_SGNL')]},
2306  'afterburn': {'generate': [('out', '-', 'EVNT')]},
2307  'doRAWtoALL': {},
2308  'doTRIGtoALL': {}
2309  }
2310 
2311  # Reset getter
2312  @property
2313  def value(self):
2314  return self._value
2315 
2316  # This argument gets dumped in a special way, using an alias directly
2317  # instead of the expanded value
2318  @property
2319  def dumpvalue(self):
2320  return self._dumpvalue
2321 
2322  @property
2324  desc = {'type': 'substep', 'substeptype': 'steering', 'listtype': 'str', 'separator': self._separator,
2325  'default': self._defaultSubstep}
2326  return desc
2327 
2328 
2331  @value.setter
2332  def value(self, value):
2333  msg.debug('Attempting to set argSubstepSteering from {0!s} (type {1})'.format(value, type(value)))
2334  if value is None:
2335  self._value = {}
2336  self._dumpvalue = [""]
2337  elif isinstance(value, dict):
2338  # OK, this should be the direct setable dictionary - but do a check of that
2339  for k, v in value.items():
2340  if not isinstance(k, str) or not isinstance(v, list):
2341  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2342  'Failed to convert dict {0!s} to argSubstepSteering'.format(value))
2343  for subv in v:
2344  if not isinstance(subv, (list, tuple)) or len(subv) != 3 or subv[0] not in ('in', 'out') or subv[1] not in ('+', '-'):
2345  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2346  'Failed to convert dict {0!s} to argSubstepSteering'.format(value))
2347  self._value = value
2348  # Note we are a little careful here to never reset the dumpvalue - this is
2349  # because when processing the _list_ of steering arguments down to a single
2350  # multi-valued argument we re-call value() with an expanded diectionary and
2351  # one can nievely reset dumpvalue by mistake
2352  self._dumpvalue = getattr(self, "_dumpvalue", value)
2353  elif isinstance(value, (str, list, tuple)):
2354  if isinstance(value, str):
2355  value = [value,]
2356  self._dumpvalue = getattr(self, "_dumpvalue", value)
2357  # Now we have a list of strings to parse
2358  self._value = {}
2359  for item in value:
2360  if not isinstance(item, str):
2361  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2362  'Failed to convert list item {0!s} to substep (should be a string)'.format(item))
2363  if item in argSubstepSteering.steeringAlises:
2364  msg.debug("Found value {0} in steeringAlises ({1})".format(item, argSubstepSteering.steeringAlises[item]))
2365  for substep, steerlist in argSubstepSteering.steeringAlises[item].items():
2366  if substep in self._value:
2367  self._value[substep].extend(steerlist)
2368  else:
2369  self._value[substep] = steerlist
2370  else:
2371  subStepList = self._parseStringAsSubstep(item)
2372  self._value.update(dict([(subStep[0], self._parseSteeringString(subStep[1])) for subStep in subStepList]))
2373  else:
2374  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2375  'Setter value {0!s} (type {1}) for substep argument cannot be parsed'.format(value, type(value)))
2376 
2377  def _parseSetterString(self, string):
2378  if string in argSubstepSteering.steeringAlises:
2379  return argSubstepSteering.steeringAlises[string]
2380 
2381  def _parseSteeringString(self, ivalue):
2382  retvalue = []
2383  for subvalue in ivalue.split(','):
2384  matchedParts = re.match(r'(in|out)(\+|\-)([A-Z_]+)$', subvalue)
2385  if not matchedParts:
2386  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2387  'Failed to convert string {0!s} to argSubstepSteering'.format(subvalue))
2388  retvalue.append((matchedParts.group(1), matchedParts.group(2), matchedParts.group(3)))
2389  return retvalue
2390 
2391 
2392 
2394  @property
2395  def value(self):
2396  return self._value
2397 
2398  @value.setter
2399  def value(self, value):
2400  msg.debug('Attempting to set argSubstepConditions from {0!s} (type {1}'.format(value, type(value)))
2401  # super().value = value workaround:
2402  super(self.__class__, self.__class__).value.fset(self, value)
2403 
2404  current = None
2405  for k, v in self._value.items():
2406  if "CurrentMC" == v:
2407  if current is None:
2408  current = self._amiLookUp(getAMIClient())
2409  self._value[k] = current
2410 
2411  def _amiLookUp(self, client):
2412  cmd = "COMAGetGlobalTagNameByCurrentState --state=CurrentMC"
2413  return str(client.execute(cmd, format = 'dom_object').get_rows().pop()['globalTag'])
2414 
2415  @property
2417  desc = {'type': 'substep', 'substeptype': 'str', 'separator': self._separator,
2418  'default': self._defaultSubstep}
2419  return desc
2420 
2421 
2422 class trfArgParser(argparse.ArgumentParser):
2423 
2424 
2429  def __init__(self, *args, **kwargs):
2430  self._helpString = {}
2431  self._argClass = {}
2432  self._argGroups = {}
2433  self._argKeyGroups = {}
2434  self._argAlias = {}
2435  super(trfArgParser, self).__init__(*args, **kwargs)
2436 
2437  def add_argument(self, *args, **kwargs):
2438  argName = args[0].lstrip('-')
2439  msg.debug('Found arg name {0}'.format(argName))
2440 
2441  # Ban arguments with hyphens as they cause trouble in signature files and then
2442  # AMI tag definitions because of the auto-translation to underscores in argparse
2443  if '-' in argName:
2444  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_ERROR'),
2445  'Transform arguments may not use hyphens (use camelCase or underscore')
2446 
2447  # Prevent a crash if this argument already exists (there are valid use cases for 'grabbing' an
2448  # argument, so this is DEBUG, not WARNING)
2449  if argName in self._argClass:
2450  msg.debug('Double definition of argument {0} - ignored'.format(argName))
2451  return
2452 
2453  # if there is a help function defined for the argument then populate the helpString dict
2454  if 'help' in kwargs:
2455  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
2456  else:
2457  self._helpString[argName] = None
2458  if 'action' in kwargs and 'factory' in dir(kwargs['action']):
2459  self._argClass[argName] = kwargs['action'].factory
2460  elif 'type' in kwargs:
2461  self._argClass[argName] = kwargs['type']
2462  else:
2463  self._argClass[argName] = None
2464 
2465  # Remove kwargs which are not understood by ArgumentParser.add_argument()
2466  strippedArgs = {}
2467  for arg in ('group',):
2468  if arg in kwargs:
2469  strippedArgs[arg] = kwargs.pop(arg)
2470 
2471  # Setup aliases
2472  if len(args) > 1:
2473  for i in range(1, len(args)):
2474  argAlias = args[i].lstrip('-')
2475  msg.debug('Adding an alias of {0}: {1}'.format(argName, argAlias))
2476  self._argAlias[argAlias] = argName
2477 
2478  # Optinally add an argument to an argparse argument group
2479  if 'group' in strippedArgs:
2480  if strippedArgs['group'] in self._argGroups:
2481  msg.debug('Adding argument to group {0}: ({1}; {2})'.format(strippedArgs['group'], args, kwargs))
2482  self._argGroups[strippedArgs['group']].add_argument(*args, **kwargs)
2483  self._argKeyGroups[argName] = strippedArgs['group']
2484  else:
2485  msg.warning('Argument group {0} not defined - adding argument to main parser'.format(strippedArgs['group']))
2486  msg.debug('Adding argument: ({0}; {1})'.format(args, kwargs))
2487  super(trfArgParser, self).add_argument(*args, **kwargs)
2488  else:
2489  msg.debug('Adding argument: ({0}; {1})'.format(args, kwargs))
2490  super(trfArgParser, self).add_argument(*args, **kwargs)
2491 
2492  @property
2493  def getProdsysDesc(self):
2494  desc = {}
2495  for name, argClass in self._argClass.items():
2496  msg.debug('Detected the local variable {0}'.format(name))
2497  if argClass is not None:
2498  desc[name] = argClass().prodsysDescription
2499  if name in self._helpString:
2500  desc[name].update({'help': self._helpString[name]})
2501  if name in self._argKeyGroups:
2502  desc[name].update({'group':self._argKeyGroups[name]})
2503  return desc
2504 
2505 
2506  def defineArgGroup(self, *args):
2507  # Get an argparse group
2508  if args[0] in self._argGroups:
2509  msg.warning('Argument group %s already exists', args[0])
2510  return
2511  self._argGroups[args[0]] = self.add_argument_group(*args)
2512 
2513 
2514  def getHelpString(self, argument):
2515  try:
2516  return(self._helpString[argument])
2517  except KeyError:
2518  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_KEY_ERROR'), 'no help string available for argument %s' %argument)
2519  return None
2520 
2521 
2523  def dumpArgs(self):
2524  keyArray = [ '--' + str(key) for key in self._helpString if key not in ('h', 'verbose', 'loglevel', 'dumpargs', 'argdict') ]
2525  keyArray.sort()
2526  print('ListOfDefaultPositionalKeys={0}'.format(keyArray))
2527 
2528 
2529  @property
2530  def allArgs(self):
2531  return list(self._helpString)
2532 
2533  # @brief parsing helper
2534  def _parse_list_helper(self, value):
2535  # We build on the value[0] instance as this contains the correct metadata
2536  # and object references for this instance (shallow copying can
2537  # mess up object references and deepcopy thows exceptions!)
2538  newValueObj = value[0]
2539  msg.debug('Started with: %s = %s', type(newValueObj), newValueObj)
2540  if isinstance(value[0], argSubstep):
2541  # Make sure you do not have a reference to the original value - this is a deeper copy
2542  newValues = dictSubstepMerge(value[0].value, {})
2543  elif isinstance(value[0], list):
2544  if len(value) == 1:
2545  return self._parse_list_helper(value[0])
2546  msg.debug('Handling a list of arguments for key')
2547  newValues = []
2548  for v in value:
2549  processedValueObj, processedValues = self._parse_list_helper(v)
2550  processedValueObj.value = processedValues
2551  newValues.append(processedValueObj)
2552  newValueObj = newValues
2553  return newValueObj, newValues
2554  elif isinstance(value[0].value, list):
2555  newValues = value[0].value
2556  elif isinstance(value[0].value, dict):
2557  newValues = value[0].value
2558  else:
2559  newValues = [value[0].value,]
2560  for valueObj in value[1:]:
2561  msg.debug('Value Object: %s = %s', type(valueObj), valueObj)
2562  if isinstance(value[0], argSubstep):
2563  # Special merger for lists attached to substeps
2564  newValues = dictSubstepMerge(newValues, valueObj.value)
2565  elif isinstance(valueObj.value, list):
2566  # General lists are concatenated
2567  newValues.extend(valueObj.value)
2568  elif isinstance(valueObj.value, dict):
2569  # General dictionaries are merged
2570  newValues.update(valueObj.value)
2571  else:
2572  newValues.append(valueObj.value)
2573  return newValueObj, newValues
2574 
2575 
2580  def parse_args(self, args = None, namespace = None):
2581  if namespace:
2582  super(trfArgParser, self).parse_args(args = args, namespace = namespace)
2583  else:
2584  namespace = super(trfArgParser, self).parse_args(args = args)
2585  for k, v in namespace.__dict__.items():
2586  msg.debug('Treating key %s (%s)', k, v)
2587  if isinstance(v, list):
2588  newValueObj, newValues = self._parse_list_helper(v)
2589  if not isinstance(newValueObj, list):
2590  newValueObj.value = newValues
2591  namespace.__dict__[k] = newValueObj
2592  msg.debug('Set to %s', newValues)
2593 
2594  return namespace
2595 
2596 
2597 
2598 def strToBool(string):
2599  try:
2600  msg.debug("converting string {string} to boolean".format(string = string))
2601  if string.lower() == 'false':
2602  return False
2603  elif string.lower() == 'true':
2604  return True
2605  else:
2606  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Failed to convert value {0} to bool'.format(string))
2607  except AttributeError:
2608  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'), 'Failed to convert value {0} to bool'.format(string))
2609 
2610 
2619 def dictSubstepMerge(dict1, dict2):
2620  mergeDict = {}
2621  allKeys = set(dict1) | set(dict2)
2622  # Find the value type - lists are special...
2623  listType = False
2624  if len(dict1) > 0:
2625  if isinstance(list(dict1.values())[0], list):
2626  listType = True
2627  elif len(dict2) > 0:
2628  if isinstance(list(dict2.values())[0], list):
2629  listType = True
2630  if listType:
2631  for key in allKeys:
2632  mergeDict[key] = dict1.get(key, []) + dict2.get(key, [])
2633  else:
2634  for key in allKeys:
2635  if key in dict1 and key in dict2:
2636  # Don't really know what to do if these clash...
2637  if dict1[key] != dict2[key]:
2638  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2639  'Merging substep arguments found clashing values for substep {0}: {1}!={2}'.format(key, dict1[key], dict2[key]))
2640  mergeDict[key] = dict1[key]
2641  elif key in dict1:
2642  mergeDict[key] = dict1[key]
2643  else:
2644  mergeDict[key] = dict2[key]
2645 
2646  return mergeDict
2647 
2648 
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
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
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:2017
python.trfArgClasses.argFTKIPFile._getNumberOfEvents
def _getNumberOfEvents(self, files)
Definition: trfArgClasses.py:1808
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:2224
python.trfFileUtils.ROOTGetSize
def ROOTGetSize(filename)
Get the size of a file via ROOT's TFile.
Definition: trfFileUtils.py:248
python.trfArgClasses.argSubstepConditions._amiLookUp
def _amiLookUp(self, client)
Definition: trfArgClasses.py:2411
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:1776
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:2422
python.trfArgClasses.trfArgParser.getHelpString
def getHelpString(self, argument)
Return the help string for a given argument.
Definition: trfArgClasses.py:2514
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
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:1925
python.trfArgClasses.argString.choices
def choices(self)
Choices getter.
Definition: trfArgClasses.py:208
python.trfArgClasses.trfArgParser._argGroups
_argGroups
Definition: trfArgClasses.py:2432
python.trfArgClasses.trfArgParser.parse_args
def parse_args(self, args=None, namespace=None)
Call argument_parser parse_args, then concatenate values.
Definition: trfArgClasses.py:2580
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:1924
python.trfArgClasses.argSubstepInt.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:2182
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:2226
python.trfArgClasses.argument.isRunarg
def isRunarg(self)
Return runarg status.
Definition: trfArgClasses.py:134
python.trfArgClasses.argSubstepBool.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:2138
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:1850
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:2429
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:1822
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:1979
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:1794
python.trfArgClasses.argActionFactory.__init__
def __init__(self, genclass, *args, **kwargs)
Definition: trfArgClasses.py:84
python.trfArgClasses.trfArgParser._helpString
_helpString
Definition: trfArgClasses.py:2430
python.trfArgClasses.argHepEvtAsciiFile._getNumberOfEvents
def _getNumberOfEvents(self, files)
Definition: trfArgClasses.py:1836
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:1880
python.trfArgClasses.argHepEvtAsciiFile
HEP ASCII file.
Definition: trfArgClasses.py:1828
python.trfArgClasses.argHISTFile._getNumberOfEvents
def _getNumberOfEvents(self, files)
Definition: trfArgClasses.py:1664
python.trfArgClasses.argSubstepBool
Boolean substep argument.
Definition: trfArgClasses.py:2130
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:1775
python.trfArgClasses.argSubstepString.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:2097
python.trfArgClasses.trfArgParser.getProdsysDesc
def getProdsysDesc(self)
Definition: trfArgClasses.py:2493
python.trfArgClasses.trfArgParser.allArgs
def allArgs(self)
Getter for argument list.
Definition: trfArgClasses.py:2530
python.trfArgClasses.argSubstepList._splitter
_splitter
Definition: trfArgClasses.py:2034
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:797
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:1801
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:2434
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:2534
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:2080
python.trfArgClasses.argLHEFile._getNumberOfEvents
def _getNumberOfEvents(self, files)
Definition: trfArgClasses.py:1861
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.trfArgClasses.argLHEFile.__init__
def __init__(self, value=list(), io='output', type=None, splitter=',', runarg=True, multipleOK=None, name=None)
Definition: trfArgClasses.py:1851
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:2336
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:2028
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:2089
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:2433
python.trfArgClasses.argSubstepFloat._min
_min
Definition: trfArgClasses.py:2225
python.trfArgClasses.argList._supressEmptyStrings
_supressEmptyStrings
Definition: trfArgClasses.py:358
python.trfArgClasses.argSubstepSteering.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:2323
python.trfArgClasses.argSubstepList.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:2044
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:2523
python.trfArgClasses.argSubstepSteering.dumpvalue
def dumpvalue(self)
Definition: trfArgClasses.py:2319
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:2381
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:224
python.trfArgClasses.argList.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:370
python.trfArgClasses.argList._splitter
_splitter
Definition: trfArgClasses.py:357
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:1829
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.PerfMonSerializer.decode
def decode(s)
Definition: PerfMonSerializer.py:388
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:279
TrigJetMonitorAlgorithm.items
items
Definition: TrigJetMonitorAlgorithm.py:79
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:1735
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:1923
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:1959
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
dqt_zlumi_pandas.update
update
Definition: dqt_zlumi_pandas.py:42
python.trfArgClasses.argFile._originalName
_originalName
Definition: trfArgClasses.py:554
python.trfArgClasses.argSubstepSteering
Special argument class to hold steering information.
Definition: trfArgClasses.py:2289
python.trfArgClasses.argSubstepFloat.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:2230
python.trfArgClasses.argSubstepFloat
Float substep argument.
Definition: trfArgClasses.py:2222
python.trfArgClasses.argNTUPFile.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:1768
python.trfArgClasses.argFTKIPFile
Class which defines a special input file format used in FTK simulation
Definition: trfArgClasses.py:1800
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:2393
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
python.trfArgClasses.dictSubstepMerge
def dictSubstepMerge(dict1, dict2)
special dictionary merger which is used for substep type arguments
Definition: trfArgClasses.py:2619
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:2033
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
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
python.trfArgClasses.argFloat._max
_max
Definition: trfArgClasses.py:269
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:569
python.trfArgClasses.argSubstep
Base class for substep arguments.
Definition: trfArgClasses.py:1918
python.trfArgClasses.argYODAFile
Definition: trfArgClasses.py:1249
python.trfArgClasses.argSubstepSteering._parseSetterString
def _parseSetterString(self, string)
Definition: trfArgClasses.py:2377
python.trfArgClasses.argSubstepConditions.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:2416
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:2431
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:2506
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:2437
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:2174
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:2598
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:1725
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
readCCLHist.float
float
Definition: readCCLHist.py:83
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.trfArgClasses.argKeyFloatValueList.prodsysDescription
def prodsysDescription(self)
Definition: trfArgClasses.py:515