ATLAS Offline Software
Public Member Functions | Public Attributes | Private Member Functions | List of all members
python.PoolFile.DiffFiles Class Reference
Inheritance diagram for python.PoolFile.DiffFiles:
Collaboration diagram for python.PoolFile.DiffFiles:

Public Member Functions

def __init__ (self, refFileName, chkFileName, verbose=False, ignoreList=None, strict=False)
 
def status (self)
 
def printSummary (self, out=sys.stdout)
 

Public Attributes

 verbose
 
 strict
 
 refFile
 
 chkFile
 
 ignList
 
 allGood
 
 summary
 

Private Member Functions

def __checkDiff (self)
 

Detailed Description

A helper class to compare 2 POOL files and check that they match, both in
terms of containers' content and containers' sizes

Definition at line 989 of file PoolFile.py.

Constructor & Destructor Documentation

◆ __init__()

def python.PoolFile.DiffFiles.__init__ (   self,
  refFileName,
  chkFileName,
  verbose = False,
  ignoreList = None,
  strict = False 
)

Definition at line 995 of file PoolFile.py.

995  def __init__(self, refFileName, chkFileName, verbose = False, ignoreList = None, strict = False):
996  object.__init__(self)
997 
998  self.verbose = verbose
999  self.strict = strict
1000  refFileName = os.path.expandvars( os.path.expanduser( refFileName ) )
1001  chkFileName = os.path.expandvars( os.path.expanduser( chkFileName ) )
1002 
1003  if ignoreList is None:
1004  ignoreList = []
1005 
1006  try:
1007  self.refFile = PoolFile( refFileName )
1008  self.chkFile = PoolFile( chkFileName )
1009  self.ignList = sorted( ignoreList )
1010  except Exception as err:
1011  print("## Caught exception [%s] !!" % str(err.__class__))
1012  print("## What:",err)
1013  print(sys.exc_info()[0])
1014  print(sys.exc_info()[1])
1015  err = "Error while opening POOL files !"
1016  err += " chk : %s%s" % ( chkFileName, os.linesep )
1017  err += " ref : %s%s" % ( refFileName, os.linesep )
1018  raise Exception(err)
1019 
1020  self.allGood = True
1021  self.summary = []
1022 
1023  self.__checkDiff()
1024  return
1025 

Member Function Documentation

◆ __checkDiff()

def python.PoolFile.DiffFiles.__checkDiff (   self)
private

Definition at line 1026 of file PoolFile.py.

1026  def __checkDiff(self):
1027 
1028  self.summary += [
1029  "=" * 80,
1030  "::: Comparing POOL files...",
1031  " ref : %s" % self.refFile._fileInfos['name'],
1032  " chk : %s" % self.chkFile._fileInfos['name'],
1033  "-" * 80,
1034  ]
1035 
1036  if self.chkFile.dataHeader.nEntries != \
1037  self.refFile.dataHeader.nEntries :
1038  self.summary += [
1039  "## WARNING: files don't have the same number of entries !!",
1040  " ref : %r" % self.refFile.dataHeader.nEntries,
1041  " chk : %r" % self.chkFile.dataHeader.nEntries,
1042  ]
1043 
1044  refNames = sorted( [d.name for d in self.refFile.data] )
1045  chkNames = sorted( [d.name for d in self.chkFile.data] )
1046 
1047  if chkNames != refNames:
1048  self.summary += [
1049  "## ERROR: files don't have the same content !!",
1050  ]
1051  addNames = [ n for n in chkNames if n not in refNames ]
1052  if len( addNames ) > 0:
1053  self.summary += [ "## collections in 'chk' and not in 'ref'" ]
1054  for n in addNames:
1055  self.summary += [ " + %s" % n ]
1056  subNames = [ n for n in refNames if n not in chkNames ]
1057  if len( subNames ) > 0:
1058  self.summary += [ "## collections in 'ref' and not in 'chk'" ]
1059  for n in subNames:
1060  self.summary += [ " - %s" % n ]
1061  self.allGood = False
1062  pass
1063 
1064  if len(self.ignList) > 0:
1065  self.summary += [ "## Ignoring the following:" ]
1066  for n in self.ignList:
1067  self.summary += [ " %s" % n ]
1068 
1069  commonContent = [ d for d in chkNames if (d in refNames and d not in self.ignList)]
1070 
1071  if not self.allGood:
1072  self.summary += [ "=" * 80 ]
1073  self.summary += [ "::: comparing common content (mem-size / disk-size)..." ]
1074 
1075  for name in commonContent:
1076  chkMemSize = self.chkFile.poolRecord(name).memSize
1077  refMemSize = self.refFile.poolRecord(name).memSize
1078  chkDiskSize = self.chkFile.poolRecord(name).diskSize
1079  refDiskSize = self.refFile.poolRecord(name).diskSize
1080 
1081  if chkMemSize != refMemSize or (self.strict and chkDiskSize != refDiskSize):
1082  self.summary += [
1083  "[ERR] %12.3f / %12.3f kb (ref) ==> %12.3f / %12.3f kb (chk) | %s" % \
1084  ( refMemSize,refDiskSize,chkMemSize,chkDiskSize, name )
1085  ]
1086  self.allGood = False
1087  elif self.verbose:
1088  self.summary += [
1089  " [OK] %12.3f/%12.3f kb | %s" % \
1090  ( chkMemSize, chkDiskSize, name )
1091  ]
1092 
1093  self.summary += [ "=" * 80 ]
1094 
1095 
1096  if self.allGood: self.summary += [ "## Comparison : [OK]" ]
1097  else: self.summary += [ "## Comparison : [ERR]" ]
1098 
1099  return self.allGood
1100 

◆ printSummary()

def python.PoolFile.DiffFiles.printSummary (   self,
  out = sys.stdout 
)

Definition at line 1105 of file PoolFile.py.

1105  def printSummary(self, out = sys.stdout):
1106  for i in self.summary:
1107  out.writelines( i + os.linesep )
1108  pass
1109  return

◆ status()

def python.PoolFile.DiffFiles.status (   self)

Definition at line 1101 of file PoolFile.py.

1101  def status(self):
1102  if self.allGood: return 0
1103  else: return 1
1104 

Member Data Documentation

◆ allGood

python.PoolFile.DiffFiles.allGood

Definition at line 1020 of file PoolFile.py.

◆ chkFile

python.PoolFile.DiffFiles.chkFile

Definition at line 1008 of file PoolFile.py.

◆ ignList

python.PoolFile.DiffFiles.ignList

Definition at line 1009 of file PoolFile.py.

◆ refFile

python.PoolFile.DiffFiles.refFile

Definition at line 1007 of file PoolFile.py.

◆ strict

python.PoolFile.DiffFiles.strict

Definition at line 999 of file PoolFile.py.

◆ summary

python.PoolFile.DiffFiles.summary

Definition at line 1021 of file PoolFile.py.

◆ verbose

python.PoolFile.DiffFiles.verbose

Definition at line 998 of file PoolFile.py.


The documentation for this class was generated from the following file:
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename R::value_type > sorted(const R &r, PROJ proj={})
Helper function to create a sorted vector from an unsorted range.
python.PoolFile.poolRecord
def poolRecord(self, name)
Definition: PoolFile.py:911
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
str
Definition: BTagTrackIpAccessor.cxx:11
merge.status
status
Definition: merge.py:16