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 978 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 984 of file PoolFile.py.

984  def __init__(self, refFileName, chkFileName, verbose = False, ignoreList = None, strict = False):
985  object.__init__(self)
986 
987  self.verbose = verbose
988  self.strict = strict
989  refFileName = os.path.expandvars( os.path.expanduser( refFileName ) )
990  chkFileName = os.path.expandvars( os.path.expanduser( chkFileName ) )
991 
992  if ignoreList is None:
993  ignoreList = []
994 
995  try:
996  self.refFile = PoolFile( refFileName )
997  self.chkFile = PoolFile( chkFileName )
998  self.ignList = sorted( ignoreList )
999  except Exception as err:
1000  print("## Caught exception [%s] !!" % str(err.__class__))
1001  print("## What:",err)
1002  print(sys.exc_info()[0])
1003  print(sys.exc_info()[1])
1004  err = "Error while opening POOL files !"
1005  err += " chk : %s%s" % ( chkFileName, os.linesep )
1006  err += " ref : %s%s" % ( refFileName, os.linesep )
1007  raise Exception(err)
1008 
1009  self.allGood = True
1010  self.summary = []
1011 
1012  self.__checkDiff()
1013  return
1014 

Member Function Documentation

◆ __checkDiff()

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

Definition at line 1015 of file PoolFile.py.

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

◆ printSummary()

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

Definition at line 1094 of file PoolFile.py.

1094  def printSummary(self, out = sys.stdout):
1095  for i in self.summary:
1096  out.writelines( i + os.linesep )
1097  pass
1098  return

◆ status()

def python.PoolFile.DiffFiles.status (   self)

Definition at line 1090 of file PoolFile.py.

1090  def status(self):
1091  if self.allGood: return 0
1092  else: return 1
1093 

Member Data Documentation

◆ allGood

python.PoolFile.DiffFiles.allGood

Definition at line 1009 of file PoolFile.py.

◆ chkFile

python.PoolFile.DiffFiles.chkFile

Definition at line 997 of file PoolFile.py.

◆ ignList

python.PoolFile.DiffFiles.ignList

Definition at line 998 of file PoolFile.py.

◆ refFile

python.PoolFile.DiffFiles.refFile

Definition at line 996 of file PoolFile.py.

◆ strict

python.PoolFile.DiffFiles.strict

Definition at line 988 of file PoolFile.py.

◆ summary

python.PoolFile.DiffFiles.summary

Definition at line 1010 of file PoolFile.py.

◆ verbose

python.PoolFile.DiffFiles.verbose

Definition at line 987 of file PoolFile.py.


The documentation for this class was generated from the following file:
python.PoolFile.poolRecord
def poolRecord(self, name)
Definition: PoolFile.py:900
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
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:17