Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print function migration for Validation_Tools #24019

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions Validation/Tools/examples/printConversionInfo.py
@@ -1,5 +1,6 @@
#! /usr/bin/env python

from __future__ import print_function
import ROOT
import sys
from DataFormats.FWLite import Events, Handle
Expand All @@ -8,16 +9,16 @@
options = VarParsing ('python')
options.parseArguments()

print "maxEvents", options.maxEvents
print("maxEvents", options.maxEvents)

events = Events (options)
conversionHandle = Handle ('vector<reco::Conversion>')
conversionLabel = ("conversions")

for event in events:
aux = event.object().eventAuxiliary()
print "run %6d event %d" % (aux.run(), aux.event())
print("run %6d event %d" % (aux.run(), aux.event()))
event.getByLabel (conversionLabel, conversionHandle)
conversionVector = conversionHandle.product()
for index, conversion in enumerate (conversionVector):
print " %2d %8.4f" % (index, conversion.EoverP())
print(" %2d %8.4f" % (index, conversion.EoverP()))
111 changes: 56 additions & 55 deletions Validation/Tools/python/GenObject.py

Large diffs are not rendered by default.

49 changes: 25 additions & 24 deletions Validation/Tools/scripts/diffTreeTool.py
@@ -1,5 +1,6 @@
#! /usr/bin/env python

from __future__ import print_function
import optparse
import os
import re
Expand Down Expand Up @@ -150,54 +151,54 @@ def format (objDict, label, spacing=9, firstOnly = False):
firstOnlyColl = getPieceFromObject (tree, name + '.firstOnly')
size = firstOnlyColl.size()
if size:
print "First Only:\n index ",
print("First Only:\n index ", end=' ')
for var in variables:
print "%-12s" % (' ' + var),
print
print '-' * (12 + 11 * len(variables))
print("%-12s" % (' ' + var), end=' ')
print()
print('-' * (12 + 11 * len(variables)))
for index in range (size):
firstOnly = firstOnlyColl[index]
index = getDictFromObject (firstOnly, indexSingleDict)
print ' ', format (index, 'index', 3, firstOnly = True),
print(' ', format (index, 'index', 3, firstOnly = True), end=' ')
info = getDictFromObject (firstOnly, infoSingleDict)
for var in variables:
print ' ', format (info, var, firstOnly = True),
print
print
print(' ', format (info, var, firstOnly = True), end=' ')
print()
print()
# second only
secondOnlyColl = getPieceFromObject (tree, name + '.secondOnly')
size = secondOnlyColl.size()
if size:
print "Second Only:\n index ",
print("Second Only:\n index ", end=' ')
for var in variables:
print "%-12s" % (' ' + var),
print
print '-' * (12 + 11 * len(variables))
print("%-12s" % (' ' + var), end=' ')
print()
print('-' * (12 + 11 * len(variables)))
for index in range (size):
secondOnly = secondOnlyColl[index]
index = getDictFromObject (secondOnly, indexSingleDict)
print ' ', format (index, 'index', 3, firstOnly = True),
print(' ', format (index, 'index', 3, firstOnly = True), end=' ')
info = getDictFromObject (secondOnly, infoSingleDict)
for var in variables:
print ' ', format (info, var, firstOnly = True),
print
print
print(' ', format (info, var, firstOnly = True), end=' ')
print()
print()
# both
diffColl = getPieceFromObject (tree, name+'.diff')
size = diffColl.size()
if size:
print "Both:\n index",
print("Both:\n index", end=' ')
for var in variables:
print "%-24s" % (' ' + var),
print
print '-' * (16 + 23 * len(variables))
print("%-24s" % (' ' + var), end=' ')
print()
print('-' * (16 + 23 * len(variables)))
for index in range (size):
diff = diffColl[index]
index = getDictFromObject (diff, indexDoubleDict)
print ' ', format (index, 'index', 3),
print(' ', format (index, 'index', 3), end=' ')
info = getDictFromObject (diff, infoDoubleDict)
for var in variables:
print ' ', format (info, var),
print
print
print(' ', format (info, var), end=' ')
print()
print()

7 changes: 4 additions & 3 deletions Validation/Tools/scripts/edmOneToOneComparison.py
@@ -1,5 +1,6 @@
#! /usr/bin/env python

from __future__ import print_function
if __name__ == "__main__":
import optparse
parser = optparse.OptionParser("usage: %prog [options] config.txt file1.root [file2.root]\nVisit https://twiki.cern.ch/twiki/bin/view/CMS/SWGuidePhysicsToolsEdmOneToOneComparison\nfor full documentation.")
Expand Down Expand Up @@ -118,7 +119,7 @@
for arg in options.alias:
aliasMatch = doubleColonRE.match (arg)
if aliasMatch:
print "aM", aliasMatch
print("aM", aliasMatch)
GenObject.changeAlias (aliasMatch.group (1),
aliasMatch.group (2),
aliasMatch.group (3))
Expand Down Expand Up @@ -169,14 +170,14 @@
problems = \
GenObject.compareTwoTrees (chain1, chain2,
diffOutputName = options.compRoot)
print "Summary"
print("Summary")
pprint.pprint (problems)
if options.saveAs:
chain1 = GenObject.prepareTuple (options.tuple1, options.file1,
options.numEvents1)
GenObject.saveTupleAs (chain1, options.saveAs)
if options.printTuple:
print "printing tuple"
print("printing tuple")
GenObject.setGlobalFlag ('printEvent', True)
chain1 = GenObject.prepareTuple (options.tuple1, options.file1,
options.numEvents1)
Expand Down
33 changes: 17 additions & 16 deletions Validation/Tools/scripts/runEdmFileComparison.py
@@ -1,5 +1,6 @@
#! /usr/bin/env python

from __future__ import print_function
import optparse
import commands
import pprint
Expand Down Expand Up @@ -195,7 +196,7 @@ def label (self):
if options.verboseDebug:
options.verbose = True
if options.verbose:
print "files", filename1, filename2
print("files", filename1, filename2)
if options.singletons and not options.describeOnly:
raise RuntimeError("--singletons can only be used with "\
"--describeOnly option")
Expand All @@ -208,18 +209,18 @@ def label (self):
#############################
## Run edmDumpEventContent ##
#############################
print "Getting edmDumpEventContent output"
print("Getting edmDumpEventContent output")
regexLine = ""
for regex in options.regex:
regexLine += ' "--regex=%s"' % regex
dumpCommand = 'edmDumpEventContent %s %s' % (regexLine, filename1)
if options.verboseDebug:
print dumpCommand, '\n'
print(dumpCommand, '\n')
output = commands.getoutput (dumpCommand).split("\n")
if not len(output):
raise RuntimeError("No output from edmDumpEventContent.")
if options.verboseDebug:
print "output:\n", "\n".join(output)
print("output:\n", "\n".join(output))
collection = {}
total = failed = skipped = useless = 0
for line in output:
Expand All @@ -245,7 +246,7 @@ def label (self):
and os.path.getsize (descriptionName) \
and not options.forceDescribe:
if options.verbose:
print '%s exists. Skipping' % descriptionName
print('%s exists. Skipping' % descriptionName)
continue
#print name, prettyName, key
describeCmd = "%s %s %s useReflexToDescribeForGenObject.py %s '--type=%s'" \
Expand All @@ -256,23 +257,23 @@ def label (self):
if options.precision:
describeCmd += " --precision=" + options.precision
if options.verbose:
print "describing %s" % name
print("describing %s" % name)
if options.verboseDebug:
print describeCmd, '\n'
print(describeCmd, '\n')
returnCode = os.system (describeCmd)
if returnCode:
# return codes are shifted by 8 bits:
if returnCode == GenObject.uselessReturnCode << 8:
useless += 1
else:
print "Error trying to describe '%s'. Continuing.\n" % \
(name)
print("Error trying to describe '%s'. Continuing.\n" % \
(name))
failed += 1
if options.describeOnly:
print "Total: %3d Skipped: %3d Failed: %3d Useless: %3d" % \
(total, skipped, failed, useless)
print("Total: %3d Skipped: %3d Failed: %3d Useless: %3d" % \
(total, skipped, failed, useless))
if not options.noQueue:
print "Note: Failed not recorded when using queuing system."
print("Note: Failed not recorded when using queuing system.")
sys.exit()

##################################
Expand Down Expand Up @@ -310,9 +311,9 @@ def label (self):
if options.strictPairing:
fullCompareCmd += ' --strictPairing'
if options.verbose:
print "comparing branch %s %s" % (name, obj.label())
print("comparing branch %s %s" % (name, obj.label()))
if options.verboseDebug:
print fullCompareCmd,'\n'
print(fullCompareCmd,'\n')
os.system (fullCompareCmd)

##################################
Expand All @@ -329,5 +330,5 @@ def label (self):
summaryOptions = '--counts'
summaryCmd = 'summarizeEdmComparisonLogfiles.py %s %s logfiles' \
% (summaryOptions, summaryMask)
print summaryCmd
print commands.getoutput (summaryCmd)
print(summaryCmd)
print(commands.getoutput (summaryCmd))
5 changes: 3 additions & 2 deletions Validation/Tools/scripts/simpleEdmComparison.py
@@ -1,5 +1,6 @@
#! /usr/bin/env python

from __future__ import print_function
import inspect
import itertools
import logging
Expand Down Expand Up @@ -158,13 +159,13 @@ def compareEvents(event1, event2, handleName, label, options):
plagerDict.update({'count_%s' % objName : totalCount})
if mismatches:
plagerDict.update({objName: {'_var' : {handleName:mismatches}}})
print "Summary"
print("Summary")
pprint.pprint(plagerDict)
except ProductNotFoundError:
logging.info("No product found for handle=%s, label=%s" % (handleName, label))

logging.info("Total products compared: %s, %s/%s" % (productsCompared, mismatches, totalCount))

if not productsCompared:
print "Plager compatible message: not able to get any products"
print("Plager compatible message: not able to get any products")
sys.exit()
33 changes: 17 additions & 16 deletions Validation/Tools/scripts/summarizeEdmComparisonLogfiles.py
@@ -1,5 +1,6 @@
#! /usr/bin/env python

from __future__ import print_function
import optparse
import os
from glob import glob
Expand Down Expand Up @@ -204,36 +205,36 @@ def summaryOK (summary):
mismatches = problemTypes.get('mismatch', 0)
if 'mismatch' in problemTypes:
del problemTypes['mismatch']
print "total: ", len (files)
print "success: ", succeeded
print "mismatches: ", mismatches
print "weird: ", weird
print "Tool issue types:"
print("total: ", len (files))
print("success: ", succeeded)
print("mismatches: ", mismatches)
print("weird: ", weird)
print("Tool issue types:")
total = 0
for key, value in sorted (six.iteritems(problemTypes)):
print " %-15s: %4d" % (key, value)
print(" %-15s: %4d" % (key, value))
total += value
print " ", '-'*13, " : ----"
print " %-15s: %4d + %d + %d + %d = %d" \
print(" ", '-'*13, " : ----")
print(" %-15s: %4d + %d + %d + %d = %d" \
% ('total', total, succeeded, mismatches, weird,
total + succeeded + mismatches + weird)
total + succeeded + mismatches + weird))

if not options.counts:
print "\nDetailed Problems list:"
print("\nDetailed Problems list:")
for key, problemList in sorted (six.iteritems(problems)):
if options.problem and problemList[0] != options.problem:
continue
if options.mismatch and not isinstance (problemList, str):
continue
#if options.mismatch and
print " %s:\n %s\n" % (key, problemList)
print(" %s:\n %s\n" % (key, problemList))
if options.mismatch and goShlib and compRoot:
print "diffTree %s %s" % (goShlib, compRoot)
print("diffTree %s %s" % (goShlib, compRoot))
diffCmd = diffOutput.get(key)
if diffCmd:
print commands.getoutput (diffCmd)
print(commands.getoutput (diffCmd))
if not options.problem and not options.mismatch:
print "\n", '='*78, '\n'
print "Success list:"
print("\n", '='*78, '\n')
print("Success list:")
for key, successesList in sorted (six.iteritems(successes)):
print " %s:\n %s\n" % (key, successesList)
print(" %s:\n %s\n" % (key, successesList))