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 975 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 981 of file PoolFile.py.

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

Member Function Documentation

◆ __checkDiff()

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

Definition at line 1012 of file PoolFile.py.

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

◆ printSummary()

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

Definition at line 1091 of file PoolFile.py.

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

◆ status()

def python.PoolFile.DiffFiles.status (   self)

Definition at line 1087 of file PoolFile.py.

1087  def status(self):
1088  if self.allGood: return 0
1089  else: return 1
1090 

Member Data Documentation

◆ allGood

python.PoolFile.DiffFiles.allGood

Definition at line 1006 of file PoolFile.py.

◆ chkFile

python.PoolFile.DiffFiles.chkFile

Definition at line 994 of file PoolFile.py.

◆ ignList

python.PoolFile.DiffFiles.ignList

Definition at line 995 of file PoolFile.py.

◆ refFile

python.PoolFile.DiffFiles.refFile

Definition at line 993 of file PoolFile.py.

◆ strict

python.PoolFile.DiffFiles.strict

Definition at line 985 of file PoolFile.py.

◆ summary

python.PoolFile.DiffFiles.summary

Definition at line 1007 of file PoolFile.py.

◆ verbose

python.PoolFile.DiffFiles.verbose

Definition at line 984 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:897
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.
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
str
Definition: BTagTrackIpAccessor.cxx:11
merge.status
status
Definition: merge.py:17