17msg = logging.getLogger(__name__)
19import PyJobTransforms.trfExceptions
as trfExceptions
21from PyJobTransforms.trfFileUtils import athFileInterestingKeys, AthenaLiteFileInfo, NTUPEntries, HISTEntries, PHYSVALEntries, PRWEntries, urlType, ROOTGetSize
23from PyJobTransforms.trfExeStepTools
import commonExecutorStepName
25from PyJobTransforms.trfDecorators
import timelimited
33 msg.debug(
'Initialised class %s with args=%s; kwargs=%s', genclass, args, kwargs)
39 msg.debug(
'Called class %s with value=%s; args=%s; kwargs=%s', self.
_genclass, valueString, self.
_args, self.
_kwargs)
47 if valueString
is None:
51 except Exception
as e:
52 msg.fatal(
'Got this exception raised when calling object factory: {0}'.format(e))
62 def __init__(self, factory, option_strings, dest, **kwargs):
64 super().
__init__(option_strings, dest, **kwargs)
66 def __call__(self, parser, namespace, values, option_string=None):
67 msg.debug(
'Called action for factory=%s; values=%s', self.
_factory, values)
70 if isinstance(values, list):
75 setattr(namespace, self.
dest, [self.
_factory(v)
for v
in values])
85 msg.debug(
'Initialised action class %s with args=%s; kwargs=%s', genclass, args, kwargs)
92 def __call__(self, option_strings, dest, **kwargs):
96 return 'argActionFactory for {0}'.format(self.
_factory)
109 def __init__(self, value = None, runarg = True, name = None):
149 desc = {
'type' :
None}
154 return '{0}: Value {1} (isRunArg={2})'.format(self.__class__.__name__, self.
_value, self.
_runarg)
158 return repr(self.
value)
162 return self.
value == other.value
165 return self.
value != other.value
168 return self.
value < other.value
171 return self.
value > other.value
182 def __init__(self, value = None, runarg = True, name = None, choices = None):
184 super(argString, self).
__init__(value = value, runarg = runarg, name=name)
214 desc = {
'type' :
'str'}
242 if isinstance(value, int):
248 except ValueError
as e:
250 'Failed to convert value {0} to int: {1}'.format(value, e))
255 desc = {
'type' :
'int'}
267 def __init__(self, value=None, min=None, max=None, runarg=True, name=None):
270 super(argFloat, self).
__init__(value = value, runarg = runarg, name=name)
280 desc = {
'type' :
'float'}
282 desc[
'min'] = self.
_min
284 desc[
'max'] = self.
_max
296 if self.
_min is not None:
302 if isinstance(value, float):
305 self.
_value = float(value)
308 'Failed to convert %s to a float' % str(value))
312 'argFloat value out of range: %g is not between %s and %s' %
336 if isinstance(value, bool):
344 desc = {
'type' :
'bool'}
356 def __init__(self, value = [], supressEmptyStrings = True, splitter=',', runarg=True, name=None):
360 super(argList, self).
__init__(value = value, runarg = runarg, name=name)
371 desc = {
'type' :
'list',
'listtype':
'str'}
381 if isinstance(value, (list, tuple)):
392 except AttributeError:
394 'Failed to convert %s to a list' % str(value))
405 return " ".join(self.
_value)
410 return '[' +
','.join([ repr(s)
for s
in self.
_value ]) +
']'
428 if isinstance(value, list):
430 if not isinstance(v, int):
432 'Illegal value {0} in list of ints'.format(v))
444 except (AttributeError, ValueError):
446 'Failed to convert %s to a list of ints' % str(value))
449 return " ".join([ str(el)
for el
in self.
_value ])
453 desc = {
'type' :
'list',
'listtype' :
'int'}
465 def __init__(self, value = {}, supressEmptyStrings = True, splitter=',', kvsplitter=":
", runarg=True, name=None):
470 super(argList, self).__init__(value = value, runarg = runarg, name=name)
485 if isinstance(value, dict):
486 for k, v
in value.items():
487 if not isinstance(k, str):
489 'Illegal key argument type {0} in dictionary for argKeyFloatValueList'.format(k))
490 if not isinstance(v, float):
492 'Illegal value argument type {0} in dictionary for argKeyFloatValueList'.format(v))
501 kvlist = [ v
for v
in value.split(self.
_splitter)
if v !=
'' ]
507 except (AttributeError, ValueError):
509 'Failed to convert {0} to a dictionary of string:int values'.format(value))
516 desc = {
'type' :
'list',
'listtype' :
'str:float'}
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):
576 if multipleOK
is None:
585 super(argFile, self).
__init__(value=value, splitter=splitter, runarg=runarg, name=name)
617 @mergeTargetSize.setter
626 if isinstance(self.
_type, dict):
628 desc = {
'type' :
'file',
'subtype' :
"NONE" }
630 desc = {
'type' :
'file',
'subtype' : dict((str(k).
upper(), str(v).
upper())
for (k,v)
in self.
_type.items())}
632 desc = {
'type' :
'file',
'subtype' : str(self.
_type).
upper()}
647 if isinstance(value, (list, tuple)):
648 if len(value) > 0
and isinstance(value[0], dict):
656 'Filename (key "lfn") not found in Tier-0 file dictionary: {0}'.format(myfile))
657 for k, v
in myfile.items():
662 elif k ==
'checksum':
669 'Inconsistent dataset names in Tier-0 dictionary: {0} != {1}'.format(self.
dataset, v))
679 if value.lower().startswith(
'lfn'):
681 from PyUtils.PoolFile
import file_name
682 protocol, pfn = file_name(value)
688 if self.
_io ==
'output' and (
'[' in value)
and (
']' in value):
694 except (AttributeError, TypeError):
696 'Failed to convert %s to a list' % str(value))
699 deDuplicatedValue = []
701 if fname
not in deDuplicatedValue:
702 deDuplicatedValue.append(fname)
704 msg.warning(
"Removing duplicated file {0} from file list".format(fname))
705 if len(self.
_value) != len(deDuplicatedValue):
706 self.
_value = deDuplicatedValue
707 msg.warning(
'File list after duplicate removal: {0}'.format(self.
_value))
718 if self.
_io ==
'input':
724 msg.debug(
'Found POSIX filesystem input - activating globbing')
726 for filename
in self.
_value:
728 globbedFiles = glob.glob(filename)
729 if len(globbedFiles) == 0:
731 'Input file argument {0} globbed to NO input files - probably the file(s) are missing'.format(filename))
734 newValue.extend(globbedFiles)
737 msg.debug (
'File input is globbed to %s' % self.
_value)
740 msg.debug(
'Found root filesystem input - activating globbing')
742 for filename
in self.
_value:
743 if str(filename).startswith(
"root"):
744 msg.debug(
'Found input file name starting with "root," setting XRD_RUNFORKHANDLER=1, which enables fork handlers for xrootd in direct I/O')
745 os.environ[
"XRD_RUNFORKHANDLER"] =
"1"
746 if str(filename).startswith(
"https")
or str(filename).startswith(
"davs")
or not(str(filename).endswith(
'/'))
and '*' not in filename
and '?' not in filename:
747 msg.debug(
'Seems that only one file was given: {0}'.format(filename))
748 newValue.extend(([filename]))
753 if '*' in filename
or '?' in filename:
754 msg.debug(
'Split input into path for listdir() and a filemask to select available files.')
755 path = filename[0:filename.rfind(
'/')+1]
756 msg.debug(
'path: {0}'.format(path))
757 fileMask = filename[filename.rfind(
'/')+1:len(filename)]
758 msg.debug(
'Will select according to: {0}'.format(fileMask))
760 cmd = [
'/afs/cern.ch/project/eos/installation/atlas/bin/eos.select' ]
761 if not os.access (
'/afs/cern.ch/project/eos/installation/atlas/bin/eos.select', os.X_OK ):
763 'No execute access to "eos.select" - could not glob EOS input files.')
770 proc = subprocess.Popen(args = cmd,bufsize = 1, shell =
False, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
772 output = proc.stdout.readlines()
775 'EOS list command ("{0!s}") failed: rc {1}, output {2}'.format(cmd, rc, output))
776 msg.debug(
"eos returned: {0}".format(output))
779 myFiles += [str(path)+str(line.rstrip(
'\n'))]
781 patt = re.compile(fileMask.replace(
'*',
'.*').
replace(
'?',
'.'))
782 for srmFile
in myFiles:
784 if(patt.search(srmFile))
is not None:
786 msg.debug(
'match: %s',srmFile)
787 newValue.extend(([srmFile]))
789 newValue.extend(([srmFile]))
791 msg.debug(
'Selected files: %s', newValue)
792 except (AttributeError, TypeError, OSError):
794 'Failed to convert %s to a list' % str(value))
795 if len(self.
_value) > 0
and len(newValue) == 0:
798 'Input file argument(s) {0!s} globbed to NO input files - ls command failed')
800 msg.debug (
'File input is globbed to %s' % self.
_value)
804 'Multiple file arguments are not supported for {0} (was given: {1}'.format(self, self.
_value))
812 if value
not in (
'input',
'output',
'temporary'):
814 'File arguments must be specified as input, output or temporary - got {0}'.format(value))
861 m = re.match(
r'(input|output|tmp.)([A-Za-z0-9_]+?)(File)?$', value)
863 msg.debug(
"ArgFile name setter matched this: {0}".format(m.groups()))
864 if self.
_type is None:
865 dtype = m.group(2).
split(
'_', 1)[0]
867 if re.match(
r'D(RAW|ESD|AOD)', dtype):
869 msg.debug(
"Autoset data type to {0}".format(dtype))
872 msg.debug(
"Autoset data subtype to {0}".format(m.group(2)))
875 msg.debug(
"ArgFile name setter did not match against '{0}'".format(value))
897 events = self.
getSingleMetadata(fname=fname, metadataKey=
'nentries', populate =
not fast)
899 msg.debug(
'Got events=None for file {0} - returning None for this instance'.format(fname))
901 if events ==
'UNDEFINED':
902 msg.debug(
'Got events=UNDEFINED for file {0} - returning UNDEFINED for this instance'.format(fname))
904 if not isinstance(events, int):
905 msg.warning(
'Got unexpected events metadata for file {0}: {1!s} - returning None for this instance'.format(fname, events))
907 totalEvents += events
918 if files == []
or '_fileMetadata' not in dir(self):
924 if fname
in self.
value:
928 msg.debug(
'Metadata dictionary now {0}'.format(self.
_fileMetadata))
931 if self.
_guid is not None:
932 msg.debug(
'Now trying to set file GUID metadata using {0}'.format(self.
_guid))
933 for fname, guid
in self.
_guid.items():
937 msg.warning(
'Explicit GUID {0} was passed for file {1}, but this file is not a member of this instance'.format(guid, fname))
945 def getMetadata(self, files = None, metadataKeys = None, maskMetadataKeys = None, populate = True, flush = False):
949 elif isinstance(files, str):
951 msg.debug(
'getMetadata will examine these files: {0!s}'.format(files))
953 if metadataKeys
is None:
955 elif isinstance(metadataKeys, str):
956 metadataKeys = [metadataKeys,]
957 if maskMetadataKeys
is not None:
958 metadataKeys = [k
for k
in metadataKeys
if k
not in maskMetadataKeys]
959 msg.debug(
'getMetadata will retrieve these keys: {0!s}'.format(metadataKeys))
962 msg.debug(
'Flushing cached metadata values')
966 msg.debug(
'Checking metadata values')
972 for mdkey
in metadataKeys:
978 msg.error(
'Did not find metadata key {0!s} for file {1!s} - setting to None'.format(mdkey, fname))
979 metadata[fname][mdkey] =
None
990 if not (isinstance(fname, str)
and isinstance(metadataKey, str)):
992 'Illegal call to getSingleMetadata function: {0!s} {1!s}'.format(fname, metadataKey))
993 md = self.
getMetadata(files = fname, metadataKeys = metadataKey, populate = populate, flush = flush)
994 return md[fname][metadataKey]
1001 msg.debug(
'Retrieving metadata keys {1!s} for files {0!s}'.format(files, metadataKeys))
1012 for key
in metadataKeys:
1013 if key !=
'_exists':
1017 for key
in metadataKeys:
1019 msg.debug(
'Metadata key {0} is unknown for {1}'.format(key, self.__class__.__name__))
1023 msg.debug(
'Found cached value for {0}:{1} = {2!s}'.format(fname, key, self.
_fileMetadata[fname][key]))
1025 msg.debug(
'No cached value for {0}:{1}. Calling generator function {2} ({3})'.format(fname, key, self.
_metadataKeys[key].__name__, self.
_metadataKeys[key]))
1028 msg.info(
"Metadata generator called to obtain {0} for {1}".format(key, files))
1031 msg.error(
'Calling {0!s} raised an exception: {1!s}'.format(self.
_metadataKeys[key].__name__, e))
1033 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))
1035 msg.debug(
'Now have {0}:{1} = {2!s}'.format(fname, key, self.
_fileMetadata[fname][key]))
1054 for k, v
in metadataKeys.items():
1055 msg.debug(
'Manualy setting {0} for file {1} to {2}'.format(k, fname, v))
1066 msg.debug(
'Testing for cached values for files {0} and keys {1}'.format(files, metadataKeys))
1069 elif isinstance(files, str):
1071 if metadataKeys
is None:
1073 elif isinstance(metadataKeys, str):
1074 metadataKeys = (metadataKeys,)
1078 for key
in metadataKeys:
1080 isCachedFlag =
False
1082 if isCachedFlag
is False:
1097 for filename
in self.
_value:
1098 if filename.find(
'#') > -1:
1099 (dataset, fname) = filename.split(
'#', 1)
1100 newValue.append(fname)
1101 msg.debug(
'Current dataset: {0}; New dataset {1}'.format(self.
_dataset, dataset))
1104 'Found inconsistent dataset assignment in argFile setup: %s != %s' % (self.
_dataset, dataset))
1106 if len(newValue) == 0:
1108 elif len(newValue) != len (self.
_value):
1110 'Found partial dataset assignment in argFile setup from {0} (dsn#lfn notation must be uniform for all inputs)'.format(self.
_value))
1122 except OSError
as e:
1123 msg.error(
'Got exception {0!s} raised while stating file {1}'.format(e, fname))
1127 msg.debug(
'Calling ROOT TFile.GetSize({0})'.format(fname))
1138 with open(fname)
as f:
1141 chunk = len(f.read(1024*1024))
1142 msg.debug(
'Read {0} bytes from {1}'.format(chunk, fname))
1146 except OSError
as e:
1147 msg.error(
'Got exception {0!s} raised while checking integrity of file {1}'.format(e, fname))
1149 except UnicodeDecodeError:
1150 msg.debug(
'Problem reading file as unicode, attempting with binary')
1153 with open(fname,
'rb')
as f:
1156 chunk = len(f.read(1024*1024))
1157 msg.debug(
'Read {0} bytes from {1}'.format(chunk, fname))
1161 except OSError
as e:
1162 msg.error(
'Got exception {0!s} raised while checking integrity of file {1}'.format(e, fname))
1171 msg.debug(
'Generating a GUID for file {0}'.format(fname))
1182 msg.debug(
'Testing existance for {0}'.format(files))
1183 def split_filelist(fn):
1184 if self.
io !=
'output':
1186 file_split_regex = re.compile(
r"(.+)\[(.+)](.+)")
1187 if (
'[' in fn)
and (
']' in fn):
1188 match = file_split_regex.match(fn)
1189 return [f
"{match.group(1)}{it}{match.group(3)}" for it
in match.group(2).
split(
',')]
1193 file_list = split_filelist(fname)
1196 size =
map(
lambda fn: os.stat(fn).st_size, file_list)
1199 msg.debug(
'POSIX file {0} exists (or all elements of list)'.format(fname))
1200 except OSError
as e:
1201 msg.error(
'Got exception {0!s} raised while stating file {1} (or some element of list) - probably it does not exist'.format(e, fname))
1205 msg.debug(
'Calling ROOT TFile.GetSize on {0} (or elements of list)'.format(fname))
1206 size =
map(ROOTGetSize, file_list)
1209 msg.error(
'Non-POSIX file {0} (or element of list) could not be opened - probably it does not exist'.format(fname))
1211 msg.debug(
'Non-POSIX file {0} (or all elements of list) exists'.format(fname))
1227 for arg
in copyArgs:
1229 myargdict[arg] = copy.copy(argdict[arg])
1232 myargdict = copy.copy(argdict)
1234 myargdict[
'checkEventCount'] =
argSubstepBool(
'False', runarg=
False)
1236 if 'athenaopts' in myargdict:
1239 for subStep
in myargdict[
'athenaopts'].value:
1242 for opt
in myargdict[
'athenaopts'].value[subStep]:
1243 if opt.startswith(
'--nprocs'):
1247 elif opt.startswith(
'--threads'):
1253 if hasNprocs
and hasNthreads:
1256 if opt.startswith(
'--threads'):
1265 def __init__(self, value=list(), io =
'output', type=
None, splitter=
',', runarg=
True, multipleOK=
None, name=
None):
1266 super(argYODAFile, self).
__init__(value=value, io=io, type=type, splitter=splitter, runarg=runarg, multipleOK=multipleOK,
1272 'lheSumOfNegWeights': 0,
1276 msg.debug(
'Retrieving event count for LHE file {0}'.format(files))
1281 tar = tarfile.open(fname,
"r:gz")
1283 for untar
in tar.getmembers():
1284 fileTXT = tar.extractfile(untar)
1285 if fileTXT
is not None :
1286 lines = fileTXT.read().decode(
"utf-8")
1287 lhecount = lines.count(
'/event')
1291 msg.debug(
'Entries is set to None - event count undefined for this LHE')
1295 msg.debug(
'Retrieving weight count for LHE file {0}'.format(files))
1303 tar = tarfile.open(fname,
"r:gz")
1304 for untar
in tar.getmembers():
1305 fileTXT = tar.extractfile(untar)
1307 if fileTXT
is not None :
1308 for line
in fileTXT :
1309 line = line.decode(
"utf-8")
1312 w = float(re.sub(
' +',
' ',line).
split(
" ")[2])
1313 if w > 0 : weightPos += w
1314 else : weightNeg += abs(w)
1318 if "<event" in line :
1324 msg.debug(
'Entries is set to None - negative fraction count undefined for this LHE')
1331 def __init__(self, value = list(), type=
None, subtype=
None, io =
'output', splitter=
',', runarg=
True, multipleOK =
None,
1332 name=
None, executor=list(), mergeTargetSize=-1, auxiliaryFile=
False):
1333 super(argAthenaFile, self).
__init__(value=value, subtype=subtype, io=io, type=type, splitter=splitter, runarg=runarg,
1334 multipleOK=multipleOK, name=name, executor=executor, mergeTargetSize=mergeTargetSize,
1335 auxiliaryFile=auxiliaryFile)
1338 for key
in athFileInterestingKeys:
1347 msg.debug(
'Will retrieve metadata info for {0!s}'.format(myFiles))
1355 for fname
in myFiles:
1356 athFileMetadata = AthenaLiteFileInfo(fname, aftype, retrieveKeys=retrieveKeys)
1357 if athFileMetadata
is None:
1359 msg.debug(
'Setting metadata for file {0} to {1}'.format(fname, athFileMetadata[fname]))
1364 self.
_callAthInfo(files, doAllFiles =
True, retrieveKeys=athFileInterestingKeys)
1368 desc=super(argAthenaFile, self).prodsysDescription
1375 integrityFunction =
"returnIntegrityOfBSFile"
1380 rc=call([
"AtlListBSEvents",
"-c", fname], logger=msg, message=
"Report by AtlListBSEvents: ", timeout=600)
1390 desc=super(argBSFile, self).prodsysDescription
1401 msg.debug(
'selfMerge attempted for {0} -> {1} with {2} (index {3})'.format(inputs, output, argdict, counter))
1404 for fname
in inputs:
1407 "File {0} is not part of this agument: {1}".format(fname, self))
1413 myargdict[
'maskEmptyInputs'] =
argBool(
True)
1414 myargdict[
'allowRename'] =
argBool(
True)
1415 myargdict[
'emptyStubFile'] =
argString(inputs[0])
1420 myDataDictionary = {
'BS_MRG_INPUT' :
argBSFile(inputs, type=self.
type, io=
'input'),
1421 'BS_MRG_OUTPUT' :
argBSFile(output, type=self.
type, io=
'output')}
1422 myMergeConf = executorConfig(myargdict, myDataDictionary)
1423 myMerger = bsMergeExecutor(name=
'BSMergeAthenaMP{0}{1}'.format(self.
_subtype, counter), conf=myMergeConf, exe =
'file_merging',
1424 inData=
set([
'BS_MRG_INPUT']), outData=
set([
'BS_MRG_OUTPUT']))
1425 myMerger.doAll(input=
set([
'BS_MRG_INPUT']), output=
set([
'BS_MRG_OUTPUT']))
1429 for fname
in inputs:
1430 self.
_value.remove(fname)
1433 msg.debug(
'Post self-merge files are: {0}'.format(self.
_value))
1442 integrityFunction =
"returnIntegrityOfPOOLFile"
1448 from PyJobTransforms.trfValidateRootFile
import checkFile
1449 rc=
checkFile(fileName=fname, the_type=
'event', requireTree=
False)
1457 desc=super(argPOOLFile, self).prodsysDescription
1466 msg.debug(
'selfMerge attempted for {0} -> {1} with {2}'.format(inputs, output, argdict))
1469 for fname
in inputs:
1472 "File {0} is not part of this agument: {1}".format(fname, self))
1482 myDataDictionary = {
'POOL_MRG_INPUT' :
argPOOLFile(inputs, type=self.
type, io=
'input'),
1484 myMergeConf = executorConfig(myargdict, myDataDictionary)
1485 myMerger = athenaExecutor(name=
'POOLMergeAthenaMP{0}{1}'.format(self.
_subtype, counter), conf=myMergeConf,
1486 skeletonCA =
'RecJobTransforms.MergePool_Skeleton',
1487 inData=
set([
'POOL_MRG_INPUT']), outData=
set([
'POOL_MRG_OUTPUT']),
1488 disableMT=
True, disableMP=
True)
1489 myMerger.doAll(input=
set([
'POOL_MRG_INPUT']), output=
set([
'POOL_MRG_OUTPUT']))
1493 for fname
in inputs:
1494 self.
_value.remove(fname)
1497 msg.debug(
'Post self-merge files are: {0}'.format(self.
_value))
1503 integrityFunction =
"returnIntegrityOfPOOLFile"
1507 msg.debug(
'selfMerge attempted for {0} -> {1} with {2}'.format(inputs, output, argdict))
1510 for fname
in inputs:
1513 "File {0} is not part of this agument: {1}".format(fname, self))
1516 mySubstepName =
'HITSMergeAthenaMP{0}'.format(counter)
1520 myDataDictionary = {
'HITS' :
argHITSFile(inputs, type=self.
type, io=
'input'),
1522 myMergeConf = executorConfig(myargdict, myDataDictionary)
1523 myMerger = athenaExecutor(name = mySubstepName,
1524 skeletonCA =
'SimuJobTransforms.HITSMerge_Skeleton',
1526 inData=
set([
'HITS']), outData=
set([
'HITS_MRG']),
1527 disableMT=
False, disableMP=
True)
1528 myMerger.doAll(input=
set([
'HITS']), output=
set([
'HITS_MRG']))
1532 for fname
in inputs:
1533 self.
_value.remove(fname)
1536 msg.debug(
'Post self-merge files are: {0}'.format(self.
_value))
1543 integrityFunction =
"returnIntegrityOfPOOLFile"
1547 msg.debug(
'selfMerge attempted for {0} -> {1} with {2}'.format(inputs, output, argdict))
1550 for fname
in inputs:
1553 "File {0} is not part of this agument: {1}".format(fname, self))
1556 mySubstepName =
'EVNT_TRMergeAthenaMP{0}'.format(counter)
1562 myMergeConf = executorConfig(myargdict, myDataDictionary)
1563 myMerger = athenaExecutor(name = mySubstepName, skeletonFile =
'SimuJobTransforms/skeleton.EVNT_TRMerge.py',
1565 inData=
set([
'EVNT_TR']), outData=
set([
'EVNT_TR_MRG']),
1566 disableMT=
False, disableMP=
True)
1567 myMerger.doAll(input=
set([
'EVNT_TR']), output=
set([
'EVNT_TR_MRG']))
1571 for fname
in inputs:
1572 self.
_value.remove(fname)
1575 msg.debug(
'Post self-merge files are: {0}'.format(self.
_value))
1582 integrityFunction =
"returnIntegrityOfPOOLFile"
1586 msg.debug(
'selfMerge attempted for {0} -> {1} with {2}'.format(inputs, output, argdict))
1589 for fname
in inputs:
1592 "File {0} is not part of this agument: {1}".format(fname, self))
1598 myDataDictionary = {
'RDO' :
argHITSFile(inputs, type=self.
type, io=
'input'),
1600 myMergeConf = executorConfig(myargdict, myDataDictionary)
1601 myMerger = athenaExecutor(name =
'RDOMergeAthenaMP{0}'.format(counter),
1602 skeletonCA =
'SimuJobTransforms.RDOMerge_Skeleton',
1604 inData=
set([
'RDO']), outData=
set([
'RDO_MRG']),
1605 disableMT=
False, disableMP=
True)
1606 myMerger.doAll(input=
set([
'RDO']), output=
set([
'RDO_MRG']))
1610 for fname
in inputs:
1611 self.
_value.remove(fname)
1614 msg.debug(
'Post self-merge files are: {0}'.format(self.
_value))
1620 integrityFunction =
"returnIntegrityOfPOOLFile"
1624 msg.debug(
'selfMerge attempted for {0} -> {1} with {2}'.format(inputs, output, argdict))
1627 for fname
in inputs:
1630 "File {0} is not part of this agument: {1}".format(fname, self))
1633 mySubstepName =
'EVNTMergeAthenaMP{0}'.format(counter)
1637 myDataDictionary = {
'EVNT' :
argEVNTFile(inputs, type=self.
type, io=
'input'),
1639 myMergeConf = executorConfig(myargdict, myDataDictionary)
1640 myMerger = athenaExecutor(name = mySubstepName, skeletonCA =
'EvgenJobTransforms.EVNTMerge_Skeleton',
1642 inData=
set([
'EVNT']), outData=
set([
'EVNT_MRG']),
1643 disableMT=
False, disableMP=
True)
1644 myMerger.doAll(input=
set([
'EVNT']), output=
set([
'EVNT_MRG']))
1648 for fname
in inputs:
1649 self.
_value.remove(fname)
1652 msg.debug(
'Post self-merge files are: {0}'.format(self.
_value))
1660 integrityFunction =
"returnIntegrityOfHISTFile"
1662 def __init__(self, value=list(), io =
'output', type=
None, subtype=
None, splitter=
',', runarg=
True, countable=
True, multipleOK =
None,
1663 name=
None, auxiliaryFile=
False):
1664 super(argHISTFile, self).
__init__(value=value, io=io, type=type, subtype=subtype, splitter=splitter, runarg=runarg, multipleOK=multipleOK,
1665 name=name, auxiliaryFile=auxiliaryFile)
1684 msg.error(
'Timeout counting events for {0}'.format(fname))
1688 desc=super(argHISTFile, self).prodsysDescription
1696 integrityFunction =
"returnIntegrityOfNTUPFile"
1701 def __init__(self, value=list(), io =
'output', type=
None, subtype=
None, splitter=
',', treeNames=
None, runarg=
True, multipleOK =
None,
1702 name=
None, mergeTargetSize=-1, auxiliaryFile=
False):
1703 super(argNTUPFile, self).
__init__(value=value, io=io, type=type, subtype=subtype, splitter=splitter, runarg=runarg, multipleOK=multipleOK,
1704 name=name, mergeTargetSize=mergeTargetSize, auxiliaryFile=auxiliaryFile)
1713 if name
and 'NTUP_PILEUP' in name:
1719 msg.debug(
'Retrieving event count for NTUP files {0}'.format(files))
1723 myPRWEntries = PRWEntries(fileName=fname)
1724 if myPRWEntries
is not None:
1727 myPRWEntries = PRWEntries(fileName=fname, integral=
True)
1731 myPHYSVALEntries = PHYSVALEntries(fileName=fname)
1732 if myPHYSVALEntries
is not None:
1734 if self.
name and 'NTUP_PHYSVAL' in self.
name:
1735 myPHYSVALEntries = PHYSVALEntries(fileName=fname, integral=
True)
1736 self.
_fileMetadata[fname][
'sumOfWeights'] = myPHYSVALEntries
1738 msg.debug(
'treeNames is set to None - event count undefined for this NTUP')
1745 msg.error(
'Timeout counting events for {0}'.format(fname))
1750 from PyJobTransforms.trfValidateRootFile
import checkFile
1751 rc=
checkFile(fileName=fname, the_type=
'basket', requireTree=
False)
1759 msg.debug(
'selfMerge attempted for {0} -> {1} with {2}'.format(inputs, output, argdict))
1762 for fname
in inputs:
1765 "File {0} is not part of this agument: {1}".format(fname, self))
1773 myDataDictionary = {
'NTUP_MRG_INPUT' :
argNTUPFile(inputs, type=self.
type, io=
'input'),
1775 myMergeConf = executorConfig(myargdict, myDataDictionary)
1776 myMerger = NTUPMergeExecutor(name=
'NTUPMergeAthenaMP{0}{1}'.format(self.
_subtype, counter), conf=myMergeConf,
1777 inData=
set([
'NTUP_MRG_INPUT']), outData=
set([
'NTUP_MRG_OUTPUT']))
1778 myMerger.doAll(input=
set([
'NTUP_MRG_INPUT']), output=
set([
'NYUP_MRG_OUTPUT']))
1782 for fname
in inputs:
1783 self.
_value.remove(fname)
1786 msg.debug(
'Post self-merge files are: {0}'.format(self.
_value))
1792 desc=super(argNTUPFile, self).prodsysDescription
1803 f = bz2.BZ2File(fname,
'r')
1805 chunk = len(f.read(1024*1024))
1806 msg.debug(
'Read {0} bytes from {1}'.format(chunk, fname))
1811 except OSError
as e:
1812 msg.error(
'Got exception {0!s} raised while checking integrity of file {1}'.format(e, fname))
1818 desc=super(argBZ2File, self).prodsysDescription
1824 def __init__(self, value=list(), io =
'output', type=
None, splitter=
',', runarg=
True, multipleOK=
None, name=
None):
1825 super(argFTKIPFile, self).
__init__(value=value, io=io, type=type, splitter=splitter, runarg=runarg, multipleOK=multipleOK,
1835 f = bz2.BZ2File(fname,
'r')
1837 if line.startswith(
'F'):
1840 except OSError
as e:
1841 msg.error(
'Event count for file {0} failed: {1!s}'.format(fname, e))
1846 desc=super(argFTKIPFile, self).prodsysDescription
1852 def __init__(self, value=list(), io =
'output', type=
'txt_evt', splitter=
',', runarg=
True, multipleOK=
None, name=
None):
1853 super(argHepEvtAsciiFile, self).
__init__(value=value, io=io, type=type, splitter=splitter, runarg=runarg,
1854 multipleOK=multipleOK, name=name)
1864 if '.tar.gz' in fname
or '.tgz' in fname:
1866 with tarfile.open(fname,
"r:gz")
as tar:
1867 for untar
in tar.getmembers():
1868 fileTXT = tar.extractfile(untar)
1869 if fileTXT
is not None:
1871 for aline
in fileTXT:
1872 if aline.startswith(b
'E '):
1874 elif '.gz' in fname:
1876 with gzip.open(fname,
'rb')
as gzin:
1878 if aline.startswith(b
'E '):
1882 with open(fname,
'r')
as infile:
1883 for aline
in infile:
1884 if aline.startswith(
'E '):
1887 except OSError
as e:
1888 msg.error(
'Event count for file {0} failed: {1!s}'.format(fname, e))
1893 def __init__(self, value=list(), io =
'output', type=
None, splitter=
',', runarg=
True, multipleOK=
None, name=
None):
1894 super(argLHEFile, self).
__init__(value=value, io=io, type=type, splitter=splitter, runarg=runarg, multipleOK=multipleOK,
1900 'lheSumOfNegWeights': 0,
1904 msg.debug(
'Retrieving event count for LHE file {0}'.format(files))
1909 tar = tarfile.open(fname,
"r:gz")
1911 for untar
in tar.getmembers():
1912 fileTXT = tar.extractfile(untar)
1913 if fileTXT
is not None :
1914 lines = fileTXT.read().decode(
"utf-8")
1915 lhecount = lines.count(
'/event')
1919 msg.debug(
'Entries is set to None - event count undefined for this LHE')
1923 msg.debug(
'Retrieving weight count for LHE file {0}'.format(files))
1931 tar = tarfile.open(fname,
"r:gz")
1932 for untar
in tar.getmembers():
1933 fileTXT = tar.extractfile(untar)
1935 if fileTXT
is not None :
1936 lines = fileTXT.readlines()
1940 w = float(re.sub(
' +',
' ',line).
split(
" ")[2])
1941 if w > 0 : weightPos += w
1942 else : weightNeg += abs(w)
1946 if "<event" in line :
1952 msg.debug(
'Entries is set to None - negative fraction count undefined for this LHE')
1953 self.
_fileMetadata[fname][
'lheSumOfPosWeights'] =
'UNDEFINED'
1954 self.
_fileMetadata[fname][
'lheSumOfNegWeights'] =
'UNDEFINED'
1965 def __init__(self, value = None, runarg = True, name = None, defaultSubstep = 'all', separator = ':
'):
1968 super(argSubstep, self).__init__(value, runarg, name)
1978 msg.debug(
'Attempting to set argSubstep from {0!s} (type {1}'.format(value,
type(value)))
1981 elif isinstance(value, str):
1983 elif isinstance(value, (list, tuple)):
1987 if not isinstance(item, str):
1990 elif isinstance(value, dict):
2002 subStepMatch = re.match(
r'([a-zA-Z0-9,]+)' + self.
_separator +
r'(.*)', string)
2005 subStep = subStepMatch.group(1).
split(
',')
2006 subStepValue = subStepMatch.group(2)
2009 subStepValue = string
2010 msg.debug(
'Parsed {0} as substep {1}, argument {2}'.format(string, subStep, subStepValue))
2011 for step
in subStep:
2012 subStepList.append((step, subStepValue))
2024 substep = exe.substep
2025 first = exe.conf.firstExecutor
2027 name = commonExecutorStepName(name)
2032 value = self.
_value[name]
2033 elif substep
in self.
_value:
2034 value = self.
_value[substep]
2035 elif first
and 'first' in self.
_value:
2036 value = self.
_value[
'first']
2037 elif 'default' in self.
_value:
2038 value = self.
_value[
'default']
2050 value = self.
_value[
'all']
2051 elif isinstance(value, list):
2052 value = self.
_value[
'all'] + value
2054 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))
2060 desc = {
'type':
'substep',
'substeptype':
'str',
'separator': self.
_separator,
2075 def __init__(self, value = None, runarg = True, name = None, defaultSubstep = 'all', splitter = None, separator=':
'):
2077 super(argSubstepList, self).__init__(value, runarg, name, defaultSubstep, separator)
2087 desc = {
'type':
'substep',
'substeptype':
'list',
'listtype':
'str',
2093 msg.debug(
'Attempting to set argSubstep from {0!s} (type {1}'.format(value,
type(value)))
2096 elif isinstance(value, str):
2098 elif isinstance(value, (list, tuple)):
2102 if not isinstance(item, str):
2105 for subStep
in subStepList:
2106 if subStep[0]
in self.
_value:
2107 self.
_value[subStep[0]].extend(subStep[1])
2109 self.
_value[subStep[0]] = subStep[1]
2110 elif isinstance(value, dict):
2111 for k, v
in value.items():
2112 if not isinstance(k, str):
2114 if not isinstance(v, list):
2125 subStepList = [(s[0], s[1].
split(self.
_splitter))
for s
in subStepList]
2127 subStepList = [(s[0], [s[1]])
for s
in subStepList]
2140 desc = {
'type':
'substep',
'substeptype':
'str',
'separator': self.
_separator,
2146 msg.debug(
'Attempting to set argSubstep from {0!s} (type {1}'.format(value,
type(value)))
2149 elif isinstance(value, str):
2151 self.
_value = dict([(subStep[0], subStep[1])
for subStep
in subStepList])
2152 elif isinstance(value, (list, tuple)):
2156 if not isinstance(item, str):
2159 for subStep
in subStepList:
2160 self.
_value[subStep[0]] = subStep[1]
2161 elif isinstance(value, dict):
2162 for k, v
in value.items():
2163 if not isinstance(k, str):
2165 if not isinstance(v, str):
2181 desc = {
'type':
'substep',
'substeptype':
'bool',
'separator': self.
_separator,
2187 msg.debug(
'Attempting to set argSubstep from {0!s} (type {1})'.format(value,
type(value)))
2190 elif isinstance(value, bool):
2192 elif isinstance(value, str):
2194 self.
_value = dict([(subStep[0],
strToBool(subStep[1]))
for subStep
in subStepList])
2195 elif isinstance(value, (list, tuple)):
2199 if not isinstance(item, str):
2202 for subStep
in subStepList:
2204 elif isinstance(value, dict):
2205 for k, v
in value.items():
2206 if not isinstance(k, str):
2208 if not isinstance(v, bool):
2225 desc = {
'type':
'substep',
'substeptype':
'int',
'separator': self.
_separator,
2231 msg.debug(
'Attempting to set argSubstep from {0!s} (type {1}'.format(value,
type(value)))
2235 elif isinstance(value, int):
2237 elif isinstance(value, str):
2239 self.
_value = dict([(subStep[0], int(subStep[1]))
for subStep
in subStepList])
2240 elif isinstance(value, (list, tuple)):
2244 if not isinstance(item, str):
2247 for subStep
in subStepList:
2248 self.
_value[subStep[0]] = int(subStep[1])
2249 elif isinstance(value, dict):
2250 for k, v
in value.items():
2251 if not isinstance(k, str):
2253 if not isinstance(v, int):
2266 def __init__(self, value=None, min=None, max=None, runarg=True, name=None):
2269 super(argSubstepFloat, self).
__init__(value = value, runarg = runarg, name=name)
2273 desc = {
'type':
'substep',
'substeptype':
'float',
'separator': self.
_separator,
2276 desc[
'min'] = self.
_min
2278 desc[
'max'] = self.
_max
2289 msg.debug(
'Attempting to set argSubstep from {0!s} (type {1}'.format(value,
type(value)))
2293 elif isinstance(value, float):
2295 elif isinstance(value, str):
2297 self.
_value = dict([(subStep[0], float(subStep[1]))
for subStep
in subStepList])
2298 elif isinstance(value, (list, tuple)):
2302 if not isinstance(item, str):
2304 'Failed to convert list item {0!s} to substep (should be a string)'.format(item))
2306 for subStep
in subStepList:
2307 self.
_value[subStep[0]] = float(subStep[1])
2308 elif isinstance(value, dict):
2309 for k, v
in value.items():
2310 if not isinstance(k, str):
2312 'Dictionary key {0!s} for substep is not a string'.format(k))
2313 if not isinstance(v, float):
2315 'Dictionary value {0!s} for substep is not an float'.format(v))
2319 'Setter value {0!s} (type {1}) for substep argument cannot be parsed'.format(value,
type(value)))
2321 for my_float
in self.
_value.values():
2322 if (self.
_min is not None and my_float < self.
_min)
or (self.
_max is not None and my_float > self.
_max):
2324 'argFloat value out of range: {0} is not between {1} and {2}'.format(my_float, self.
_min, self.
_max))
2325 except ValueError
as e:
2327 'Failed to convert substep value {0} to float: {1}'.format(value, e))
2343 'doRDO_TRIG': {
'RAWtoALL': [(
'in',
'-',
'RDO'), (
'in',
'+',
'RDO_TRIG'), (
'in',
'-',
'BS')]},
2344 'doOverlay': {
'HITtoRDO': [(
'in',
'-',
'HITS'), (
'out',
'-',
'RDO'), (
'out',
'-',
'RDO_FILT')],
2345 'Overlay': [(
'in',
'+', (
'HITS',
'RDO_BKG')), (
'out',
'+',
'RDO')]},
2346 'doFCtoDAOD': {
'Derivation': [(
'in',
'-',
'EVNT')]},
2347 'afterburn': {
'generate': [(
'out',
'-',
'EVNT')]},
2365 desc = {
'type':
'substep',
'substeptype':
'steering',
'listtype':
'str',
'separator': self.
_separator,
2374 msg.debug(
'Attempting to set argSubstepSteering from {0!s} (type {1})'.format(value,
type(value)))
2378 elif isinstance(value, dict):
2380 for k, v
in value.items():
2381 if not isinstance(k, str)
or not isinstance(v, list):
2383 'Failed to convert dict {0!s} to argSubstepSteering'.format(value))
2385 if not isinstance(subv, (list, tuple))
or len(subv) != 3
or subv[0]
not in (
'in',
'out')
or subv[1]
not in (
'+',
'-'):
2387 'Failed to convert dict {0!s} to argSubstepSteering'.format(value))
2393 self.
_dumpvalue = getattr(self,
"_dumpvalue", value)
2394 elif isinstance(value, (str, list, tuple)):
2395 if isinstance(value, str):
2397 self.
_dumpvalue = getattr(self,
"_dumpvalue", value)
2401 if not isinstance(item, str):
2403 'Failed to convert list item {0!s} to substep (should be a string)'.format(item))
2404 if item
in argSubstepSteering.steeringAlises:
2405 msg.debug(
"Found value {0} in steeringAlises ({1})".format(item, argSubstepSteering.steeringAlises[item]))
2406 for substep, steerlist
in argSubstepSteering.steeringAlises[item].items():
2407 if substep
in self.
_value:
2408 self.
_value[substep].extend(steerlist)
2410 self.
_value[substep] = steerlist
2416 'Setter value {0!s} (type {1}) for substep argument cannot be parsed'.format(value,
type(value)))
2419 if string
in argSubstepSteering.steeringAlises:
2420 return argSubstepSteering.steeringAlises[string]
2424 for subvalue
in ivalue.split(
','):
2425 matchedParts = re.match(
r'(in|out)(\+|\-)([A-Z_]+)$', subvalue)
2426 if not matchedParts:
2428 'Failed to convert string {0!s} to argSubstepSteering'.format(subvalue))
2429 retvalue.append((matchedParts.group(1), matchedParts.group(2), matchedParts.group(3)))
2441 msg.debug(
'Attempting to set argSubstepConditions from {0!s} (type {1}'.format(value,
type(value)))
2446 for k, v
in self.
_value.items():
2447 if "CurrentMC" == v:
2453 cmd =
"COMAGetGlobalTagNameByCurrentState --state=CurrentMC"
2454 return str(client.execute(cmd, format =
'dom_object').get_rows().pop()[
'globalTag'])
2458 desc = {
'type':
'substep',
'substeptype':
'str',
'separator': self.
_separator,
2476 super(trfArgParser, self).
__init__(*args, **kwargs)
2479 argName = args[0].lstrip(
'-')
2480 msg.debug(
'Found arg name {0}'.format(argName))
2486 'Transform arguments may not use hyphens (use camelCase or underscore')
2491 msg.debug(
'Double definition of argument {0} - ignored'.format(argName))
2495 if 'help' in kwargs:
2499 if 'action' in kwargs
and 'factory' in dir(kwargs[
'action']):
2500 self.
_argClass[argName] = kwargs[
'action'].factory
2501 elif 'type' in kwargs:
2502 self.
_argClass[argName] = kwargs[
'type']
2508 for arg
in (
'group',):
2510 strippedArgs[arg] = kwargs.pop(arg)
2514 for i
in range(1, len(args)):
2515 argAlias = args[i].lstrip(
'-')
2516 msg.debug(
'Adding an alias of {0}: {1}'.format(argName, argAlias))
2520 if 'group' in strippedArgs:
2522 msg.debug(
'Adding argument to group {0}: ({1}; {2})'.format(strippedArgs[
'group'], args, kwargs))
2526 msg.warning(
'Argument group {0} not defined - adding argument to main parser'.format(strippedArgs[
'group']))
2527 msg.debug(
'Adding argument: ({0}; {1})'.format(args, kwargs))
2528 super(trfArgParser, self).
add_argument(*args, **kwargs)
2530 msg.debug(
'Adding argument: ({0}; {1})'.format(args, kwargs))
2531 super(trfArgParser, self).
add_argument(*args, **kwargs)
2536 for name, argClass
in self.
_argClass.items():
2537 msg.debug(
'Detected the local variable {0}'.format(name))
2538 if argClass
is not None:
2539 desc[name] = argClass().prodsysDescription
2541 desc[name].update({
'help': self.
_helpString[name]})
2550 msg.warning(
'Argument group %s already exists', args[0])
2552 self.
_argGroups[args[0]] = self.add_argument_group(*args)
2565 keyArray = [
'--' + str(key)
for key
in self.
_helpString if key
not in (
'h',
'verbose',
'loglevel',
'dumpargs',
'argdict') ]
2567 print(
'ListOfDefaultPositionalKeys={0}'.format(keyArray))
2579 newValueObj = value[0]
2580 msg.debug(
'Started with: %s = %s',
type(newValueObj), newValueObj)
2581 if isinstance(value[0], argSubstep):
2584 elif isinstance(value[0], list):
2587 msg.debug(
'Handling a list of arguments for key')
2591 processedValueObj.value = processedValues
2592 newValues.append(processedValueObj)
2593 newValueObj = newValues
2594 return newValueObj, newValues
2595 elif isinstance(value[0].value, list):
2596 newValues = value[0].value
2597 elif isinstance(value[0].value, dict):
2598 newValues = value[0].value
2600 newValues = [value[0].value,]
2601 for valueObj
in value[1:]:
2602 msg.debug(
'Value Object: %s = %s',
type(valueObj), valueObj)
2603 if isinstance(value[0], argSubstep):
2606 elif isinstance(valueObj.value, list):
2608 newValues.extend(valueObj.value)
2609 elif isinstance(valueObj.value, dict):
2611 newValues.update(valueObj.value)
2613 newValues.append(valueObj.value)
2614 return newValueObj, newValues
2623 super(trfArgParser, self).
parse_args(args = args, namespace = namespace)
2625 namespace = super(trfArgParser, self).
parse_args(args = args)
2626 for k, v
in namespace.__dict__.items():
2627 msg.debug(
'Treating key %s (%s)', k, v)
2628 if isinstance(v, list):
2630 if not isinstance(newValueObj, list):
2631 newValueObj.value = newValues
2632 namespace.__dict__[k] = newValueObj
2633 msg.debug(
'Set to %s', newValues)
2641 msg.debug(
"converting string {string} to boolean".format(string = string))
2642 if string.lower() ==
'false':
2644 elif string.lower() ==
'true':
2648 except AttributeError:
2662 allKeys =
set(dict1) |
set(dict2)
2666 if isinstance(list(dict1.values())[0], list):
2668 elif len(dict2) > 0:
2669 if isinstance(list(dict2.values())[0], list):
2673 mergeDict[key] = dict1.get(key, []) + dict2.get(key, [])
2676 if key
in dict1
and key
in dict2:
2678 if dict1[key] != dict2[key]:
2680 'Merging substep arguments found clashing values for substep {0}: {1}!={2}'.format(key, dict1[key], dict2[key]))
2681 mergeDict[key] = dict1[key]
2683 mergeDict[key] = dict1[key]
2685 mergeDict[key] = dict2[key]
void print(char *figname, TCanvas *c1)
Factory class used to generate argparse actions, actions should be used when arguments are used witho...
__call__(self, option_strings, dest, **kwargs)
__init__(self, genclass, *args, **kwargs)
__init__(self, factory, option_strings, dest, **kwargs)
__call__(self, parser, namespace, values, option_string=None)
_callAthInfo(self, files, doAllFiles, retrieveKeys)
Workhorse which actually calls Meta Reader.
__init__(self, value=list(), type=None, subtype=None, io='output', splitter=',', runarg=True, multipleOK=None, name=None, executor=list(), mergeTargetSize=-1, auxiliaryFile=False)
_getAthInfo(self, files)
Small wrapper which sets the standard options for doAllFiles and retrieveKeys.
_getIntegrity(self, files)
File integrity checker.
selfMerge(self, output, inputs, counter=0, argdict={})
Method which can be used to merge files of this type.
_getIntegrity(self, files)
File integrity checker.
selfMerge(self, output, inputs, counter=0, argdict={})
Method which can be used to merge EVNT files.
selfMerge(self, output, inputs, counter=0, argdict={})
Method which can be used to merge EVNT_TR files.
Class which defines a special input file format used in FTK simulation.
_getNumberOfEvents(self, files)
__init__(self, value=list(), io='output', type=None, splitter=',', runarg=True, multipleOK=None, name=None)
Factory class used to generate argument class instances for argparse.
__call__(self, valueString=None)
__init__(self, genclass, *args, **kwargs)
_getDatasetFromFilename(self, reset=False)
Look for dataset name in dataset.filename Tier0 convention.
_resetMetadata(self, files=[])
Resets all metadata files in this instance.
_readMetadata(self, files, metadataKeys)
Check metadata is in the cache or generate it if it's missing.
_getSize(self, files)
Determines the size of files.
mergeTargetSize(self)
mergeTargeSize value getter
getMetadata(self, files=None, metadataKeys=None, maskMetadataKeys=None, populate=True, flush=False)
Return specific keys for specific files.
_exists(self, files)
Try to determine if a file actually exists...
getSingleMetadata(self, fname, metadataKey, populate=True, flush=False)
Convenience function to extract a single metadata key for a single file.
_generateGUID(self, files)
Generate a GUID on demand - no intrinsic for this file type.
multipleOK(self)
multipleOK getter
str _urlType
Input file globbing and expansion.
executor(self)
Executor status getter.
_getIntegrity(self, files)
File integrity checker.
__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.
_setMetadata(self, files=None, metadataKeys={})
Set metadata values into the cache.
nentries(self)
Return total number of events in all constituent files.
__str__(self)
String representation of a file argument.
originalName(self, value)
isCached(self, files=None, metadataKeys=None)
Test if certain metadata elements are already cached.
getnentries(self, fast=False)
Explicit getter, offering fast switch.
_mergeArgs(self, argdict, copyArgs=None)
Utility to strip arguments which should not be passed to the selfMerge methods of our child classes.
str _io
Input file globbing and expansion.
metadata(self)
Returns the whole kit and kaboodle...
valueSetter(self, value)
Set the argFile value, but allow parameters here.
__init__(self, value=None, min=None, max=None, runarg=True, name=None)
Float argument constructor.
Data quality histogram file class.
__init__(self, value=list(), io='output', type=None, subtype=None, splitter=',', runarg=True, countable=True, multipleOK=None, name=None, auxiliaryFile=False)
_getNumberOfEvents(self, files)
_getIntegrity(self, files)
There is no integrity check for HIST files - return 'UNDEFINED'.
selfMerge(self, output, inputs, counter=0, argdict={})
Method which can be used to merge HITS files.
_getNumberOfEvents(self, files)
__init__(self, value=list(), io='output', type='txt_evt', splitter=',', runarg=True, multipleOK=None, name=None)
__init__(self, value={}, supressEmptyStrings=True, splitter=',', kvsplitter=":", runarg=True, name=None)
Dictionary of key value arguments, where the values are floats.
__init__(self, value=list(), io='output', type=None, splitter=',', runarg=True, multipleOK=None, name=None)
List of string arguments.
__init__(self, value=[], supressEmptyStrings=True, splitter=',', runarg=True, name=None)
List of string arguments.
__str__(self)
String conversion.
append(self, addme)
Append a value to the list.
__repr__(self)
Repr conversion.
NTUP (plain ROOT) file class.
selfMerge(self, output, inputs, counter=0, argdict={})
__init__(self, value=list(), io='output', type=None, subtype=None, splitter=',', treeNames=None, runarg=True, multipleOK=None, name=None, mergeTargetSize=-1, auxiliaryFile=False)
selfMerge(self, output, inputs, counter=0, argdict={})
Method which can be used to merge files of this type.
_getIntegrity(self, files)
File integrity checker.
selfMerge(self, output, inputs, counter=0, argdict={})
Method which can be used to merge RDO files.
choices(self)
Choices getter.
__init__(self, value=None, runarg=True, name=None, choices=None)
Class initialisation.
Boolean substep argument.
Substep class for conditionsTag.
__init__(self, value=None, min=None, max=None, runarg=True, name=None)
Argument class for substep lists, suitable for preExec/postExec.
__init__(self, value=None, runarg=True, name=None, defaultSubstep='all', splitter=None, separator=':')
argSubstepList constructor
_parseStringAsSubstep(self, value)
Specialist parser for lists, which applies the splitter string, if defined.
Special argument class to hold steering information.
_parseSetterString(self, string)
_parseSteeringString(self, ivalue)
Base class for substep arguments.
_parseStringAsSubstep(self, string)
Parse a string for substep:value format.
returnMyValue(self, name=None, substep=None, first=False, exe=None)
Return the value of this substep arg for an executor with the given parameters.
__init__(self, value=None, runarg=True, name=None, defaultSubstep='all', separator=':')
argSubstep constructor
__init__(self, value=list(), io='output', type=None, splitter=',', runarg=True, multipleOK=None, name=None)
Basic argument class holding a value which can be get and set.
__repr__(self)
Repr conversion of our value.
__init__(self, value=None, runarg=True, name=None)
Initialise argument class.
__eq__(self, other)
Comparison is based on value attribute.
isRunarg(self)
Return runarg status.
__str__(self)
String conversion of our value.
_parse_list_helper(self, value)
defineArgGroup(self, *args)
Define an argparse argument group for the main parser to use.
getHelpString(self, argument)
Return the help string for a given argument.
allArgs(self)
Getter for argument list.
dumpArgs(self)
Return a list of all arguments understood by this transform in prodsys style.
add_argument(self, *args, **kwargs)
parse_args(self, args=None, namespace=None)
Call argument_parser parse_args, then concatenate values.
__init__(self, *args, **kwargs)
Subclassing argparse.
std::string replace(std::string s, const std::string &s2, const std::string &s3)
std::vector< std::string > split(const std::string &s, const std::string &t=":")
strToBool(string)
Small utility to convert a string value to a boolean.
dictSubstepMerge(dict1, dict2)
special dictionary merger which is used for substep type arguments