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 957 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 963 of file PoolFile.py.

963  def __init__(self, refFileName, chkFileName, verbose = False, ignoreList = None, strict = False):
964  object.__init__(self)
965 
966  self.verbose = verbose
967  self.strict = strict
968  refFileName = os.path.expandvars( os.path.expanduser( refFileName ) )
969  chkFileName = os.path.expandvars( os.path.expanduser( chkFileName ) )
970 
971  if ignoreList is None:
972  ignoreList = []
973 
974  try:
975  self.refFile = PoolFile( refFileName )
976  self.chkFile = PoolFile( chkFileName )
977  self.ignList = sorted( ignoreList )
978  except Exception as err:
979  print("## Caught exception [%s] !!" % str(err.__class__))
980  print("## What:",err)
981  print(sys.exc_info()[0])
982  print(sys.exc_info()[1])
983  err = "Error while opening POOL files !"
984  err += " chk : %s%s" % ( chkFileName, os.linesep )
985  err += " ref : %s%s" % ( refFileName, os.linesep )
986  raise Exception(err)
987 
988  self.allGood = True
989  self.summary = []
990 
991  self.__checkDiff()
992  return
993 

Member Function Documentation

◆ __checkDiff()

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

Definition at line 994 of file PoolFile.py.

994  def __checkDiff(self):
995 
996  self.summary += [
997  "=" * 80,
998  "::: Comparing POOL files...",
999  " ref : %s" % self.refFile._fileInfos['name'],
1000  " chk : %s" % self.chkFile._fileInfos['name'],
1001  "-" * 80,
1002  ]
1003 
1004  if self.chkFile.dataHeader.nEntries != \
1005  self.refFile.dataHeader.nEntries :
1006  self.summary += [
1007  "## WARNING: files don't have the same number of entries !!",
1008  " ref : %r" % self.refFile.dataHeader.nEntries,
1009  " chk : %r" % self.chkFile.dataHeader.nEntries,
1010  ]
1011 
1012  refNames = sorted( [d.name for d in self.refFile.data] )
1013  chkNames = sorted( [d.name for d in self.chkFile.data] )
1014 
1015  if chkNames != refNames:
1016  self.summary += [
1017  "## ERROR: files don't have the same content !!",
1018  ]
1019  addNames = [ n for n in chkNames if n not in refNames ]
1020  if len( addNames ) > 0:
1021  self.summary += [ "## collections in 'chk' and not in 'ref'" ]
1022  for n in addNames:
1023  self.summary += [ " + %s" % n ]
1024  subNames = [ n for n in refNames if n not in chkNames ]
1025  if len( subNames ) > 0:
1026  self.summary += [ "## collections in 'ref' and not in 'chk'" ]
1027  for n in subNames:
1028  self.summary += [ " - %s" % n ]
1029  self.allGood = False
1030  pass
1031 
1032  if len(self.ignList) > 0:
1033  self.summary += [ "## Ignoring the following:" ]
1034  for n in self.ignList:
1035  self.summary += [ " %s" % n ]
1036 
1037  commonContent = [ d for d in chkNames if (d in refNames and d not in self.ignList)]
1038 
1039  if not self.allGood:
1040  self.summary += [ "=" * 80 ]
1041  self.summary += [ "::: comparing common content (mem-size / disk-size)..." ]
1042 
1043  for name in commonContent:
1044  chkMemSize = self.chkFile.poolRecord(name).memSize
1045  refMemSize = self.refFile.poolRecord(name).memSize
1046  chkDiskSize = self.chkFile.poolRecord(name).diskSize
1047  refDiskSize = self.refFile.poolRecord(name).diskSize
1048 
1049  if chkMemSize != refMemSize or (self.strict and chkDiskSize != refDiskSize):
1050  self.summary += [
1051  "[ERR] %12.3f / %12.3f kb (ref) ==> %12.3f / %12.3f kb (chk) | %s" % \
1052  ( refMemSize,refDiskSize,chkMemSize,chkDiskSize, name )
1053  ]
1054  self.allGood = False
1055  elif self.verbose:
1056  self.summary += [
1057  " [OK] %12.3f/%12.3f kb | %s" % \
1058  ( chkMemSize, chkDiskSize, name )
1059  ]
1060 
1061  self.summary += [ "=" * 80 ]
1062 
1063 
1064  if self.allGood: self.summary += [ "## Comparison : [OK]" ]
1065  else: self.summary += [ "## Comparison : [ERR]" ]
1066 
1067  return self.allGood
1068 

◆ printSummary()

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

Definition at line 1073 of file PoolFile.py.

1073  def printSummary(self, out = sys.stdout):
1074  for i in self.summary:
1075  out.writelines( i + os.linesep )
1076  pass
1077  return

◆ status()

def python.PoolFile.DiffFiles.status (   self)

Definition at line 1069 of file PoolFile.py.

1069  def status(self):
1070  if self.allGood: return 0
1071  else: return 1
1072 

Member Data Documentation

◆ allGood

python.PoolFile.DiffFiles.allGood

Definition at line 988 of file PoolFile.py.

◆ chkFile

python.PoolFile.DiffFiles.chkFile

Definition at line 976 of file PoolFile.py.

◆ ignList

python.PoolFile.DiffFiles.ignList

Definition at line 977 of file PoolFile.py.

◆ refFile

python.PoolFile.DiffFiles.refFile

Definition at line 975 of file PoolFile.py.

◆ strict

python.PoolFile.DiffFiles.strict

Definition at line 967 of file PoolFile.py.

◆ summary

python.PoolFile.DiffFiles.summary

Definition at line 989 of file PoolFile.py.

◆ verbose

python.PoolFile.DiffFiles.verbose

Definition at line 966 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:879
python.processes.powheg.ZZj_MiNNLO.ZZj_MiNNLO.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZj_MiNNLO.py:18
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:26
str
Definition: BTagTrackIpAccessor.cxx:11
merge.status
status
Definition: merge.py:16