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.116.2.8 by fanzago, Wed Oct 17 13:25:00 2007 UTC vs.
Revision 1.136 by fanzago, Wed Nov 14 17:53:21 2007 UTC

# Line 28 | Line 28 | class Cmssw(JobType):
28          self.ncjobs = ncjobs
29  
30          log = common.logger
31 <        
31 >
32          self.scram = Scram.Scram(cfg_params)
33          self.additional_inbox_files = []
34          self.scriptExe = ''
# Line 37 | Line 37 | class Cmssw(JobType):
37          self.tgz_name = 'default.tgz'
38          self.additional_tgz_name = 'additional.tgz'
39          self.scriptName = 'CMSSW.sh'
40 <        self.pset = ''      #scrip use case Da  
40 >        self.pset = ''      #scrip use case Da
41          self.datasetPath = '' #scrip use case Da
42  
43          # set FJR file name
44          self.fjrFileName = 'crab_fjr.xml'
45  
46          self.version = self.scram.getSWVersion()
47 <        
47 >
48          #
49          # Try to block creation in case of arch/version mismatch
50          #
# Line 52 | Line 52 | class Cmssw(JobType):
52          a = string.split(self.version, "_")
53  
54          if int(a[1]) == 1 and (int(a[2]) < 5 and self.executable_arch.find('slc4') == 0):
55 <            msg = "Error: CMS does not support %s with %s architecture"%(self.version, self.executable_arch)
56 <            raise CrabException(msg)
55 >            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)
56 >            common.logger.message(msg)
57          if int(a[1]) == 1 and (int(a[2]) >= 5 and self.executable_arch.find('slc3') == 0):
58              msg = "Error: CMS does not support %s with %s architecture"%(self.version, self.executable_arch)
59              raise CrabException(msg)
60 <        
60 >
61          common.taskDB.setDict('codeVersion',self.version)
62          self.setParam_('application', self.version)
63  
# Line 68 | Line 68 | class Cmssw(JobType):
68              self.use_dbs_1 = int(self.cfg_params['CMSSW.use_dbs_1'])
69          except KeyError:
70              self.use_dbs_1 = 0
71 <            
71 >
72          try:
73              tmp =  cfg_params['CMSSW.datasetpath']
74              log.debug(6, "CMSSW::CMSSW(): datasetPath = "+tmp)
# Line 79 | Line 79 | class Cmssw(JobType):
79                  self.datasetPath = tmp
80                  self.selectNoInput = 0
81          except KeyError:
82 <            msg = "Error: datasetpath not defined "  
82 >            msg = "Error: datasetpath not defined "
83              raise CrabException(msg)
84  
85          # ML monitoring
# Line 101 | Line 101 | class Cmssw(JobType):
101              except:
102                  self.setParam_('dataset', self.datasetPath)
103                  self.setParam_('owner', self.datasetPath)
104 <                
104 >
105          self.setTaskid_()
106          self.setParam_('taskId', self.cfg_params['taskId'])
107  
# Line 124 | Line 124 | class Cmssw(JobType):
124          try:
125              self.pset = cfg_params['CMSSW.pset']
126              log.debug(6, "Cmssw::Cmssw(): PSet file = "+self.pset)
127 <            if self.pset.lower() != 'none' :
127 >            if self.pset.lower() != 'none' :
128                  if (not os.path.exists(self.pset)):
129                      raise CrabException("User defined PSet file "+self.pset+" does not exist")
130              else:
# Line 216 | Line 216 | class Cmssw(JobType):
216          except KeyError:
217              self.eventsPerJob = -1
218              self.selectEventsPerJob = 0
219 <    
219 >
220          ## number of jobs
221          try:
222              self.theNumberOfJobs =int( cfg_params['CMSSW.number_of_jobs'])
# Line 232 | Line 232 | class Cmssw(JobType):
232              self.total_number_of_events = 0
233              self.selectTotalNumberEvents = 0
234  
235 <        if self.pset != None: #CarlosDaniele
235 >        if self.pset != None: #CarlosDaniele
236               if ( (self.selectTotalNumberEvents + self.selectEventsPerJob + self.selectNumberOfJobs) != 2 ):
237                   msg = 'Must define exactly two of total_number_of_events, events_per_job, or number_of_jobs.'
238                   raise CrabException(msg)
# Line 272 | Line 272 | class Cmssw(JobType):
272              self.firstRun = None
273              common.logger.debug(5,"No first run given")
274          if self.pset != None: #CarlosDaniele
275 <            ver = string.split(self.version,"_")
276 <            if (int(ver[1])>=1 and int(ver[2])>=5):
277 <                import PsetManipulator150 as pp
278 <            else:
279 <                import PsetManipulator as pp
275 >            import PsetManipulator as pp
276              PsetEdit = pp.PsetManipulator(self.pset) #Daniele Pset
277  
278          #DBSDLS-start
279 <        ## Initialize the variables that are extracted from DBS/DLS and needed in other places of the code
279 >        ## Initialize the variables that are extracted from DBS/DLS and needed in other places of the code
280          self.maxEvents=0  # max events available   ( --> check the requested nb. of evts in Creator.py)
281          self.DBSPaths={}  # all dbs paths requested ( --> input to the site local discovery script)
282          self.jobDestination=[]  # Site destination(s) for each job (list of lists)
# Line 289 | Line 285 | class Cmssw(JobType):
285          blockSites = {}
286          if self.datasetPath:
287              blockSites = self.DataDiscoveryAndLocation(cfg_params)
288 <        #DBSDLS-end          
288 >        #DBSDLS-end
289  
290          self.tgzNameWithPath = self.getTarBall(self.executable)
291 <    
291 >
292          ## Select Splitting
293 <        if self.selectNoInput:
293 >        if self.selectNoInput:
294              if self.pset == None: #CarlosDaniele
295                  self.jobSplittingForScript()
296              else:
# Line 307 | Line 303 | class Cmssw(JobType):
303              try:
304                  if (self.datasetPath): # standard job
305                      # allow to processa a fraction of events in a file
306 <                    PsetEdit.inputModule("INPUT")
307 <                    PsetEdit.maxEvent("INPUTMAXEVENTS")
308 <                    PsetEdit.skipEvent("INPUTSKIPEVENTS")
306 >                    PsetEdit.inputModule("INPUTFILE")
307 >                    PsetEdit.maxEvent(0)
308 >                    PsetEdit.skipEvent(0)
309                  else:  # pythia like job
310                      PsetEdit.maxEvent(self.eventsPerJob)
311                      if (self.firstRun):
312 <                        PsetEdit.pythiaFirstRun("INPUTFIRSTRUN")  #First Run
312 >                        PsetEdit.pythiaFirstRun(0)  #First Run
313                      if (self.sourceSeed) :
314 <                        PsetEdit.pythiaSeed("INPUT")
314 >                        PsetEdit.pythiaSeed(0)
315                          if (self.sourceSeedVtx) :
316 <                            PsetEdit.vtxSeed("INPUTVTX")
316 >                            PsetEdit.vtxSeed(0)
317                          if (self.sourceSeedG4) :
318 <                            PsetEdit.g4Seed("INPUTG4")
318 >                            PsetEdit.g4Seed(0)
319                          if (self.sourceSeedMix) :
320 <                            PsetEdit.mixSeed("INPUTMIX")
320 >                            PsetEdit.mixSeed(0)
321                  # add FrameworkJobReport to parameter-set
322                  PsetEdit.addCrabFJR(self.fjrFileName)
323                  PsetEdit.psetWriter(self.configFilename())
# Line 372 | Line 368 | class Cmssw(JobType):
368          self.eventsbyfile=self.pubdata.getEventsPerFile()
369  
370          ## get max number of events
371 <        self.maxEvents=self.pubdata.getMaxEvents() ##  self.maxEvents used in Creator.py
371 >        self.maxEvents=self.pubdata.getMaxEvents() ##  self.maxEvents used in Creator.py
372  
373          ## Contact the DLS and build a list of sites hosting the fileblocks
374          try:
# Line 381 | Line 377 | class Cmssw(JobType):
377          except DataLocation.DataLocationError , ex:
378              msg = 'ERROR ***: failed Data Location in DLS \n %s '%ex.getErrorMessage()
379              raise CrabException(msg)
380 <        
380 >
381  
382          sites = dataloc.getSites()
383          allSites = []
# Line 395 | Line 391 | class Cmssw(JobType):
391          common.logger.message("Requested dataset: " + datasetPath + " has " + str(self.maxEvents) + " events in " + str(len(self.filesbyblock.keys())) + " blocks.\n")
392  
393          return sites
394 <    
394 >
395      def jobSplittingByBlocks(self, blockSites):
396          """
397          Perform job splitting. Jobs run over an integer number of files
# Line 445 | Line 441 | class Cmssw(JobType):
441              totalNumberOfJobs = 999999999
442          else :
443              totalNumberOfJobs = self.ncjobs
444 <            
444 >
445  
446          blocks = blockSites.keys()
447          blockCount = 0
# Line 465 | Line 461 | class Cmssw(JobType):
461              blockCount += 1
462              if block not in jobsOfBlock.keys() :
463                  jobsOfBlock[block] = []
464 <            
464 >
465              if self.eventsbyblock.has_key(block) :
466                  numEventsInBlock = self.eventsbyblock[block]
467                  common.logger.debug(5,'Events in Block File '+str(numEventsInBlock))
468 <            
468 >
469                  files = self.filesbyblock[block]
470                  numFilesInBlock = len(files)
471                  if (numFilesInBlock <= 0):
# Line 477 | Line 473 | class Cmssw(JobType):
473                  fileCount = 0
474  
475                  # ---- New block => New job ---- #
476 <                parString = "\\{"
476 >                parString = ""
477                  # counter for number of events in files currently worked on
478                  filesEventCount = 0
479                  # flag if next while loop should touch new file
480                  newFile = 1
481                  # job event counter
482                  jobSkipEventCount = 0
483 <            
483 >
484                  # ---- Iterate over the files in the block until we've met the requested ---- #
485                  # ---- total # of events or we've gone over all the files in this block  ---- #
486                  while ( (eventsRemaining > 0) and (fileCount < numFilesInBlock) and (jobCount < totalNumberOfJobs) ):
# Line 500 | Line 496 | class Cmssw(JobType):
496                              newFile = 0
497                          except KeyError:
498                              common.logger.message("File "+str(file)+" has unknown number of events: skipping")
499 <                        
499 >
500  
501                      # if less events in file remain than eventsPerJobRequested
502                      if ( filesEventCount - jobSkipEventCount < eventsPerJobRequested ) :
# Line 509 | Line 505 | class Cmssw(JobType):
505                              # end job using last file, use remaining events in block
506                              # close job and touch new file
507                              fullString = parString[:-2]
512                            fullString += '\\}'
508                              list_of_lists.append([fullString,str(-1),str(jobSkipEventCount)])
509                              common.logger.debug(3,"Job "+str(jobCount+1)+" can run over "+str(filesEventCount - jobSkipEventCount)+" events (last file in block).")
510                              self.jobDestination.append(blockSites[block])
# Line 522 | Line 517 | class Cmssw(JobType):
517                              eventsRemaining = eventsRemaining - filesEventCount + jobSkipEventCount
518                              jobSkipEventCount = 0
519                              # reset file
520 <                            parString = "\\{"
520 >                            parString = ""
521                              filesEventCount = 0
522                              newFile = 1
523                              fileCount += 1
# Line 534 | Line 529 | class Cmssw(JobType):
529                      elif ( filesEventCount - jobSkipEventCount == eventsPerJobRequested ) :
530                          # close job and touch new file
531                          fullString = parString[:-2]
537                        fullString += '\\}'
532                          list_of_lists.append([fullString,str(eventsPerJobRequested),str(jobSkipEventCount)])
533                          common.logger.debug(3,"Job "+str(jobCount+1)+" can run over "+str(eventsPerJobRequested)+" events.")
534                          self.jobDestination.append(blockSites[block])
# Line 546 | Line 540 | class Cmssw(JobType):
540                          eventsRemaining = eventsRemaining - eventsPerJobRequested
541                          jobSkipEventCount = 0
542                          # reset file
543 <                        parString = "\\{"
543 >                        parString = ""
544                          filesEventCount = 0
545                          newFile = 1
546                          fileCount += 1
547 <                        
547 >
548                      # if more events in file remain than eventsPerJobRequested
549                      else :
550                          # close job but don't touch new file
551                          fullString = parString[:-2]
558                        fullString += '\\}'
552                          list_of_lists.append([fullString,str(eventsPerJobRequested),str(jobSkipEventCount)])
553                          common.logger.debug(3,"Job "+str(jobCount+1)+" can run over "+str(eventsPerJobRequested)+" events.")
554                          self.jobDestination.append(blockSites[block])
# Line 570 | Line 563 | class Cmssw(JobType):
563                          jobSkipEventCount = eventsPerJobRequested - (filesEventCount - jobSkipEventCount - self.eventsbyfile[file])
564                          # remove all but the last file
565                          filesEventCount = self.eventsbyfile[file]
566 <                        parString = "\\{"
566 >                        parString = ""
567                          parString += '\\\"' + file + '\\\"\,'
568                      pass # END if
569                  pass # END while (iterate over files in the block)
# Line 579 | Line 572 | class Cmssw(JobType):
572          if (eventsRemaining > 0 and jobCount < totalNumberOfJobs ):
573              common.logger.message("Could not run on all requested events because some blocks not hosted at allowed sites.")
574          common.logger.message(str(jobCount)+" job(s) can run on "+str(totalEventCount)+" events.\n")
575 <        
575 >
576          # screen output
577          screenOutput = "List of jobs and available destination sites:\n\n"
578  
# Line 593 | Line 586 | class Cmssw(JobType):
586                  blockCounter += 1
587                  screenOutput += "Block %5i: jobs %20s: sites: %s\n" % (blockCounter,spanRanges(jobsOfBlock[block]),','.join(self.blackWhiteListParser.checkWhiteList(self.blackWhiteListParser.checkBlackList(blockSites[block],block),block)))
588                  if len(self.blackWhiteListParser.checkWhiteList(self.blackWhiteListParser.checkBlackList(blockSites[block],block),block)) == 0:
589 <                    noSiteBlock.append( spanRanges(jobsOfBlock[block]) )
589 >                    noSiteBlock.append( spanRanges(jobsOfBlock[block]) )
590                      bloskNoSite.append( blockCounter )
591 <        
591 >
592          common.logger.message(screenOutput)
593          if len(noSiteBlock) > 0 and len(bloskNoSite) > 0:
594              msg = 'WARNING: No sites are hosting any part of data for block:\n                '
# Line 621 | Line 614 | class Cmssw(JobType):
614          Perform job splitting based on number of event per job
615          """
616          common.logger.debug(5,'Splitting per events')
617 <        
618 <        if (self.selectEventsPerJob):
617 >
618 >        if (self.selectEventsPerJob):
619              common.logger.message('Required '+str(self.eventsPerJob)+' events per job ')
620          if (self.selectNumberOfJobs):
621              common.logger.message('Required '+str(self.theNumberOfJobs)+' jobs in total ')
# Line 636 | Line 629 | class Cmssw(JobType):
629          if (self.selectEventsPerJob):
630              if (self.selectTotalNumberEvents):
631                  self.total_number_of_jobs = int(self.total_number_of_events/self.eventsPerJob)
632 <            elif(self.selectNumberOfJobs) :  
632 >            elif(self.selectNumberOfJobs) :
633                  self.total_number_of_jobs =self.theNumberOfJobs
634 <                self.total_number_of_events =int(self.theNumberOfJobs*self.eventsPerJob)
634 >                self.total_number_of_events =int(self.theNumberOfJobs*self.eventsPerJob)
635  
636          elif (self.selectNumberOfJobs) :
637              self.total_number_of_jobs = self.theNumberOfJobs
638              self.eventsPerJob = int(self.total_number_of_events/self.total_number_of_jobs)
639 <
639 >
640          common.logger.debug(5,'N jobs  '+str(self.total_number_of_jobs))
641  
642          # is there any remainder?
# Line 660 | Line 653 | class Cmssw(JobType):
653          for i in range(self.total_number_of_jobs):
654              ## Since there is no input, any site is good
655             # self.jobDestination.append(["Any"])
656 <            self.jobDestination.append([""]) #must be empty to write correctly the xml
656 >            self.jobDestination.append([""]) #must be empty to write correctly the xml
657              args=[]
658              if (self.firstRun):
659                      ## pythia first run
# Line 678 | Line 671 | class Cmssw(JobType):
671                  if (self.sourceSeedG4):
672                      ## + G4 random seed
673                      args.append(str(self.sourceSeedG4)+str(i))
674 <                if (self.sourceSeedMix):    
674 >                if (self.sourceSeedMix):
675                      ## + Mix random seed
676                      args.append(str(self.sourceSeedMix)+str(i))
677                  pass
678              pass
679              self.list_of_args.append(args)
680          pass
681 <            
681 >
682          # print self.list_of_args
683  
684          return
# Line 715 | Line 708 | class Cmssw(JobType):
708          return
709  
710      def split(self, jobParams):
711 <
711 >
712          common.jobDB.load()
713          #### Fabio
714          njobs = self.total_number_of_jobs
# Line 723 | Line 716 | class Cmssw(JobType):
716          # create the empty structure
717          for i in range(njobs):
718              jobParams.append("")
719 <        
719 >
720          for job in range(njobs):
721              jobParams[job] = arglist[job]
722              # print str(arglist[job])
# Line 734 | Line 727 | class Cmssw(JobType):
727  
728          common.jobDB.save()
729          return
730 <    
730 >
731      def getJobTypeArguments(self, nj, sched):
732          result = ''
733          for i in common.jobDB.arguments(nj):
734              result=result+str(i)+" "
735          return result
736 <  
736 >
737      def numberOfJobs(self):
738          # Fabio
739          return self.total_number_of_jobs
# Line 749 | Line 742 | class Cmssw(JobType):
742          """
743          Return the TarBall with lib and exe
744          """
745 <        
745 >
746          # if it exist, just return it
747          #
748          # Marco. Let's start to use relative path for Boss XML files
# Line 772 | Line 765 | class Cmssw(JobType):
765          # print "swVersion = ", swVersion
766          swReleaseTop = self.scram.getReleaseTop_()
767          #print "swReleaseTop = ", swReleaseTop
768 <        
768 >
769          ## check if working area is release top
770          if swReleaseTop == '' or swArea == swReleaseTop:
771              return
# Line 785 | Line 778 | class Cmssw(JobType):
778                  exeWithPath = self.scram.findFile_(executable)
779                  if ( not exeWithPath ):
780                      raise CrabException('User executable '+executable+' not found')
781 <    
781 >
782                  ## then check if it's private or not
783                  if exeWithPath.find(swReleaseTop) == -1:
784                      # the exe is private, so we must ship
# Line 801 | Line 794 | class Cmssw(JobType):
794                  else:
795                      # the exe is from release, we'll find it on WN
796                      pass
797 <    
797 >
798              ## Now get the libraries: only those in local working area
799              libDir = 'lib'
800              lib = swArea+'/' +libDir
801              common.logger.debug(5,"lib "+lib+" to be tarred")
802              if os.path.exists(lib):
803                  tar.add(lib,libDir)
804 <    
804 >
805              ## Now check if module dir is present
806              moduleDir = 'module'
807              module = swArea + '/' + moduleDir
# Line 834 | Line 827 | class Cmssw(JobType):
827              prodcommonPath = os.environ['CRABDIR'] + '/' + 'ProdCommon'
828              if os.path.isdir(prodcommonPath):
829                  tar.add(prodcommonPath,prodcommonDir)
830 <            #############################    
831 <        
830 >            #############################
831 >
832              common.logger.debug(5,"Files added to "+self.tgzNameWithPath+" : "+str(tar.getnames()))
833              tar.close()
834          except :
# Line 847 | Line 840 | class Cmssw(JobType):
840              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.')
841  
842          ## create tar-ball with ML stuff
843 <        self.MLtgzfile =  common.work_space.pathForTgz()+'share/MLfiles.tgz'
843 >        self.MLtgzfile =  common.work_space.pathForTgz()+'share/MLfiles.tgz'
844          try:
845              tar = tarfile.open(self.MLtgzfile, "w:gz")
846              path=os.environ['CRABDIR'] + '/python/'
# Line 857 | Line 850 | class Cmssw(JobType):
850              tar.close()
851          except :
852              raise CrabException('Could not create ML files tar-ball')
853 <        
853 >
854          return
855 <        
855 >
856      def additionalInputFileTgz(self):
857          """
858          Put all additional files into a tar ball and return its name
# Line 879 | Line 872 | class Cmssw(JobType):
872          the execution environment for the job 'nj'.
873          """
874          # Prepare JobType-independent part
875 <        txt = ''
876 <  
877 <        ## OLI_Daniele at this level  middleware already known
885 <
886 <        txt += 'if [ $middleware == LCG ]; then \n'
887 <        txt += '    echo "### First set SCRAM ARCH and BUILD_ARCH to ' + self.executable_arch + ' ###"\n'
888 <        txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
889 <        txt += '    export BUILD_ARCH='+self.executable_arch+'\n'
875 >        txt = ''
876 >        txt += 'echo ">>> setup environment"\n'
877 >        txt += 'if [ $middleware == LCG ]; then \n'
878          txt += self.wsSetupCMSLCGEnvironment_()
879          txt += 'elif [ $middleware == OSG ]; then\n'
880          txt += '    WORKING_DIR=`/bin/mktemp  -d $OSG_WN_TMP/cms_XXXXXXXXXXXX`\n'
881 <        txt += '    echo "Created working directory: $WORKING_DIR"\n'
894 <        txt += '    if [ ! -d $WORKING_DIR ] ;then\n'
881 >        txt += '    if [ ! $? == 0 ] ;then\n'
882          txt += '        echo "SET_CMS_ENV 10016 ==> OSG $WORKING_DIR could not be created on WN `hostname`"\n'
883 <        txt += '    echo "JOB_EXIT_STATUS = 10016"\n'
884 <        txt += '    echo "JobExitCode=10016" | tee -a $RUNTIME_AREA/$repo\n'
885 <        txt += '    dumpStatus $RUNTIME_AREA/$repo\n'
899 <        txt += '        rm -f $RUNTIME_AREA/$repo \n'
900 <        txt += '        echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
901 <        txt += '        echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
883 >        txt += '        echo "JOB_EXIT_STATUS = 10016"\n'
884 >        txt += '        echo "JobExitCode=10016" | tee -a $RUNTIME_AREA/$repo\n'
885 >        txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
886          txt += '        exit 1\n'
887          txt += '    fi\n'
888 +        txt += '    echo ">>> Created working directory: $WORKING_DIR"\n'
889          txt += '\n'
890          txt += '    echo "Change to working directory: $WORKING_DIR"\n'
891          txt += '    cd $WORKING_DIR\n'
892 <        txt += self.wsSetupCMSOSGEnvironment_()
893 <        txt += '    echo "### Set SCRAM ARCH to ' + self.executable_arch + ' ###"\n'
894 <        txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
892 >        txt += '    echo ">>> current directory (WORKING_DIR): $WORKING_DIR"\n'
893 >        txt += self.wsSetupCMSOSGEnvironment_()
894 >        #txt += '    echo "### Set SCRAM ARCH to ' + self.executable_arch + ' ###"\n'
895 >        #txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
896          txt += 'fi\n'
897  
898          # Prepare JobType-specific part
899          scram = self.scram.commandName()
900          txt += '\n\n'
901 <        txt += 'echo "### SPECIFIC JOB SETUP ENVIRONMENT ###"\n'
901 >        txt += 'echo ">>> specific cmssw setup environment:"\n'
902 >        txt += 'echo "CMSSW_VERSION =  '+self.version+'"\n'
903          txt += scram+' project CMSSW '+self.version+'\n'
904          txt += 'status=$?\n'
905          txt += 'if [ $status != 0 ] ; then\n'
906 <        txt += '   echo "SET_EXE_ENV 10034 ==>ERROR CMSSW '+self.version+' not found on `hostname`" \n'
907 <        txt += '   echo "JOB_EXIT_STATUS = 10034"\n'
908 <        txt += '   echo "JobExitCode=10034" | tee -a $RUNTIME_AREA/$repo\n'
909 <        txt += '   dumpStatus $RUNTIME_AREA/$repo\n'
923 <        txt += '   rm -f $RUNTIME_AREA/$repo \n'
924 <        txt += '   echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
925 <        txt += '   echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
926 <        ## OLI_Daniele
906 >        txt += '    echo "SET_EXE_ENV 10034 ==>ERROR CMSSW '+self.version+' not found on `hostname`" \n'
907 >        txt += '    echo "JOB_EXIT_STATUS = 10034"\n'
908 >        txt += '    echo "JobExitCode=10034" | tee -a $RUNTIME_AREA/$repo\n'
909 >        txt += '    dumpStatus $RUNTIME_AREA/$repo\n'
910          txt += '    if [ $middleware == OSG ]; then \n'
928        txt += '        echo "Remove working directory: $WORKING_DIR"\n'
911          txt += '        cd $RUNTIME_AREA\n'
912 +        txt += '        echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
913 +        txt += '        echo ">>> Remove working directory: $WORKING_DIR"\n'
914          txt += '        /bin/rm -rf $WORKING_DIR\n'
915          txt += '        if [ -d $WORKING_DIR ] ;then\n'
916          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'
917          txt += '            echo "JOB_EXIT_STATUS = 10018"\n'
918          txt += '            echo "JobExitCode=10018" | tee -a $RUNTIME_AREA/$repo\n'
919          txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
936        txt += '            rm -f $RUNTIME_AREA/$repo \n'
937        txt += '            echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
938        txt += '            echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
920          txt += '        fi\n'
921          txt += '    fi \n'
922 <        txt += '   exit 1 \n'
922 >        txt += '    exit 1 \n'
923          txt += 'fi \n'
943        txt += 'echo "CMSSW_VERSION =  '+self.version+'"\n'
924          txt += 'cd '+self.version+'\n'
925          ########## FEDE FOR DBS2 ######################
926          txt += 'SOFTWARE_DIR=`pwd`\n'
927 <        txt += 'echo SOFTWARE_DIR=$SOFTWARE_DIR \n'
927 >        txt += 'echo ">>> current directory (SOFTWARE_DIR): $SOFTWARE_DIR" \n'
928          ###############################################
929          ### needed grep for bug in scramv1 ###
930          txt += scram+' runtime -sh\n'
# Line 955 | Line 935 | class Cmssw(JobType):
935          txt += "\n"
936          txt += "## number of arguments (first argument always jobnumber)\n"
937          txt += "\n"
958 #        txt += "narg=$#\n"
938          txt += "if [ $nargs -lt 2 ]\n"
939          txt += "then\n"
940          txt += "    echo 'SET_EXE_ENV 1 ==> ERROR Too few arguments' +$nargs+ \n"
941          txt += '    echo "JOB_EXIT_STATUS = 50113"\n'
942          txt += '    echo "JobExitCode=50113" | tee -a $RUNTIME_AREA/$repo\n'
943          txt += '    dumpStatus $RUNTIME_AREA/$repo\n'
965        txt += '    rm -f $RUNTIME_AREA/$repo \n'
966        txt += '    echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
967        txt += '    echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
968        ## OLI_Daniele
944          txt += '    if [ $middleware == OSG ]; then \n'
970        txt += '        echo "Remove working directory: $WORKING_DIR"\n'
945          txt += '        cd $RUNTIME_AREA\n'
946 +        txt += '        echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
947 +        txt += '        echo ">>> Remove working directory: $WORKING_DIR"\n'
948          txt += '        /bin/rm -rf $WORKING_DIR\n'
949          txt += '        if [ -d $WORKING_DIR ] ;then\n'
950          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'
951          txt += '            echo "JOB_EXIT_STATUS = 50114"\n'
952          txt += '            echo "JobExitCode=50114" | tee -a $RUNTIME_AREA/$repo\n'
953          txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
978        txt += '            rm -f $RUNTIME_AREA/$repo \n'
979        txt += '            echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
980        txt += '            echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
954          txt += '        fi\n'
955          txt += '    fi \n'
956          txt += "    exit 1\n"
# Line 987 | Line 960 | class Cmssw(JobType):
960          # Prepare job-specific part
961          job = common.job_list[nj]
962          ### FEDE FOR DBS OUTPUT PUBLICATION
963 <        if (self.datasetPath):
963 >        if (self.datasetPath):
964              txt += '\n'
965              txt += 'DatasetPath='+self.datasetPath+'\n'
966  
967              datasetpath_split = self.datasetPath.split("/")
968 <            
968 >
969              txt += 'PrimaryDataset='+datasetpath_split[1]+'\n'
970              txt += 'DataTier='+datasetpath_split[2]+'\n'
998            #txt += 'ProcessedDataset='+datasetpath_split[3]+'\n'
971              txt += 'ApplicationFamily=cmsRun\n'
972  
973          else:
974              txt += 'DatasetPath=MCDataTier\n'
975              txt += 'PrimaryDataset=null\n'
976              txt += 'DataTier=null\n'
1005            #txt += 'ProcessedDataset=null\n'
977              txt += 'ApplicationFamily=MCDataTier\n'
978          if self.pset != None: #CarlosDaniele
979              pset = os.path.basename(job.configFilename())
980              txt += '\n'
981              txt += 'cp  $RUNTIME_AREA/'+pset+' .\n'
982              if (self.datasetPath): # standard job
1012                #txt += 'InputFiles=$2\n'
983                  txt += 'InputFiles=${args[1]}\n'
984                  txt += 'MaxEvents=${args[2]}\n'
985                  txt += 'SkipEvents=${args[3]}\n'
986                  txt += 'echo "Inputfiles:<$InputFiles>"\n'
987 <                txt += 'sed "s#{\'INPUT\'}#$InputFiles#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
987 >                txt += 'sed "s#\'INPUTFILE\'#$InputFiles#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
988                  txt += 'echo "MaxEvents:<$MaxEvents>"\n'
989 <                txt += 'sed "s#INPUTMAXEVENTS#$MaxEvents#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
989 >                txt += 'sed "s#int32 input = 0#int32 input = $MaxEvents#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
990                  txt += 'echo "SkipEvents:<$SkipEvents>"\n'
991 <                txt += 'sed "s#INPUTSKIPEVENTS#$SkipEvents#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
991 >                txt += 'sed "s#uint32 skipEvents = 0#uint32 skipEvents = $SkipEvents#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
992              else:  # pythia like job
993                  seedIndex=1
994                  if (self.firstRun):
995                      txt += 'FirstRun=${args['+str(seedIndex)+']}\n'
996                      txt += 'echo "FirstRun: <$FirstRun>"\n'
997 <                    txt += 'sed "s#\<INPUTFIRSTRUN\>#$FirstRun#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
997 >                    txt += 'sed "s#uint32 firstRun = 0#uint32 firstRun = $FirstRun#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
998                      seedIndex=seedIndex+1
999  
1000                  if (self.sourceSeed):
1001                      txt += 'Seed=${args['+str(seedIndex)+']}\n'
1002 <                    txt += 'sed "s#\<INPUT\>#$Seed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
1002 >                    txt += 'sed "s#uint32 sourceSeed = 0#uint32 sourceSeed = $Seed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
1003                      seedIndex=seedIndex+1
1004                      ## the following seeds are not always present
1005                      if (self.sourceSeedVtx):
1006                          txt += 'VtxSeed=${args['+str(seedIndex)+']}\n'
1007                          txt += 'echo "VtxSeed: <$VtxSeed>"\n'
1008 <                        txt += 'sed "s#\<INPUTVTX\>#$VtxSeed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
1008 >                        txt += 'sed "s#uint32 VtxSmeared = 0#uint32 VtxSmeared = $VtxSeed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
1009                          seedIndex += 1
1010                      if (self.sourceSeedG4):
1011                          txt += 'G4Seed=${args['+str(seedIndex)+']}\n'
1012                          txt += 'echo "G4Seed: <$G4Seed>"\n'
1013 <                        txt += 'sed "s#\<INPUTG4\>#$G4Seed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
1013 >                        txt += 'sed "s#uint32 g4SimHits = 0#uint32 g4SimHits = $G4Seed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
1014                          seedIndex += 1
1015                      if (self.sourceSeedMix):
1016                          txt += 'mixSeed=${args['+str(seedIndex)+']}\n'
1017                          txt += 'echo "MixSeed: <$mixSeed>"\n'
1018 <                        txt += 'sed "s#\<INPUTMIX\>#$mixSeed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
1018 >                        txt += 'sed "s#uint32 mix = 0#uint32 mix = $mixSeed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
1019                          seedIndex += 1
1020                      pass
1021                  pass
# Line 1055 | Line 1025 | class Cmssw(JobType):
1025              txt += 'if [ -e $RUNTIME_AREA/'+self.additional_tgz_name+' ] ; then\n'
1026              txt += '  tar xzvf $RUNTIME_AREA/'+self.additional_tgz_name+'\n'
1027              txt += 'fi\n'
1028 <            pass
1028 >            pass
1029  
1030          if self.pset != None: #CarlosDaniele
1061            txt += 'echo "### END JOB SETUP ENVIRONMENT ###"\n\n'
1062        
1031              txt += '\n'
1032              txt += 'echo "***** cat pset.cfg *********"\n'
1033              txt += 'cat pset.cfg\n'
# Line 1068 | Line 1036 | class Cmssw(JobType):
1036              ### FEDE FOR DBS OUTPUT PUBLICATION
1037              txt += 'PSETHASH=`EdmConfigHash < pset.cfg` \n'
1038              txt += 'echo "PSETHASH = $PSETHASH" \n'
1039 <            ##############
1039 >            ##############
1040              txt += '\n'
1073            # txt += 'echo "***** cat pset1.cfg *********"\n'
1074            # txt += 'cat pset1.cfg\n'
1075            # txt += 'echo "****** end pset1.cfg ********"\n'
1041          return txt
1042  
1043      def wsBuildExe(self, nj=0):
# Line 1084 | Line 1049 | class Cmssw(JobType):
1049          txt = ""
1050  
1051          if os.path.isfile(self.tgzNameWithPath):
1052 <            txt += 'echo "tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'"\n'
1052 >            txt += 'echo ">>> tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+' :" \n'
1053              txt += 'tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'\n'
1054              txt += 'untar_status=$? \n'
1055              txt += 'if [ $untar_status -ne 0 ]; then \n'
# Line 1092 | Line 1057 | class Cmssw(JobType):
1057              txt += '   echo "JOB_EXIT_STATUS = $untar_status" \n'
1058              txt += '   echo "JobExitCode=$untar_status" | tee -a $RUNTIME_AREA/$repo\n'
1059              txt += '   if [ $middleware == OSG ]; then \n'
1095            txt += '       echo "Remove working directory: $WORKING_DIR"\n'
1060              txt += '       cd $RUNTIME_AREA\n'
1061 +            txt += '        echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
1062 +            txt += '        echo ">>> Remove working directory: $WORKING_DIR"\n'
1063              txt += '       /bin/rm -rf $WORKING_DIR\n'
1064              txt += '       if [ -d $WORKING_DIR ] ;then\n'
1065              txt += '           echo "SET_EXE 50999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after Untarring .tgz file failed"\n'
1066              txt += '           echo "JOB_EXIT_STATUS = 50999"\n'
1067              txt += '           echo "JobExitCode=50999" | tee -a $RUNTIME_AREA/$repo\n'
1068              txt += '           dumpStatus $RUNTIME_AREA/$repo\n'
1103            txt += '           rm -f $RUNTIME_AREA/$repo \n'
1104            txt += '           echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1105            txt += '           echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1069              txt += '       fi\n'
1070              txt += '   fi \n'
1071              txt += '   \n'
# Line 1111 | Line 1074 | class Cmssw(JobType):
1074              txt += '   echo "Successful untar" \n'
1075              txt += 'fi \n'
1076              txt += '\n'
1077 <            txt += 'echo "Include ProdAgentApi and PRODCOMMON in PYTHONPATH"\n'
1077 >            txt += 'echo ">>> Include ProdAgentApi and PRODCOMMON in PYTHONPATH:"\n'
1078              txt += 'if [ -z "$PYTHONPATH" ]; then\n'
1079              #### FEDE FOR DBS OUTPUT PUBLICATION
1080              txt += '   export PYTHONPATH=$SOFTWARE_DIR/ProdAgentApi:$SOFTWARE_DIR/ProdCommon\n'
1118            #txt += '   export PYTHONPATH=`pwd`/ProdAgentApi:`pwd`/ProdCommon\n'
1119            #txt += '   export PYTHONPATH=ProdAgentApi\n'
1081              txt += 'else\n'
1082              txt += '   export PYTHONPATH=$SOFTWARE_DIR/ProdAgentApi:$SOFTWARE_DIR/ProdCommon:${PYTHONPATH}\n'
1122            #txt += '   export PYTHONPATH=`pwd`/ProdAgentApi:`pwd`/ProdCommon:${PYTHONPATH}\n'
1123            #txt += '   export PYTHONPATH=ProdAgentApi:${PYTHONPATH}\n'
1083              txt += 'echo "PYTHONPATH=$PYTHONPATH"\n'
1084 <            ###################  
1084 >            ###################
1085              txt += 'fi\n'
1086              txt += '\n'
1087  
1088              pass
1089 <        
1089 >
1090          return txt
1091  
1092      def modifySteeringCards(self, nj):
1093          """
1094 <        modify the card provided by the user,
1094 >        modify the card provided by the user,
1095          writing a new card into share dir
1096          """
1097 <        
1097 >
1098      def executableName(self):
1099          if self.scriptExe: #CarlosDaniele
1100              return "sh "
# Line 1154 | Line 1113 | class Cmssw(JobType):
1113                  major = int(version_array[1])
1114                  minor = int(version_array[2])
1115              except:
1116 <                msg = "Cannot parse CMSSW version string: " + "_".join(version_array) + " for major and minor release number!"  
1116 >                msg = "Cannot parse CMSSW version string: " + "_".join(version_array) + " for major and minor release number!"
1117                  raise CrabException(msg)
1118              if major >= 1 and minor >= 5 :
1119                  return " -e -p pset.cfg"
# Line 1189 | Line 1148 | class Cmssw(JobType):
1148  
1149          ## User Declared output files
1150          for out in (self.output_file+self.output_file_sandbox):
1151 <            n_out = nj + 1
1151 >            n_out = nj + 1
1152              out_box.append(self.numberFile_(out,str(n_out)))
1153          return out_box
1154  
# Line 1205 | Line 1164 | class Cmssw(JobType):
1164          """
1165  
1166          txt = '\n'
1167 <        txt += '# directory content\n'
1167 >        txt += 'echo" >>> directory content:"\n'
1168          txt += 'ls \n'
1169 +        txt = '\n'
1170  
1171          txt += 'output_exit_status=0\n'
1172 <        
1172 >
1173          for fileWithSuffix in (self.output_file_sandbox):
1174              output_file_num = self.numberFile_(fileWithSuffix, '$NJob')
1175              txt += '\n'
# Line 1226 | Line 1186 | class Cmssw(JobType):
1186                  txt += '        echo "Processing of job output failed" > $RUNTIME_AREA/'+output_file_num+'\n'
1187                  txt += '    fi \n'
1188              txt += 'fi\n'
1189 <        
1189 >
1190          for fileWithSuffix in (self.output_file):
1191              output_file_num = self.numberFile_(fileWithSuffix, '$NJob')
1192              txt += '\n'
# Line 1248 | Line 1208 | class Cmssw(JobType):
1208          file_list = []
1209          for fileWithSuffix in (self.output_file):
1210               file_list.append(self.numberFile_(fileWithSuffix, '$NJob'))
1211 <            
1211 >
1212          txt += 'file_list="'+string.join(file_list,' ')+'"\n'
1213          txt += 'cd $RUNTIME_AREA\n'
1214 +        txt += 'echo ">>> current directory (RUNTIME_AREA):  $RUNTIME_AREA"\n'
1215          return txt
1216  
1217      def numberFile_(self, file, txt):
# Line 1268 | Line 1229 | class Cmssw(JobType):
1229              result = name + '_' + txt + "." + ext
1230          else:
1231              result = name + '_' + txt
1232 <        
1232 >
1233          return result
1234  
1235      def getRequirements(self, nj=[]):
1236          """
1237 <        return job requirements to add to jdl files
1237 >        return job requirements to add to jdl files
1238          """
1239          req = ''
1240          if self.version:
# Line 1295 | Line 1256 | class Cmssw(JobType):
1256          """ return the config filename """
1257          return self.name()+'.cfg'
1258  
1298    ### OLI_DANIELE
1259      def wsSetupCMSOSGEnvironment_(self):
1260          """
1261          Returns part of a job script which is prepares
1262          the execution environment and which is common for all CMS jobs.
1263          """
1264 <        txt = '\n'
1265 <        txt += '   echo "### SETUP CMS OSG  ENVIRONMENT ###"\n'
1266 <        txt += '   if [ -f $GRID3_APP_DIR/cmssoft/cmsset_default.sh ] ;then\n'
1267 <        txt += '      # Use $GRID3_APP_DIR/cmssoft/cmsset_default.sh to setup cms software\n'
1268 <        txt += '       export SCRAM_ARCH='+self.executable_arch+'\n'
1309 <        txt += '       source $GRID3_APP_DIR/cmssoft/cmsset_default.sh '+self.version+'\n'
1310 <        txt += '   elif [ -f $OSG_APP/cmssoft/cms/cmsset_default.sh ] ;then\n'
1264 >        txt = '    echo ">>> setup CMS OSG environment:"\n'
1265 >        txt += '    echo "set SCRAM ARCH to ' + self.executable_arch + '"\n'
1266 >        txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
1267 >        txt += '    echo "SCRAM_ARCH = $SCRAM_ARCH"\n'
1268 >        txt += '    if [ -f $OSG_APP/cmssoft/cms/cmsset_default.sh ] ;then\n'
1269          txt += '      # Use $OSG_APP/cmssoft/cms/cmsset_default.sh to setup cms software\n'
1270 <        txt += '       export SCRAM_ARCH='+self.executable_arch+'\n'
1271 <        txt += '       source $OSG_APP/cmssoft/cms/cmsset_default.sh '+self.version+'\n'
1272 <        txt += '   else\n'
1273 <        txt += '       echo "SET_CMS_ENV 10020 ==> ERROR $GRID3_APP_DIR/cmssoft/cmsset_default.sh and $OSG_APP/cmssoft/cms/cmsset_default.sh file not found"\n'
1274 <        txt += '       echo "JOB_EXIT_STATUS = 10020"\n'
1275 <        txt += '       echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
1318 <        txt += '       dumpStatus $RUNTIME_AREA/$repo\n'
1319 <        txt += '       rm -f $RUNTIME_AREA/$repo \n'
1320 <        txt += '       echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1321 <        txt += '       echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1322 <        txt += '       exit 1\n'
1270 >        txt += '        source $OSG_APP/cmssoft/cms/cmsset_default.sh '+self.version+'\n'
1271 >        txt += '    else\n'
1272 >        txt += '        echo "SET_CMS_ENV 10020 ==> ERROR $OSG_APP/cmssoft/cms/cmsset_default.sh file not found"\n'
1273 >        txt += '        echo "JOB_EXIT_STATUS = 10020"\n'
1274 >        txt += '        echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
1275 >        txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
1276          txt += '\n'
1277 <        txt += '       echo "Remove working directory: $WORKING_DIR"\n'
1278 <        txt += '       cd $RUNTIME_AREA\n'
1279 <        txt += '       /bin/rm -rf $WORKING_DIR\n'
1280 <        txt += '       if [ -d $WORKING_DIR ] ;then\n'
1281 <        txt += '           echo "SET_CMS_ENV 10017 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after $GRID3_APP_DIR/cmssoft/cmsset_default.sh and $OSG_APP/cmssoft/cms/cmsset_default.sh file not found"\n'
1282 <        txt += '           echo "JOB_EXIT_STATUS = 10017"\n'
1283 <        txt += '           echo "JobExitCode=10017" | tee -a $RUNTIME_AREA/$repo\n'
1284 <        txt += '           dumpStatus $RUNTIME_AREA/$repo\n'
1285 <        txt += '           rm -f $RUNTIME_AREA/$repo \n'
1286 <        txt += '           echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1334 <        txt += '           echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1335 <        txt += '       fi\n'
1277 >        txt += '        cd $RUNTIME_AREA\n'
1278 >        txt += '        echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
1279 >        txt += '        echo ">>> Remove working directory: $WORKING_DIR"\n'
1280 >        txt += '        /bin/rm -rf $WORKING_DIR\n'
1281 >        txt += '        if [ -d $WORKING_DIR ] ;then\n'
1282 >        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'
1283 >        txt += '            echo "JOB_EXIT_STATUS = 10017"\n'
1284 >        txt += '            echo "JobExitCode=10017" | tee -a $RUNTIME_AREA/$repo\n'
1285 >        txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
1286 >        txt += '        fi\n'
1287          txt += '\n'
1288 <        txt += '       exit 1\n'
1289 <        txt += '   fi\n'
1288 >        txt += '        exit 1\n'
1289 >        txt += '    fi\n'
1290          txt += '\n'
1291 <        txt += '   echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'
1292 <        txt += '   echo " END SETUP CMS OSG  ENVIRONMENT "\n'
1291 >        txt += '    echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'
1292 >        txt += '    echo "SCRAM_ARCH = $SCRAM_ARCH"\n'
1293  
1294          return txt
1295 <
1295 >
1296      ### OLI_DANIELE
1297      def wsSetupCMSLCGEnvironment_(self):
1298          """
1299          Returns part of a job script which is prepares
1300          the execution environment and which is common for all CMS jobs.
1301          """
1302 <        txt  = '   \n'
1303 <        txt += '   echo " ### SETUP CMS LCG  ENVIRONMENT ### "\n'
1304 <        txt += '   if [ ! $VO_CMS_SW_DIR ] ;then\n'
1305 <        txt += '       echo "SET_CMS_ENV 10031 ==> ERROR CMS software dir not found on WN `hostname`"\n'
1306 <        txt += '       echo "JOB_EXIT_STATUS = 10031" \n'
1307 <        txt += '       echo "JobExitCode=10031" | tee -a $RUNTIME_AREA/$repo\n'
1308 <        txt += '       dumpStatus $RUNTIME_AREA/$repo\n'
1309 <        txt += '       rm -f $RUNTIME_AREA/$repo \n'
1310 <        txt += '       echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1311 <        txt += '       echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1312 <        txt += '       exit 1\n'
1313 <        txt += '   else\n'
1314 <        txt += '       echo "Sourcing environment... "\n'
1315 <        txt += '       if [ ! -s $VO_CMS_SW_DIR/cmsset_default.sh ] ;then\n'
1316 <        txt += '           echo "SET_CMS_ENV 10020 ==> ERROR cmsset_default.sh file not found into dir $VO_CMS_SW_DIR"\n'
1317 <        txt += '           echo "JOB_EXIT_STATUS = 10020"\n'
1318 <        txt += '           echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
1319 <        txt += '           dumpStatus $RUNTIME_AREA/$repo\n'
1320 <        txt += '           rm -f $RUNTIME_AREA/$repo \n'
1321 <        txt += '           echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1322 <        txt += '           echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1323 <        txt += '           exit 1\n'
1324 <        txt += '       fi\n'
1325 <        txt += '       echo "sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
1326 <        txt += '       source $VO_CMS_SW_DIR/cmsset_default.sh\n'
1327 <        txt += '       result=$?\n'
1328 <        txt += '       if [ $result -ne 0 ]; then\n'
1329 <        txt += '           echo "SET_CMS_ENV 10032 ==> ERROR problem sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
1330 <        txt += '           echo "JOB_EXIT_STATUS = 10032"\n'
1331 <        txt += '           echo "JobExitCode=10032" | tee -a $RUNTIME_AREA/$repo\n'
1332 <        txt += '           dumpStatus $RUNTIME_AREA/$repo\n'
1333 <        txt += '           rm -f $RUNTIME_AREA/$repo \n'
1383 <        txt += '           echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1384 <        txt += '           echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1385 <        txt += '           exit 1\n'
1386 <        txt += '       fi\n'
1387 <        txt += '   fi\n'
1388 <        txt += '   \n'
1389 <        txt += '   echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'
1390 <        txt += '   echo "### END SETUP CMS LCG ENVIRONMENT ###"\n'
1302 >        txt = '    echo ">>> setup CMS LCG environment:"\n'
1303 >        txt += '    echo "set SCRAM ARCH and BUILD_ARCH to ' + self.executable_arch + ' ###"\n'
1304 >        txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
1305 >        txt += '    export BUILD_ARCH='+self.executable_arch+'\n'
1306 >        txt += '    if [ ! $VO_CMS_SW_DIR ] ;then\n'
1307 >        txt += '        echo "SET_CMS_ENV 10031 ==> ERROR CMS software dir not found on WN `hostname`"\n'
1308 >        txt += '        echo "JOB_EXIT_STATUS = 10031" \n'
1309 >        txt += '        echo "JobExitCode=10031" | tee -a $RUNTIME_AREA/$repo\n'
1310 >        txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
1311 >        txt += '        exit 1\n'
1312 >        txt += '    else\n'
1313 >        txt += '        echo "Sourcing environment... "\n'
1314 >        txt += '        if [ ! -s $VO_CMS_SW_DIR/cmsset_default.sh ] ;then\n'
1315 >        txt += '            echo "SET_CMS_ENV 10020 ==> ERROR cmsset_default.sh file not found into dir $VO_CMS_SW_DIR"\n'
1316 >        txt += '            echo "JOB_EXIT_STATUS = 10020"\n'
1317 >        txt += '            echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
1318 >        txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
1319 >        txt += '            exit 1\n'
1320 >        txt += '        fi\n'
1321 >        txt += '        echo "sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
1322 >        txt += '        source $VO_CMS_SW_DIR/cmsset_default.sh\n'
1323 >        txt += '        result=$?\n'
1324 >        txt += '        if [ $result -ne 0 ]; then\n'
1325 >        txt += '            echo "SET_CMS_ENV 10032 ==> ERROR problem sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
1326 >        txt += '            echo "JOB_EXIT_STATUS = 10032"\n'
1327 >        txt += '            echo "JobExitCode=10032" | tee -a $RUNTIME_AREA/$repo\n'
1328 >        txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
1329 >        txt += '            exit 1\n'
1330 >        txt += '        fi\n'
1331 >        txt += '    fi\n'
1332 >        txt += '    \n'
1333 >        txt += '    echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'
1334          return txt
1335  
1336 <    ### FEDE FOR DBS OUTPUT PUBLICATION
1336 >    ### FEDE FOR DBS OUTPUT PUBLICATION
1337      def modifyReport(self, nj):
1338          """
1339 <        insert the part of the script that modifies the FrameworkJob Report
1339 >        insert the part of the script that modifies the FrameworkJob Report
1340          """
1341  
1342 <        txt = ''
1342 >        txt = ''
1343          try:
1344 <            publish_data = int(self.cfg_params['USER.publish_data'])          
1344 >            publish_data = int(self.cfg_params['USER.publish_data'])
1345          except KeyError:
1346              publish_data = 0
1347 <        if (publish_data == 1):  
1348 <            txt += 'echo "Modify Job Report" \n'
1406 <            #txt += 'chmod a+x $RUNTIME_AREA/'+self.version+'/ProdAgentApi/FwkJobRep/ModifyJobReport.py\n'
1347 >        if (publish_data == 1):
1348 >            txt += 'echo ">>> Modify Job Report:" \n'
1349              ################ FEDE FOR DBS2 #############################################
1350              txt += 'chmod a+x $SOFTWARE_DIR/ProdAgentApi/FwkJobRep/ModifyJobReport.py\n'
1351              #############################################################################
1410            #try:
1411            #    publish_data = int(self.cfg_params['USER.publish_data'])          
1412            #except KeyError:
1413            #    publish_data = 0
1352  
1353              txt += 'if [ -z "$SE" ]; then\n'
1354              txt += '    SE="" \n'
1355 <            txt += 'fi \n'
1355 >            txt += 'fi \n'
1356              txt += 'if [ -z "$SE_PATH" ]; then\n'
1357              txt += '    SE_PATH="" \n'
1358 <            txt += 'fi \n'
1359 <            txt += 'echo "SE = $SE"\n'
1358 >            txt += 'fi \n'
1359 >            txt += 'echo "SE = $SE"\n'
1360              txt += 'echo "SE_PATH = $SE_PATH"\n'
1361  
1424        #if (publish_data == 1):  
1425            #processedDataset = self.cfg_params['USER.processed_datasetname']
1362              processedDataset = self.cfg_params['USER.publish_data_name']
1363              txt += 'ProcessedDataset='+processedDataset+'\n'
1364              #### LFN=/store/user/<user>/processedDataset_PSETHASH
1365              txt += 'if [ "$SE_PATH" == "" ]; then\n'
1366              #### FEDE: added slash in LFN ##############
1367              txt += '    FOR_LFN=/copy_problems/ \n'
1368 <            txt += 'else \n'
1368 >            txt += 'else \n'
1369              txt += '    tmp=`echo $SE_PATH | awk -F \'store\' \'{print$2}\'` \n'
1370              #####  FEDE TO BE CHANGED, BECAUSE STORE IS HARDCODED!!!! ########
1371              txt += '    FOR_LFN=/store$tmp \n'
1372 <            txt += 'fi \n'
1372 >            txt += 'fi \n'
1373              txt += 'echo "ProcessedDataset = $ProcessedDataset"\n'
1374              txt += 'echo "FOR_LFN = $FOR_LFN" \n'
1375              txt += 'echo "CMSSW_VERSION = $CMSSW_VERSION"\n\n'
1376 <            #txt += 'echo "$RUNTIME_AREA/'+self.version+'/ProdAgentApi/FwkJobRep/ModifyJobReport.py crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH"\n'
1377 <            txt += 'echo "$SOFTWARE_DIR/ProdAgentApi/FwkJobRep/ModifyJobReport.py crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH"\n'
1376 >            #txt += 'echo "$RUNTIME_AREA/'+self.version+'/ProdAgentApi/FwkJobRep/ModifyJobReport.py crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH"\n'
1377 >            txt += 'echo "$SOFTWARE_DIR/ProdAgentApi/FwkJobRep/ModifyJobReport.py crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH"\n'
1378              txt += '$SOFTWARE_DIR/ProdAgentApi/FwkJobRep/ModifyJobReport.py crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH\n'
1379              #txt += '$RUNTIME_AREA/'+self.version+'/ProdAgentApi/FwkJobRep/ModifyJobReport.py crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH\n'
1380 <      
1380 >
1381              txt += 'modifyReport_result=$?\n'
1382              txt += 'echo modifyReport_result = $modifyReport_result\n'
1383              txt += 'if [ $modifyReport_result -ne 0 ]; then\n'
# Line 1452 | Line 1388 | class Cmssw(JobType):
1388              txt += 'fi\n'
1389          else:
1390              txt += 'echo "no data publication required"\n'
1455            #txt += 'ProcessedDataset=no_data_to_publish \n'
1456            #### FEDE: added slash in LFN ##############
1457            #txt += 'FOR_LFN=/local/ \n'
1458            #txt += 'echo "ProcessedDataset = $ProcessedDataset"\n'
1459            #txt += 'echo "FOR_LFN = $FOR_LFN" \n'
1391          return txt
1392  
1393      def cleanEnv(self):
1394 <        ### OLI_DANIELE
1395 <        txt = ''
1465 <        txt += 'if [ $middleware == OSG ]; then\n'  
1394 >        txt = ''
1395 >        txt += 'if [ $middleware == OSG ]; then\n'
1396          txt += '    cd $RUNTIME_AREA\n'
1397 <        txt += '    echo "Remove working directory: $WORKING_DIR"\n'
1397 >        txt += '    echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
1398 >        txt += '    echo ">>> Remove working directory: $WORKING_DIR"\n'
1399          txt += '    /bin/rm -rf $WORKING_DIR\n'
1400          txt += '    if [ -d $WORKING_DIR ] ;then\n'
1401 <        txt += '              echo "SET_EXE 60999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after cleanup of WN"\n'
1402 <        txt += '              echo "JOB_EXIT_STATUS = 60999"\n'
1403 <        txt += '              echo "JobExitCode=60999" | tee -a $RUNTIME_AREA/$repo\n'
1404 <        txt += '              dumpStatus $RUNTIME_AREA/$repo\n'
1474 <        txt += '        rm -f $RUNTIME_AREA/$repo \n'
1475 <        txt += '        echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1476 <        txt += '        echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1401 >        txt += '        echo "SET_EXE 60999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after cleanup of WN"\n'
1402 >        txt += '        echo "JOB_EXIT_STATUS = 60999"\n'
1403 >        txt += '        echo "JobExitCode=60999" | tee -a $RUNTIME_AREA/$repo\n'
1404 >        txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
1405          txt += '    fi\n'
1406          txt += 'fi\n'
1407          txt += '\n'
# Line 1487 | Line 1415 | class Cmssw(JobType):
1415  
1416      def setTaskid_(self):
1417          self._taskId = self.cfg_params['taskId']
1418 <        
1418 >
1419      def getTaskid(self):
1420          return self._taskId
1421  
# Line 1505 | Line 1433 | class Cmssw(JobType):
1433          """
1434          check the dimension of the output files
1435          """
1436 <        txt = 'echo "*****************************************"\n'
1509 <        txt += 'echo "** Starting output sandbox limit check **"\n'
1510 <        txt += 'echo "*****************************************"\n'
1436 >        txt += 'echo ">>> Starting output sandbox limit check :"\n'
1437          allOutFiles = ""
1438          listOutFiles = []
1439          for fileOut in (self.output_file+self.output_file_sandbox):
# Line 1562 | Line 1488 | class Cmssw(JobType):
1488          txt += '        fi\n'
1489          txt += '    done\n'
1490          txt += '    echo "Dimension calculated: $tot"; echo "First file to exclude: $file";\n'
1491 <        txt += '    flag=0;\n'    
1491 >        txt += '    flag=0;\n'
1492          txt += '    for filess in '+str(allOutFiles)+' ; do\n'
1493          txt += '        if [ $fileLast = $filess ]; then\n'
1494          txt += '            flag=1;\n'
# Line 1578 | Line 1504 | class Cmssw(JobType):
1504          txt += 'else'
1505          txt += '    echo "Total Output dimension $sum is fine.";\n'
1506          txt += 'fi\n'
1507 <        txt += 'echo "*****************************************"\n'
1582 <        txt += 'echo "*** Ending output sandbox limit check ***"\n'
1583 <        txt += 'echo "*****************************************"\n'
1507 >        txt += 'echo "Ending output sandbox limit check"\n'
1508          return txt

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines