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.203 by spiga, Tue Jun 3 09:06:51 2008 UTC

# Line 5 | Line 5 | from crab_util import *
5   from BlackWhiteListParser import BlackWhiteListParser
6   import common
7   import Scram
8 + from LFNBaseName import *
9  
10   import os, string, glob
11  
# Line 33 | Line 34 | class Cmssw(JobType):
34          self.executable = ''
35          self.executable_arch = self.scram.getArch()
36          self.tgz_name = 'default.tgz'
36        self.additional_tgz_name = 'additional.tgz'
37          self.scriptName = 'CMSSW.sh'
38 <        self.pset = ''      #scrip use case Da
39 <        self.datasetPath = '' #scrip use case Da
38 >        self.pset = ''
39 >        self.datasetPath = ''
40  
41          # set FJR file name
42          self.fjrFileName = 'crab_fjr.xml'
43  
44          self.version = self.scram.getSWVersion()
45 <
46 <        #
47 <        # Try to block creation in case of arch/version mismatch
48 <        #
49 <
50 < #        a = string.split(self.version, "_")
51 < #
52 < #        if int(a[1]) == 1 and (int(a[2]) < 5 and self.executable_arch.find('slc4') == 0):
53 < #            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)
54 < #            common.logger.message(msg)
55 < #        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)
45 >        version_array = self.version.split('_')
46 >        self.CMSSW_major = 0
47 >        self.CMSSW_minor = 0
48 >        self.CMSSW_patch = 0
49 >        try:
50 >            self.CMSSW_major = int(version_array[1])
51 >            self.CMSSW_minor = int(version_array[2])
52 >            self.CMSSW_patch = int(version_array[3])
53 >        except:
54 >            msg = "Cannot parse CMSSW version string: " + self.version + " for major and minor release number!"
55 >            raise CrabException(msg)
56  
57          ### collect Data cards
58  
# Line 73 | Line 68 | class Cmssw(JobType):
68              self.datasetPath = tmp
69              self.selectNoInput = 0
70  
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
71          self.dataTiers = []
72 <
72 >        self.debugWrap = ''
73 >        self.debug_wrapper = cfg_params.get('USER.debug_wrapper',False)
74 >        if self.debug_wrapper: self.debugWrap='--debug'
75          ## now the application
76          self.executable = cfg_params.get('CMSSW.executable','cmsRun')
99        self.setParam_('exe', self.executable)
77          log.debug(6, "CMSSW::CMSSW(): executable = "+self.executable)
78  
79          if not cfg_params.has_key('CMSSW.pset'):
# Line 133 | Line 110 | class Cmssw(JobType):
110          # script_exe file as additional file in inputSandbox
111          self.scriptExe = cfg_params.get('USER.script_exe',None)
112          if self.scriptExe :
113 <           if not os.path.isfile(self.scriptExe):
114 <              msg ="ERROR. file "+self.scriptExe+" not found"
115 <              raise CrabException(msg)
116 <           self.additional_inbox_files.append(string.strip(self.scriptExe))
113 >            if not os.path.isfile(self.scriptExe):
114 >                msg ="ERROR. file "+self.scriptExe+" not found"
115 >                raise CrabException(msg)
116 >            self.additional_inbox_files.append(string.strip(self.scriptExe))
117  
141        #CarlosDaniele
118          if self.datasetPath == None and self.pset == None and self.scriptExe == '' :
119 <           msg ="Error. script_exe  not defined"
120 <           raise CrabException(msg)
119 >            msg ="Error. script_exe  not defined"
120 >            raise CrabException(msg)
121  
122          ## additional input files
123          if cfg_params.has_key('USER.additional_input_files'):
# Line 161 | Line 137 | class Cmssw(JobType):
137                      if not os.path.exists(file):
138                          raise CrabException("Additional input file not found: "+file)
139                      pass
164                    # fname = string.split(file, '/')[-1]
165                    # storedFile = common.work_space.pathForTgz()+'share/'+fname
166                    # shutil.copyfile(file, storedFile)
140                      self.additional_inbox_files.append(string.strip(file))
141                  pass
142              pass
# Line 189 | Line 162 | class Cmssw(JobType):
162          if cfg_params.has_key('CMSSW.total_number_of_events'):
163              self.total_number_of_events = int(cfg_params['CMSSW.total_number_of_events'])
164              self.selectTotalNumberEvents = 1
165 +            if self.selectNumberOfJobs  == 1:
166 +                if (self.total_number_of_events != -1) and int(self.total_number_of_events) < int(self.theNumberOfJobs):
167 +                    msg = 'Must specify at least one event per job. total_number_of_events > number_of_jobs '
168 +                    raise CrabException(msg)
169          else:
170              self.total_number_of_events = 0
171              self.selectTotalNumberEvents = 0
172  
173 <        if self.pset != None: #CarlosDaniele
173 >        if self.pset != None:
174               if ( (self.selectTotalNumberEvents + self.selectEventsPerJob + self.selectNumberOfJobs) != 2 ):
175                   msg = 'Must define exactly two of total_number_of_events, events_per_job, or number_of_jobs.'
176                   raise CrabException(msg)
# Line 221 | Line 198 | class Cmssw(JobType):
198          ## remove
199          self.sourceSeed = cfg_params.get('CMSSW.pythia_seed',None)
200          if self.sourceSeed:
201 <          print "pythia_seed is a deprecated parameter. Use preserve_seeds or increment_seeds in the future.\n","Added to increment_seeds."
202 <          self.incrementSeeds.append('sourceSeed')
201 >            print "pythia_seed is a deprecated parameter. Use preserve_seeds or increment_seeds in the future.\n","Added to increment_seeds."
202 >            self.incrementSeeds.append('sourceSeed')
203 >            self.incrementSeeds.append('theSource')
204  
205          self.sourceSeedVtx = cfg_params.get('CMSSW.vtx_seed',None)
206          if self.sourceSeedVtx:
207 <          print "vtx_seed is a deprecated parameter. Use preserve_seeds or increment_seeds in the future.\n","Added to increment_seeds."
208 <          self.incrementSeeds.append('VtxSmeared')
207 >            print "vtx_seed is a deprecated parameter. Use preserve_seeds or increment_seeds in the future.\n","Added to increment_seeds."
208 >            self.incrementSeeds.append('VtxSmeared')
209  
210          self.sourceSeedG4 = cfg_params.get('CMSSW.g4_seed',None)
211          if self.sourceSeedG4:
212 <          print "g4_seed is a deprecated parameter. Use preserve_seeds or increment_seeds in the future.\n","Added to increment_seeds."
213 <          self.incrementSeeds.append('g4SimHits')
212 >            print "g4_seed is a deprecated parameter. Use preserve_seeds or increment_seeds in the future.\n","Added to increment_seeds."
213 >            self.incrementSeeds.append('g4SimHits')
214  
215          self.sourceSeedMix = cfg_params.get('CMSSW.mix_seed',None)
216          if self.sourceSeedMix:
217 <          print "mix_seed is a deprecated parameter. Use preserve_seeds or increment_seeds in the future.\n","Added to increment_seeds."
218 <          self.incrementSeeds.append('mix')
217 >            print "mix_seed is a deprecated parameter. Use preserve_seeds or increment_seeds in the future.\n","Added to increment_seeds."
218 >            self.incrementSeeds.append('mix')
219  
220          self.firstRun = cfg_params.get('CMSSW.first_run',None)
221  
# Line 262 | Line 240 | class Cmssw(JobType):
240              blockSites = self.DataDiscoveryAndLocation(cfg_params)
241          #DBSDLS-end
242  
265        self.tgzNameWithPath = self.getTarBall(self.executable)
243  
244          ## Select Splitting
245          if self.selectNoInput:
246 <            if self.pset == None: #CarlosDaniele
246 >            if self.pset == None:
247                  self.jobSplittingForScript()
248              else:
249                  self.jobSplittingNoInput()
# Line 274 | Line 251 | class Cmssw(JobType):
251              self.jobSplittingByBlocks(blockSites)
252  
253          # modify Pset
254 <        if self.pset != None: #CarlosDaniele
254 >        if self.pset != None:
255              try:
256                  # Add FrameworkJobReport to parameter-set, set max events.
257                  # Reset later for data jobs by writeCFG which does all modifications
258 <                PsetEdit.addCrabFJR(self.fjrFileName)
258 >                PsetEdit.addCrabFJR(self.fjrFileName) # FUTURE: Job report addition not needed by CMSSW>1.5
259                  PsetEdit.maxEvent(self.eventsPerJob)
260                  PsetEdit.psetWriter(self.configFilename())
261              except:
262 <                msg='Error while manipuliating ParameterSet: exiting...'
262 >                msg='Error while manipulating ParameterSet: exiting...'
263                  raise CrabException(msg)
264 +        self.tgzNameWithPath = self.getTarBall(self.executable)
265  
266      def DataDiscoveryAndLocation(self, cfg_params):
267  
# Line 314 | Line 292 | class Cmssw(JobType):
292          self.eventsbyfile=self.pubdata.getEventsPerFile()
293  
294          ## get max number of events
295 <        self.maxEvents=self.pubdata.getMaxEvents() ##  self.maxEvents used in Creator.py
295 >        self.maxEvents=self.pubdata.getMaxEvents()
296  
297          ## Contact the DLS and build a list of sites hosting the fileblocks
298          try:
# Line 338 | Line 316 | class Cmssw(JobType):
316  
317          return sites
318  
341  # to Be Removed  DS -- BL
342  #  def setArgsList(self, argsList):
343  #      self.argsList = argsList
344
319      def jobSplittingByBlocks(self, blockSites):
320          """
321          Perform job splitting. Jobs run over an integer number of files
# Line 392 | Line 366 | class Cmssw(JobType):
366          else :
367              totalNumberOfJobs = self.ncjobs
368  
395
369          blocks = blockSites.keys()
370          blockCount = 0
371          # Backup variable in case self.maxEvents counted events in a non-included block
# Line 447 | Line 420 | class Cmssw(JobType):
420                          except KeyError:
421                              common.logger.message("File "+str(file)+" has unknown number of events: skipping")
422  
423 <
423 >                    eventsPerJobRequested = min(eventsPerJobRequested, eventsRemaining)
424                      # if less events in file remain than eventsPerJobRequested
425 <                    if ( filesEventCount - jobSkipEventCount < eventsPerJobRequested ) :
425 >                    if ( filesEventCount - jobSkipEventCount < eventsPerJobRequested):
426                          # if last file in block
427                          if ( fileCount == numFilesInBlock-1 ) :
428                              # end job using last file, use remaining events in block
# Line 533 | Line 506 | class Cmssw(JobType):
506          for block in blocks:
507              if block in jobsOfBlock.keys() :
508                  blockCounter += 1
509 <                screenOutput += "Block %5i: jobs %20s: sites: %s\n" % (blockCounter,spanRanges(jobsOfBlock[block]),','.join(self.blackWhiteListParser.checkWhiteList(self.blackWhiteListParser.checkBlackList(blockSites[block],block),block)))
509 >                screenOutput += "Block %5i: jobs %20s: sites: %s\n" % (blockCounter,spanRanges(jobsOfBlock[block]),
510 >                    ','.join(self.blackWhiteListParser.checkWhiteList(self.blackWhiteListParser.checkBlackList(blockSites[block],block),block)))
511                  if len(self.blackWhiteListParser.checkWhiteList(self.blackWhiteListParser.checkBlackList(blockSites[block],block),block)) == 0:
512                      noSiteBlock.append( spanRanges(jobsOfBlock[block]) )
513                      bloskNoSite.append( blockCounter )
# Line 620 | Line 594 | class Cmssw(JobType):
594          return
595  
596  
597 <    def jobSplittingForScript(self):#CarlosDaniele
597 >    def jobSplittingForScript(self):
598          """
599          Perform job splitting based on number of job
600          """
# Line 636 | Line 610 | class Cmssw(JobType):
610          # argument is seed number.$i
611          self.list_of_args = []
612          for i in range(self.total_number_of_jobs):
639            ## Since there is no input, any site is good
640           # self.jobDestination.append(["Any"])
613              self.jobDestination.append([""])
642            ## no random seed
614              self.list_of_args.append([str(i)])
615          return
616  
617      def split(self, jobParams):
618  
648        #### Fabio
619          njobs = self.total_number_of_jobs
620          arglist = self.list_of_args
621          # create the empty structure
# Line 662 | Line 632 | class Cmssw(JobType):
632              argu=''
633              if len(jobParams[job]):
634                  argu +=   concString.join(jobParams[job] )
635 <            job_ToSave['arguments']= str(job+1)+' '+argu## new BL--DS
636 <            job_ToSave['dlsDestination']= self.jobDestination[job]## new BL--DS
667 <            #common._db.updateJob_(job,job_ToSave)## new BL--DS
635 >            job_ToSave['arguments']= str(job+1)+' '+argu
636 >            job_ToSave['dlsDestination']= self.jobDestination[job]
637              listField.append(job_ToSave)
638              msg="Job "+str(job)+" Arguments:   "+str(job+1)+" "+argu+"\n"  \
639              +"                     Destination: "+str(self.jobDestination[job])
640              common.logger.debug(5,msg)
641 <            #common.logger.debug(5,"Job "+str(job)+" Destination: "+str(self.jobDestination[job]))
642 <        common._db.updateJob_(listID,listField)## new BL--DS
674 <        ## Pay Attention Here....DS--BL
675 <        self.argsList = (len(jobParams[1])+1)
641 >        common._db.updateJob_(listID,listField)
642 >        self.argsList = (len(jobParams[0])+1)
643  
644          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
645  
646      def numberOfJobs(self):
688        # Fabio
647          return self.total_number_of_jobs
648  
649      def getTarBall(self, exe):
650          """
651          Return the TarBall with lib and exe
652          """
695
696        # if it exist, just return it
697        #
698        # Marco. Let's start to use relative path for Boss XML files
699        #
653          self.tgzNameWithPath = common.work_space.pathForTgz()+'share/'+self.tgz_name
654          if os.path.exists(self.tgzNameWithPath):
655              return self.tgzNameWithPath
# Line 710 | Line 663 | class Cmssw(JobType):
663  
664          # First of all declare the user Scram area
665          swArea = self.scram.getSWArea_()
713        #print "swArea = ", swArea
714        # swVersion = self.scram.getSWVersion()
715        # print "swVersion = ", swVersion
666          swReleaseTop = self.scram.getReleaseTop_()
717        #print "swReleaseTop = ", swReleaseTop
667  
668          ## check if working area is release top
669          if swReleaseTop == '' or swArea == swReleaseTop:
670 +            common.logger.debug(3,"swArea = "+swArea+" swReleaseTop ="+swReleaseTop)
671              return
672  
673          import tarfile
# Line 760 | Line 710 | class Cmssw(JobType):
710  
711              ## Now check if any data dir(s) is present
712              swAreaLen=len(swArea)
713 +            self.dataExist = False
714              for root, dirs, files in os.walk(swArea):
715                  if "data" in dirs:
716 +                    self.dataExist=True
717                      common.logger.debug(5,"data "+root+"/data"+" to be tarred")
718                      tar.add(root+"/data",root[swAreaLen:]+"/data")
719  
720 +            ### CMSSW ParameterSet
721 +            if not self.pset is None:
722 +                cfg_file = common.work_space.jobDir()+self.configFilename()
723 +                tar.add(cfg_file,self.configFilename())
724 +                common.logger.debug(5,"File added to "+self.tgzNameWithPath+" : "+str(tar.getnames()))
725 +
726  
727              ## Add ProdCommon dir to tar
728              prodcommonDir = 'ProdCommon'
729              prodcommonPath = os.environ['CRABDIR'] + '/' + 'ProdCommon'
730              if os.path.isdir(prodcommonPath):
731                  tar.add(prodcommonPath,prodcommonDir)
732 +            common.logger.debug(5,"Files added to "+self.tgzNameWithPath+" : "+str(tar.getnames()))
733  
734 +            ##### ML stuff
735 +            ML_file_list=['report.py', 'DashboardAPI.py', 'Logger.py', 'ProcInfo.py', 'apmon.py']
736 +            path=os.environ['CRABDIR'] + '/python/'
737 +            for file in ML_file_list:
738 +                tar.add(path+file,file)
739              common.logger.debug(5,"Files added to "+self.tgzNameWithPath+" : "+str(tar.getnames()))
740 +
741 +            ##### Utils
742 +            Utils_file_list=['parseCrabFjr.py','writeCfg.py', 'fillCrabFjr.py']
743 +            for file in Utils_file_list:
744 +                tar.add(path+file,file)
745 +            common.logger.debug(5,"Files added to "+self.tgzNameWithPath+" : "+str(tar.getnames()))
746 +
747 +            ##### AdditionalFiles
748 +            for file in self.additional_inbox_files:
749 +                tar.add(file,string.split(file,'/')[-1])
750 +            common.logger.debug(5,"Files added to "+self.tgzNameWithPath+" : "+str(tar.getnames()))
751 +
752              tar.close()
753          except :
754              raise CrabException('Could not create tar-ball')
# Line 783 | Line 759 | class Cmssw(JobType):
759              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.')
760  
761          ## 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
762  
763      def wsSetupEnvironment(self, nj=0):
764          """
765          Returns part of a job script which prepares
766          the execution environment for the job 'nj'.
767          """
768 +        if (self.CMSSW_major >= 2 and self.CMSSW_minor >= 1) or (self.CMSSW_major >= 3):
769 +            psetName = 'pset.py'
770 +        else:
771 +            psetName = 'pset.cfg'
772          # Prepare JobType-independent part
773          txt = '\n#Written by cms_cmssw::wsSetupEnvironment\n'
774          txt += 'echo ">>> setup environment"\n'
# Line 825 | Line 777 | class Cmssw(JobType):
777          txt += 'elif [ $middleware == OSG ]; then\n'
778          txt += '    WORKING_DIR=`/bin/mktemp  -d $OSG_WN_TMP/cms_XXXXXXXXXXXX`\n'
779          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'
780          txt += '        echo "ERROR ==> OSG $WORKING_DIR could not be created on WN `hostname`"\n'
781          txt += '        job_exit_code=10016\n'
782          txt += '        func_exit\n'
# Line 840 | Line 787 | class Cmssw(JobType):
787          txt += '    cd $WORKING_DIR\n'
788          txt += '    echo ">>> current directory (WORKING_DIR): $WORKING_DIR"\n'
789          txt += self.wsSetupCMSOSGEnvironment_()
843        #txt += '    echo "### Set SCRAM ARCH to ' + self.executable_arch + ' ###"\n'
844        #txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
790          txt += 'fi\n'
791  
792          # Prepare JobType-specific part
# Line 852 | Line 797 | class Cmssw(JobType):
797          txt += scram+' project CMSSW '+self.version+'\n'
798          txt += 'status=$?\n'
799          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'
800          txt += '    echo "ERROR ==> CMSSW '+self.version+' not found on `hostname`" \n'
801          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'
802          txt += '    func_exit\n'
803          txt += 'fi \n'
804          txt += 'cd '+self.version+'\n'
879        ########## FEDE FOR DBS2 ######################
805          txt += 'SOFTWARE_DIR=`pwd`\n'
806          txt += 'echo ">>> current directory (SOFTWARE_DIR): $SOFTWARE_DIR" \n'
882        ###############################################
883        ### needed grep for bug in scramv1 ###
807          txt += 'eval `'+scram+' runtime -sh | grep -v SCRAMRT_LSB_JOBNAME`\n'
808 +        txt += 'if [ $? != 0 ] ; then\n'
809 +        txt += '    echo "ERROR ==> Problem with the command: "\n'
810 +        txt += '    echo "eval \`'+scram+' runtime -sh | grep -v SCRAMRT_LSB_JOBNAME \` at `hostname`"\n'
811 +        txt += '    job_exit_code=10034\n'
812 +        txt += '    func_exit\n'
813 +        txt += 'fi \n'
814          # Handle the arguments:
815          txt += "\n"
816          txt += "## number of arguments (first argument always jobnumber)\n"
817          txt += "\n"
889       # txt += "if [ $nargs -lt "+str(len(self.argsList[nj].split()))+" ]\n"
818          txt += "if [ $nargs -lt "+str(self.argsList)+" ]\n"
819          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'
820          txt += "    echo 'ERROR ==> Too few arguments' +$nargs+ \n"
821          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"
822          txt += "    func_exit\n"
823          txt += "fi\n"
824          txt += "\n"
825  
826          # Prepare job-specific part
827          job = common.job_list[nj]
919        ### FEDE FOR DBS OUTPUT PUBLICATION
828          if (self.datasetPath):
829              txt += '\n'
830              txt += 'DatasetPath='+self.datasetPath+'\n'
# Line 932 | Line 840 | class Cmssw(JobType):
840              txt += 'PrimaryDataset=null\n'
841              txt += 'DataTier=null\n'
842              txt += 'ApplicationFamily=MCDataTier\n'
843 <        if self.pset != None:
843 >        if self.pset != None:
844              pset = os.path.basename(job.configFilename())
845              txt += '\n'
846              txt += 'cp  $RUNTIME_AREA/'+pset+' .\n'
# Line 952 | Line 860 | class Cmssw(JobType):
860                      txt += 'FirstRun=${args[1]}; export FirstRun\n'
861                      txt += 'echo "FirstRun: <$FirstRun>"\n'
862  
863 <            txt += 'mv -f '+pset+' pset.cfg\n'
863 >            txt += 'mv -f ' + pset + ' ' + psetName + '\n'
864  
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
865  
866          if self.pset != None:
867 +            # FUTURE: Can simply for 2_1_x and higher
868              txt += '\n'
869 <            txt += 'echo "***** cat pset.cfg *********"\n'
870 <            txt += 'cat pset.cfg\n'
871 <            txt += 'echo "****** end pset.cfg ********"\n'
872 <            txt += '\n'
873 <            txt += 'PSETHASH=`EdmConfigHash < pset.cfg` \n'
869 >            if self.debug_wrapper==True:
870 >                txt += 'echo "***** cat ' + psetName + ' *********"\n'
871 >                txt += 'cat ' + psetName + '\n'
872 >                txt += 'echo "****** end ' + psetName + ' ********"\n'
873 >                txt += '\n'
874 >            txt += 'PSETHASH=`edmConfigHash < ' + psetName + '` \n'
875              txt += 'echo "PSETHASH = $PSETHASH" \n'
876              txt += '\n'
877          return txt
878 <    #### FEDE #####
878 >
879      def wsUntarSoftware(self, nj=0):
880          """
881          Put in the script the commands to build an executable
# Line 982 | Line 887 | class Cmssw(JobType):
887          if os.path.isfile(self.tgzNameWithPath):
888              txt += 'echo ">>> tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+' :" \n'
889              txt += 'tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'\n'
890 +            if  self.debug_wrapper:
891 +                txt += 'ls -Al \n'
892              txt += 'untar_status=$? \n'
893              txt += 'if [ $untar_status -ne 0 ]; then \n'
894              txt += '   echo "ERROR ==> Untarring .tgz file failed"\n'
# Line 1003 | Line 910 | class Cmssw(JobType):
910              pass
911  
912          return txt
913 <        
913 >
914      def wsBuildExe(self, nj=0):
915          """
916          Put in the script the commands to build an executable
# Line 1013 | Line 920 | class Cmssw(JobType):
920          txt = '\n#Written by cms_cmssw::wsBuildExe\n'
921          txt += 'echo ">>> moving CMSSW software directories in `pwd`" \n'
922  
923 <        txt += 'mv $RUNTIME_AREA/lib . \n'
924 <        txt += 'mv $RUNTIME_AREA/module . \n'
925 <        txt += 'mv $RUNTIME_AREA/ProdCommon . \n'
926 <        
927 <
928 <        #if os.path.isfile(self.tgzNameWithPath):
929 <        #    txt += 'echo ">>> tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+' :" \n'
930 <        #    txt += 'tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'\n'
931 <        #    txt += 'untar_status=$? \n'
932 <        #    txt += 'if [ $untar_status -ne 0 ]; then \n'
933 <        #    txt += '   echo "ERROR ==> Untarring .tgz file failed"\n'
1027 <        #    txt += '   job_exit_code=$untar_status\n'
1028 <        #    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'
923 >        txt += 'rm -r lib/ module/ \n'
924 >        txt += 'mv $RUNTIME_AREA/lib/ . \n'
925 >        txt += 'mv $RUNTIME_AREA/module/ . \n'
926 >        if self.dataExist == True:
927 >            txt += 'rm -r src/ \n'
928 >            txt += 'mv $RUNTIME_AREA/src/ . \n'
929 >        if len(self.additional_inbox_files)>0:
930 >            for file in self.additional_inbox_files:
931 >                txt += 'mv $RUNTIME_AREA/'+os.path.basename(file)+' . \n'
932 >        txt += 'mv $RUNTIME_AREA/ProdCommon/ . \n'
933 >
934          txt += 'if [ -z "$PYTHONPATH" ]; then\n'
935          txt += '   export PYTHONPATH=$SOFTWARE_DIR/ProdCommon\n'
936          txt += 'else\n'
# Line 1040 | Line 940 | class Cmssw(JobType):
940          txt += '\n'
941  
942          return txt
1043    ############################################################################
943  
944      def modifySteeringCards(self, nj):
945          """
# Line 1049 | Line 948 | class Cmssw(JobType):
948          """
949  
950      def executableName(self):
951 <        if self.scriptExe: #CarlosDaniele
951 >        if self.scriptExe:
952              return "sh "
953          else:
954              return self.executable
# Line 1059 | Line 958 | class Cmssw(JobType):
958          if self.scriptExe:#CarlosDaniele
959              return   self.scriptExe + " $NJob"
960          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
961              ex_args = ""
962 <
962 >            # FUTURE: This tests the CMSSW version. Can remove code as versions deprecated
963              # Framework job report
964 <            if major >= 1 and minor >= 5 :
1076 <                #ex_args += " -j " + self.fjrFileName
1077 <            ### FEDE it could be improved!!! ####    
964 >            if (self.CMSSW_major >= 1 and self.CMSSW_minor >= 5) or (self.CMSSW_major >= 2):
965                  ex_args += " -j $RUNTIME_AREA/crab_fjr_$NJob.xml"
966 <            #######################################
967 <            # Type of cfg file
968 <            if major >= 2 :
1082 <                ex_args += " -p pset.pycfg"
966 >            # Type of config file
967 >            if self.CMSSW_major >= 2 :
968 >                ex_args += " -p pset.py"
969              else:
970                  ex_args += " -p pset.cfg"
971              return ex_args
# Line 1089 | Line 975 | class Cmssw(JobType):
975          Returns a list of filenames to be put in JDL input sandbox.
976          """
977          inp_box = []
1092        # # dict added to delete duplicate from input sandbox file list
1093        # seen = {}
1094        ## code
978          if os.path.isfile(self.tgzNameWithPath):
979              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
980          wrapper = os.path.basename(str(common._db.queryTask('scriptName')))
981          inp_box.append(common.work_space.pathForTgz() +'job/'+ wrapper)
982          return inp_box
# Line 1133 | Line 1007 | class Cmssw(JobType):
1007          txt = '\n#Written by cms_cmssw::wsRenameOutput\n'
1008          txt += 'echo ">>> current directory (SOFTWARE_DIR): $SOFTWARE_DIR" \n'
1009          txt += 'echo ">>> current directory content:"\n'
1010 <        txt += 'ls \n'
1010 >        if self.debug_wrapper:
1011 >            txt += 'ls -Al\n'
1012          txt += '\n'
1013  
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
1014          for fileWithSuffix in (self.output_file):
1015              output_file_num = self.numberFile_(fileWithSuffix, '$NJob')
1016              txt += '\n'
# Line 1163 | Line 1018 | class Cmssw(JobType):
1018              txt += 'if [ -e ./'+fileWithSuffix+' ] ; then\n'
1019              if (self.copy_data == 1):  # For OSG nodes, file is in $WORKING_DIR, should not be moved to $RUNTIME_AREA
1020                  txt += '    mv '+fileWithSuffix+' '+output_file_num+'\n'
1021 <                txt += '    ln -s `pwd`/'+output_file_num+' $RUNTIME_AREA/'+fileWithSuffix+'\n'
1021 >                #txt += '    ln -s `pwd`/'+output_file_num+' $RUNTIME_AREA/'+fileWithSuffix+'\n'
1022              else:
1023                  txt += '    mv '+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
1024                  txt += '    ln -s $RUNTIME_AREA/'+output_file_num+' $RUNTIME_AREA/'+fileWithSuffix+'\n'
1025              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'
1026              txt += '    job_exit_code=60302\n'
1027              txt += '    echo "WARNING: Output file '+fileWithSuffix+' not found"\n'
1028              if common.scheduler.name().upper() == 'CONDOR_G':
# Line 1188 | Line 1039 | class Cmssw(JobType):
1039          txt += '\n'
1040          txt += 'echo ">>> current directory (SOFTWARE_DIR): $SOFTWARE_DIR" \n'
1041          txt += 'echo ">>> current directory content:"\n'
1042 <        txt += 'ls \n'
1042 >        if self.debug_wrapper:
1043 >            txt += 'ls -Al\n'
1044          txt += '\n'
1045          txt += 'cd $RUNTIME_AREA\n'
1046          txt += 'echo ">>> current directory (RUNTIME_AREA):  $RUNTIME_AREA"\n'
# Line 1221 | Line 1073 | class Cmssw(JobType):
1073              req='Member("VO-cms-' + \
1074                   self.version + \
1075                   '", other.GlueHostApplicationSoftwareRunTimeEnvironment)'
1076 <        ## 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):
1076 >        if self.executable_arch:
1077              req+=' && Member("VO-cms-' + \
1078                   self.executable_arch + \
1079                   '", other.GlueHostApplicationSoftwareRunTimeEnvironment)'
# Line 1236 | Line 1086 | class Cmssw(JobType):
1086  
1087      def configFilename(self):
1088          """ return the config filename """
1089 <        return self.name()+'.cfg'
1089 >        # FUTURE: Can remove cfg mode for CMSSW >= 2_1_x
1090 >        if (self.CMSSW_major >= 2 and self.CMSSW_minor >= 1) or (self.CMSSW_major >= 3):
1091 >          return self.name()+'.py'
1092 >        else:
1093 >          return self.name()+'.cfg'
1094  
1095      def wsSetupCMSOSGEnvironment_(self):
1096          """
# Line 1252 | Line 1106 | class Cmssw(JobType):
1106          txt += '      # Use $OSG_APP/cmssoft/cms/cmsset_default.sh to setup cms software\n'
1107          txt += '        source $OSG_APP/cmssoft/cms/cmsset_default.sh '+self.version+'\n'
1108          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'
1109          txt += '        echo "ERROR ==> $OSG_APP/cmssoft/cms/cmsset_default.sh file not found"\n'
1110          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'
1111          txt += '        func_exit\n'
1112          txt += '    fi\n'
1113          txt += '\n'
# Line 1280 | Line 1116 | class Cmssw(JobType):
1116  
1117          return txt
1118  
1283    ### OLI_DANIELE
1119      def wsSetupCMSLCGEnvironment_(self):
1120          """
1121          Returns part of a job script which is prepares
# Line 1292 | Line 1127 | class Cmssw(JobType):
1127          txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
1128          txt += '    export BUILD_ARCH='+self.executable_arch+'\n'
1129          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'
1130          txt += '        echo "ERROR ==> CMS software dir not found on WN `hostname`"\n'
1131          txt += '        job_exit_code=10031\n'
1132          txt += '        func_exit\n'
1133          txt += '    else\n'
1134          txt += '        echo "Sourcing environment... "\n'
1135          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'
1136          txt += '            echo "ERROR ==> cmsset_default.sh file not found into dir $VO_CMS_SW_DIR"\n'
1137          txt += '            job_exit_code=10020\n'
1138          txt += '            func_exit\n'
# Line 1316 | Line 1141 | class Cmssw(JobType):
1141          txt += '        source $VO_CMS_SW_DIR/cmsset_default.sh\n'
1142          txt += '        result=$?\n'
1143          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'
1144          txt += '            echo "ERROR ==> problem sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
1145          txt += '            job_exit_code=10032\n'
1146          txt += '            func_exit\n'
# Line 1330 | Line 1150 | class Cmssw(JobType):
1150          txt += '    echo "==> setup cms environment ok"\n'
1151          return txt
1152  
1333    ### FEDE FOR DBS OUTPUT PUBLICATION
1153      def modifyReport(self, nj):
1154          """
1155          insert the part of the script that modifies the FrameworkJob Report
1156          """
1338
1157          txt = '\n#Written by cms_cmssw::modifyReport\n'
1158 <        try:
1341 <            publish_data = int(self.cfg_params['USER.publish_data'])
1342 <        except KeyError:
1343 <            publish_data = 0
1158 >        publish_data = int(self.cfg_params.get('USER.publish_data',0))
1159          if (publish_data == 1):
1160 <            
1160 >            processedDataset = self.cfg_params['USER.publish_data_name']
1161 >            LFNBaseName = LFNBase(processedDataset)
1162 >
1163              txt += 'if [ $copy_exit_status -eq 0 ]; then\n'
1164 <            txt += '    echo ">>> Modify Job Report:" \n'
1165 <            txt += '    chmod a+x $SOFTWARE_DIR/ProdCommon/ProdCommon/FwkJobRep/ModifyJobReport.py\n'
1166 <            #txt += '    if [ -z "$SE" ]; then\n'
1167 <            #txt += '        SE="" \n'
1168 <            #txt += '    fi \n'
1169 <            #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'
1164 >            txt += '    FOR_LFN=%s_${PSETHASH}/\n'%(LFNBaseName)
1165 >            txt += 'else\n'
1166 >            txt += '    FOR_LFN=/copy_problems/ \n'
1167 >            txt += '    SE=""\n'
1168 >            txt += '    SE_PATH=""\n'
1169 >            txt += 'fi\n'
1170  
1171 <            processedDataset = self.cfg_params['USER.publish_data_name']
1172 <            txt += '    ProcessedDataset='+processedDataset+'\n'
1173 <            #txt += '    if [ "$SE_PATH" == "" ]; then\n'
1174 <            #txt += '        FOR_LFN=/copy_problems/ \n'
1175 <            #txt += '    else \n'
1176 <            #txt += '        tmp=`echo $SE_PATH | awk -F \'store\' \'{print$2}\'` \n'
1177 <            #txt += '        FOR_LFN=/store$tmp \n'
1178 <            #txt += '    fi \n'
1179 <            txt += '    tmp=`echo $SE_PATH | awk -F \'store\' \'{print$2}\'` \n'
1180 <            txt += '    FOR_LFN=/store$tmp \n'
1181 <            txt += '    echo "ProcessedDataset = $ProcessedDataset"\n'
1182 <            txt += '    echo "FOR_LFN = $FOR_LFN" \n'
1183 <            txt += '    echo "CMSSW_VERSION = $CMSSW_VERSION"\n\n'
1184 <            #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'
1185 <            #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'
1186 <            ### FEDE ####
1187 <            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'
1188 <            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'
1171 >            txt += 'echo ">>> Modify Job Report:" \n'
1172 >            txt += 'chmod a+x $SOFTWARE_DIR/ProdCommon/ProdCommon/FwkJobRep/ModifyJobReport.py\n'
1173 >            txt += 'ProcessedDataset='+processedDataset+'\n'
1174 >            txt += 'echo "ProcessedDataset = $ProcessedDataset"\n'
1175 >            txt += 'echo "SE = $SE"\n'
1176 >            txt += 'echo "SE_PATH = $SE_PATH"\n'
1177 >            txt += 'echo "FOR_LFN = $FOR_LFN" \n'
1178 >            txt += 'echo "CMSSW_VERSION = $CMSSW_VERSION"\n\n'
1179 >            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'
1180 >            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'
1181 >            txt += 'modifyReport_result=$?\n'
1182 >            txt += 'if [ $modifyReport_result -ne 0 ]; then\n'
1183 >            txt += '    modifyReport_result=70500\n'
1184 >            txt += '    job_exit_code=$modifyReport_result\n'
1185 >            txt += '    echo "ModifyReportResult=$modifyReport_result" | tee -a $RUNTIME_AREA/$repo\n'
1186 >            txt += '    echo "WARNING: Problem with ModifyJobReport"\n'
1187 >            txt += 'else\n'
1188 >            txt += '    mv NewFrameworkJobReport.xml $RUNTIME_AREA/crab_fjr_$NJob.xml\n'
1189              txt += 'fi\n'
1190          return txt
1191  
1192 <    def cleanEnv(self):
1193 <        txt = '\n#Written by cms_cmssw::cleanEnv\n'
1194 <        txt += 'if [ $middleware == OSG ]; then\n'
1195 <        txt += '    cd $RUNTIME_AREA\n'
1196 <        txt += '    echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
1197 <        txt += '    echo ">>> Remove working directory: $WORKING_DIR"\n'
1198 <        txt += '    /bin/rm -rf $WORKING_DIR\n'
1199 <        txt += '    if [ -d $WORKING_DIR ] ;then\n'
1200 <        txt += '        echo "ERROR ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after cleanup of WN"\n'
1201 <        txt += '        job_exit_code=10017\n'
1202 <        txt += '        func_exit\n'
1192 >    def wsParseFJR(self):
1193 >        """
1194 >        Parse the FrameworkJobReport to obtain useful infos
1195 >        """
1196 >        txt = '\n#Written by cms_cmssw::wsParseFJR\n'
1197 >        txt += 'echo ">>> Parse FrameworkJobReport crab_fjr.xml"\n'
1198 >        txt += 'if [ -s $RUNTIME_AREA/crab_fjr_$NJob.xml ]; then\n'
1199 >        txt += '    if [ -s $RUNTIME_AREA/parseCrabFjr.py ]; then\n'
1200 >        txt += '        cmd_out=`python $RUNTIME_AREA/parseCrabFjr.py --input $RUNTIME_AREA/crab_fjr_$NJob.xml --dashboard $MonitorID,$MonitorJobID '+self.debugWrap+'`\n'
1201 >        if self.debug_wrapper :
1202 >            txt += '        echo "Result of parsing the FrameworkJobReport crab_fjr.xml: $cmd_out"\n'
1203 >        txt += '        executable_exit_status=`python $RUNTIME_AREA/parseCrabFjr.py --input $RUNTIME_AREA/crab_fjr_$NJob.xml --exitcode`\n'
1204 >        txt += '        if [ $executable_exit_status -eq 50115 ];then\n'
1205 >        txt += '            echo ">>> crab_fjr.xml contents: "\n'
1206 >        txt += '            cat $RUNTIME_AREA/crab_fjr_NJob.xml\n'
1207 >        txt += '            echo "Wrong FrameworkJobReport --> does not contain useful info. ExitStatus: $executable_exit_status"\n'
1208 >        txt += '        elif [ $executable_exit_status -eq -999 ];then\n'
1209 >        txt += '            echo "ExitStatus from FrameworkJobReport not available. not available. Using exit code of executable from command line."\n'
1210 >        txt += '        else\n'
1211 >        txt += '            echo "Extracted ExitStatus from FrameworkJobReport parsing output: $executable_exit_status"\n'
1212 >        txt += '        fi\n'
1213 >        txt += '    else\n'
1214 >        txt += '        echo "CRAB python script to parse CRAB FrameworkJobReport crab_fjr.xml is not available, using exit code of executable from command line."\n'
1215          txt += '    fi\n'
1216 +          #### Patch to check input data reading for CMSSW16x Hopefully we-ll remove it asap
1217 +
1218 +        if self.datasetPath:
1219 +          # VERIFY PROCESSED DATA
1220 +            txt += '    if [ $executable_exit_status -eq 0 ];then\n'
1221 +            txt += '      echo ">>> Verify list of processed files:"\n'
1222 +            txt += '      echo $InputFiles |tr -d \'\\\\\' |tr \',\' \'\\n\'|tr -d \'"\' > input-files.txt\n'
1223 +            txt += '      python $RUNTIME_AREA/parseCrabFjr.py --input $RUNTIME_AREA/crab_fjr_$NJob.xml --lfn > processed-files.txt\n'
1224 +            txt += '      cat input-files.txt  | sort | uniq > tmp.txt\n'
1225 +            txt += '      mv tmp.txt input-files.txt\n'
1226 +            txt += '      echo "cat input-files.txt"\n'
1227 +            txt += '      echo "----------------------"\n'
1228 +            txt += '      cat input-files.txt\n'
1229 +            txt += '      cat processed-files.txt | sort | uniq > tmp.txt\n'
1230 +            txt += '      mv tmp.txt processed-files.txt\n'
1231 +            txt += '      echo "----------------------"\n'
1232 +            txt += '      echo "cat processed-files.txt"\n'
1233 +            txt += '      echo "----------------------"\n'
1234 +            txt += '      cat processed-files.txt\n'
1235 +            txt += '      echo "----------------------"\n'
1236 +            txt += '      diff -q input-files.txt processed-files.txt\n'
1237 +            txt += '      fileverify_status=$?\n'
1238 +            txt += '      if [ $fileverify_status -ne 0 ]; then\n'
1239 +            txt += '         executable_exit_status=30001\n'
1240 +            txt += '         echo "ERROR ==> not all input files processed"\n'
1241 +            txt += '         echo "      ==> list of processed files from crab_fjr.xml differs from list in pset.cfg"\n'
1242 +            txt += '         echo "      ==> diff input-files.txt processed-files.txt"\n'
1243 +            txt += '      fi\n'
1244 +            txt += '    fi\n'
1245 +            txt += '\n'
1246 +        txt += 'else\n'
1247 +        txt += '    echo "CRAB FrameworkJobReport crab_fjr.xml is not available, using exit code of executable from command line."\n'
1248          txt += 'fi\n'
1249          txt += '\n'
1250 +        txt += 'echo "ExeExitCode=$executable_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
1251 +        txt += 'echo "EXECUTABLE_EXIT_STATUS = $executable_exit_status"\n'
1252 +        txt += 'job_exit_code=$executable_exit_status\n'
1253 +
1254          return txt
1255  
1256      def setParam_(self, param, value):
# Line 1427 | Line 1275 | class Cmssw(JobType):
1275          txt = ''
1276          txt += 'echo ">>> list of expected files on output sandbox"\n'
1277          listOutFiles = []
1278 <        stdout = 'CMSSW_$NJob.stdout'
1278 >        stdout = 'CMSSW_$NJob.stdout'
1279          stderr = 'CMSSW_$NJob.stderr'
1280          if (self.return_data == 1):
1281              for file in (self.output_file+self.output_file_sandbox):
# Line 1442 | Line 1290 | class Cmssw(JobType):
1290          txt += 'echo "output files: '+string.join(listOutFiles,' ')+'"\n'
1291          txt += 'filesToCheck="'+string.join(listOutFiles,' ')+'"\n'
1292          txt += 'export filesToCheck\n'
1293 <        return txt
1293 >        return txt

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines