Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-08 23:57:43

0001 #!/usr/bin/env python3
0002 """
0003 _RunMerge_
0004 
0005 Test/Debugging harness for the merge configuration builder
0006 
0007 """
0008 from __future__ import print_function
0009 
0010 
0011 
0012 import sys
0013 import getopt
0014 
0015 from Configuration.DataProcessing.Merge import mergeProcess
0016 
0017 
0018 class RunMerge:
0019 
0020     def __init__(self):
0021         self.processName = "Merge"
0022         self.outputFile = "Merged.root"
0023         self.outputLFN = None
0024         self.inputFiles = []
0025         self.newDQMIO = False
0026         self.mergeNANO = False
0027         self.bypassVersionCheck = False
0028         
0029 
0030     def __call__(self):
0031         if self.inputFiles == []:
0032             msg = "No Input Files provided"
0033             raise RuntimeError(msg)
0034 
0035         try:
0036             process = mergeProcess(
0037                 *self.inputFiles,
0038                 process_name = self.processName,
0039                 output_file = self.outputFile,
0040                 output_lfn = self.outputLFN,
0041                 newDQMIO = self.newDQMIO,
0042                 mergeNANO = self.mergeNANO,
0043                 bypassVersionCheck = self.bypassVersionCheck)
0044         except Exception as ex:
0045             msg = "Error creating process for Merge:\n"
0046             msg += str(ex)
0047             raise RuntimeError(msg)
0048 
0049         psetFile = open("RunMergeCfg.py", "w")
0050         psetFile.write(process.dumpPython())
0051         psetFile.close()
0052         cmsRun = "cmsRun -j FrameworkJobReport.xml RunMergeCfg.py"
0053         print("Now do:\n%s" % cmsRun)
0054         
0055                 
0056 
0057 
0058 if __name__ == '__main__':
0059     valid = ["input-files=", "output-file=", "output-lfn=", "dqmroot", "mergeNANO", "bypassVersionCheck" ]
0060              
0061     usage = """RunMerge.py <options>"""
0062     try:
0063         opts, args = getopt.getopt(sys.argv[1:], "", valid)
0064     except getopt.GetoptError as ex:
0065         print(usage)
0066         print(str(ex))
0067         sys.exit(1)
0068 
0069 
0070     merger = RunMerge()
0071 
0072     for opt, arg in opts:
0073         if opt == "--input-files":
0074             merger.inputFiles = [
0075                 x for x in arg.split(',') if x.strip() != '' ]
0076 
0077         if opt == "--output-file" :
0078             merger.outputFile = arg
0079         if opt == "--output-lfn" :
0080             merger.outputLFN = arg
0081         if opt == "--dqmroot" :
0082             merger.newDQMIO = True
0083         if opt == "--mergeNANO" :
0084             merger.mergeNANO = True
0085         if opt == "--bypassVersionCheck" :
0086             merger.bypassVersionCheck = True
0087 
0088     merger()