ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/cms_cmssw.py
(Generate patch)

Comparing COMP/CRAB/python/cms_cmssw.py (file contents):
Revision 1.169 by spiga, Tue Apr 1 14:53:36 2008 UTC vs.
Revision 1.228 by ewv, Wed Jul 9 19:55:56 2008 UTC

# Line 2 | Line 2 | from JobType import JobType
2   from crab_logger import Logger
3   from crab_exceptions import *
4   from crab_util import *
5 < from BlackWhiteListParser import BlackWhiteListParser
5 > from BlackWhiteListParser import SEBlackWhiteListParser
6   import common
7   import Scram
8 + from LFNBaseName import *
9  
10   import os, string, glob
11  
12   class Cmssw(JobType):
13 <    def __init__(self, cfg_params, ncjobs):
13 >    def __init__(self, cfg_params, ncjobs,skip_blocks, isNew):
14          JobType.__init__(self, 'CMSSW')
15          common.logger.debug(3,'CMSSW::__init__')
16 +        self.skip_blocks = skip_blocks
17  
18          self.argsList = []
19  
20          self._params = {}
21          self.cfg_params = cfg_params
22          # init BlackWhiteListParser
23 <        self.blackWhiteListParser = BlackWhiteListParser(cfg_params)
23 >        self.blackWhiteListParser = SEBlackWhiteListParser(cfg_params)
24  
25          self.MaxTarBallSize = float(self.cfg_params.get('EDG.maxtarballsize',9.5))
26  
# Line 33 | Line 35 | class Cmssw(JobType):
35          self.executable = ''
36          self.executable_arch = self.scram.getArch()
37          self.tgz_name = 'default.tgz'
36        self.additional_tgz_name = 'additional.tgz'
38          self.scriptName = 'CMSSW.sh'
39 <        self.pset = ''      #scrip use case Da
40 <        self.datasetPath = '' #scrip use case Da
39 >        self.pset = ''
40 >        self.datasetPath = ''
41  
42          # set FJR file name
43          self.fjrFileName = 'crab_fjr.xml'
44  
45          self.version = self.scram.getSWVersion()
46 <
47 <        #
48 <        # Try to block creation in case of arch/version mismatch
49 <        #
50 <
51 < #        a = string.split(self.version, "_")
52 < #
53 < #        if int(a[1]) == 1 and (int(a[2]) < 5 and self.executable_arch.find('slc4') == 0):
54 < #            msg = "Warning: You are using %s version of CMSSW  with %s architecture. \n--> Did you compile your libraries with SLC3? Otherwise you can find some problems running on SLC4 Grid nodes.\n"%(self.version, self.executable_arch)
55 < #            common.logger.message(msg)
56 < #        if int(a[1]) == 1 and (int(a[2]) >= 5 and self.executable_arch.find('slc3') == 0):
56 < #            msg = "Error: CMS does not support %s with %s architecture"%(self.version, self.executable_arch)
57 < #            raise CrabException(msg)
58 < #
59 <
60 <        self.setParam_('application', self.version)
46 >        version_array = self.version.split('_')
47 >        self.CMSSW_major = 0
48 >        self.CMSSW_minor = 0
49 >        self.CMSSW_patch = 0
50 >        try:
51 >            self.CMSSW_major = int(version_array[1])
52 >            self.CMSSW_minor = int(version_array[2])
53 >            self.CMSSW_patch = int(version_array[3])
54 >        except:
55 >            msg = "Cannot parse CMSSW version string: " + self.version + " for major and minor release number!"
56 >            raise CrabException(msg)
57  
58          ### collect Data cards
59  
60          if not cfg_params.has_key('CMSSW.datasetpath'):
61              msg = "Error: datasetpath not defined "
62              raise CrabException(msg)
63 +
64 +        ### Temporary: added to remove input file control in the case of PU
65 +        self.dataset_pu = cfg_params.get('CMSSW.dataset_pu', None)
66 +
67          tmp =  cfg_params['CMSSW.datasetpath']
68          log.debug(6, "CMSSW::CMSSW(): datasetPath = "+tmp)
69          if string.lower(tmp)=='none':
# Line 73 | Line 73 | class Cmssw(JobType):
73              self.datasetPath = tmp
74              self.selectNoInput = 0
75  
76        # ML monitoring
77        # split dataset path style: /PreProdR3Minbias/SIM/GEN-SIM
78        if not self.datasetPath:
79            self.setParam_('dataset', 'None')
80            self.setParam_('owner', 'None')
81        else:
82            ## SL what is supposed to fail here?
83            try:
84                datasetpath_split = self.datasetPath.split("/")
85                # standard style
86                self.setParam_('datasetFull', self.datasetPath)
87                self.setParam_('dataset', datasetpath_split[1])
88                self.setParam_('owner', datasetpath_split[2])
89            except:
90                self.setParam_('dataset', self.datasetPath)
91                self.setParam_('owner', self.datasetPath)
92
93        self.setParam_('taskId', common._db.queryTask('name')) ## new BL--DS
94
76          self.dataTiers = []
77 <
77 >        self.debugWrap = ''
78 >        self.debug_wrapper = cfg_params.get('USER.debug_wrapper',False)
79 >        if self.debug_wrapper: self.debugWrap='--debug'
80          ## now the application
81          self.executable = cfg_params.get('CMSSW.executable','cmsRun')
99        self.setParam_('exe', self.executable)
82          log.debug(6, "CMSSW::CMSSW(): executable = "+self.executable)
83  
84          if not cfg_params.has_key('CMSSW.pset'):
# Line 117 | Line 99 | class Cmssw(JobType):
99          self.output_file_sandbox.append(self.fjrFileName)
100  
101          # other output files to be returned via sandbox or copied to SE
102 +        outfileflag = False
103          self.output_file = []
104          tmp = cfg_params.get('CMSSW.output_file',None)
105          if tmp :
106 <            tmpOutFiles = string.split(tmp,',')
107 <            log.debug(7, 'cmssw::cmssw(): output files '+str(tmpOutFiles))
108 <            for tmp in tmpOutFiles:
109 <                tmp=string.strip(tmp)
127 <                self.output_file.append(tmp)
128 <                pass
129 <        else:
130 <            log.message("No output file defined: only stdout/err and the CRAB Framework Job Report will be available\n")
131 <        pass
106 >            self.output_file = [x.strip() for x in tmp.split(',')]
107 >            outfileflag = True #output found
108 >        #else:
109 >        #    log.message("No output file defined: only stdout/err and the CRAB Framework Job Report will be available\n")
110  
111          # script_exe file as additional file in inputSandbox
112          self.scriptExe = cfg_params.get('USER.script_exe',None)
113          if self.scriptExe :
114 <           if not os.path.isfile(self.scriptExe):
115 <              msg ="ERROR. file "+self.scriptExe+" not found"
116 <              raise CrabException(msg)
117 <           self.additional_inbox_files.append(string.strip(self.scriptExe))
114 >            if not os.path.isfile(self.scriptExe):
115 >                msg ="ERROR. file "+self.scriptExe+" not found"
116 >                raise CrabException(msg)
117 >            self.additional_inbox_files.append(string.strip(self.scriptExe))
118  
141        #CarlosDaniele
119          if self.datasetPath == None and self.pset == None and self.scriptExe == '' :
120 <           msg ="Error. script_exe  not defined"
121 <           raise CrabException(msg)
120 >            msg ="Error. script_exe  not defined"
121 >            raise CrabException(msg)
122 >
123 >        # use parent files...
124 >        self.useParent = self.cfg_params.get('CMSSW.use_parent',False)
125  
126          ## additional input files
127          if cfg_params.has_key('USER.additional_input_files'):
# Line 161 | Line 141 | class Cmssw(JobType):
141                      if not os.path.exists(file):
142                          raise CrabException("Additional input file not found: "+file)
143                      pass
164                    # fname = string.split(file, '/')[-1]
165                    # storedFile = common.work_space.pathForTgz()+'share/'+fname
166                    # shutil.copyfile(file, storedFile)
144                      self.additional_inbox_files.append(string.strip(file))
145                  pass
146              pass
# Line 189 | Line 166 | class Cmssw(JobType):
166          if cfg_params.has_key('CMSSW.total_number_of_events'):
167              self.total_number_of_events = int(cfg_params['CMSSW.total_number_of_events'])
168              self.selectTotalNumberEvents = 1
169 +            if self.selectNumberOfJobs  == 1:
170 +                if (self.total_number_of_events != -1) and int(self.total_number_of_events) < int(self.theNumberOfJobs):
171 +                    msg = 'Must specify at least one event per job. total_number_of_events > number_of_jobs '
172 +                    raise CrabException(msg)
173          else:
174              self.total_number_of_events = 0
175              self.selectTotalNumberEvents = 0
176  
177 <        if self.pset != None: #CarlosDaniele
177 >        if self.pset != None:
178               if ( (self.selectTotalNumberEvents + self.selectEventsPerJob + self.selectNumberOfJobs) != 2 ):
179                   msg = 'Must define exactly two of total_number_of_events, events_per_job, or number_of_jobs.'
180                   raise CrabException(msg)
# Line 216 | Line 197 | class Cmssw(JobType):
197                  tmp.strip()
198                  self.incrementSeeds.append(tmp)
199  
200 <        ## Old method of dealing with seeds
201 <        ## FUTURE: This is for old CMSSW and old CRAB. Can throw exceptions after a couple of CRAB releases and then
221 <        ## remove
222 <        self.sourceSeed = cfg_params.get('CMSSW.pythia_seed',None)
223 <        if self.sourceSeed:
224 <          print "pythia_seed is a deprecated parameter. Use preserve_seeds or increment_seeds in the future.\n","Added to increment_seeds."
225 <          self.incrementSeeds.append('sourceSeed')
226 <
200 >        ## FUTURE: Can remove in CRAB 2.4.0
201 >        self.sourceSeed    = cfg_params.get('CMSSW.pythia_seed',None)
202          self.sourceSeedVtx = cfg_params.get('CMSSW.vtx_seed',None)
203 <        if self.sourceSeedVtx:
229 <          print "vtx_seed is a deprecated parameter. Use preserve_seeds or increment_seeds in the future.\n","Added to increment_seeds."
230 <          self.incrementSeeds.append('VtxSmeared')
231 <
232 <        self.sourceSeedG4 = cfg_params.get('CMSSW.g4_seed',None)
233 <        if self.sourceSeedG4:
234 <          print "g4_seed is a deprecated parameter. Use preserve_seeds or increment_seeds in the future.\n","Added to increment_seeds."
235 <          self.incrementSeeds.append('g4SimHits')
236 <
203 >        self.sourceSeedG4  = cfg_params.get('CMSSW.g4_seed',None)
204          self.sourceSeedMix = cfg_params.get('CMSSW.mix_seed',None)
205 <        if self.sourceSeedMix:
206 <          print "mix_seed is a deprecated parameter. Use preserve_seeds or increment_seeds in the future.\n","Added to increment_seeds."
207 <          self.incrementSeeds.append('mix')
205 >        if self.sourceSeed or self.sourceSeedVtx or self.sourceSeedG4 or self.sourceSeedMix:
206 >            msg = 'pythia_seed, vtx_seed, g4_seed, and mix_seed are no longer valid settings. You must use increment_seeds or preserve_seeds'
207 >            raise CrabException(msg)
208  
209          self.firstRun = cfg_params.get('CMSSW.first_run',None)
210  
244        if self.pset != None: #CarlosDaniele
245            import PsetManipulator as pp
246            PsetEdit = pp.PsetManipulator(self.pset) #Daniele Pset
247
211          # Copy/return
249
212          self.copy_data = int(cfg_params.get('USER.copy_data',0))
213          self.return_data = int(cfg_params.get('USER.return_data',0))
214  
# Line 262 | Line 224 | class Cmssw(JobType):
224              blockSites = self.DataDiscoveryAndLocation(cfg_params)
225          #DBSDLS-end
226  
265        self.tgzNameWithPath = self.getTarBall(self.executable)
266
227          ## Select Splitting
228          if self.selectNoInput:
229 <            if self.pset == None: #CarlosDaniele
229 >            if self.pset == None:
230                  self.jobSplittingForScript()
231              else:
232                  self.jobSplittingNoInput()
233          else:
234              self.jobSplittingByBlocks(blockSites)
235  
236 <        # modify Pset
237 <        if self.pset != None: #CarlosDaniele
238 <            try:
239 <                # Add FrameworkJobReport to parameter-set, set max events.
240 <                # Reset later for data jobs by writeCFG which does all modifications
241 <                PsetEdit.addCrabFJR(self.fjrFileName)
242 <                PsetEdit.maxEvent(self.eventsPerJob)
243 <                PsetEdit.psetWriter(self.configFilename())
244 <            except:
245 <                msg='Error while manipuliating ParameterSet: exiting...'
246 <                raise CrabException(msg)
236 >        # modify Pset only the first time
237 >        if isNew:
238 >            if self.pset != None:
239 >                import PsetManipulator as pp
240 >                PsetEdit = pp.PsetManipulator(self.pset)
241 >                try:
242 >                    # Add FrameworkJobReport to parameter-set, set max events.
243 >                    # Reset later for data jobs by writeCFG which does all modifications
244 >                    PsetEdit.addCrabFJR(self.fjrFileName) # FUTURE: Job report addition not needed by CMSSW>1.5
245 >                    PsetEdit.maxEvent(self.eventsPerJob)
246 >                    PsetEdit.psetWriter(self.configFilename())
247 >                    ## If present, add TFileService to output files
248 >                    if not int(cfg_params.get('CMSSW.skip_TFileService_output',0)):
249 >                        tfsOutput = PsetEdit.getTFileService()
250 >                        if tfsOutput:
251 >                            if tfsOutput in self.output_file:
252 >                                common.logger.debug(5,"Output from TFileService "+tfsOutput+" already in output files")
253 >                            else:
254 >                                outfileflag = True #output found
255 >                                self.output_file.append(tfsOutput)
256 >                                common.logger.message("Adding "+tfsOutput+" to output files (from TFileService)")
257 >                            pass
258 >                        pass
259 >                    ## If present and requested, add PoolOutputModule to output files
260 >                    if int(cfg_params.get('CMSSW.get_edm_output',0)):
261 >                        edmOutput = PsetEdit.getPoolOutputModule()
262 >                        if edmOutput:
263 >                            if edmOutput in self.output_file:
264 >                                common.logger.debug(5,"Output from PoolOutputModule "+edmOutput+" already in output files")
265 >                            else:
266 >                                self.output_file.append(edmOutput)
267 >                                common.logger.message("Adding "+edmOutput+" to output files (from PoolOutputModule)")
268 >                            pass
269 >                        pass
270 >                except CrabException:
271 >                    msg='Error while manipulating ParameterSet: exiting...'
272 >                    raise CrabException(msg)
273 >            ## Prepare inputSandbox TarBall (only the first time)
274 >            self.tgzNameWithPath = self.getTarBall(self.executable)
275  
276      def DataDiscoveryAndLocation(self, cfg_params):
277  
# Line 296 | Line 284 | class Cmssw(JobType):
284          ## Contact the DBS
285          common.logger.message("Contacting Data Discovery Services ...")
286          try:
287 <            self.pubdata=DataDiscovery.DataDiscovery(datasetPath, cfg_params)
287 >            self.pubdata=DataDiscovery.DataDiscovery(datasetPath, cfg_params,self.skip_blocks)
288              self.pubdata.fetchDBSInfo()
289  
290          except DataDiscovery.NotExistingDatasetError, ex :
# Line 312 | Line 300 | class Cmssw(JobType):
300          self.filesbyblock=self.pubdata.getFiles()
301          self.eventsbyblock=self.pubdata.getEventsPerBlock()
302          self.eventsbyfile=self.pubdata.getEventsPerFile()
303 +        self.parentFiles=self.pubdata.getParent()
304  
305          ## get max number of events
306 <        self.maxEvents=self.pubdata.getMaxEvents() ##  self.maxEvents used in Creator.py
306 >        self.maxEvents=self.pubdata.getMaxEvents()
307  
308          ## Contact the DLS and build a list of sites hosting the fileblocks
309          try:
# Line 338 | Line 327 | class Cmssw(JobType):
327  
328          return sites
329  
341  # to Be Removed  DS -- BL
342  #  def setArgsList(self, argsList):
343  #      self.argsList = argsList
344
330      def jobSplittingByBlocks(self, blockSites):
331          """
332          Perform job splitting. Jobs run over an integer number of files
# Line 392 | Line 377 | class Cmssw(JobType):
377          else :
378              totalNumberOfJobs = self.ncjobs
379  
395
380          blocks = blockSites.keys()
381          blockCount = 0
382          # Backup variable in case self.maxEvents counted events in a non-included block
# Line 433 | Line 417 | class Cmssw(JobType):
417  
418                  # ---- Iterate over the files in the block until we've met the requested ---- #
419                  # ---- total # of events or we've gone over all the files in this block  ---- #
420 +                pString=''
421                  while ( (eventsRemaining > 0) and (fileCount < numFilesInBlock) and (jobCount < totalNumberOfJobs) ):
422                      file = files[fileCount]
423 +                    if self.useParent:
424 +                        parent = self.parentFiles[file]
425 +                        for f in parent :
426 +                            pString += '\\\"' + f + '\\\"\,'
427 +                        common.logger.debug(6, "File "+str(file)+" has the following parents: "+str(parent))
428 +                        common.logger.write("File "+str(file)+" has the following parents: "+str(parent))
429                      if newFile :
430                          try:
431                              numEventsInFile = self.eventsbyfile[file]
# Line 447 | Line 438 | class Cmssw(JobType):
438                          except KeyError:
439                              common.logger.message("File "+str(file)+" has unknown number of events: skipping")
440  
441 <
441 >                    eventsPerJobRequested = min(eventsPerJobRequested, eventsRemaining)
442                      # if less events in file remain than eventsPerJobRequested
443 <                    if ( filesEventCount - jobSkipEventCount < eventsPerJobRequested ) :
443 >                    if ( filesEventCount - jobSkipEventCount < eventsPerJobRequested):
444                          # if last file in block
445                          if ( fileCount == numFilesInBlock-1 ) :
446                              # end job using last file, use remaining events in block
447                              # close job and touch new file
448                              fullString = parString[:-2]
449 <                            list_of_lists.append([fullString,str(-1),str(jobSkipEventCount)])
449 >                            if self.useParent:
450 >                                fullParentString = pString[:-2]
451 >                                list_of_lists.append([fullString,fullParentString,str(-1),str(jobSkipEventCount)])
452 >                            else:
453 >                                list_of_lists.append([fullString,str(-1),str(jobSkipEventCount)])
454                              common.logger.debug(3,"Job "+str(jobCount+1)+" can run over "+str(filesEventCount - jobSkipEventCount)+" events (last file in block).")
455                              self.jobDestination.append(blockSites[block])
456                              common.logger.debug(5,"Job "+str(jobCount+1)+" Destination: "+str(self.jobDestination[jobCount]))
# Line 467 | Line 462 | class Cmssw(JobType):
462                              eventsRemaining = eventsRemaining - filesEventCount + jobSkipEventCount
463                              jobSkipEventCount = 0
464                              # reset file
465 +                            pString = ""
466                              parString = ""
467                              filesEventCount = 0
468                              newFile = 1
# Line 479 | Line 475 | class Cmssw(JobType):
475                      elif ( filesEventCount - jobSkipEventCount == eventsPerJobRequested ) :
476                          # close job and touch new file
477                          fullString = parString[:-2]
478 <                        list_of_lists.append([fullString,str(eventsPerJobRequested),str(jobSkipEventCount)])
478 >                        if self.useParent:
479 >                            fullParentString = pString[:-2]
480 >                            list_of_lists.append([fullString,fullParentString,str(eventsPerJobRequested),str(jobSkipEventCount)])
481 >                        else:
482 >                            list_of_lists.append([fullString,str(eventsPerJobRequested),str(jobSkipEventCount)])
483                          common.logger.debug(3,"Job "+str(jobCount+1)+" can run over "+str(eventsPerJobRequested)+" events.")
484                          self.jobDestination.append(blockSites[block])
485                          common.logger.debug(5,"Job "+str(jobCount+1)+" Destination: "+str(self.jobDestination[jobCount]))
# Line 490 | Line 490 | class Cmssw(JobType):
490                          eventsRemaining = eventsRemaining - eventsPerJobRequested
491                          jobSkipEventCount = 0
492                          # reset file
493 +                        pString = ""
494                          parString = ""
495                          filesEventCount = 0
496                          newFile = 1
# Line 499 | Line 500 | class Cmssw(JobType):
500                      else :
501                          # close job but don't touch new file
502                          fullString = parString[:-2]
503 <                        list_of_lists.append([fullString,str(eventsPerJobRequested),str(jobSkipEventCount)])
503 >                        if self.useParent:
504 >                            fullParentString = pString[:-2]
505 >                            list_of_lists.append([fullString,fullParentString,str(eventsPerJobRequested),str(jobSkipEventCount)])
506 >                        else:
507 >                            list_of_lists.append([fullString,str(eventsPerJobRequested),str(jobSkipEventCount)])
508                          common.logger.debug(3,"Job "+str(jobCount+1)+" can run over "+str(eventsPerJobRequested)+" events.")
509                          self.jobDestination.append(blockSites[block])
510                          common.logger.debug(5,"Job "+str(jobCount+1)+" Destination: "+str(self.jobDestination[jobCount]))
# Line 513 | Line 518 | class Cmssw(JobType):
518                          jobSkipEventCount = eventsPerJobRequested - (filesEventCount - jobSkipEventCount - self.eventsbyfile[file])
519                          # remove all but the last file
520                          filesEventCount = self.eventsbyfile[file]
521 +                        if self.useParent:
522 +                            for f in parent : pString += '\\\"' + f + '\\\"\,'
523                          parString = '\\\"' + file + '\\\"\,'
524                      pass # END if
525                  pass # END while (iterate over files in the block)
# Line 533 | Line 540 | class Cmssw(JobType):
540          for block in blocks:
541              if block in jobsOfBlock.keys() :
542                  blockCounter += 1
543 <                screenOutput += "Block %5i: jobs %20s: sites: %s\n" % (blockCounter,spanRanges(jobsOfBlock[block]),','.join(self.blackWhiteListParser.checkWhiteList(self.blackWhiteListParser.checkBlackList(blockSites[block],block),block)))
543 >                screenOutput += "Block %5i: jobs %20s: sites: %s\n" % (blockCounter,spanRanges(jobsOfBlock[block]),
544 >                    ','.join(self.blackWhiteListParser.checkWhiteList(self.blackWhiteListParser.checkBlackList(blockSites[block],block),block)))
545                  if len(self.blackWhiteListParser.checkWhiteList(self.blackWhiteListParser.checkBlackList(blockSites[block],block),block)) == 0:
546                      noSiteBlock.append( spanRanges(jobsOfBlock[block]) )
547                      bloskNoSite.append( blockCounter )
# Line 620 | Line 628 | class Cmssw(JobType):
628          return
629  
630  
631 <    def jobSplittingForScript(self):#CarlosDaniele
631 >    def jobSplittingForScript(self):
632          """
633          Perform job splitting based on number of job
634          """
# Line 636 | Line 644 | class Cmssw(JobType):
644          # argument is seed number.$i
645          self.list_of_args = []
646          for i in range(self.total_number_of_jobs):
639            ## Since there is no input, any site is good
640           # self.jobDestination.append(["Any"])
647              self.jobDestination.append([""])
642            ## no random seed
648              self.list_of_args.append([str(i)])
649          return
650  
651 <    def split(self, jobParams):
651 >    def split(self, jobParams,firstJobID):
652  
648        #### Fabio
653          njobs = self.total_number_of_jobs
654          arglist = self.list_of_args
655          # create the empty structure
# Line 654 | Line 658 | class Cmssw(JobType):
658  
659          listID=[]
660          listField=[]
661 <        for job in range(njobs):
662 <            jobParams[job] = arglist[job]
661 >        for id in range(njobs):
662 >            job = id + int(firstJobID)
663 >            jobParams[id] = arglist[id]
664              listID.append(job+1)
665              job_ToSave ={}
666              concString = ' '
667              argu=''
668 <            if len(jobParams[job]):
669 <                argu +=   concString.join(jobParams[job] )
670 <            job_ToSave['arguments']= str(job+1)+' '+argu## new BL--DS
671 <            job_ToSave['dlsDestination']= self.jobDestination[job]## new BL--DS
667 <            #common._db.updateJob_(job,job_ToSave)## new BL--DS
668 >            if len(jobParams[id]):
669 >                argu +=   concString.join(jobParams[id] )
670 >            job_ToSave['arguments']= str(job+1)+' '+argu
671 >            job_ToSave['dlsDestination']= self.jobDestination[id]
672              listField.append(job_ToSave)
673              msg="Job "+str(job)+" Arguments:   "+str(job+1)+" "+argu+"\n"  \
674 <            +"                     Destination: "+str(self.jobDestination[job])
674 >            +"                     Destination: "+str(self.jobDestination[id])
675              common.logger.debug(5,msg)
676 <            #common.logger.debug(5,"Job "+str(job)+" Destination: "+str(self.jobDestination[job]))
677 <        common._db.updateJob_(listID,listField)## new BL--DS
674 <        ## Pay Attention Here....DS--BL
675 <        self.argsList = (len(jobParams[1])+1)
676 >        common._db.updateJob_(listID,listField)
677 >        self.argsList = (len(jobParams[0])+1)
678  
679          return
678 #
679 #    def getJobTypeArguments(self, nj, sched):
680 #        result = ''
681 #        jobs=[]
682 #        jobs.append(nj)
683 #        for i in common._db.queryJob('arguments',jobs):##  BL--DS
684 #            result=result+str(i)+" "
685 #        return result
680  
681      def numberOfJobs(self):
688        # Fabio
682          return self.total_number_of_jobs
683  
684      def getTarBall(self, exe):
685          """
686          Return the TarBall with lib and exe
687          """
695
696        # if it exist, just return it
697        #
698        # Marco. Let's start to use relative path for Boss XML files
699        #
688          self.tgzNameWithPath = common.work_space.pathForTgz()+'share/'+self.tgz_name
689          if os.path.exists(self.tgzNameWithPath):
690              return self.tgzNameWithPath
# Line 710 | Line 698 | class Cmssw(JobType):
698  
699          # First of all declare the user Scram area
700          swArea = self.scram.getSWArea_()
713        #print "swArea = ", swArea
714        # swVersion = self.scram.getSWVersion()
715        # print "swVersion = ", swVersion
701          swReleaseTop = self.scram.getReleaseTop_()
717        #print "swReleaseTop = ", swReleaseTop
702  
703          ## check if working area is release top
704          if swReleaseTop == '' or swArea == swReleaseTop:
705 +            common.logger.debug(3,"swArea = "+swArea+" swReleaseTop ="+swReleaseTop)
706              return
707  
708          import tarfile
# Line 759 | Line 744 | class Cmssw(JobType):
744                  tar.add(module,moduleDir)
745  
746              ## Now check if any data dir(s) is present
747 <            swAreaLen=len(swArea)
748 <            for root, dirs, files in os.walk(swArea):
749 <                if "data" in dirs:
750 <                    common.logger.debug(5,"data "+root+"/data"+" to be tarred")
751 <                    tar.add(root+"/data",root[swAreaLen:]+"/data")
747 >            self.dataExist = False
748 >            todo_list = [(i, i) for i in  os.listdir(swArea+"/src")]
749 >            while len(todo_list):
750 >                entry, name = todo_list.pop()
751 >                if name.startswith('crab_0_') or  name.startswith('.') or name == 'CVS':
752 >                    continue
753 >                if os.path.isdir(swArea+"/src/"+entry):
754 >                    entryPath = entry + '/'
755 >                    todo_list += [(entryPath + i, i) for i in  os.listdir(swArea+"/src/"+entry)]
756 >                    if name == 'data':
757 >                        self.dataExist=True
758 >                        common.logger.debug(5,"data "+entry+" to be tarred")
759 >                        tar.add(swArea+"/src/"+entry,"src/"+entry)
760 >                    pass
761 >                pass
762 >
763 >            ### CMSSW ParameterSet
764 >            if not self.pset is None:
765 >                cfg_file = common.work_space.jobDir()+self.configFilename()
766 >                tar.add(cfg_file,self.configFilename())
767 >                common.logger.debug(5,"File added to "+self.tgzNameWithPath+" : "+str(tar.getnames()))
768  
769  
770              ## Add ProdCommon dir to tar
771 <            prodcommonDir = 'ProdCommon'
772 <            prodcommonPath = os.environ['CRABDIR'] + '/' + 'ProdCommon'
773 <            if os.path.isdir(prodcommonPath):
774 <                tar.add(prodcommonPath,prodcommonDir)
771 >            prodcommonDir = './'
772 >            prodcommonPath = os.environ['CRABDIR'] + '/' + 'external/'
773 >            neededStuff = ['ProdCommon/__init__.py','ProdCommon/FwkJobRep', 'ProdCommon/CMSConfigTools','ProdCommon/Core','ProdCommon/MCPayloads', 'IMProv']
774 >            for file in neededStuff:
775 >                tar.add(prodcommonPath+file,prodcommonDir+file)
776 >            common.logger.debug(5,"Files added to "+self.tgzNameWithPath+" : "+str(tar.getnames()))
777  
778 +            ##### ML stuff
779 +            ML_file_list=['report.py', 'DashboardAPI.py', 'Logger.py', 'ProcInfo.py', 'apmon.py']
780 +            path=os.environ['CRABDIR'] + '/python/'
781 +            for file in ML_file_list:
782 +                tar.add(path+file,file)
783 +            common.logger.debug(5,"Files added to "+self.tgzNameWithPath+" : "+str(tar.getnames()))
784 +
785 +            ##### Utils
786 +            Utils_file_list=['parseCrabFjr.py','writeCfg.py', 'fillCrabFjr.py']
787 +            for file in Utils_file_list:
788 +                tar.add(path+file,file)
789              common.logger.debug(5,"Files added to "+self.tgzNameWithPath+" : "+str(tar.getnames()))
790 +
791 +            ##### AdditionalFiles
792 +            for file in self.additional_inbox_files:
793 +                tar.add(file,string.split(file,'/')[-1])
794 +            common.logger.debug(5,"Files added to "+self.tgzNameWithPath+" : "+str(tar.getnames()))
795 +
796              tar.close()
797 <        except :
798 <            raise CrabException('Could not create tar-ball')
797 >        except IOError:
798 >            raise CrabException('Could not create tar-ball '+self.tgzNameWithPath)
799 >        except tarfile.TarError:
800 >            raise CrabException('Could not create tar-ball '+self.tgzNameWithPath)
801  
802          ## check for tarball size
803          tarballinfo = os.stat(self.tgzNameWithPath)
# Line 783 | Line 805 | class Cmssw(JobType):
805              raise CrabException('Input sandbox size of ' + str(float(tarballinfo.st_size)/1024.0/1024.0) + ' MB is larger than the allowed ' + str(self.MaxTarBallSize) + ' MB input sandbox limit and not supported by the used GRID submission system. Please make sure that no unnecessary files are in all data directories in your local CMSSW project area as they are automatically packed into the input sandbox.')
806  
807          ## create tar-ball with ML stuff
786        self.MLtgzfile =  common.work_space.pathForTgz()+'share/MLfiles.tgz'
787        try:
788            tar = tarfile.open(self.MLtgzfile, "w:gz")
789            path=os.environ['CRABDIR'] + '/python/'
790            #for file in ['report.py', 'DashboardAPI.py', 'Logger.py', 'ProcInfo.py', 'apmon.py', 'parseCrabFjr.py','writeCfg.py']:
791            ### FEDE ####
792            for file in ['report.py', 'DashboardAPI.py', 'Logger.py', 'ProcInfo.py', 'apmon.py', 'parseCrabFjr.py','writeCfg.py', 'JobReportErrorCode.py']:
793            ###############
794                tar.add(path+file,file)
795            common.logger.debug(5,"Files added to "+self.MLtgzfile+" : "+str(tar.getnames()))
796            tar.close()
797        except :
798            raise CrabException('Could not create ML files tar-ball')
799
800        return
801
802    def additionalInputFileTgz(self):
803        """
804        Put all additional files into a tar ball and return its name
805        """
806        import tarfile
807        tarName=  common.work_space.pathForTgz()+'share/'+self.additional_tgz_name
808        tar = tarfile.open(tarName, "w:gz")
809        for file in self.additional_inbox_files:
810            tar.add(file,string.split(file,'/')[-1])
811        common.logger.debug(5,"Files added to "+self.additional_tgz_name+" : "+str(tar.getnames()))
812        tar.close()
813        return tarName
808  
809      def wsSetupEnvironment(self, nj=0):
810          """
811          Returns part of a job script which prepares
812          the execution environment for the job 'nj'.
813          """
814 +        if (self.CMSSW_major >= 2 and self.CMSSW_minor >= 1) or (self.CMSSW_major >= 3):
815 +            psetName = 'pset.py'
816 +        else:
817 +            psetName = 'pset.cfg'
818          # Prepare JobType-independent part
819          txt = '\n#Written by cms_cmssw::wsSetupEnvironment\n'
820          txt += 'echo ">>> setup environment"\n'
# Line 825 | Line 823 | class Cmssw(JobType):
823          txt += 'elif [ $middleware == OSG ]; then\n'
824          txt += '    WORKING_DIR=`/bin/mktemp  -d $OSG_WN_TMP/cms_XXXXXXXXXXXX`\n'
825          txt += '    if [ ! $? == 0 ] ;then\n'
828        #txt += '        echo "SET_CMS_ENV 10016 ==> OSG $WORKING_DIR could not be created on WN `hostname`"\n'
829        #txt += '        echo "JOB_EXIT_STATUS = 10016"\n'
830        #txt += '        echo "JobExitCode=10016" | tee -a $RUNTIME_AREA/$repo\n'
831        #txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
832        #txt += '        exit 1\n'
826          txt += '        echo "ERROR ==> OSG $WORKING_DIR could not be created on WN `hostname`"\n'
827          txt += '        job_exit_code=10016\n'
828          txt += '        func_exit\n'
# Line 840 | Line 833 | class Cmssw(JobType):
833          txt += '    cd $WORKING_DIR\n'
834          txt += '    echo ">>> current directory (WORKING_DIR): $WORKING_DIR"\n'
835          txt += self.wsSetupCMSOSGEnvironment_()
843        #txt += '    echo "### Set SCRAM ARCH to ' + self.executable_arch + ' ###"\n'
844        #txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
836          txt += 'fi\n'
837  
838          # Prepare JobType-specific part
# Line 852 | Line 843 | class Cmssw(JobType):
843          txt += scram+' project CMSSW '+self.version+'\n'
844          txt += 'status=$?\n'
845          txt += 'if [ $status != 0 ] ; then\n'
855        #txt += '    echo "SET_EXE_ENV 10034 ==>ERROR CMSSW '+self.version+' not found on `hostname`" \n'
856        #txt += '    echo "JOB_EXIT_STATUS = 10034"\n'
857        #txt += '    echo "JobExitCode=10034" | tee -a $RUNTIME_AREA/$repo\n'
858        #txt += '    dumpStatus $RUNTIME_AREA/$repo\n'
846          txt += '    echo "ERROR ==> CMSSW '+self.version+' not found on `hostname`" \n'
847          txt += '    job_exit_code=10034\n'
861        #txt += '    if [ $middleware == OSG ]; then \n'
862        #txt += '        cd $RUNTIME_AREA\n'
863        #txt += '        echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
864        #txt += '        echo ">>> Remove working directory: $WORKING_DIR"\n'
865        #txt += '        /bin/rm -rf $WORKING_DIR\n'
866        #txt += '        if [ -d $WORKING_DIR ] ;then\n'
867        #txt += '            echo "SET_CMS_ENV 10018 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after CMSSW CMSSW_0_6_1 not found on `hostname`"\n'
868        #txt += '            echo "JOB_EXIT_STATUS = 10018"\n'
869        #txt += '            echo "JobExitCode=10018" | tee -a $RUNTIME_AREA/$repo\n'
870        #txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
871        #txt += '            echo "ERROR ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after CMSSW CMSSW_0_6_1 not found on `hostname`"\n'
872        #txt += '            job_exit_code=10017\n'
873        #txt += '        fi\n'
874        #txt += '    fi \n'
875        #txt += '    exit 1 \n'
848          txt += '    func_exit\n'
849          txt += 'fi \n'
850          txt += 'cd '+self.version+'\n'
879        ########## FEDE FOR DBS2 ######################
851          txt += 'SOFTWARE_DIR=`pwd`\n'
852          txt += 'echo ">>> current directory (SOFTWARE_DIR): $SOFTWARE_DIR" \n'
882        ###############################################
883        ### needed grep for bug in scramv1 ###
853          txt += 'eval `'+scram+' runtime -sh | grep -v SCRAMRT_LSB_JOBNAME`\n'
854 +        txt += 'if [ $? != 0 ] ; then\n'
855 +        txt += '    echo "ERROR ==> Problem with the command: "\n'
856 +        txt += '    echo "eval \`'+scram+' runtime -sh | grep -v SCRAMRT_LSB_JOBNAME \` at `hostname`"\n'
857 +        txt += '    job_exit_code=10034\n'
858 +        txt += '    func_exit\n'
859 +        txt += 'fi \n'
860          # Handle the arguments:
861          txt += "\n"
862          txt += "## number of arguments (first argument always jobnumber)\n"
863          txt += "\n"
889       # txt += "if [ $nargs -lt "+str(len(self.argsList[nj].split()))+" ]\n"
864          txt += "if [ $nargs -lt "+str(self.argsList)+" ]\n"
865          txt += "then\n"
892        #txt += "    echo 'SET_EXE_ENV 1 ==> ERROR Too few arguments' +$nargs+ \n"
893        #txt += '    echo "JOB_EXIT_STATUS = 50113"\n'
894        #txt += '    echo "JobExitCode=50113" | tee -a $RUNTIME_AREA/$repo\n'
895        #txt += '    dumpStatus $RUNTIME_AREA/$repo\n'
866          txt += "    echo 'ERROR ==> Too few arguments' +$nargs+ \n"
867          txt += '    job_exit_code=50113\n'
898        #txt += '    if [ $middleware == OSG ]; then \n'
899        #txt += '        cd $RUNTIME_AREA\n'
900        #txt += '        echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
901        #txt += '        echo ">>> Remove working directory: $WORKING_DIR"\n'
902        #txt += '        /bin/rm -rf $WORKING_DIR\n'
903        #txt += '        if [ -d $WORKING_DIR ] ;then\n'
904        #txt += '            echo "SET_EXE_ENV 50114 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after Too few arguments for CRAB job wrapper"\n'
905        #txt += '            echo "JOB_EXIT_STATUS = 50114"\n'
906        #txt += '            echo "JobExitCode=50114" | tee -a $RUNTIME_AREA/$repo\n'
907        #txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
908        #txt += '            echo "ERROR ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after Too few arguments for CRAB job wrapper"\n'
909        #txt += '            job_exit_code=10017\n'
910        #txt += '        fi\n'
911        #txt += '    fi\n'
912        #txt += "    exit 1\n"
868          txt += "    func_exit\n"
869          txt += "fi\n"
870          txt += "\n"
871  
872          # Prepare job-specific part
873          job = common.job_list[nj]
919        ### FEDE FOR DBS OUTPUT PUBLICATION
874          if (self.datasetPath):
875              txt += '\n'
876              txt += 'DatasetPath='+self.datasetPath+'\n'
# Line 932 | Line 886 | class Cmssw(JobType):
886              txt += 'PrimaryDataset=null\n'
887              txt += 'DataTier=null\n'
888              txt += 'ApplicationFamily=MCDataTier\n'
889 <        if self.pset != None:
889 >        if self.pset != None:
890              pset = os.path.basename(job.configFilename())
891              txt += '\n'
892              txt += 'cp  $RUNTIME_AREA/'+pset+' .\n'
893              if (self.datasetPath): # standard job
894                  txt += 'InputFiles=${args[1]}; export InputFiles\n'
895 <                txt += 'MaxEvents=${args[2]}; export MaxEvents\n'
896 <                txt += 'SkipEvents=${args[3]}; export SkipEvents\n'
895 >                if (self.useParent):
896 >                    txt += 'ParentFiles=${args[2]}; export ParentFiles\n'
897 >                    txt += 'MaxEvents=${args[3]}; export MaxEvents\n'
898 >                    txt += 'SkipEvents=${args[4]}; export SkipEvents\n'
899 >                else:
900 >                    txt += 'MaxEvents=${args[2]}; export MaxEvents\n'
901 >                    txt += 'SkipEvents=${args[3]}; export SkipEvents\n'
902                  txt += 'echo "Inputfiles:<$InputFiles>"\n'
903 +                if (self.useParent): txt += 'echo "ParentFiles:<$ParentFiles>"\n'
904                  txt += 'echo "MaxEvents:<$MaxEvents>"\n'
905                  txt += 'echo "SkipEvents:<$SkipEvents>"\n'
906              else:  # pythia like job
# Line 952 | Line 912 | class Cmssw(JobType):
912                      txt += 'FirstRun=${args[1]}; export FirstRun\n'
913                      txt += 'echo "FirstRun: <$FirstRun>"\n'
914  
915 <            txt += 'mv -f '+pset+' pset.cfg\n'
915 >            txt += 'mv -f ' + pset + ' ' + psetName + '\n'
916  
957        if len(self.additional_inbox_files) > 0:
958            txt += 'if [ -e $RUNTIME_AREA/'+self.additional_tgz_name+' ] ; then\n'
959            txt += '  tar xzvf $RUNTIME_AREA/'+self.additional_tgz_name+'\n'
960            txt += 'fi\n'
961            pass
917  
918          if self.pset != None:
919 +            # FUTURE: Can simply for 2_1_x and higher
920              txt += '\n'
921 <            txt += 'echo "***** cat pset.cfg *********"\n'
922 <            txt += 'cat pset.cfg\n'
923 <            txt += 'echo "****** end pset.cfg ********"\n'
924 <            txt += '\n'
925 <            txt += 'PSETHASH=`EdmConfigHash < pset.cfg` \n'
921 >            if self.debug_wrapper==True:
922 >                txt += 'echo "***** cat ' + psetName + ' *********"\n'
923 >                txt += 'cat ' + psetName + '\n'
924 >                txt += 'echo "****** end ' + psetName + ' ********"\n'
925 >                txt += '\n'
926 >            if (self.CMSSW_major >= 2 and self.CMSSW_minor >= 1) or (self.CMSSW_major >= 3):
927 >                txt += 'PSETHASH=`edmConfigHash ' + psetName + '` \n'
928 >            else:
929 >                txt += 'PSETHASH=`edmConfigHash < ' + psetName + '` \n'
930              txt += 'echo "PSETHASH = $PSETHASH" \n'
931              txt += '\n'
932          return txt
933 <    #### FEDE #####
933 >
934      def wsUntarSoftware(self, nj=0):
935          """
936          Put in the script the commands to build an executable
# Line 982 | Line 942 | class Cmssw(JobType):
942          if os.path.isfile(self.tgzNameWithPath):
943              txt += 'echo ">>> tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+' :" \n'
944              txt += 'tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'\n'
945 +            if  self.debug_wrapper:
946 +                txt += 'ls -Al \n'
947              txt += 'untar_status=$? \n'
948              txt += 'if [ $untar_status -ne 0 ]; then \n'
949              txt += '   echo "ERROR ==> Untarring .tgz file failed"\n'
# Line 991 | Line 953 | class Cmssw(JobType):
953              txt += '   echo "Successful untar" \n'
954              txt += 'fi \n'
955              txt += '\n'
956 <            txt += 'echo ">>> Include ProdCommon in PYTHONPATH:"\n'
956 >            txt += 'echo ">>> Include $RUNTIME_AREA in PYTHONPATH:"\n'
957              txt += 'if [ -z "$PYTHONPATH" ]; then\n'
958 <            txt += '   export PYTHONPATH=$RUNTIME_AREA/ProdCommon\n'
958 >            txt += '   export PYTHONPATH=$RUNTIME_AREA/\n'
959              txt += 'else\n'
960 <            txt += '   export PYTHONPATH=$RUNTIME_AREA/ProdCommon:${PYTHONPATH}\n'
960 >            txt += '   export PYTHONPATH=$RUNTIME_AREA/:${PYTHONPATH}\n'
961              txt += 'echo "PYTHONPATH=$PYTHONPATH"\n'
962              txt += 'fi\n'
963              txt += '\n'
# Line 1003 | Line 965 | class Cmssw(JobType):
965              pass
966  
967          return txt
968 <        
968 >
969      def wsBuildExe(self, nj=0):
970          """
971          Put in the script the commands to build an executable
# Line 1013 | Line 975 | class Cmssw(JobType):
975          txt = '\n#Written by cms_cmssw::wsBuildExe\n'
976          txt += 'echo ">>> moving CMSSW software directories in `pwd`" \n'
977  
978 <        txt += 'mv $RUNTIME_AREA/lib . \n'
979 <        txt += 'mv $RUNTIME_AREA/module . \n'
980 <        txt += 'mv $RUNTIME_AREA/ProdCommon . \n'
981 <        
982 <
983 <        #if os.path.isfile(self.tgzNameWithPath):
984 <        #    txt += 'echo ">>> tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+' :" \n'
985 <        #    txt += 'tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'\n'
986 <        #    txt += 'untar_status=$? \n'
987 <        #    txt += 'if [ $untar_status -ne 0 ]; then \n'
988 <        #    txt += '   echo "ERROR ==> Untarring .tgz file failed"\n'
989 <        #    txt += '   job_exit_code=$untar_status\n'
990 <        #    txt += '   func_exit\n'
1029 <        #    txt += 'else \n'
1030 <        #    txt += '   echo "Successful untar" \n'
1031 <        #    txt += 'fi \n'
1032 <        #    txt += '\n'
1033 <        #    txt += 'echo ">>> Include ProdCommon in PYTHONPATH:"\n'
978 >        txt += 'rm -r lib/ module/ \n'
979 >        txt += 'mv $RUNTIME_AREA/lib/ . \n'
980 >        txt += 'mv $RUNTIME_AREA/module/ . \n'
981 >        if self.dataExist == True:
982 >            txt += 'rm -r src/ \n'
983 >            txt += 'mv $RUNTIME_AREA/src/ . \n'
984 >        if len(self.additional_inbox_files)>0:
985 >            for file in self.additional_inbox_files:
986 >                txt += 'mv $RUNTIME_AREA/'+os.path.basename(file)+' . \n'
987 >        # txt += 'mv $RUNTIME_AREA/ProdCommon/ . \n'
988 >        # txt += 'mv $RUNTIME_AREA/IMProv/ . \n'
989 >
990 >        txt += 'echo ">>> Include $RUNTIME_AREA in PYTHONPATH:"\n'
991          txt += 'if [ -z "$PYTHONPATH" ]; then\n'
992 <        txt += '   export PYTHONPATH=$SOFTWARE_DIR/ProdCommon\n'
992 >        txt += '   export PYTHONPATH=$RUNTIME_AREA/\n'
993          txt += 'else\n'
994 <        txt += '   export PYTHONPATH=$SOFTWARE_DIR/ProdCommon:${PYTHONPATH}\n'
994 >        txt += '   export PYTHONPATH=$RUNTIME_AREA/:${PYTHONPATH}\n'
995          txt += 'echo "PYTHONPATH=$PYTHONPATH"\n'
996          txt += 'fi\n'
997          txt += '\n'
998  
999          return txt
1043    ############################################################################
1000  
1045    def modifySteeringCards(self, nj):
1046        """
1047        modify the card provided by the user,
1048        writing a new card into share dir
1049        """
1001  
1002      def executableName(self):
1003 <        if self.scriptExe: #CarlosDaniele
1003 >        if self.scriptExe:
1004              return "sh "
1005          else:
1006              return self.executable
# Line 1059 | Line 1010 | class Cmssw(JobType):
1010          if self.scriptExe:#CarlosDaniele
1011              return   self.scriptExe + " $NJob"
1012          else:
1062            version_array = self.scram.getSWVersion().split('_')
1063            major = 0
1064            minor = 0
1065            try:
1066                major = int(version_array[1])
1067                minor = int(version_array[2])
1068            except:
1069                msg = "Cannot parse CMSSW version string: " + "_".join(version_array) + " for major and minor release number!"
1070                raise CrabException(msg)
1071
1013              ex_args = ""
1014 <
1014 >            # FUTURE: This tests the CMSSW version. Can remove code as versions deprecated
1015              # Framework job report
1016 <            if major >= 1 and minor >= 5 :
1076 <                #ex_args += " -j " + self.fjrFileName
1077 <            ### FEDE it could be improved!!! ####    
1016 >            if (self.CMSSW_major >= 1 and self.CMSSW_minor >= 5) or (self.CMSSW_major >= 2):
1017                  ex_args += " -j $RUNTIME_AREA/crab_fjr_$NJob.xml"
1018 <            #######################################
1019 <            # Type of cfg file
1020 <            if major >= 2 :
1082 <                ex_args += " -p pset.pycfg"
1018 >            # Type of config file
1019 >            if self.CMSSW_major >= 2 :
1020 >                ex_args += " -p pset.py"
1021              else:
1022                  ex_args += " -p pset.cfg"
1023              return ex_args
# Line 1089 | Line 1027 | class Cmssw(JobType):
1027          Returns a list of filenames to be put in JDL input sandbox.
1028          """
1029          inp_box = []
1092        # # dict added to delete duplicate from input sandbox file list
1093        # seen = {}
1094        ## code
1030          if os.path.isfile(self.tgzNameWithPath):
1031              inp_box.append(self.tgzNameWithPath)
1097        if os.path.isfile(self.MLtgzfile):
1098            inp_box.append(self.MLtgzfile)
1099        ## config
1100        if not self.pset is None:
1101            inp_box.append(common.work_space.pathForTgz() + 'job/' + self.configFilename())
1102        ## additional input files
1103        tgz = self.additionalInputFileTgz()
1104        inp_box.append(tgz)
1105        ## executable
1032          wrapper = os.path.basename(str(common._db.queryTask('scriptName')))
1033          inp_box.append(common.work_space.pathForTgz() +'job/'+ wrapper)
1034          return inp_box
# Line 1116 | Line 1042 | class Cmssw(JobType):
1042          ## User Declared output files
1043          for out in (self.output_file+self.output_file_sandbox):
1044              n_out = nj + 1
1045 <            out_box.append(self.numberFile_(out,str(n_out)))
1045 >            out_box.append(numberFile(out,str(n_out)))
1046          return out_box
1047  
1122    def prepareSteeringCards(self):
1123        """
1124        Make initial modifications of the user's steering card file.
1125        """
1126        return
1048  
1049      def wsRenameOutput(self, nj):
1050          """
# Line 1133 | Line 1054 | class Cmssw(JobType):
1054          txt = '\n#Written by cms_cmssw::wsRenameOutput\n'
1055          txt += 'echo ">>> current directory (SOFTWARE_DIR): $SOFTWARE_DIR" \n'
1056          txt += 'echo ">>> current directory content:"\n'
1057 <        txt += 'ls \n'
1057 >        if self.debug_wrapper:
1058 >            txt += 'ls -Al\n'
1059          txt += '\n'
1060  
1139        #txt += 'output_exit_status=0\n'
1140
1141        ### FEDE #######
1142        #for fileWithSuffix in (self.output_file_sandbox):
1143        #    output_file_num = self.numberFile_(fileWithSuffix, '$NJob')
1144        #    txt += '\n'
1145        #    txt += '# check output file\n'
1146        #    txt += 'if [ -e ./'+fileWithSuffix+' ] ; then\n'
1147        #    txt += '    mv '+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
1148        #    txt += '    ln -s $RUNTIME_AREA/'+output_file_num+' $RUNTIME_AREA/'+fileWithSuffix+'\n'
1149        #    txt += 'else\n'
1150        #    txt += '    echo "WARNING: Output file '+fileWithSuffix+' not found"\n'
1151        #    txt += '    job_exit_code=60302\n'
1152        #    if common.scheduler.name().upper() == 'CONDOR_G':
1153        #        txt += '    if [ $middleware == OSG ]; then \n'
1154        #        txt += '        echo "prepare dummy output file"\n'
1155        #        txt += '        echo "Processing of job output failed" > $RUNTIME_AREA/'+output_file_num+'\n'
1156        #        txt += '    fi \n'
1157        #    txt += 'fi\n'
1158
1061          for fileWithSuffix in (self.output_file):
1062 <            output_file_num = self.numberFile_(fileWithSuffix, '$NJob')
1062 >            output_file_num = numberFile(fileWithSuffix, '$NJob')
1063              txt += '\n'
1064              txt += '# check output file\n'
1065              txt += 'if [ -e ./'+fileWithSuffix+' ] ; then\n'
# Line 1168 | Line 1070 | class Cmssw(JobType):
1070                  txt += '    mv '+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
1071                  txt += '    ln -s $RUNTIME_AREA/'+output_file_num+' $RUNTIME_AREA/'+fileWithSuffix+'\n'
1072              txt += 'else\n'
1171            #txt += '    exit_status=60302\n'
1172            #txt += '    echo "ERROR: Output file '+fileWithSuffix+' not found"\n'
1173            #txt += '    echo "JOB_EXIT_STATUS = $exit_status"\n'
1174            #txt += '    output_exit_status=$exit_status\n'
1073              txt += '    job_exit_code=60302\n'
1074              txt += '    echo "WARNING: Output file '+fileWithSuffix+' not found"\n'
1075              if common.scheduler.name().upper() == 'CONDOR_G':
# Line 1182 | Line 1080 | class Cmssw(JobType):
1080              txt += 'fi\n'
1081          file_list = []
1082          for fileWithSuffix in (self.output_file):
1083 <             file_list.append(self.numberFile_(fileWithSuffix, '$NJob'))
1083 >             file_list.append(numberFile(fileWithSuffix, '$NJob'))
1084  
1085          txt += 'file_list="'+string.join(file_list,' ')+'"\n'
1086          txt += '\n'
1087          txt += 'echo ">>> current directory (SOFTWARE_DIR): $SOFTWARE_DIR" \n'
1088          txt += 'echo ">>> current directory content:"\n'
1089 <        txt += 'ls \n'
1089 >        if self.debug_wrapper:
1090 >            txt += 'ls -Al\n'
1091          txt += '\n'
1092          txt += 'cd $RUNTIME_AREA\n'
1093          txt += 'echo ">>> current directory (RUNTIME_AREA):  $RUNTIME_AREA"\n'
1094          return txt
1095  
1197    def numberFile_(self, file, txt):
1198        """
1199        append _'txt' before last extension of a file
1200        """
1201        p = string.split(file,".")
1202        # take away last extension
1203        name = p[0]
1204        for x in p[1:-1]:
1205            name=name+"."+x
1206        # add "_txt"
1207        if len(p)>1:
1208            ext = p[len(p)-1]
1209            result = name + '_' + txt + "." + ext
1210        else:
1211            result = name + '_' + txt
1212
1213        return result
1214
1096      def getRequirements(self, nj=[]):
1097          """
1098          return job requirements to add to jdl files
# Line 1221 | Line 1102 | class Cmssw(JobType):
1102              req='Member("VO-cms-' + \
1103                   self.version + \
1104                   '", other.GlueHostApplicationSoftwareRunTimeEnvironment)'
1105 <        ## SL add requirement for OS version only if SL4
1225 <        #reSL4 = re.compile( r'slc4' )
1226 <        if self.executable_arch: # and reSL4.search(self.executable_arch):
1105 >        if self.executable_arch:
1106              req+=' && Member("VO-cms-' + \
1107                   self.executable_arch + \
1108                   '", other.GlueHostApplicationSoftwareRunTimeEnvironment)'
# Line 1236 | Line 1115 | class Cmssw(JobType):
1115  
1116      def configFilename(self):
1117          """ return the config filename """
1118 <        return self.name()+'.cfg'
1118 >        # FUTURE: Can remove cfg mode for CMSSW >= 2_1_x
1119 >        if (self.CMSSW_major >= 2 and self.CMSSW_minor >= 1) or (self.CMSSW_major >= 3):
1120 >          return self.name()+'.py'
1121 >        else:
1122 >          return self.name()+'.cfg'
1123  
1124      def wsSetupCMSOSGEnvironment_(self):
1125          """
# Line 1252 | Line 1135 | class Cmssw(JobType):
1135          txt += '      # Use $OSG_APP/cmssoft/cms/cmsset_default.sh to setup cms software\n'
1136          txt += '        source $OSG_APP/cmssoft/cms/cmsset_default.sh '+self.version+'\n'
1137          txt += '    else\n'
1255        #txt += '        echo "SET_CMS_ENV 10020 ==> ERROR $OSG_APP/cmssoft/cms/cmsset_default.sh file not found"\n'
1256        #txt += '        echo "JOB_EXIT_STATUS = 10020"\n'
1257        #txt += '        echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
1258        #txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
1138          txt += '        echo "ERROR ==> $OSG_APP/cmssoft/cms/cmsset_default.sh file not found"\n'
1139          txt += '        job_exit_code=10020\n'
1261        #txt += '        cd $RUNTIME_AREA\n'
1262        #txt += '        echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
1263        #txt += '        echo ">>> Remove working directory: $WORKING_DIR"\n'
1264        #txt += '        /bin/rm -rf $WORKING_DIR\n'
1265        #txt += '        if [ -d $WORKING_DIR ] ;then\n'
1266        #txt += '            echo "SET_CMS_ENV 10017 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after $OSG_APP/cmssoft/cms/cmsset_default.sh file not found"\n'
1267        #txt += '            echo "JOB_EXIT_STATUS = 10017"\n'
1268        #txt += '            echo "JobExitCode=10017" | tee -a $RUNTIME_AREA/$repo\n'
1269        #txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
1270        #txt += '            echo "ERROR ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after $OSG_APP/cmssoft/cms/cmsset_default.sh file not found"\n'
1271        #txt += '            job_exit_code=10017\n'
1272        #txt += '        fi\n'
1273        txt += '\n'
1274        #txt += '        exit 1\n'
1140          txt += '        func_exit\n'
1141          txt += '    fi\n'
1142          txt += '\n'
# Line 1280 | Line 1145 | class Cmssw(JobType):
1145  
1146          return txt
1147  
1283    ### OLI_DANIELE
1148      def wsSetupCMSLCGEnvironment_(self):
1149          """
1150          Returns part of a job script which is prepares
# Line 1292 | Line 1156 | class Cmssw(JobType):
1156          txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
1157          txt += '    export BUILD_ARCH='+self.executable_arch+'\n'
1158          txt += '    if [ ! $VO_CMS_SW_DIR ] ;then\n'
1295        #txt += '        echo "SET_CMS_ENV 10031 ==> ERROR CMS software dir not found on WN `hostname`"\n'
1296        #txt += '        echo "JOB_EXIT_STATUS = 10031" \n'
1297        #txt += '        echo "JobExitCode=10031" | tee -a $RUNTIME_AREA/$repo\n'
1298        #txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
1299        #txt += '        exit 1\n'
1159          txt += '        echo "ERROR ==> CMS software dir not found on WN `hostname`"\n'
1160          txt += '        job_exit_code=10031\n'
1161          txt += '        func_exit\n'
1162          txt += '    else\n'
1163          txt += '        echo "Sourcing environment... "\n'
1164          txt += '        if [ ! -s $VO_CMS_SW_DIR/cmsset_default.sh ] ;then\n'
1306        #txt += '            echo "SET_CMS_ENV 10020 ==> ERROR cmsset_default.sh file not found into dir $VO_CMS_SW_DIR"\n'
1307        #txt += '            echo "JOB_EXIT_STATUS = 10020"\n'
1308        #txt += '            echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
1309        #txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
1310        #txt += '            exit 1\n'
1165          txt += '            echo "ERROR ==> cmsset_default.sh file not found into dir $VO_CMS_SW_DIR"\n'
1166          txt += '            job_exit_code=10020\n'
1167          txt += '            func_exit\n'
# Line 1316 | Line 1170 | class Cmssw(JobType):
1170          txt += '        source $VO_CMS_SW_DIR/cmsset_default.sh\n'
1171          txt += '        result=$?\n'
1172          txt += '        if [ $result -ne 0 ]; then\n'
1319        #txt += '            echo "SET_CMS_ENV 10032 ==> ERROR problem sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
1320        #txt += '            echo "JOB_EXIT_STATUS = 10032"\n'
1321        #txt += '            echo "JobExitCode=10032" | tee -a $RUNTIME_AREA/$repo\n'
1322        #txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
1323        #txt += '            exit 1\n'
1173          txt += '            echo "ERROR ==> problem sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
1174          txt += '            job_exit_code=10032\n'
1175          txt += '            func_exit\n'
# Line 1330 | Line 1179 | class Cmssw(JobType):
1179          txt += '    echo "==> setup cms environment ok"\n'
1180          return txt
1181  
1333    ### FEDE FOR DBS OUTPUT PUBLICATION
1182      def modifyReport(self, nj):
1183          """
1184          insert the part of the script that modifies the FrameworkJob Report
1185          """
1338
1186          txt = '\n#Written by cms_cmssw::modifyReport\n'
1187 <        try:
1341 <            publish_data = int(self.cfg_params['USER.publish_data'])
1342 <        except KeyError:
1343 <            publish_data = 0
1187 >        publish_data = int(self.cfg_params.get('USER.publish_data',0))
1188          if (publish_data == 1):
1189 <            
1189 >            processedDataset = self.cfg_params['USER.publish_data_name']
1190 >            ### FEDE  for publication with LSF and CAF schedulers ####
1191 >            print "common.scheduler.name().upper() = ", common.scheduler.name().upper()
1192 >            if (common.scheduler.name().upper() == "CAF" or common.scheduler.name().upper() == "LSF"):
1193 >                print "chiamo LFNBaseName con localUser = true"
1194 >                LFNBaseName = LFNBase(processedDataset, LocalUser=True)
1195 >            else :
1196 >                LFNBaseName = LFNBase(processedDataset)
1197 >            ####
1198 >
1199              txt += 'if [ $copy_exit_status -eq 0 ]; then\n'
1200 <            txt += '    echo ">>> Modify Job Report:" \n'
1201 <            txt += '    chmod a+x $SOFTWARE_DIR/ProdCommon/ProdCommon/FwkJobRep/ModifyJobReport.py\n'
1202 <            #txt += '    if [ -z "$SE" ]; then\n'
1203 <            #txt += '        SE="" \n'
1204 <            #txt += '    fi \n'
1205 <            #txt += '    if [ -z "$SE_PATH" ]; then\n'
1353 <            #txt += '        SE_PATH="" \n'
1354 <            #txt += '    fi \n'
1355 <            txt += '    echo "SE = $SE"\n'
1356 <            txt += '    echo "SE_PATH = $SE_PATH"\n'
1200 >            txt += '    FOR_LFN=%s_${PSETHASH}/\n'%(LFNBaseName)
1201 >            txt += 'else\n'
1202 >            txt += '    FOR_LFN=/copy_problems/ \n'
1203 >            txt += '    SE=""\n'
1204 >            txt += '    SE_PATH=""\n'
1205 >            txt += 'fi\n'
1206  
1207 <            processedDataset = self.cfg_params['USER.publish_data_name']
1208 <            txt += '    ProcessedDataset='+processedDataset+'\n'
1209 <            #txt += '    if [ "$SE_PATH" == "" ]; then\n'
1210 <            #txt += '        FOR_LFN=/copy_problems/ \n'
1211 <            #txt += '    else \n'
1212 <            #txt += '        tmp=`echo $SE_PATH | awk -F \'store\' \'{print$2}\'` \n'
1213 <            #txt += '        FOR_LFN=/store$tmp \n'
1214 <            #txt += '    fi \n'
1215 <            txt += '    tmp=`echo $SE_PATH | awk -F \'store\' \'{print$2}\'` \n'
1216 <            txt += '    FOR_LFN=/store$tmp \n'
1217 <            txt += '    echo "ProcessedDataset = $ProcessedDataset"\n'
1218 <            txt += '    echo "FOR_LFN = $FOR_LFN" \n'
1219 <            txt += '    echo "CMSSW_VERSION = $CMSSW_VERSION"\n\n'
1220 <            #txt += '    echo "$SOFTWARE_DIR/ProdCommon/ProdCommon/FwkJobRep/ModifyJobReport.py crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH"\n'
1221 <            #txt += '    $SOFTWARE_DIR/ProdCommon/ProdCommon/FwkJobRep/ModifyJobReport.py crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH\n'
1222 <            ### FEDE ####
1223 <            txt += '    echo "$SOFTWARE_DIR/ProdCommon/ProdCommon/FwkJobRep/ModifyJobReport.py $RUNTIME_AREA/crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH"\n'
1224 <            txt += '    $SOFTWARE_DIR/ProdCommon/ProdCommon/FwkJobRep/ModifyJobReport.py $RUNTIME_AREA/crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH\n'
1376 <            ####################################
1377 <            txt += '    modifyReport_result=$?\n'
1378 <            txt += '    if [ $modifyReport_result -ne 0 ]; then\n'
1379 <            txt += '        modifyReport_result=70500\n'
1380 <            txt += '        job_exit_code=$modifyReport_result\n'
1381 <            txt += '        echo "ModifyReportResult=$modifyReport_result" | tee -a $RUNTIME_AREA/$repo\n'
1382 <            txt += '        echo "WARNING: Problem with ModifyJobReport"\n'
1383 <            txt += '    else\n'
1384 <            ### FEDE #####
1385 <            #txt += '        mv NewFrameworkJobReport.xml crab_fjr_$NJob.xml\n'
1386 <            #######################
1387 <            txt += '        mv NewFrameworkJobReport.xml $RUNTIME_AREA/crab_fjr_$NJob.xml\n'
1388 <            txt += '    fi\n'
1207 >            txt += 'echo ">>> Modify Job Report:" \n'
1208 >            txt += 'chmod a+x $RUNTIME_AREA/ProdCommon/FwkJobRep/ModifyJobReport.py\n'
1209 >            txt += 'ProcessedDataset='+processedDataset+'\n'
1210 >            txt += 'echo "ProcessedDataset = $ProcessedDataset"\n'
1211 >            txt += 'echo "SE = $SE"\n'
1212 >            txt += 'echo "SE_PATH = $SE_PATH"\n'
1213 >            txt += 'echo "FOR_LFN = $FOR_LFN" \n'
1214 >            txt += 'echo "CMSSW_VERSION = $CMSSW_VERSION"\n\n'
1215 >            txt += 'echo "$RUNTIME_AREA/ProdCommon/FwkJobRep/ModifyJobReport.py $RUNTIME_AREA/crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH"\n'
1216 >            txt += '$RUNTIME_AREA/ProdCommon/FwkJobRep/ModifyJobReport.py $RUNTIME_AREA/crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH\n'
1217 >            txt += 'modifyReport_result=$?\n'
1218 >            txt += 'if [ $modifyReport_result -ne 0 ]; then\n'
1219 >            txt += '    modifyReport_result=70500\n'
1220 >            txt += '    job_exit_code=$modifyReport_result\n'
1221 >            txt += '    echo "ModifyReportResult=$modifyReport_result" | tee -a $RUNTIME_AREA/$repo\n'
1222 >            txt += '    echo "WARNING: Problem with ModifyJobReport"\n'
1223 >            txt += 'else\n'
1224 >            txt += '    mv NewFrameworkJobReport.xml $RUNTIME_AREA/crab_fjr_$NJob.xml\n'
1225              txt += 'fi\n'
1226          return txt
1227  
1228 <    def cleanEnv(self):
1229 <        txt = '\n#Written by cms_cmssw::cleanEnv\n'
1230 <        txt += 'if [ $middleware == OSG ]; then\n'
1231 <        txt += '    cd $RUNTIME_AREA\n'
1232 <        txt += '    echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
1233 <        txt += '    echo ">>> Remove working directory: $WORKING_DIR"\n'
1234 <        txt += '    /bin/rm -rf $WORKING_DIR\n'
1235 <        txt += '    if [ -d $WORKING_DIR ] ;then\n'
1236 <        txt += '        echo "ERROR ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after cleanup of WN"\n'
1237 <        txt += '        job_exit_code=10017\n'
1238 <        txt += '        func_exit\n'
1228 >    def wsParseFJR(self):
1229 >        """
1230 >        Parse the FrameworkJobReport to obtain useful infos
1231 >        """
1232 >        txt = '\n#Written by cms_cmssw::wsParseFJR\n'
1233 >        txt += 'echo ">>> Parse FrameworkJobReport crab_fjr.xml"\n'
1234 >        txt += 'if [ -s $RUNTIME_AREA/crab_fjr_$NJob.xml ]; then\n'
1235 >        txt += '    if [ -s $RUNTIME_AREA/parseCrabFjr.py ]; then\n'
1236 >        txt += '        cmd_out=`python $RUNTIME_AREA/parseCrabFjr.py --input $RUNTIME_AREA/crab_fjr_$NJob.xml --dashboard $MonitorID,$MonitorJobID '+self.debugWrap+'`\n'
1237 >        if self.debug_wrapper :
1238 >            txt += '        echo "Result of parsing the FrameworkJobReport crab_fjr.xml: $cmd_out"\n'
1239 >        txt += '        executable_exit_status=`python $RUNTIME_AREA/parseCrabFjr.py --input $RUNTIME_AREA/crab_fjr_$NJob.xml --exitcode`\n'
1240 >        txt += '        if [ $executable_exit_status -eq 50115 ];then\n'
1241 >        txt += '            echo ">>> crab_fjr.xml contents: "\n'
1242 >        txt += '            cat $RUNTIME_AREA/crab_fjr_$NJob.xml\n'
1243 >        txt += '            echo "Wrong FrameworkJobReport --> does not contain useful info. ExitStatus: $executable_exit_status"\n'
1244 >        txt += '        elif [ $executable_exit_status -eq -999 ];then\n'
1245 >        txt += '            echo "ExitStatus from FrameworkJobReport not available. not available. Using exit code of executable from command line."\n'
1246 >        txt += '        else\n'
1247 >        txt += '            echo "Extracted ExitStatus from FrameworkJobReport parsing output: $executable_exit_status"\n'
1248 >        txt += '        fi\n'
1249 >        txt += '    else\n'
1250 >        txt += '        echo "CRAB python script to parse CRAB FrameworkJobReport crab_fjr.xml is not available, using exit code of executable from command line."\n'
1251          txt += '    fi\n'
1252 +          #### Patch to check input data reading for CMSSW16x Hopefully we-ll remove it asap
1253 +
1254 +        if (self.datasetPath and not self.dataset_pu ):
1255 +          # VERIFY PROCESSED DATA
1256 +            txt += '    if [ $executable_exit_status -eq 0 ];then\n'
1257 +            txt += '      echo ">>> Verify list of processed files:"\n'
1258 +            txt += '      echo $InputFiles |tr -d \'\\\\\' |tr \',\' \'\\n\'|tr -d \'"\' > input-files.txt\n'
1259 +            txt += '      python $RUNTIME_AREA/parseCrabFjr.py --input $RUNTIME_AREA/crab_fjr_$NJob.xml --lfn > processed-files.txt\n'
1260 +            txt += '      cat input-files.txt  | sort | uniq > tmp.txt\n'
1261 +            txt += '      mv tmp.txt input-files.txt\n'
1262 +            txt += '      echo "cat input-files.txt"\n'
1263 +            txt += '      echo "----------------------"\n'
1264 +            txt += '      cat input-files.txt\n'
1265 +            txt += '      cat processed-files.txt | sort | uniq > tmp.txt\n'
1266 +            txt += '      mv tmp.txt processed-files.txt\n'
1267 +            txt += '      echo "----------------------"\n'
1268 +            txt += '      echo "cat processed-files.txt"\n'
1269 +            txt += '      echo "----------------------"\n'
1270 +            txt += '      cat processed-files.txt\n'
1271 +            txt += '      echo "----------------------"\n'
1272 +            txt += '      diff -q input-files.txt processed-files.txt\n'
1273 +            txt += '      fileverify_status=$?\n'
1274 +            txt += '      if [ $fileverify_status -ne 0 ]; then\n'
1275 +            txt += '         executable_exit_status=30001\n'
1276 +            txt += '         echo "ERROR ==> not all input files processed"\n'
1277 +            txt += '         echo "      ==> list of processed files from crab_fjr.xml differs from list in pset.cfg"\n'
1278 +            txt += '         echo "      ==> diff input-files.txt processed-files.txt"\n'
1279 +            txt += '      fi\n'
1280 +            txt += '    fi\n'
1281 +            txt += '\n'
1282 +        txt += 'else\n'
1283 +        txt += '    echo "CRAB FrameworkJobReport crab_fjr.xml is not available, using exit code of executable from command line."\n'
1284          txt += 'fi\n'
1285          txt += '\n'
1286 +        txt += 'echo "ExeExitCode=$executable_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
1287 +        txt += 'echo "EXECUTABLE_EXIT_STATUS = $executable_exit_status"\n'
1288 +        txt += 'job_exit_code=$executable_exit_status\n'
1289 +
1290          return txt
1291  
1292      def setParam_(self, param, value):
# Line 1427 | Line 1311 | class Cmssw(JobType):
1311          txt = ''
1312          txt += 'echo ">>> list of expected files on output sandbox"\n'
1313          listOutFiles = []
1314 <        stdout = 'CMSSW_$NJob.stdout'
1314 >        stdout = 'CMSSW_$NJob.stdout'
1315          stderr = 'CMSSW_$NJob.stderr'
1316          if (self.return_data == 1):
1317              for file in (self.output_file+self.output_file_sandbox):
1318 <                listOutFiles.append(self.numberFile_(file, '$NJob'))
1318 >                listOutFiles.append(numberFile(file, '$NJob'))
1319              listOutFiles.append(stdout)
1320              listOutFiles.append(stderr)
1321          else:
1322              for file in (self.output_file_sandbox):
1323 <                listOutFiles.append(self.numberFile_(file, '$NJob'))
1323 >                listOutFiles.append(numberFile(file, '$NJob'))
1324              listOutFiles.append(stdout)
1325              listOutFiles.append(stderr)
1326          txt += 'echo "output files: '+string.join(listOutFiles,' ')+'"\n'
1327          txt += 'filesToCheck="'+string.join(listOutFiles,' ')+'"\n'
1328          txt += 'export filesToCheck\n'
1329 <        return txt
1329 >        return txt

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines