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.130 by fanzago, Wed Oct 17 13:24:41 2007 UTC vs.
Revision 1.139 by ewv, Tue Nov 20 17:06:50 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  
64          ### collect Data cards
65  
66        ## get DBS mode
67        try:
68            self.use_dbs_1 = int(self.cfg_params['CMSSW.use_dbs_1'])
69        except KeyError:
70            self.use_dbs_1 = 0
71            
66          try:
67              tmp =  cfg_params['CMSSW.datasetpath']
68              log.debug(6, "CMSSW::CMSSW(): datasetPath = "+tmp)
# Line 79 | Line 73 | class Cmssw(JobType):
73                  self.datasetPath = tmp
74                  self.selectNoInput = 0
75          except KeyError:
76 <            msg = "Error: datasetpath not defined "  
76 >            msg = "Error: datasetpath not defined "
77              raise CrabException(msg)
78  
79          # ML monitoring
# Line 92 | Line 86 | class Cmssw(JobType):
86                  datasetpath_split = self.datasetPath.split("/")
87                  # standard style
88                  self.setParam_('datasetFull', self.datasetPath)
89 <                if self.use_dbs_1 == 1 :
90 <                    self.setParam_('dataset', datasetpath_split[1])
97 <                    self.setParam_('owner', datasetpath_split[-1])
98 <                else:
99 <                    self.setParam_('dataset', datasetpath_split[1])
100 <                    self.setParam_('owner', datasetpath_split[2])
89 >                self.setParam_('dataset', datasetpath_split[1])
90 >                self.setParam_('owner', datasetpath_split[2])
91              except:
92                  self.setParam_('dataset', self.datasetPath)
93                  self.setParam_('owner', self.datasetPath)
94 <                
94 >
95          self.setTaskid_()
96          self.setParam_('taskId', self.cfg_params['taskId'])
97  
# Line 124 | Line 114 | class Cmssw(JobType):
114          try:
115              self.pset = cfg_params['CMSSW.pset']
116              log.debug(6, "Cmssw::Cmssw(): PSet file = "+self.pset)
117 <            if self.pset.lower() != 'none' :
117 >            if self.pset.lower() != 'none' :
118                  if (not os.path.exists(self.pset)):
119                      raise CrabException("User defined PSet file "+self.pset+" does not exist")
120              else:
# Line 216 | Line 206 | class Cmssw(JobType):
206          except KeyError:
207              self.eventsPerJob = -1
208              self.selectEventsPerJob = 0
209 <    
209 >
210          ## number of jobs
211          try:
212              self.theNumberOfJobs =int( cfg_params['CMSSW.number_of_jobs'])
# Line 232 | Line 222 | class Cmssw(JobType):
222              self.total_number_of_events = 0
223              self.selectTotalNumberEvents = 0
224  
225 <        if self.pset != None: #CarlosDaniele
225 >        if self.pset != None: #CarlosDaniele
226               if ( (self.selectTotalNumberEvents + self.selectEventsPerJob + self.selectNumberOfJobs) != 2 ):
227                   msg = 'Must define exactly two of total_number_of_events, events_per_job, or number_of_jobs.'
228                   raise CrabException(msg)
# Line 272 | Line 262 | class Cmssw(JobType):
262              self.firstRun = None
263              common.logger.debug(5,"No first run given")
264          if self.pset != None: #CarlosDaniele
265 <            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
265 >            import PsetManipulator as pp
266              PsetEdit = pp.PsetManipulator(self.pset) #Daniele Pset
267  
268          #DBSDLS-start
269 <        ## Initialize the variables that are extracted from DBS/DLS and needed in other places of the code
269 >        ## Initialize the variables that are extracted from DBS/DLS and needed in other places of the code
270          self.maxEvents=0  # max events available   ( --> check the requested nb. of evts in Creator.py)
271          self.DBSPaths={}  # all dbs paths requested ( --> input to the site local discovery script)
272          self.jobDestination=[]  # Site destination(s) for each job (list of lists)
# Line 289 | Line 275 | class Cmssw(JobType):
275          blockSites = {}
276          if self.datasetPath:
277              blockSites = self.DataDiscoveryAndLocation(cfg_params)
278 <        #DBSDLS-end          
278 >        #DBSDLS-end
279  
280          self.tgzNameWithPath = self.getTarBall(self.executable)
281 <    
281 >
282          ## Select Splitting
283 <        if self.selectNoInput:
283 >        if self.selectNoInput:
284              if self.pset == None: #CarlosDaniele
285                  self.jobSplittingForScript()
286              else:
# Line 307 | Line 293 | class Cmssw(JobType):
293              try:
294                  if (self.datasetPath): # standard job
295                      # allow to processa a fraction of events in a file
296 <                    PsetEdit.inputModule("INPUT")
297 <                    PsetEdit.maxEvent("INPUTMAXEVENTS")
298 <                    PsetEdit.skipEvent("INPUTSKIPEVENTS")
296 >                    PsetEdit.inputModule("INPUTFILE")
297 >                    PsetEdit.maxEvent(0)
298 >                    PsetEdit.skipEvent(0)
299                  else:  # pythia like job
300                      PsetEdit.maxEvent(self.eventsPerJob)
301                      if (self.firstRun):
302 <                        PsetEdit.pythiaFirstRun("INPUTFIRSTRUN")  #First Run
302 >                        PsetEdit.pythiaFirstRun(0)  #First Run
303                      if (self.sourceSeed) :
304 <                        PsetEdit.pythiaSeed("INPUT")
304 >                        PsetEdit.pythiaSeed(0)
305                          if (self.sourceSeedVtx) :
306 <                            PsetEdit.vtxSeed("INPUTVTX")
306 >                            PsetEdit.vtxSeed(0)
307                          if (self.sourceSeedG4) :
308 <                            PsetEdit.g4Seed("INPUTG4")
308 >                            PsetEdit.g4Seed(0)
309                          if (self.sourceSeedMix) :
310 <                            PsetEdit.mixSeed("INPUTMIX")
310 >                            PsetEdit.mixSeed(0)
311                  # add FrameworkJobReport to parameter-set
312                  PsetEdit.addCrabFJR(self.fjrFileName)
313                  PsetEdit.psetWriter(self.configFilename())
# Line 332 | Line 318 | class Cmssw(JobType):
318      def DataDiscoveryAndLocation(self, cfg_params):
319  
320          import DataDiscovery
335        import DataDiscovery_DBS2
321          import DataLocation
322          common.logger.debug(10,"CMSSW::DataDiscoveryAndLocation()")
323  
# Line 342 | Line 327 | class Cmssw(JobType):
327          common.logger.message("Contacting Data Discovery Services ...")
328          try:
329  
330 <            if self.use_dbs_1 == 1 :
346 <                self.pubdata=DataDiscovery.DataDiscovery(datasetPath, cfg_params)
347 <            else :
348 <                self.pubdata=DataDiscovery_DBS2.DataDiscovery_DBS2(datasetPath, cfg_params)
330 >            self.pubdata=DataDiscovery.DataDiscovery(datasetPath, cfg_params)
331              self.pubdata.fetchDBSInfo()
332  
333          except DataDiscovery.NotExistingDatasetError, ex :
# Line 357 | Line 339 | class Cmssw(JobType):
339          except DataDiscovery.DataDiscoveryError, ex:
340              msg = 'ERROR ***: failed Data Discovery in DBS :  %s'%ex.getErrorMessage()
341              raise CrabException(msg)
360        except DataDiscovery_DBS2.NotExistingDatasetError_DBS2, ex :
361            msg = 'ERROR ***: failed Data Discovery in DBS : %s'%ex.getErrorMessage()
362            raise CrabException(msg)
363        except DataDiscovery_DBS2.NoDataTierinProvenanceError_DBS2, ex :
364            msg = 'ERROR ***: failed Data Discovery in DBS : %s'%ex.getErrorMessage()
365            raise CrabException(msg)
366        except DataDiscovery_DBS2.DataDiscoveryError_DBS2, ex:
367            msg = 'ERROR ***: failed Data Discovery in DBS :  %s'%ex.getErrorMessage()
368            raise CrabException(msg)
342  
343          self.filesbyblock=self.pubdata.getFiles()
344          self.eventsbyblock=self.pubdata.getEventsPerBlock()
345          self.eventsbyfile=self.pubdata.getEventsPerFile()
346  
347          ## get max number of events
348 <        self.maxEvents=self.pubdata.getMaxEvents() ##  self.maxEvents used in Creator.py
348 >        self.maxEvents=self.pubdata.getMaxEvents() ##  self.maxEvents used in Creator.py
349  
350          ## Contact the DLS and build a list of sites hosting the fileblocks
351          try:
# Line 381 | Line 354 | class Cmssw(JobType):
354          except DataLocation.DataLocationError , ex:
355              msg = 'ERROR ***: failed Data Location in DLS \n %s '%ex.getErrorMessage()
356              raise CrabException(msg)
357 <        
357 >
358  
359          sites = dataloc.getSites()
360          allSites = []
# Line 395 | Line 368 | class Cmssw(JobType):
368          common.logger.message("Requested dataset: " + datasetPath + " has " + str(self.maxEvents) + " events in " + str(len(self.filesbyblock.keys())) + " blocks.\n")
369  
370          return sites
371 <    
371 >
372      def jobSplittingByBlocks(self, blockSites):
373          """
374          Perform job splitting. Jobs run over an integer number of files
# Line 445 | Line 418 | class Cmssw(JobType):
418              totalNumberOfJobs = 999999999
419          else :
420              totalNumberOfJobs = self.ncjobs
421 <            
421 >
422  
423          blocks = blockSites.keys()
424          blockCount = 0
# Line 465 | Line 438 | class Cmssw(JobType):
438              blockCount += 1
439              if block not in jobsOfBlock.keys() :
440                  jobsOfBlock[block] = []
441 <            
441 >
442              if self.eventsbyblock.has_key(block) :
443                  numEventsInBlock = self.eventsbyblock[block]
444                  common.logger.debug(5,'Events in Block File '+str(numEventsInBlock))
445 <            
445 >
446                  files = self.filesbyblock[block]
447                  numFilesInBlock = len(files)
448                  if (numFilesInBlock <= 0):
# Line 477 | Line 450 | class Cmssw(JobType):
450                  fileCount = 0
451  
452                  # ---- New block => New job ---- #
453 <                parString = "\\{"
453 >                parString = ""
454                  # counter for number of events in files currently worked on
455                  filesEventCount = 0
456                  # flag if next while loop should touch new file
457                  newFile = 1
458                  # job event counter
459                  jobSkipEventCount = 0
460 <            
460 >
461                  # ---- Iterate over the files in the block until we've met the requested ---- #
462                  # ---- total # of events or we've gone over all the files in this block  ---- #
463                  while ( (eventsRemaining > 0) and (fileCount < numFilesInBlock) and (jobCount < totalNumberOfJobs) ):
# Line 500 | Line 473 | class Cmssw(JobType):
473                              newFile = 0
474                          except KeyError:
475                              common.logger.message("File "+str(file)+" has unknown number of events: skipping")
476 <                        
476 >
477  
478                      # if less events in file remain than eventsPerJobRequested
479                      if ( filesEventCount - jobSkipEventCount < eventsPerJobRequested ) :
# Line 509 | Line 482 | class Cmssw(JobType):
482                              # end job using last file, use remaining events in block
483                              # close job and touch new file
484                              fullString = parString[:-2]
512                            fullString += '\\}'
485                              list_of_lists.append([fullString,str(-1),str(jobSkipEventCount)])
486                              common.logger.debug(3,"Job "+str(jobCount+1)+" can run over "+str(filesEventCount - jobSkipEventCount)+" events (last file in block).")
487                              self.jobDestination.append(blockSites[block])
# Line 522 | Line 494 | class Cmssw(JobType):
494                              eventsRemaining = eventsRemaining - filesEventCount + jobSkipEventCount
495                              jobSkipEventCount = 0
496                              # reset file
497 <                            parString = "\\{"
497 >                            parString = ""
498                              filesEventCount = 0
499                              newFile = 1
500                              fileCount += 1
# Line 534 | Line 506 | class Cmssw(JobType):
506                      elif ( filesEventCount - jobSkipEventCount == eventsPerJobRequested ) :
507                          # close job and touch new file
508                          fullString = parString[:-2]
537                        fullString += '\\}'
509                          list_of_lists.append([fullString,str(eventsPerJobRequested),str(jobSkipEventCount)])
510                          common.logger.debug(3,"Job "+str(jobCount+1)+" can run over "+str(eventsPerJobRequested)+" events.")
511                          self.jobDestination.append(blockSites[block])
# Line 546 | Line 517 | class Cmssw(JobType):
517                          eventsRemaining = eventsRemaining - eventsPerJobRequested
518                          jobSkipEventCount = 0
519                          # reset file
520 <                        parString = "\\{"
520 >                        parString = ""
521                          filesEventCount = 0
522                          newFile = 1
523                          fileCount += 1
524 <                        
524 >
525                      # if more events in file remain than eventsPerJobRequested
526                      else :
527                          # close job but don't touch new file
528                          fullString = parString[:-2]
558                        fullString += '\\}'
529                          list_of_lists.append([fullString,str(eventsPerJobRequested),str(jobSkipEventCount)])
530                          common.logger.debug(3,"Job "+str(jobCount+1)+" can run over "+str(eventsPerJobRequested)+" events.")
531                          self.jobDestination.append(blockSites[block])
# Line 570 | Line 540 | class Cmssw(JobType):
540                          jobSkipEventCount = eventsPerJobRequested - (filesEventCount - jobSkipEventCount - self.eventsbyfile[file])
541                          # remove all but the last file
542                          filesEventCount = self.eventsbyfile[file]
543 <                        parString = "\\{"
543 >                        parString = ""
544                          parString += '\\\"' + file + '\\\"\,'
545                      pass # END if
546                  pass # END while (iterate over files in the block)
# Line 579 | Line 549 | class Cmssw(JobType):
549          if (eventsRemaining > 0 and jobCount < totalNumberOfJobs ):
550              common.logger.message("Could not run on all requested events because some blocks not hosted at allowed sites.")
551          common.logger.message(str(jobCount)+" job(s) can run on "+str(totalEventCount)+" events.\n")
552 <        
552 >
553          # screen output
554          screenOutput = "List of jobs and available destination sites:\n\n"
555  
# Line 593 | Line 563 | class Cmssw(JobType):
563                  blockCounter += 1
564                  screenOutput += "Block %5i: jobs %20s: sites: %s\n" % (blockCounter,spanRanges(jobsOfBlock[block]),','.join(self.blackWhiteListParser.checkWhiteList(self.blackWhiteListParser.checkBlackList(blockSites[block],block),block)))
565                  if len(self.blackWhiteListParser.checkWhiteList(self.blackWhiteListParser.checkBlackList(blockSites[block],block),block)) == 0:
566 <                    noSiteBlock.append( spanRanges(jobsOfBlock[block]) )
566 >                    noSiteBlock.append( spanRanges(jobsOfBlock[block]) )
567                      bloskNoSite.append( blockCounter )
568 <        
568 >
569          common.logger.message(screenOutput)
570          if len(noSiteBlock) > 0 and len(bloskNoSite) > 0:
571              msg = 'WARNING: No sites are hosting any part of data for block:\n                '
# Line 622 | Line 592 | class Cmssw(JobType):
592          """
593          common.logger.debug(5,'Splitting per events')
594  
595 <        if (self.selectEventsPerJob):
595 >        if (self.selectEventsPerJob):
596              common.logger.message('Required '+str(self.eventsPerJob)+' events per job ')
597          if (self.selectNumberOfJobs):
598              common.logger.message('Required '+str(self.theNumberOfJobs)+' jobs in total ')
# Line 636 | Line 606 | class Cmssw(JobType):
606          if (self.selectEventsPerJob):
607              if (self.selectTotalNumberEvents):
608                  self.total_number_of_jobs = int(self.total_number_of_events/self.eventsPerJob)
609 <            elif(self.selectNumberOfJobs) :  
609 >            elif(self.selectNumberOfJobs) :
610                  self.total_number_of_jobs =self.theNumberOfJobs
611 <                self.total_number_of_events =int(self.theNumberOfJobs*self.eventsPerJob)
611 >                self.total_number_of_events =int(self.theNumberOfJobs*self.eventsPerJob)
612  
613          elif (self.selectNumberOfJobs) :
614              self.total_number_of_jobs = self.theNumberOfJobs
615              self.eventsPerJob = int(self.total_number_of_events/self.total_number_of_jobs)
616 <
616 >
617          common.logger.debug(5,'N jobs  '+str(self.total_number_of_jobs))
618  
619          # is there any remainder?
# Line 659 | Line 629 | class Cmssw(JobType):
629          self.list_of_args = []
630          for i in range(self.total_number_of_jobs):
631              ## Since there is no input, any site is good
632 <           # self.jobDestination.append(["Any"])
663 <            self.jobDestination.append([""]) #must be empty to write correctly the xml
632 >            self.jobDestination.append([""]) #must be empty to write correctly the xml
633              args=[]
634              if (self.firstRun):
635 <                    ## pythia first run
667 <                #self.list_of_args.append([(str(self.firstRun)+str(i))])
635 >                ## pythia first run
636                  args.append(str(self.firstRun)+str(i))
669            else:
670                ## no first run
671                #self.list_of_args.append([str(i)])
672                args.append(str(i))
637              if (self.sourceSeed):
638                  args.append(str(self.sourceSeed)+str(i))
639                  if (self.sourceSeedVtx):
# Line 678 | Line 642 | class Cmssw(JobType):
642                  if (self.sourceSeedG4):
643                      ## + G4 random seed
644                      args.append(str(self.sourceSeedG4)+str(i))
645 <                if (self.sourceSeedMix):    
645 >                if (self.sourceSeedMix):
646                      ## + Mix random seed
647                      args.append(str(self.sourceSeedMix)+str(i))
648                  pass
649              pass
650              self.list_of_args.append(args)
651          pass
652 <            
652 >
653          # print self.list_of_args
654  
655          return
# Line 715 | Line 679 | class Cmssw(JobType):
679          return
680  
681      def split(self, jobParams):
682 <
682 >
683          common.jobDB.load()
684          #### Fabio
685          njobs = self.total_number_of_jobs
# Line 723 | Line 687 | class Cmssw(JobType):
687          # create the empty structure
688          for i in range(njobs):
689              jobParams.append("")
690 <        
690 >
691          for job in range(njobs):
692              jobParams[job] = arglist[job]
693              # print str(arglist[job])
# Line 734 | Line 698 | class Cmssw(JobType):
698  
699          common.jobDB.save()
700          return
701 <    
701 >
702      def getJobTypeArguments(self, nj, sched):
703          result = ''
704          for i in common.jobDB.arguments(nj):
705              result=result+str(i)+" "
706          return result
707 <  
707 >
708      def numberOfJobs(self):
709          # Fabio
710          return self.total_number_of_jobs
# Line 749 | Line 713 | class Cmssw(JobType):
713          """
714          Return the TarBall with lib and exe
715          """
716 <        
716 >
717          # if it exist, just return it
718          #
719          # Marco. Let's start to use relative path for Boss XML files
# Line 772 | Line 736 | class Cmssw(JobType):
736          # print "swVersion = ", swVersion
737          swReleaseTop = self.scram.getReleaseTop_()
738          #print "swReleaseTop = ", swReleaseTop
739 <        
739 >
740          ## check if working area is release top
741          if swReleaseTop == '' or swArea == swReleaseTop:
742              return
# Line 785 | Line 749 | class Cmssw(JobType):
749                  exeWithPath = self.scram.findFile_(executable)
750                  if ( not exeWithPath ):
751                      raise CrabException('User executable '+executable+' not found')
752 <    
752 >
753                  ## then check if it's private or not
754                  if exeWithPath.find(swReleaseTop) == -1:
755                      # the exe is private, so we must ship
# Line 801 | Line 765 | class Cmssw(JobType):
765                  else:
766                      # the exe is from release, we'll find it on WN
767                      pass
768 <    
768 >
769              ## Now get the libraries: only those in local working area
770              libDir = 'lib'
771              lib = swArea+'/' +libDir
772              common.logger.debug(5,"lib "+lib+" to be tarred")
773              if os.path.exists(lib):
774                  tar.add(lib,libDir)
775 <    
775 >
776              ## Now check if module dir is present
777              moduleDir = 'module'
778              module = swArea + '/' + moduleDir
# Line 834 | Line 798 | class Cmssw(JobType):
798              prodcommonPath = os.environ['CRABDIR'] + '/' + 'ProdCommon'
799              if os.path.isdir(prodcommonPath):
800                  tar.add(prodcommonPath,prodcommonDir)
801 <            #############################    
802 <        
801 >            #############################
802 >
803              common.logger.debug(5,"Files added to "+self.tgzNameWithPath+" : "+str(tar.getnames()))
804              tar.close()
805          except :
# Line 847 | Line 811 | class Cmssw(JobType):
811              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.')
812  
813          ## create tar-ball with ML stuff
814 <        self.MLtgzfile =  common.work_space.pathForTgz()+'share/MLfiles.tgz'
814 >        self.MLtgzfile =  common.work_space.pathForTgz()+'share/MLfiles.tgz'
815          try:
816              tar = tarfile.open(self.MLtgzfile, "w:gz")
817              path=os.environ['CRABDIR'] + '/python/'
# Line 857 | Line 821 | class Cmssw(JobType):
821              tar.close()
822          except :
823              raise CrabException('Could not create ML files tar-ball')
824 <        
824 >
825          return
826 <        
826 >
827      def additionalInputFileTgz(self):
828          """
829          Put all additional files into a tar ball and return its name
# Line 879 | Line 843 | class Cmssw(JobType):
843          the execution environment for the job 'nj'.
844          """
845          # Prepare JobType-independent part
846 <        txt = ''
847 <  
848 <        ## 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'
846 >        txt = ''
847 >        txt += 'echo ">>> setup environment"\n'
848 >        txt += 'if [ $middleware == LCG ]; then \n'
849          txt += self.wsSetupCMSLCGEnvironment_()
850          txt += 'elif [ $middleware == OSG ]; then\n'
851          txt += '    WORKING_DIR=`/bin/mktemp  -d $OSG_WN_TMP/cms_XXXXXXXXXXXX`\n'
852 <        txt += '    echo "Created working directory: $WORKING_DIR"\n'
894 <        txt += '    if [ ! -d $WORKING_DIR ] ;then\n'
852 >        txt += '    if [ ! $? == 0 ] ;then\n'
853          txt += '        echo "SET_CMS_ENV 10016 ==> OSG $WORKING_DIR could not be created on WN `hostname`"\n'
854 <        txt += '    echo "JOB_EXIT_STATUS = 10016"\n'
855 <        txt += '    echo "JobExitCode=10016" | tee -a $RUNTIME_AREA/$repo\n'
856 <        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'
854 >        txt += '        echo "JOB_EXIT_STATUS = 10016"\n'
855 >        txt += '        echo "JobExitCode=10016" | tee -a $RUNTIME_AREA/$repo\n'
856 >        txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
857          txt += '        exit 1\n'
858          txt += '    fi\n'
859 +        txt += '    echo ">>> Created working directory: $WORKING_DIR"\n'
860          txt += '\n'
861          txt += '    echo "Change to working directory: $WORKING_DIR"\n'
862          txt += '    cd $WORKING_DIR\n'
863 <        txt += self.wsSetupCMSOSGEnvironment_()
864 <        txt += '    echo "### Set SCRAM ARCH to ' + self.executable_arch + ' ###"\n'
865 <        txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
863 >        txt += '    echo ">>> current directory (WORKING_DIR): $WORKING_DIR"\n'
864 >        txt += self.wsSetupCMSOSGEnvironment_()
865 >        #txt += '    echo "### Set SCRAM ARCH to ' + self.executable_arch + ' ###"\n'
866 >        #txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
867          txt += 'fi\n'
868  
869          # Prepare JobType-specific part
870          scram = self.scram.commandName()
871          txt += '\n\n'
872 <        txt += 'echo "### SPECIFIC JOB SETUP ENVIRONMENT ###"\n'
872 >        txt += 'echo ">>> specific cmssw setup environment:"\n'
873 >        txt += 'echo "CMSSW_VERSION =  '+self.version+'"\n'
874          txt += scram+' project CMSSW '+self.version+'\n'
875          txt += 'status=$?\n'
876          txt += 'if [ $status != 0 ] ; then\n'
877 <        txt += '   echo "SET_EXE_ENV 10034 ==>ERROR CMSSW '+self.version+' not found on `hostname`" \n'
878 <        txt += '   echo "JOB_EXIT_STATUS = 10034"\n'
879 <        txt += '   echo "JobExitCode=10034" | tee -a $RUNTIME_AREA/$repo\n'
880 <        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
877 >        txt += '    echo "SET_EXE_ENV 10034 ==>ERROR CMSSW '+self.version+' not found on `hostname`" \n'
878 >        txt += '    echo "JOB_EXIT_STATUS = 10034"\n'
879 >        txt += '    echo "JobExitCode=10034" | tee -a $RUNTIME_AREA/$repo\n'
880 >        txt += '    dumpStatus $RUNTIME_AREA/$repo\n'
881          txt += '    if [ $middleware == OSG ]; then \n'
928        txt += '        echo "Remove working directory: $WORKING_DIR"\n'
882          txt += '        cd $RUNTIME_AREA\n'
883 +        txt += '        echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
884 +        txt += '        echo ">>> Remove working directory: $WORKING_DIR"\n'
885          txt += '        /bin/rm -rf $WORKING_DIR\n'
886          txt += '        if [ -d $WORKING_DIR ] ;then\n'
887          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'
888          txt += '            echo "JOB_EXIT_STATUS = 10018"\n'
889          txt += '            echo "JobExitCode=10018" | tee -a $RUNTIME_AREA/$repo\n'
890          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'
891          txt += '        fi\n'
892          txt += '    fi \n'
893 <        txt += '   exit 1 \n'
893 >        txt += '    exit 1 \n'
894          txt += 'fi \n'
943        txt += 'echo "CMSSW_VERSION =  '+self.version+'"\n'
895          txt += 'cd '+self.version+'\n'
896          ########## FEDE FOR DBS2 ######################
897          txt += 'SOFTWARE_DIR=`pwd`\n'
898 <        txt += 'echo SOFTWARE_DIR=$SOFTWARE_DIR \n'
898 >        txt += 'echo ">>> current directory (SOFTWARE_DIR): $SOFTWARE_DIR" \n'
899          ###############################################
900          ### needed grep for bug in scramv1 ###
901          txt += scram+' runtime -sh\n'
# Line 955 | Line 906 | class Cmssw(JobType):
906          txt += "\n"
907          txt += "## number of arguments (first argument always jobnumber)\n"
908          txt += "\n"
958 #        txt += "narg=$#\n"
909          txt += "if [ $nargs -lt 2 ]\n"
910          txt += "then\n"
911          txt += "    echo 'SET_EXE_ENV 1 ==> ERROR Too few arguments' +$nargs+ \n"
912          txt += '    echo "JOB_EXIT_STATUS = 50113"\n'
913          txt += '    echo "JobExitCode=50113" | tee -a $RUNTIME_AREA/$repo\n'
914          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
915          txt += '    if [ $middleware == OSG ]; then \n'
970        txt += '        echo "Remove working directory: $WORKING_DIR"\n'
916          txt += '        cd $RUNTIME_AREA\n'
917 +        txt += '        echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
918 +        txt += '        echo ">>> Remove working directory: $WORKING_DIR"\n'
919          txt += '        /bin/rm -rf $WORKING_DIR\n'
920          txt += '        if [ -d $WORKING_DIR ] ;then\n'
921          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'
922          txt += '            echo "JOB_EXIT_STATUS = 50114"\n'
923          txt += '            echo "JobExitCode=50114" | tee -a $RUNTIME_AREA/$repo\n'
924          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'
925          txt += '        fi\n'
926          txt += '    fi \n'
927          txt += "    exit 1\n"
# Line 987 | Line 931 | class Cmssw(JobType):
931          # Prepare job-specific part
932          job = common.job_list[nj]
933          ### FEDE FOR DBS OUTPUT PUBLICATION
934 <        if (self.datasetPath):
934 >        if (self.datasetPath):
935              txt += '\n'
936              txt += 'DatasetPath='+self.datasetPath+'\n'
937  
938              datasetpath_split = self.datasetPath.split("/")
939 <            
939 >
940              txt += 'PrimaryDataset='+datasetpath_split[1]+'\n'
941              txt += 'DataTier='+datasetpath_split[2]+'\n'
998            #txt += 'ProcessedDataset='+datasetpath_split[3]+'\n'
942              txt += 'ApplicationFamily=cmsRun\n'
943  
944          else:
945              txt += 'DatasetPath=MCDataTier\n'
946              txt += 'PrimaryDataset=null\n'
947              txt += 'DataTier=null\n'
1005            #txt += 'ProcessedDataset=null\n'
948              txt += 'ApplicationFamily=MCDataTier\n'
949          if self.pset != None: #CarlosDaniele
950              pset = os.path.basename(job.configFilename())
951              txt += '\n'
952              txt += 'cp  $RUNTIME_AREA/'+pset+' .\n'
953              if (self.datasetPath): # standard job
1012                #txt += 'InputFiles=$2\n'
954                  txt += 'InputFiles=${args[1]}\n'
955                  txt += 'MaxEvents=${args[2]}\n'
956                  txt += 'SkipEvents=${args[3]}\n'
957                  txt += 'echo "Inputfiles:<$InputFiles>"\n'
958 <                txt += 'sed "s#{\'INPUT\'}#$InputFiles#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
958 >                txt += 'sed "s#\'INPUTFILE\'#$InputFiles#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
959                  txt += 'echo "MaxEvents:<$MaxEvents>"\n'
960 <                txt += 'sed "s#INPUTMAXEVENTS#$MaxEvents#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
960 >                txt += 'sed "s#int32 input = 0#int32 input = $MaxEvents#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
961                  txt += 'echo "SkipEvents:<$SkipEvents>"\n'
962 <                txt += 'sed "s#INPUTSKIPEVENTS#$SkipEvents#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
962 >                txt += 'sed "s#uint32 skipEvents = 0#uint32 skipEvents = $SkipEvents#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
963              else:  # pythia like job
964                  seedIndex=1
965                  if (self.firstRun):
966                      txt += 'FirstRun=${args['+str(seedIndex)+']}\n'
967                      txt += 'echo "FirstRun: <$FirstRun>"\n'
968 <                    txt += 'sed "s#\<INPUTFIRSTRUN\>#$FirstRun#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
968 >                    txt += 'sed "s#uint32 firstRun = 0#uint32 firstRun = $FirstRun#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
969                      seedIndex=seedIndex+1
970  
971                  if (self.sourceSeed):
972                      txt += 'Seed=${args['+str(seedIndex)+']}\n'
973 <                    txt += 'sed "s#\<INPUT\>#$Seed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
973 >                    txt += 'sed "s#uint32 sourceSeed = 0#uint32 sourceSeed = $Seed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
974                      seedIndex=seedIndex+1
975                      ## the following seeds are not always present
976                      if (self.sourceSeedVtx):
977                          txt += 'VtxSeed=${args['+str(seedIndex)+']}\n'
978                          txt += 'echo "VtxSeed: <$VtxSeed>"\n'
979 <                        txt += 'sed "s#\<INPUTVTX\>#$VtxSeed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
979 >                        txt += 'sed "s#uint32 VtxSmeared = 0#uint32 VtxSmeared = $VtxSeed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
980                          seedIndex += 1
981                      if (self.sourceSeedG4):
982                          txt += 'G4Seed=${args['+str(seedIndex)+']}\n'
983                          txt += 'echo "G4Seed: <$G4Seed>"\n'
984 <                        txt += 'sed "s#\<INPUTG4\>#$G4Seed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
984 >                        txt += 'sed "s#uint32 g4SimHits = 0#uint32 g4SimHits = $G4Seed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
985                          seedIndex += 1
986                      if (self.sourceSeedMix):
987                          txt += 'mixSeed=${args['+str(seedIndex)+']}\n'
988                          txt += 'echo "MixSeed: <$mixSeed>"\n'
989 <                        txt += 'sed "s#\<INPUTMIX\>#$mixSeed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
989 >                        txt += 'sed "s#uint32 mix = 0#uint32 mix = $mixSeed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
990                          seedIndex += 1
991                      pass
992                  pass
# Line 1055 | Line 996 | class Cmssw(JobType):
996              txt += 'if [ -e $RUNTIME_AREA/'+self.additional_tgz_name+' ] ; then\n'
997              txt += '  tar xzvf $RUNTIME_AREA/'+self.additional_tgz_name+'\n'
998              txt += 'fi\n'
999 <            pass
999 >            pass
1000  
1001          if self.pset != None: #CarlosDaniele
1061            txt += 'echo "### END JOB SETUP ENVIRONMENT ###"\n\n'
1062        
1002              txt += '\n'
1003              txt += 'echo "***** cat pset.cfg *********"\n'
1004              txt += 'cat pset.cfg\n'
# Line 1068 | Line 1007 | class Cmssw(JobType):
1007              ### FEDE FOR DBS OUTPUT PUBLICATION
1008              txt += 'PSETHASH=`EdmConfigHash < pset.cfg` \n'
1009              txt += 'echo "PSETHASH = $PSETHASH" \n'
1010 <            ##############
1010 >            ##############
1011              txt += '\n'
1073            # txt += 'echo "***** cat pset1.cfg *********"\n'
1074            # txt += 'cat pset1.cfg\n'
1075            # txt += 'echo "****** end pset1.cfg ********"\n'
1012          return txt
1013  
1014      def wsBuildExe(self, nj=0):
# Line 1084 | Line 1020 | class Cmssw(JobType):
1020          txt = ""
1021  
1022          if os.path.isfile(self.tgzNameWithPath):
1023 <            txt += 'echo "tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'"\n'
1023 >            txt += 'echo ">>> tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+' :" \n'
1024              txt += 'tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'\n'
1025              txt += 'untar_status=$? \n'
1026              txt += 'if [ $untar_status -ne 0 ]; then \n'
# Line 1092 | Line 1028 | class Cmssw(JobType):
1028              txt += '   echo "JOB_EXIT_STATUS = $untar_status" \n'
1029              txt += '   echo "JobExitCode=$untar_status" | tee -a $RUNTIME_AREA/$repo\n'
1030              txt += '   if [ $middleware == OSG ]; then \n'
1095            txt += '       echo "Remove working directory: $WORKING_DIR"\n'
1031              txt += '       cd $RUNTIME_AREA\n'
1032 +            txt += '        echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
1033 +            txt += '        echo ">>> Remove working directory: $WORKING_DIR"\n'
1034              txt += '       /bin/rm -rf $WORKING_DIR\n'
1035              txt += '       if [ -d $WORKING_DIR ] ;then\n'
1036              txt += '           echo "SET_EXE 50999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after Untarring .tgz file failed"\n'
1037              txt += '           echo "JOB_EXIT_STATUS = 50999"\n'
1038              txt += '           echo "JobExitCode=50999" | tee -a $RUNTIME_AREA/$repo\n'
1039              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'
1040              txt += '       fi\n'
1041              txt += '   fi \n'
1042              txt += '   \n'
# Line 1111 | Line 1045 | class Cmssw(JobType):
1045              txt += '   echo "Successful untar" \n'
1046              txt += 'fi \n'
1047              txt += '\n'
1048 <            txt += 'echo "Include ProdAgentApi and PRODCOMMON in PYTHONPATH"\n'
1048 >            txt += 'echo ">>> Include ProdAgentApi and PRODCOMMON in PYTHONPATH:"\n'
1049              txt += 'if [ -z "$PYTHONPATH" ]; then\n'
1050              #### FEDE FOR DBS OUTPUT PUBLICATION
1051              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'
1052              txt += 'else\n'
1053              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'
1054              txt += 'echo "PYTHONPATH=$PYTHONPATH"\n'
1055 <            ###################  
1055 >            ###################
1056              txt += 'fi\n'
1057              txt += '\n'
1058  
1059              pass
1060 <        
1060 >
1061          return txt
1062  
1063      def modifySteeringCards(self, nj):
1064          """
1065 <        modify the card provided by the user,
1065 >        modify the card provided by the user,
1066          writing a new card into share dir
1067          """
1068 <        
1068 >
1069      def executableName(self):
1070          if self.scriptExe: #CarlosDaniele
1071              return "sh "
# Line 1146 | Line 1076 | class Cmssw(JobType):
1076          if self.scriptExe:#CarlosDaniele
1077              return   self.scriptExe + " $NJob"
1078          else:
1079 <            # if >= CMSSW_1_5_X, add -e
1079 >            # if >= CMSSW_1_5_X, add -j crab_fjr.xml
1080              version_array = self.scram.getSWVersion().split('_')
1081              major = 0
1082              minor = 0
# Line 1154 | Line 1084 | class Cmssw(JobType):
1084                  major = int(version_array[1])
1085                  minor = int(version_array[2])
1086              except:
1087 <                msg = "Cannot parse CMSSW version string: " + "_".join(version_array) + " for major and minor release number!"  
1087 >                msg = "Cannot parse CMSSW version string: " + "_".join(version_array) + " for major and minor release number!"
1088                  raise CrabException(msg)
1089              if major >= 1 and minor >= 5 :
1090 <                return " -e -p pset.cfg"
1090 >                return " -j " + self.fjrFileName + " -p pset.cfg"
1091              else:
1092                  return " -p pset.cfg"
1093  
# Line 1189 | Line 1119 | class Cmssw(JobType):
1119  
1120          ## User Declared output files
1121          for out in (self.output_file+self.output_file_sandbox):
1122 <            n_out = nj + 1
1122 >            n_out = nj + 1
1123              out_box.append(self.numberFile_(out,str(n_out)))
1124          return out_box
1125  
# Line 1205 | Line 1135 | class Cmssw(JobType):
1135          """
1136  
1137          txt = '\n'
1138 <        txt += '# directory content\n'
1138 >        txt += 'echo" >>> directory content:"\n'
1139          txt += 'ls \n'
1140 +        txt = '\n'
1141  
1142          txt += 'output_exit_status=0\n'
1143 <        
1143 >
1144          for fileWithSuffix in (self.output_file_sandbox):
1145              output_file_num = self.numberFile_(fileWithSuffix, '$NJob')
1146              txt += '\n'
# Line 1226 | Line 1157 | class Cmssw(JobType):
1157                  txt += '        echo "Processing of job output failed" > $RUNTIME_AREA/'+output_file_num+'\n'
1158                  txt += '    fi \n'
1159              txt += 'fi\n'
1160 <        
1160 >
1161          for fileWithSuffix in (self.output_file):
1162              output_file_num = self.numberFile_(fileWithSuffix, '$NJob')
1163              txt += '\n'
# Line 1248 | Line 1179 | class Cmssw(JobType):
1179          file_list = []
1180          for fileWithSuffix in (self.output_file):
1181               file_list.append(self.numberFile_(fileWithSuffix, '$NJob'))
1182 <            
1182 >
1183          txt += 'file_list="'+string.join(file_list,' ')+'"\n'
1184          txt += 'cd $RUNTIME_AREA\n'
1185 +        txt += 'echo ">>> current directory (RUNTIME_AREA):  $RUNTIME_AREA"\n'
1186          return txt
1187  
1188      def numberFile_(self, file, txt):
# Line 1268 | Line 1200 | class Cmssw(JobType):
1200              result = name + '_' + txt + "." + ext
1201          else:
1202              result = name + '_' + txt
1203 <        
1203 >
1204          return result
1205  
1206      def getRequirements(self, nj=[]):
1207          """
1208 <        return job requirements to add to jdl files
1208 >        return job requirements to add to jdl files
1209          """
1210          req = ''
1211          if self.version:
# Line 1295 | Line 1227 | class Cmssw(JobType):
1227          """ return the config filename """
1228          return self.name()+'.cfg'
1229  
1298    ### OLI_DANIELE
1230      def wsSetupCMSOSGEnvironment_(self):
1231          """
1232          Returns part of a job script which is prepares
1233          the execution environment and which is common for all CMS jobs.
1234          """
1235 <        txt = '\n'
1236 <        txt += '   echo "### SETUP CMS OSG  ENVIRONMENT ###"\n'
1237 <        txt += '   if [ -f $GRID3_APP_DIR/cmssoft/cmsset_default.sh ] ;then\n'
1238 <        txt += '      # Use $GRID3_APP_DIR/cmssoft/cmsset_default.sh to setup cms software\n'
1239 <        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'
1235 >        txt = '    echo ">>> setup CMS OSG environment:"\n'
1236 >        txt += '    echo "set SCRAM ARCH to ' + self.executable_arch + '"\n'
1237 >        txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
1238 >        txt += '    echo "SCRAM_ARCH = $SCRAM_ARCH"\n'
1239 >        txt += '    if [ -f $OSG_APP/cmssoft/cms/cmsset_default.sh ] ;then\n'
1240          txt += '      # Use $OSG_APP/cmssoft/cms/cmsset_default.sh to setup cms software\n'
1241 <        txt += '       export SCRAM_ARCH='+self.executable_arch+'\n'
1242 <        txt += '       source $OSG_APP/cmssoft/cms/cmsset_default.sh '+self.version+'\n'
1243 <        txt += '   else\n'
1244 <        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'
1245 <        txt += '       echo "JOB_EXIT_STATUS = 10020"\n'
1246 <        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'
1241 >        txt += '        source $OSG_APP/cmssoft/cms/cmsset_default.sh '+self.version+'\n'
1242 >        txt += '    else\n'
1243 >        txt += '        echo "SET_CMS_ENV 10020 ==> ERROR $OSG_APP/cmssoft/cms/cmsset_default.sh file not found"\n'
1244 >        txt += '        echo "JOB_EXIT_STATUS = 10020"\n'
1245 >        txt += '        echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
1246 >        txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
1247          txt += '\n'
1248 <        txt += '       echo "Remove working directory: $WORKING_DIR"\n'
1249 <        txt += '       cd $RUNTIME_AREA\n'
1250 <        txt += '       /bin/rm -rf $WORKING_DIR\n'
1251 <        txt += '       if [ -d $WORKING_DIR ] ;then\n'
1252 <        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'
1253 <        txt += '           echo "JOB_EXIT_STATUS = 10017"\n'
1254 <        txt += '           echo "JobExitCode=10017" | tee -a $RUNTIME_AREA/$repo\n'
1255 <        txt += '           dumpStatus $RUNTIME_AREA/$repo\n'
1256 <        txt += '           rm -f $RUNTIME_AREA/$repo \n'
1257 <        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'
1248 >        txt += '        cd $RUNTIME_AREA\n'
1249 >        txt += '        echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
1250 >        txt += '        echo ">>> Remove working directory: $WORKING_DIR"\n'
1251 >        txt += '        /bin/rm -rf $WORKING_DIR\n'
1252 >        txt += '        if [ -d $WORKING_DIR ] ;then\n'
1253 >        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'
1254 >        txt += '            echo "JOB_EXIT_STATUS = 10017"\n'
1255 >        txt += '            echo "JobExitCode=10017" | tee -a $RUNTIME_AREA/$repo\n'
1256 >        txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
1257 >        txt += '        fi\n'
1258          txt += '\n'
1259 <        txt += '       exit 1\n'
1260 <        txt += '   fi\n'
1259 >        txt += '        exit 1\n'
1260 >        txt += '    fi\n'
1261          txt += '\n'
1262 <        txt += '   echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'
1263 <        txt += '   echo " END SETUP CMS OSG  ENVIRONMENT "\n'
1262 >        txt += '    echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'
1263 >        txt += '    echo "SCRAM_ARCH = $SCRAM_ARCH"\n'
1264  
1265          return txt
1266 <
1266 >
1267      ### OLI_DANIELE
1268      def wsSetupCMSLCGEnvironment_(self):
1269          """
1270          Returns part of a job script which is prepares
1271          the execution environment and which is common for all CMS jobs.
1272          """
1273 <        txt  = '   \n'
1274 <        txt += '   echo " ### SETUP CMS LCG  ENVIRONMENT ### "\n'
1275 <        txt += '   if [ ! $VO_CMS_SW_DIR ] ;then\n'
1276 <        txt += '       echo "SET_CMS_ENV 10031 ==> ERROR CMS software dir not found on WN `hostname`"\n'
1277 <        txt += '       echo "JOB_EXIT_STATUS = 10031" \n'
1278 <        txt += '       echo "JobExitCode=10031" | tee -a $RUNTIME_AREA/$repo\n'
1279 <        txt += '       dumpStatus $RUNTIME_AREA/$repo\n'
1280 <        txt += '       rm -f $RUNTIME_AREA/$repo \n'
1281 <        txt += '       echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1282 <        txt += '       echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1283 <        txt += '       exit 1\n'
1284 <        txt += '   else\n'
1285 <        txt += '       echo "Sourcing environment... "\n'
1286 <        txt += '       if [ ! -s $VO_CMS_SW_DIR/cmsset_default.sh ] ;then\n'
1287 <        txt += '           echo "SET_CMS_ENV 10020 ==> ERROR cmsset_default.sh file not found into dir $VO_CMS_SW_DIR"\n'
1288 <        txt += '           echo "JOB_EXIT_STATUS = 10020"\n'
1289 <        txt += '           echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
1290 <        txt += '           dumpStatus $RUNTIME_AREA/$repo\n'
1291 <        txt += '           rm -f $RUNTIME_AREA/$repo \n'
1292 <        txt += '           echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1293 <        txt += '           echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1294 <        txt += '           exit 1\n'
1295 <        txt += '       fi\n'
1296 <        txt += '       echo "sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
1297 <        txt += '       source $VO_CMS_SW_DIR/cmsset_default.sh\n'
1298 <        txt += '       result=$?\n'
1299 <        txt += '       if [ $result -ne 0 ]; then\n'
1300 <        txt += '           echo "SET_CMS_ENV 10032 ==> ERROR problem sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
1301 <        txt += '           echo "JOB_EXIT_STATUS = 10032"\n'
1302 <        txt += '           echo "JobExitCode=10032" | tee -a $RUNTIME_AREA/$repo\n'
1303 <        txt += '           dumpStatus $RUNTIME_AREA/$repo\n'
1304 <        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'
1273 >        txt = '    echo ">>> setup CMS LCG environment:"\n'
1274 >        txt += '    echo "set SCRAM ARCH and BUILD_ARCH to ' + self.executable_arch + ' ###"\n'
1275 >        txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
1276 >        txt += '    export BUILD_ARCH='+self.executable_arch+'\n'
1277 >        txt += '    if [ ! $VO_CMS_SW_DIR ] ;then\n'
1278 >        txt += '        echo "SET_CMS_ENV 10031 ==> ERROR CMS software dir not found on WN `hostname`"\n'
1279 >        txt += '        echo "JOB_EXIT_STATUS = 10031" \n'
1280 >        txt += '        echo "JobExitCode=10031" | tee -a $RUNTIME_AREA/$repo\n'
1281 >        txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
1282 >        txt += '        exit 1\n'
1283 >        txt += '    else\n'
1284 >        txt += '        echo "Sourcing environment... "\n'
1285 >        txt += '        if [ ! -s $VO_CMS_SW_DIR/cmsset_default.sh ] ;then\n'
1286 >        txt += '            echo "SET_CMS_ENV 10020 ==> ERROR cmsset_default.sh file not found into dir $VO_CMS_SW_DIR"\n'
1287 >        txt += '            echo "JOB_EXIT_STATUS = 10020"\n'
1288 >        txt += '            echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
1289 >        txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
1290 >        txt += '            exit 1\n'
1291 >        txt += '        fi\n'
1292 >        txt += '        echo "sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
1293 >        txt += '        source $VO_CMS_SW_DIR/cmsset_default.sh\n'
1294 >        txt += '        result=$?\n'
1295 >        txt += '        if [ $result -ne 0 ]; then\n'
1296 >        txt += '            echo "SET_CMS_ENV 10032 ==> ERROR problem sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
1297 >        txt += '            echo "JOB_EXIT_STATUS = 10032"\n'
1298 >        txt += '            echo "JobExitCode=10032" | tee -a $RUNTIME_AREA/$repo\n'
1299 >        txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
1300 >        txt += '            exit 1\n'
1301 >        txt += '        fi\n'
1302 >        txt += '    fi\n'
1303 >        txt += '    \n'
1304 >        txt += '    echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'
1305          return txt
1306  
1307 <    ### FEDE FOR DBS OUTPUT PUBLICATION
1307 >    ### FEDE FOR DBS OUTPUT PUBLICATION
1308      def modifyReport(self, nj):
1309          """
1310 <        insert the part of the script that modifies the FrameworkJob Report
1310 >        insert the part of the script that modifies the FrameworkJob Report
1311          """
1312  
1313 <        txt = ''
1313 >        txt = ''
1314          try:
1315 <            publish_data = int(self.cfg_params['USER.publish_data'])          
1315 >            publish_data = int(self.cfg_params['USER.publish_data'])
1316          except KeyError:
1317              publish_data = 0
1318 <        if (publish_data == 1):  
1319 <            txt += 'echo "Modify Job Report" \n'
1406 <            #txt += 'chmod a+x $RUNTIME_AREA/'+self.version+'/ProdAgentApi/FwkJobRep/ModifyJobReport.py\n'
1318 >        if (publish_data == 1):
1319 >            txt += 'echo ">>> Modify Job Report:" \n'
1320              ################ FEDE FOR DBS2 #############################################
1321              txt += 'chmod a+x $SOFTWARE_DIR/ProdAgentApi/FwkJobRep/ModifyJobReport.py\n'
1322              #############################################################################
1410            #try:
1411            #    publish_data = int(self.cfg_params['USER.publish_data'])          
1412            #except KeyError:
1413            #    publish_data = 0
1323  
1324              txt += 'if [ -z "$SE" ]; then\n'
1325              txt += '    SE="" \n'
1326 <            txt += 'fi \n'
1326 >            txt += 'fi \n'
1327              txt += 'if [ -z "$SE_PATH" ]; then\n'
1328              txt += '    SE_PATH="" \n'
1329 <            txt += 'fi \n'
1330 <            txt += 'echo "SE = $SE"\n'
1329 >            txt += 'fi \n'
1330 >            txt += 'echo "SE = $SE"\n'
1331              txt += 'echo "SE_PATH = $SE_PATH"\n'
1332  
1424        #if (publish_data == 1):  
1425            #processedDataset = self.cfg_params['USER.processed_datasetname']
1333              processedDataset = self.cfg_params['USER.publish_data_name']
1334              txt += 'ProcessedDataset='+processedDataset+'\n'
1335              #### LFN=/store/user/<user>/processedDataset_PSETHASH
1336              txt += 'if [ "$SE_PATH" == "" ]; then\n'
1337              #### FEDE: added slash in LFN ##############
1338              txt += '    FOR_LFN=/copy_problems/ \n'
1339 <            txt += 'else \n'
1339 >            txt += 'else \n'
1340              txt += '    tmp=`echo $SE_PATH | awk -F \'store\' \'{print$2}\'` \n'
1341              #####  FEDE TO BE CHANGED, BECAUSE STORE IS HARDCODED!!!! ########
1342              txt += '    FOR_LFN=/store$tmp \n'
1343 <            txt += 'fi \n'
1343 >            txt += 'fi \n'
1344              txt += 'echo "ProcessedDataset = $ProcessedDataset"\n'
1345              txt += 'echo "FOR_LFN = $FOR_LFN" \n'
1346              txt += 'echo "CMSSW_VERSION = $CMSSW_VERSION"\n\n'
1347 <            #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'
1348 <            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'
1347 >            #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'
1348 >            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'
1349              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'
1350              #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'
1351 <      
1351 >
1352              txt += 'modifyReport_result=$?\n'
1353              txt += 'echo modifyReport_result = $modifyReport_result\n'
1354              txt += 'if [ $modifyReport_result -ne 0 ]; then\n'
# Line 1452 | Line 1359 | class Cmssw(JobType):
1359              txt += 'fi\n'
1360          else:
1361              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'
1362          return txt
1363  
1364      def cleanEnv(self):
1365 <        ### OLI_DANIELE
1366 <        txt = ''
1465 <        txt += 'if [ $middleware == OSG ]; then\n'  
1365 >        txt = ''
1366 >        txt += 'if [ $middleware == OSG ]; then\n'
1367          txt += '    cd $RUNTIME_AREA\n'
1368 <        txt += '    echo "Remove working directory: $WORKING_DIR"\n'
1368 >        txt += '    echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
1369 >        txt += '    echo ">>> Remove working directory: $WORKING_DIR"\n'
1370          txt += '    /bin/rm -rf $WORKING_DIR\n'
1371          txt += '    if [ -d $WORKING_DIR ] ;then\n'
1372 <        txt += '              echo "SET_EXE 60999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after cleanup of WN"\n'
1373 <        txt += '              echo "JOB_EXIT_STATUS = 60999"\n'
1374 <        txt += '              echo "JobExitCode=60999" | tee -a $RUNTIME_AREA/$repo\n'
1375 <        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'
1372 >        txt += '        echo "SET_EXE 60999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after cleanup of WN"\n'
1373 >        txt += '        echo "JOB_EXIT_STATUS = 60999"\n'
1374 >        txt += '        echo "JobExitCode=60999" | tee -a $RUNTIME_AREA/$repo\n'
1375 >        txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
1376          txt += '    fi\n'
1377          txt += 'fi\n'
1378          txt += '\n'
# Line 1487 | Line 1386 | class Cmssw(JobType):
1386  
1387      def setTaskid_(self):
1388          self._taskId = self.cfg_params['taskId']
1389 <        
1389 >
1390      def getTaskid(self):
1391          return self._taskId
1392  
# Line 1505 | Line 1404 | class Cmssw(JobType):
1404          """
1405          check the dimension of the output files
1406          """
1407 <        txt = 'echo "*****************************************"\n'
1509 <        txt += 'echo "** Starting output sandbox limit check **"\n'
1510 <        txt += 'echo "*****************************************"\n'
1407 >        txt += 'echo ">>> Starting output sandbox limit check :"\n'
1408          allOutFiles = ""
1409          listOutFiles = []
1410          for fileOut in (self.output_file+self.output_file_sandbox):
# Line 1562 | Line 1459 | class Cmssw(JobType):
1459          txt += '        fi\n'
1460          txt += '    done\n'
1461          txt += '    echo "Dimension calculated: $tot"; echo "First file to exclude: $file";\n'
1462 <        txt += '    flag=0;\n'    
1462 >        txt += '    flag=0;\n'
1463          txt += '    for filess in '+str(allOutFiles)+' ; do\n'
1464          txt += '        if [ $fileLast = $filess ]; then\n'
1465          txt += '            flag=1;\n'
# Line 1578 | Line 1475 | class Cmssw(JobType):
1475          txt += 'else'
1476          txt += '    echo "Total Output dimension $sum is fine.";\n'
1477          txt += 'fi\n'
1478 <        txt += 'echo "*****************************************"\n'
1582 <        txt += 'echo "*** Ending output sandbox limit check ***"\n'
1583 <        txt += 'echo "*****************************************"\n'
1478 >        txt += 'echo "Ending output sandbox limit check"\n'
1479          return txt

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines