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