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.128 by fanzago, Thu Oct 11 16:23:44 2007 UTC vs.
Revision 1.152 by fanzago, Wed Jan 9 16:05:10 2008 UTC

# Line 13 | Line 13 | class Cmssw(JobType):
13          JobType.__init__(self, 'CMSSW')
14          common.logger.debug(3,'CMSSW::__init__')
15  
16 +        self.argsList = []
17 +
18          self._params = {}
19          self.cfg_params = cfg_params
18
20          # init BlackWhiteListParser
21          self.blackWhiteListParser = BlackWhiteListParser(cfg_params)
22  
# Line 28 | Line 29 | class Cmssw(JobType):
29          self.ncjobs = ncjobs
30  
31          log = common.logger
32 <        
32 >
33          self.scram = Scram.Scram(cfg_params)
34          self.additional_inbox_files = []
35          self.scriptExe = ''
# Line 37 | Line 38 | class Cmssw(JobType):
38          self.tgz_name = 'default.tgz'
39          self.additional_tgz_name = 'additional.tgz'
40          self.scriptName = 'CMSSW.sh'
41 <        self.pset = ''      #scrip use case Da  
41 >        self.pset = ''      #scrip use case Da
42          self.datasetPath = '' #scrip use case Da
43  
44          # set FJR file name
45          self.fjrFileName = 'crab_fjr.xml'
46  
47          self.version = self.scram.getSWVersion()
48 <        
48 >
49          #
50          # Try to block creation in case of arch/version mismatch
51          #
# Line 52 | Line 53 | class Cmssw(JobType):
53          a = string.split(self.version, "_")
54  
55          if int(a[1]) == 1 and (int(a[2]) < 5 and self.executable_arch.find('slc4') == 0):
56 <            msg = "Error: CMS does not support %s with %s architecture"%(self.version, self.executable_arch)
57 <            raise CrabException(msg)
56 >            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)
57 >            common.logger.message(msg)
58          if int(a[1]) == 1 and (int(a[2]) >= 5 and self.executable_arch.find('slc3') == 0):
59              msg = "Error: CMS does not support %s with %s architecture"%(self.version, self.executable_arch)
60              raise CrabException(msg)
61 <        
61 >
62          common.taskDB.setDict('codeVersion',self.version)
63          self.setParam_('application', self.version)
64  
65          ### collect Data cards
66  
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            
67          try:
68              tmp =  cfg_params['CMSSW.datasetpath']
69              log.debug(6, "CMSSW::CMSSW(): datasetPath = "+tmp)
# Line 79 | Line 74 | class Cmssw(JobType):
74                  self.datasetPath = tmp
75                  self.selectNoInput = 0
76          except KeyError:
77 <            msg = "Error: datasetpath not defined "  
77 >            msg = "Error: datasetpath not defined "
78              raise CrabException(msg)
79  
80          # ML monitoring
# Line 92 | Line 87 | class Cmssw(JobType):
87                  datasetpath_split = self.datasetPath.split("/")
88                  # standard style
89                  self.setParam_('datasetFull', self.datasetPath)
90 <                if self.use_dbs_1 == 1 :
91 <                    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])
90 >                self.setParam_('dataset', datasetpath_split[1])
91 >                self.setParam_('owner', datasetpath_split[2])
92              except:
93                  self.setParam_('dataset', self.datasetPath)
94                  self.setParam_('owner', self.datasetPath)
95 <                
96 <        self.setTaskid_()
106 <        self.setParam_('taskId', self.cfg_params['taskId'])
95 >
96 >        self.setParam_('taskId', common.taskDB.dict('taskId'))
97  
98          self.dataTiers = []
99  
# 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 +        # Copy/return
269 +
270 +        try:
271 +            self.copy_data = int(cfg_params['USER.copy_data'])
272 +        except KeyError:
273 +            self.copy_data = 0
274 +        try:
275 +            self.return_data = int(cfg_params['USER.return_data'])
276 +        except KeyError:
277 +            self.return_data = 0
278 +
279          #DBSDLS-start
280 <        ## Initialize the variables that are extracted from DBS/DLS and needed in other places of the code
280 >        ## Initialize the variables that are extracted from DBS/DLS and needed in other places of the code
281          self.maxEvents=0  # max events available   ( --> check the requested nb. of evts in Creator.py)
282          self.DBSPaths={}  # all dbs paths requested ( --> input to the site local discovery script)
283          self.jobDestination=[]  # Site destination(s) for each job (list of lists)
# Line 289 | Line 286 | class Cmssw(JobType):
286          blockSites = {}
287          if self.datasetPath:
288              blockSites = self.DataDiscoveryAndLocation(cfg_params)
289 <        #DBSDLS-end          
289 >        #DBSDLS-end
290  
291          self.tgzNameWithPath = self.getTarBall(self.executable)
292 <    
292 >
293          ## Select Splitting
294 <        if self.selectNoInput:
294 >        if self.selectNoInput:
295              if self.pset == None: #CarlosDaniele
296                  self.jobSplittingForScript()
297              else:
# Line 307 | Line 304 | class Cmssw(JobType):
304              try:
305                  if (self.datasetPath): # standard job
306                      # allow to processa a fraction of events in a file
307 <                    PsetEdit.inputModule("INPUT")
308 <                    PsetEdit.maxEvent("INPUTMAXEVENTS")
309 <                    PsetEdit.skipEvent("INPUTSKIPEVENTS")
307 >                    PsetEdit.inputModule("INPUTFILE")
308 >                    PsetEdit.maxEvent(0)
309 >                    PsetEdit.skipEvent(0)
310                  else:  # pythia like job
311                      PsetEdit.maxEvent(self.eventsPerJob)
312                      if (self.firstRun):
313 <                        PsetEdit.pythiaFirstRun("INPUTFIRSTRUN")  #First Run
313 >                        PsetEdit.pythiaFirstRun(0)  #First Run
314                      if (self.sourceSeed) :
315 <                        PsetEdit.pythiaSeed("INPUT")
315 >                        PsetEdit.pythiaSeed(0)
316                          if (self.sourceSeedVtx) :
317 <                            PsetEdit.vtxSeed("INPUTVTX")
317 >                            PsetEdit.vtxSeed(0)
318                          if (self.sourceSeedG4) :
319 <                            PsetEdit.g4Seed("INPUTG4")
319 >                            PsetEdit.g4Seed(0)
320                          if (self.sourceSeedMix) :
321 <                            PsetEdit.mixSeed("INPUTMIX")
321 >                            PsetEdit.mixSeed(0)
322                  # add FrameworkJobReport to parameter-set
323                  PsetEdit.addCrabFJR(self.fjrFileName)
324                  PsetEdit.psetWriter(self.configFilename())
# Line 332 | Line 329 | class Cmssw(JobType):
329      def DataDiscoveryAndLocation(self, cfg_params):
330  
331          import DataDiscovery
335        import DataDiscovery_DBS2
332          import DataLocation
333          common.logger.debug(10,"CMSSW::DataDiscoveryAndLocation()")
334  
# Line 342 | Line 338 | class Cmssw(JobType):
338          common.logger.message("Contacting Data Discovery Services ...")
339          try:
340  
341 <            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)
341 >            self.pubdata=DataDiscovery.DataDiscovery(datasetPath, cfg_params)
342              self.pubdata.fetchDBSInfo()
343  
344          except DataDiscovery.NotExistingDatasetError, ex :
# Line 357 | Line 350 | class Cmssw(JobType):
350          except DataDiscovery.DataDiscoveryError, ex:
351              msg = 'ERROR ***: failed Data Discovery in DBS :  %s'%ex.getErrorMessage()
352              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)
353  
354          self.filesbyblock=self.pubdata.getFiles()
355          self.eventsbyblock=self.pubdata.getEventsPerBlock()
356          self.eventsbyfile=self.pubdata.getEventsPerFile()
357  
358          ## get max number of events
359 <        self.maxEvents=self.pubdata.getMaxEvents() ##  self.maxEvents used in Creator.py
359 >        self.maxEvents=self.pubdata.getMaxEvents() ##  self.maxEvents used in Creator.py
360  
361          ## Contact the DLS and build a list of sites hosting the fileblocks
362          try:
# Line 381 | Line 365 | class Cmssw(JobType):
365          except DataLocation.DataLocationError , ex:
366              msg = 'ERROR ***: failed Data Location in DLS \n %s '%ex.getErrorMessage()
367              raise CrabException(msg)
368 <        
368 >
369  
370          sites = dataloc.getSites()
371          allSites = []
# Line 395 | Line 379 | class Cmssw(JobType):
379          common.logger.message("Requested dataset: " + datasetPath + " has " + str(self.maxEvents) + " events in " + str(len(self.filesbyblock.keys())) + " blocks.\n")
380  
381          return sites
382 <    
382 >
383 >    def setArgsList(self, argsList):
384 >        self.argsList = argsList
385 >
386      def jobSplittingByBlocks(self, blockSites):
387          """
388          Perform job splitting. Jobs run over an integer number of files
# Line 445 | Line 432 | class Cmssw(JobType):
432              totalNumberOfJobs = 999999999
433          else :
434              totalNumberOfJobs = self.ncjobs
435 <            
435 >
436  
437          blocks = blockSites.keys()
438          blockCount = 0
# Line 465 | Line 452 | class Cmssw(JobType):
452              blockCount += 1
453              if block not in jobsOfBlock.keys() :
454                  jobsOfBlock[block] = []
455 <            
455 >
456              if self.eventsbyblock.has_key(block) :
457                  numEventsInBlock = self.eventsbyblock[block]
458                  common.logger.debug(5,'Events in Block File '+str(numEventsInBlock))
459 <            
459 >
460                  files = self.filesbyblock[block]
461                  numFilesInBlock = len(files)
462                  if (numFilesInBlock <= 0):
# Line 477 | Line 464 | class Cmssw(JobType):
464                  fileCount = 0
465  
466                  # ---- New block => New job ---- #
467 <                parString = "\\{"
467 >                parString = ""
468                  # counter for number of events in files currently worked on
469                  filesEventCount = 0
470                  # flag if next while loop should touch new file
471                  newFile = 1
472                  # job event counter
473                  jobSkipEventCount = 0
474 <            
474 >
475                  # ---- Iterate over the files in the block until we've met the requested ---- #
476                  # ---- total # of events or we've gone over all the files in this block  ---- #
477                  while ( (eventsRemaining > 0) and (fileCount < numFilesInBlock) and (jobCount < totalNumberOfJobs) ):
# Line 500 | Line 487 | class Cmssw(JobType):
487                              newFile = 0
488                          except KeyError:
489                              common.logger.message("File "+str(file)+" has unknown number of events: skipping")
490 <                        
490 >
491  
492                      # if less events in file remain than eventsPerJobRequested
493                      if ( filesEventCount - jobSkipEventCount < eventsPerJobRequested ) :
# Line 509 | Line 496 | class Cmssw(JobType):
496                              # end job using last file, use remaining events in block
497                              # close job and touch new file
498                              fullString = parString[:-2]
512                            fullString += '\\}'
499                              list_of_lists.append([fullString,str(-1),str(jobSkipEventCount)])
500                              common.logger.debug(3,"Job "+str(jobCount+1)+" can run over "+str(filesEventCount - jobSkipEventCount)+" events (last file in block).")
501                              self.jobDestination.append(blockSites[block])
# Line 522 | Line 508 | class Cmssw(JobType):
508                              eventsRemaining = eventsRemaining - filesEventCount + jobSkipEventCount
509                              jobSkipEventCount = 0
510                              # reset file
511 <                            parString = "\\{"
511 >                            parString = ""
512                              filesEventCount = 0
513                              newFile = 1
514                              fileCount += 1
# Line 534 | Line 520 | class Cmssw(JobType):
520                      elif ( filesEventCount - jobSkipEventCount == eventsPerJobRequested ) :
521                          # close job and touch new file
522                          fullString = parString[:-2]
537                        fullString += '\\}'
523                          list_of_lists.append([fullString,str(eventsPerJobRequested),str(jobSkipEventCount)])
524                          common.logger.debug(3,"Job "+str(jobCount+1)+" can run over "+str(eventsPerJobRequested)+" events.")
525                          self.jobDestination.append(blockSites[block])
# Line 546 | Line 531 | class Cmssw(JobType):
531                          eventsRemaining = eventsRemaining - eventsPerJobRequested
532                          jobSkipEventCount = 0
533                          # reset file
534 <                        parString = "\\{"
534 >                        parString = ""
535                          filesEventCount = 0
536                          newFile = 1
537                          fileCount += 1
538 <                        
538 >
539                      # if more events in file remain than eventsPerJobRequested
540                      else :
541                          # close job but don't touch new file
542                          fullString = parString[:-2]
558                        fullString += '\\}'
543                          list_of_lists.append([fullString,str(eventsPerJobRequested),str(jobSkipEventCount)])
544                          common.logger.debug(3,"Job "+str(jobCount+1)+" can run over "+str(eventsPerJobRequested)+" events.")
545                          self.jobDestination.append(blockSites[block])
# Line 570 | Line 554 | class Cmssw(JobType):
554                          jobSkipEventCount = eventsPerJobRequested - (filesEventCount - jobSkipEventCount - self.eventsbyfile[file])
555                          # remove all but the last file
556                          filesEventCount = self.eventsbyfile[file]
557 <                        parString = "\\{"
557 >                        parString = ""
558                          parString += '\\\"' + file + '\\\"\,'
559                      pass # END if
560                  pass # END while (iterate over files in the block)
# Line 579 | Line 563 | class Cmssw(JobType):
563          if (eventsRemaining > 0 and jobCount < totalNumberOfJobs ):
564              common.logger.message("Could not run on all requested events because some blocks not hosted at allowed sites.")
565          common.logger.message(str(jobCount)+" job(s) can run on "+str(totalEventCount)+" events.\n")
566 <        
566 >
567          # screen output
568          screenOutput = "List of jobs and available destination sites:\n\n"
569  
# Line 593 | Line 577 | class Cmssw(JobType):
577                  blockCounter += 1
578                  screenOutput += "Block %5i: jobs %20s: sites: %s\n" % (blockCounter,spanRanges(jobsOfBlock[block]),','.join(self.blackWhiteListParser.checkWhiteList(self.blackWhiteListParser.checkBlackList(blockSites[block],block),block)))
579                  if len(self.blackWhiteListParser.checkWhiteList(self.blackWhiteListParser.checkBlackList(blockSites[block],block),block)) == 0:
580 <                    noSiteBlock.append( spanRanges(jobsOfBlock[block]) )
580 >                    noSiteBlock.append( spanRanges(jobsOfBlock[block]) )
581                      bloskNoSite.append( blockCounter )
582 <        
582 >
583          common.logger.message(screenOutput)
584          if len(noSiteBlock) > 0 and len(bloskNoSite) > 0:
585              msg = 'WARNING: No sites are hosting any part of data for block:\n                '
# Line 621 | Line 605 | class Cmssw(JobType):
605          Perform job splitting based on number of event per job
606          """
607          common.logger.debug(5,'Splitting per events')
608 <        common.logger.message('Required '+str(self.eventsPerJob)+' events per job ')
609 <        common.logger.message('Required '+str(self.theNumberOfJobs)+' jobs in total ')
610 <        common.logger.message('Required '+str(self.total_number_of_events)+' events in total ')
608 >
609 >        if (self.selectEventsPerJob):
610 >            common.logger.message('Required '+str(self.eventsPerJob)+' events per job ')
611 >        if (self.selectNumberOfJobs):
612 >            common.logger.message('Required '+str(self.theNumberOfJobs)+' jobs in total ')
613 >        if (self.selectTotalNumberEvents):
614 >            common.logger.message('Required '+str(self.total_number_of_events)+' events in total ')
615  
616          if (self.total_number_of_events < 0):
617              msg='Cannot split jobs per Events with "-1" as total number of events'
# Line 632 | Line 620 | class Cmssw(JobType):
620          if (self.selectEventsPerJob):
621              if (self.selectTotalNumberEvents):
622                  self.total_number_of_jobs = int(self.total_number_of_events/self.eventsPerJob)
623 <            elif(self.selectNumberOfJobs) :  
623 >            elif(self.selectNumberOfJobs) :
624                  self.total_number_of_jobs =self.theNumberOfJobs
625 <                self.total_number_of_events =int(self.theNumberOfJobs*self.eventsPerJob)
625 >                self.total_number_of_events =int(self.theNumberOfJobs*self.eventsPerJob)
626  
627          elif (self.selectNumberOfJobs) :
628              self.total_number_of_jobs = self.theNumberOfJobs
629              self.eventsPerJob = int(self.total_number_of_events/self.total_number_of_jobs)
630 <
630 >
631          common.logger.debug(5,'N jobs  '+str(self.total_number_of_jobs))
632  
633          # is there any remainder?
# Line 655 | Line 643 | class Cmssw(JobType):
643          self.list_of_args = []
644          for i in range(self.total_number_of_jobs):
645              ## Since there is no input, any site is good
646 <           # self.jobDestination.append(["Any"])
659 <            self.jobDestination.append([""]) #must be empty to write correctly the xml
646 >            self.jobDestination.append([""]) #must be empty to write correctly the xml
647              args=[]
648              if (self.firstRun):
649 <                    ## pythia first run
663 <                #self.list_of_args.append([(str(self.firstRun)+str(i))])
649 >                ## pythia first run
650                  args.append(str(self.firstRun)+str(i))
665            else:
666                ## no first run
667                #self.list_of_args.append([str(i)])
668                args.append(str(i))
651              if (self.sourceSeed):
652                  args.append(str(self.sourceSeed)+str(i))
653                  if (self.sourceSeedVtx):
# Line 674 | Line 656 | class Cmssw(JobType):
656                  if (self.sourceSeedG4):
657                      ## + G4 random seed
658                      args.append(str(self.sourceSeedG4)+str(i))
659 <                if (self.sourceSeedMix):    
659 >                if (self.sourceSeedMix):
660                      ## + Mix random seed
661                      args.append(str(self.sourceSeedMix)+str(i))
662                  pass
663              pass
664              self.list_of_args.append(args)
665          pass
684            
685        # print self.list_of_args
666  
667          return
668  
# Line 711 | Line 691 | class Cmssw(JobType):
691          return
692  
693      def split(self, jobParams):
694 <
694 >
695          common.jobDB.load()
696          #### Fabio
697          njobs = self.total_number_of_jobs
# Line 719 | Line 699 | class Cmssw(JobType):
699          # create the empty structure
700          for i in range(njobs):
701              jobParams.append("")
702 <        
702 >
703          for job in range(njobs):
704              jobParams[job] = arglist[job]
705              # print str(arglist[job])
# Line 730 | Line 710 | class Cmssw(JobType):
710  
711          common.jobDB.save()
712          return
713 <    
713 >
714      def getJobTypeArguments(self, nj, sched):
715          result = ''
716          for i in common.jobDB.arguments(nj):
717              result=result+str(i)+" "
718          return result
719 <  
719 >
720      def numberOfJobs(self):
721          # Fabio
722          return self.total_number_of_jobs
# Line 745 | Line 725 | class Cmssw(JobType):
725          """
726          Return the TarBall with lib and exe
727          """
728 <        
728 >
729          # if it exist, just return it
730          #
731          # Marco. Let's start to use relative path for Boss XML files
# Line 768 | Line 748 | class Cmssw(JobType):
748          # print "swVersion = ", swVersion
749          swReleaseTop = self.scram.getReleaseTop_()
750          #print "swReleaseTop = ", swReleaseTop
751 <        
751 >
752          ## check if working area is release top
753          if swReleaseTop == '' or swArea == swReleaseTop:
754              return
# Line 781 | Line 761 | class Cmssw(JobType):
761                  exeWithPath = self.scram.findFile_(executable)
762                  if ( not exeWithPath ):
763                      raise CrabException('User executable '+executable+' not found')
764 <    
764 >
765                  ## then check if it's private or not
766                  if exeWithPath.find(swReleaseTop) == -1:
767                      # the exe is private, so we must ship
# Line 790 | Line 770 | class Cmssw(JobType):
770                      # distinguish case when script is in user project area or given by full path somewhere else
771                      if exeWithPath.find(path) >= 0 :
772                          exe = string.replace(exeWithPath, path,'')
773 <                        tar.add(path+exe,os.path.basename(executable))
773 >                        tar.add(path+exe,exe)
774                      else :
775                          tar.add(exeWithPath,os.path.basename(executable))
776                      pass
777                  else:
778                      # the exe is from release, we'll find it on WN
779                      pass
780 <    
780 >
781              ## Now get the libraries: only those in local working area
782              libDir = 'lib'
783              lib = swArea+'/' +libDir
784              common.logger.debug(5,"lib "+lib+" to be tarred")
785              if os.path.exists(lib):
786                  tar.add(lib,libDir)
787 <    
787 >
788              ## Now check if module dir is present
789              moduleDir = 'module'
790              module = swArea + '/' + moduleDir
# Line 818 | Line 798 | class Cmssw(JobType):
798                      common.logger.debug(5,"data "+root+"/data"+" to be tarred")
799                      tar.add(root+"/data",root[swAreaLen:]+"/data")
800  
801 <            ## Add ProdAgent dir to tar
802 <            paDir = 'ProdAgentApi'
803 <            pa = os.environ['CRABDIR'] + '/' + 'ProdAgentApi'
804 <            if os.path.isdir(pa):
805 <                tar.add(pa,paDir)
801 >            ### Removed ProdAgent Api dependencies ###
802 >            ### Add ProdAgent dir to tar
803 >            #paDir = 'ProdAgentApi'
804 >            #pa = os.environ['CRABDIR'] + '/' + 'ProdAgentApi'
805 >            #if os.path.isdir(pa):
806 >            #    tar.add(pa,paDir)
807  
808 <            ### FEDE FOR DBS PUBLICATION
828 <            ## Add PRODCOMMON dir to tar
808 >            ## Add ProdCommon dir to tar
809              prodcommonDir = 'ProdCommon'
810              prodcommonPath = os.environ['CRABDIR'] + '/' + 'ProdCommon'
811              if os.path.isdir(prodcommonPath):
812                  tar.add(prodcommonPath,prodcommonDir)
813 <            #############################    
834 <        
813 >
814              common.logger.debug(5,"Files added to "+self.tgzNameWithPath+" : "+str(tar.getnames()))
815              tar.close()
816          except :
# Line 843 | Line 822 | class Cmssw(JobType):
822              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.')
823  
824          ## create tar-ball with ML stuff
825 <        self.MLtgzfile =  common.work_space.pathForTgz()+'share/MLfiles.tgz'
825 >        self.MLtgzfile =  common.work_space.pathForTgz()+'share/MLfiles.tgz'
826          try:
827              tar = tarfile.open(self.MLtgzfile, "w:gz")
828              path=os.environ['CRABDIR'] + '/python/'
# Line 853 | Line 832 | class Cmssw(JobType):
832              tar.close()
833          except :
834              raise CrabException('Could not create ML files tar-ball')
835 <        
835 >
836          return
837 <        
837 >
838      def additionalInputFileTgz(self):
839          """
840          Put all additional files into a tar ball and return its name
# Line 875 | Line 854 | class Cmssw(JobType):
854          the execution environment for the job 'nj'.
855          """
856          # Prepare JobType-independent part
857 <        txt = ''
858 <  
859 <        ## OLI_Daniele at this level  middleware already known
881 <
882 <        txt += 'if [ $middleware == LCG ]; then \n'
883 <        txt += '    echo "### First set SCRAM ARCH and BUILD_ARCH to ' + self.executable_arch + ' ###"\n'
884 <        txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
885 <        txt += '    export BUILD_ARCH='+self.executable_arch+'\n'
857 >        txt = ''
858 >        txt += 'echo ">>> setup environment"\n'
859 >        txt += 'if [ $middleware == LCG ]; then \n'
860          txt += self.wsSetupCMSLCGEnvironment_()
861          txt += 'elif [ $middleware == OSG ]; then\n'
862          txt += '    WORKING_DIR=`/bin/mktemp  -d $OSG_WN_TMP/cms_XXXXXXXXXXXX`\n'
863 <        txt += '    echo "Created working directory: $WORKING_DIR"\n'
890 <        txt += '    if [ ! -d $WORKING_DIR ] ;then\n'
863 >        txt += '    if [ ! $? == 0 ] ;then\n'
864          txt += '        echo "SET_CMS_ENV 10016 ==> OSG $WORKING_DIR could not be created on WN `hostname`"\n'
865 <        txt += '    echo "JOB_EXIT_STATUS = 10016"\n'
866 <        txt += '    echo "JobExitCode=10016" | tee -a $RUNTIME_AREA/$repo\n'
867 <        txt += '    dumpStatus $RUNTIME_AREA/$repo\n'
895 <        txt += '        rm -f $RUNTIME_AREA/$repo \n'
896 <        txt += '        echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
897 <        txt += '        echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
865 >        txt += '        echo "JOB_EXIT_STATUS = 10016"\n'
866 >        txt += '        echo "JobExitCode=10016" | tee -a $RUNTIME_AREA/$repo\n'
867 >        txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
868          txt += '        exit 1\n'
869          txt += '    fi\n'
870 +        txt += '    echo ">>> Created working directory: $WORKING_DIR"\n'
871          txt += '\n'
872          txt += '    echo "Change to working directory: $WORKING_DIR"\n'
873          txt += '    cd $WORKING_DIR\n'
874 <        txt += self.wsSetupCMSOSGEnvironment_()
875 <        txt += '    echo "### Set SCRAM ARCH to ' + self.executable_arch + ' ###"\n'
876 <        txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
874 >        txt += '    echo ">>> current directory (WORKING_DIR): $WORKING_DIR"\n'
875 >        txt += self.wsSetupCMSOSGEnvironment_()
876 >        #txt += '    echo "### Set SCRAM ARCH to ' + self.executable_arch + ' ###"\n'
877 >        #txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
878          txt += 'fi\n'
879  
880          # Prepare JobType-specific part
881          scram = self.scram.commandName()
882          txt += '\n\n'
883 <        txt += 'echo "### SPECIFIC JOB SETUP ENVIRONMENT ###"\n'
883 >        txt += 'echo ">>> specific cmssw setup environment:"\n'
884 >        txt += 'echo "CMSSW_VERSION =  '+self.version+'"\n'
885          txt += scram+' project CMSSW '+self.version+'\n'
886          txt += 'status=$?\n'
887          txt += 'if [ $status != 0 ] ; then\n'
888 <        txt += '   echo "SET_EXE_ENV 10034 ==>ERROR CMSSW '+self.version+' not found on `hostname`" \n'
889 <        txt += '   echo "JOB_EXIT_STATUS = 10034"\n'
890 <        txt += '   echo "JobExitCode=10034" | tee -a $RUNTIME_AREA/$repo\n'
891 <        txt += '   dumpStatus $RUNTIME_AREA/$repo\n'
919 <        txt += '   rm -f $RUNTIME_AREA/$repo \n'
920 <        txt += '   echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
921 <        txt += '   echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
922 <        ## OLI_Daniele
888 >        txt += '    echo "SET_EXE_ENV 10034 ==>ERROR CMSSW '+self.version+' not found on `hostname`" \n'
889 >        txt += '    echo "JOB_EXIT_STATUS = 10034"\n'
890 >        txt += '    echo "JobExitCode=10034" | tee -a $RUNTIME_AREA/$repo\n'
891 >        txt += '    dumpStatus $RUNTIME_AREA/$repo\n'
892          txt += '    if [ $middleware == OSG ]; then \n'
924        txt += '        echo "Remove working directory: $WORKING_DIR"\n'
893          txt += '        cd $RUNTIME_AREA\n'
894 +        txt += '        echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
895 +        txt += '        echo ">>> Remove working directory: $WORKING_DIR"\n'
896          txt += '        /bin/rm -rf $WORKING_DIR\n'
897          txt += '        if [ -d $WORKING_DIR ] ;then\n'
898          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'
899          txt += '            echo "JOB_EXIT_STATUS = 10018"\n'
900          txt += '            echo "JobExitCode=10018" | tee -a $RUNTIME_AREA/$repo\n'
901          txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
932        txt += '            rm -f $RUNTIME_AREA/$repo \n'
933        txt += '            echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
934        txt += '            echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
902          txt += '        fi\n'
903          txt += '    fi \n'
904 <        txt += '   exit 1 \n'
904 >        txt += '    exit 1 \n'
905          txt += 'fi \n'
939        txt += 'echo "CMSSW_VERSION =  '+self.version+'"\n'
906          txt += 'cd '+self.version+'\n'
907          ########## FEDE FOR DBS2 ######################
908          txt += 'SOFTWARE_DIR=`pwd`\n'
909 <        txt += 'echo SOFTWARE_DIR=$SOFTWARE_DIR \n'
909 >        txt += 'echo ">>> current directory (SOFTWARE_DIR): $SOFTWARE_DIR" \n'
910          ###############################################
911          ### needed grep for bug in scramv1 ###
946        txt += scram+' runtime -sh\n'
912          txt += 'eval `'+scram+' runtime -sh | grep -v SCRAMRT_LSB_JOBNAME`\n'
948        txt += 'echo $PATH\n'
949
913          # Handle the arguments:
914          txt += "\n"
915          txt += "## number of arguments (first argument always jobnumber)\n"
916          txt += "\n"
917 < #        txt += "narg=$#\n"
955 <        txt += "if [ $nargs -lt 2 ]\n"
917 >        txt += "if [ $nargs -lt "+str(len(self.argsList[nj].split()))+" ]\n"
918          txt += "then\n"
919          txt += "    echo 'SET_EXE_ENV 1 ==> ERROR Too few arguments' +$nargs+ \n"
920          txt += '    echo "JOB_EXIT_STATUS = 50113"\n'
921          txt += '    echo "JobExitCode=50113" | tee -a $RUNTIME_AREA/$repo\n'
922          txt += '    dumpStatus $RUNTIME_AREA/$repo\n'
961        txt += '    rm -f $RUNTIME_AREA/$repo \n'
962        txt += '    echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
963        txt += '    echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
964        ## OLI_Daniele
923          txt += '    if [ $middleware == OSG ]; then \n'
966        txt += '        echo "Remove working directory: $WORKING_DIR"\n'
924          txt += '        cd $RUNTIME_AREA\n'
925 +        txt += '        echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
926 +        txt += '        echo ">>> Remove working directory: $WORKING_DIR"\n'
927          txt += '        /bin/rm -rf $WORKING_DIR\n'
928          txt += '        if [ -d $WORKING_DIR ] ;then\n'
929          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'
930          txt += '            echo "JOB_EXIT_STATUS = 50114"\n'
931          txt += '            echo "JobExitCode=50114" | tee -a $RUNTIME_AREA/$repo\n'
932          txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
974        txt += '            rm -f $RUNTIME_AREA/$repo \n'
975        txt += '            echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
976        txt += '            echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
933          txt += '        fi\n'
934          txt += '    fi \n'
935          txt += "    exit 1\n"
# Line 983 | Line 939 | class Cmssw(JobType):
939          # Prepare job-specific part
940          job = common.job_list[nj]
941          ### FEDE FOR DBS OUTPUT PUBLICATION
942 <        if (self.datasetPath):
942 >        if (self.datasetPath):
943              txt += '\n'
944              txt += 'DatasetPath='+self.datasetPath+'\n'
945  
946              datasetpath_split = self.datasetPath.split("/")
947 <            
947 >
948              txt += 'PrimaryDataset='+datasetpath_split[1]+'\n'
949              txt += 'DataTier='+datasetpath_split[2]+'\n'
994            #txt += 'ProcessedDataset='+datasetpath_split[3]+'\n'
950              txt += 'ApplicationFamily=cmsRun\n'
951  
952          else:
953              txt += 'DatasetPath=MCDataTier\n'
954              txt += 'PrimaryDataset=null\n'
955              txt += 'DataTier=null\n'
1001            #txt += 'ProcessedDataset=null\n'
956              txt += 'ApplicationFamily=MCDataTier\n'
957          if self.pset != None: #CarlosDaniele
958              pset = os.path.basename(job.configFilename())
959              txt += '\n'
960              txt += 'cp  $RUNTIME_AREA/'+pset+' .\n'
961              if (self.datasetPath): # standard job
1008                #txt += 'InputFiles=$2\n'
962                  txt += 'InputFiles=${args[1]}\n'
963                  txt += 'MaxEvents=${args[2]}\n'
964                  txt += 'SkipEvents=${args[3]}\n'
965                  txt += 'echo "Inputfiles:<$InputFiles>"\n'
966 <                txt += 'sed "s#{\'INPUT\'}#$InputFiles#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
966 >                txt += 'sed "s#\'INPUTFILE\'#$InputFiles#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
967                  txt += 'echo "MaxEvents:<$MaxEvents>"\n'
968 <                txt += 'sed "s#INPUTMAXEVENTS#$MaxEvents#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
968 >                txt += 'sed "s#int32 input = 0#int32 input = $MaxEvents#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
969                  txt += 'echo "SkipEvents:<$SkipEvents>"\n'
970 <                txt += 'sed "s#INPUTSKIPEVENTS#$SkipEvents#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
970 >                txt += 'sed "s#uint32 skipEvents = 0#uint32 skipEvents = $SkipEvents#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
971              else:  # pythia like job
972                  seedIndex=1
973                  if (self.firstRun):
974                      txt += 'FirstRun=${args['+str(seedIndex)+']}\n'
975                      txt += 'echo "FirstRun: <$FirstRun>"\n'
976 <                    txt += 'sed "s#\<INPUTFIRSTRUN\>#$FirstRun#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
976 >                    txt += 'sed "s#uint32 firstRun = 0#uint32 firstRun = $FirstRun#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
977                      seedIndex=seedIndex+1
978  
979                  if (self.sourceSeed):
980                      txt += 'Seed=${args['+str(seedIndex)+']}\n'
981 <                    txt += 'sed "s#\<INPUT\>#$Seed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
981 >                    txt += 'sed "s#uint32 sourceSeed = 0#uint32 sourceSeed = $Seed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
982                      seedIndex=seedIndex+1
983                      ## the following seeds are not always present
984                      if (self.sourceSeedVtx):
985                          txt += 'VtxSeed=${args['+str(seedIndex)+']}\n'
986                          txt += 'echo "VtxSeed: <$VtxSeed>"\n'
987 <                        txt += 'sed "s#\<INPUTVTX\>#$VtxSeed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
987 >                        txt += 'sed "s#uint32 VtxSmeared = 0#uint32 VtxSmeared = $VtxSeed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
988                          seedIndex += 1
989                      if (self.sourceSeedG4):
990                          txt += 'G4Seed=${args['+str(seedIndex)+']}\n'
991                          txt += 'echo "G4Seed: <$G4Seed>"\n'
992 <                        txt += 'sed "s#\<INPUTG4\>#$G4Seed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
992 >                        txt += 'sed "s#uint32 g4SimHits = 0#uint32 g4SimHits = $G4Seed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
993                          seedIndex += 1
994                      if (self.sourceSeedMix):
995                          txt += 'mixSeed=${args['+str(seedIndex)+']}\n'
996                          txt += 'echo "MixSeed: <$mixSeed>"\n'
997 <                        txt += 'sed "s#\<INPUTMIX\>#$mixSeed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
997 >                        txt += 'sed "s#uint32 mix = 0#uint32 mix = $mixSeed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
998                          seedIndex += 1
999                      pass
1000                  pass
# Line 1051 | Line 1004 | class Cmssw(JobType):
1004              txt += 'if [ -e $RUNTIME_AREA/'+self.additional_tgz_name+' ] ; then\n'
1005              txt += '  tar xzvf $RUNTIME_AREA/'+self.additional_tgz_name+'\n'
1006              txt += 'fi\n'
1007 <            pass
1007 >            pass
1008  
1009          if self.pset != None: #CarlosDaniele
1057            txt += 'echo "### END JOB SETUP ENVIRONMENT ###"\n\n'
1058        
1010              txt += '\n'
1011              txt += 'echo "***** cat pset.cfg *********"\n'
1012              txt += 'cat pset.cfg\n'
# Line 1064 | Line 1015 | class Cmssw(JobType):
1015              ### FEDE FOR DBS OUTPUT PUBLICATION
1016              txt += 'PSETHASH=`EdmConfigHash < pset.cfg` \n'
1017              txt += 'echo "PSETHASH = $PSETHASH" \n'
1018 <            ##############
1018 >            ##############
1019              txt += '\n'
1069            # txt += 'echo "***** cat pset1.cfg *********"\n'
1070            # txt += 'cat pset1.cfg\n'
1071            # txt += 'echo "****** end pset1.cfg ********"\n'
1020          return txt
1021  
1022      def wsBuildExe(self, nj=0):
# Line 1080 | Line 1028 | class Cmssw(JobType):
1028          txt = ""
1029  
1030          if os.path.isfile(self.tgzNameWithPath):
1031 <            txt += 'echo "tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'"\n'
1031 >            txt += 'echo ">>> tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+' :" \n'
1032              txt += 'tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'\n'
1033              txt += 'untar_status=$? \n'
1034              txt += 'if [ $untar_status -ne 0 ]; then \n'
# Line 1088 | Line 1036 | class Cmssw(JobType):
1036              txt += '   echo "JOB_EXIT_STATUS = $untar_status" \n'
1037              txt += '   echo "JobExitCode=$untar_status" | tee -a $RUNTIME_AREA/$repo\n'
1038              txt += '   if [ $middleware == OSG ]; then \n'
1091            txt += '       echo "Remove working directory: $WORKING_DIR"\n'
1039              txt += '       cd $RUNTIME_AREA\n'
1040 +            txt += '        echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
1041 +            txt += '        echo ">>> Remove working directory: $WORKING_DIR"\n'
1042              txt += '       /bin/rm -rf $WORKING_DIR\n'
1043              txt += '       if [ -d $WORKING_DIR ] ;then\n'
1044              txt += '           echo "SET_EXE 50999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after Untarring .tgz file failed"\n'
1045              txt += '           echo "JOB_EXIT_STATUS = 50999"\n'
1046              txt += '           echo "JobExitCode=50999" | tee -a $RUNTIME_AREA/$repo\n'
1047              txt += '           dumpStatus $RUNTIME_AREA/$repo\n'
1099            txt += '           rm -f $RUNTIME_AREA/$repo \n'
1100            txt += '           echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1101            txt += '           echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1048              txt += '       fi\n'
1049              txt += '   fi \n'
1050              txt += '   \n'
# Line 1107 | Line 1053 | class Cmssw(JobType):
1053              txt += '   echo "Successful untar" \n'
1054              txt += 'fi \n'
1055              txt += '\n'
1056 <            txt += 'echo "Include ProdAgentApi and PRODCOMMON in PYTHONPATH"\n'
1056 >            #### Removed ProdAgent API dependencies
1057 >            txt += 'echo ">>> Include ProdCommon in PYTHONPATH:"\n'
1058              txt += 'if [ -z "$PYTHONPATH" ]; then\n'
1059              #### FEDE FOR DBS OUTPUT PUBLICATION
1060 <            txt += '   export PYTHONPATH=$SOFTWARE_DIR/ProdAgentApi:$SOFTWARE_DIR/ProdCommon\n'
1114 <            #txt += '   export PYTHONPATH=`pwd`/ProdAgentApi:`pwd`/ProdCommon\n'
1115 <            #txt += '   export PYTHONPATH=ProdAgentApi\n'
1060 >            txt += '   export PYTHONPATH=$SOFTWARE_DIR/ProdCommon\n'
1061              txt += 'else\n'
1062 <            txt += '   export PYTHONPATH=$SOFTWARE_DIR/ProdAgentApi:$SOFTWARE_DIR/ProdCommon:${PYTHONPATH}\n'
1118 <            #txt += '   export PYTHONPATH=`pwd`/ProdAgentApi:`pwd`/ProdCommon:${PYTHONPATH}\n'
1119 <            #txt += '   export PYTHONPATH=ProdAgentApi:${PYTHONPATH}\n'
1062 >            txt += '   export PYTHONPATH=$SOFTWARE_DIR/ProdCommon:${PYTHONPATH}\n'
1063              txt += 'echo "PYTHONPATH=$PYTHONPATH"\n'
1064 <            ###################  
1064 >            ###################
1065              txt += 'fi\n'
1066              txt += '\n'
1067  
1068              pass
1069 <        
1069 >
1070          return txt
1071  
1072      def modifySteeringCards(self, nj):
1073          """
1074 <        modify the card provided by the user,
1074 >        modify the card provided by the user,
1075          writing a new card into share dir
1076          """
1077 <        
1077 >
1078      def executableName(self):
1079          if self.scriptExe: #CarlosDaniele
1080              return "sh "
# Line 1142 | Line 1085 | class Cmssw(JobType):
1085          if self.scriptExe:#CarlosDaniele
1086              return   self.scriptExe + " $NJob"
1087          else:
1088 <            # if >= CMSSW_1_5_X, add -e
1088 >            # if >= CMSSW_1_5_X, add -j crab_fjr.xml
1089              version_array = self.scram.getSWVersion().split('_')
1090              major = 0
1091              minor = 0
# Line 1150 | Line 1093 | class Cmssw(JobType):
1093                  major = int(version_array[1])
1094                  minor = int(version_array[2])
1095              except:
1096 <                msg = "Cannot parse CMSSW version string: " + "_".join(version_array) + " for major and minor release number!"  
1096 >                msg = "Cannot parse CMSSW version string: " + "_".join(version_array) + " for major and minor release number!"
1097                  raise CrabException(msg)
1098              if major >= 1 and minor >= 5 :
1099 <                return " -e -p pset.cfg"
1099 >                return " -j " + self.fjrFileName + " -p pset.cfg"
1100              else:
1101                  return " -p pset.cfg"
1102  
# Line 1185 | Line 1128 | class Cmssw(JobType):
1128  
1129          ## User Declared output files
1130          for out in (self.output_file+self.output_file_sandbox):
1131 <            n_out = nj + 1
1131 >            n_out = nj + 1
1132              out_box.append(self.numberFile_(out,str(n_out)))
1133          return out_box
1134  
# Line 1201 | Line 1144 | class Cmssw(JobType):
1144          """
1145  
1146          txt = '\n'
1147 <        txt += '# directory content\n'
1147 >        txt += 'echo ">>> current directory (SOFTWARE_DIR): $SOFTWARE_DIR" \n'
1148 >        txt += 'echo ">>> current directory content:"\n'
1149          txt += 'ls \n'
1150 +        txt += '\n'
1151  
1152          txt += 'output_exit_status=0\n'
1153 <        
1153 >
1154          for fileWithSuffix in (self.output_file_sandbox):
1155              output_file_num = self.numberFile_(fileWithSuffix, '$NJob')
1156              txt += '\n'
1157              txt += '# check output file\n'
1158              txt += 'if [ -e ./'+fileWithSuffix+' ] ; then\n'
1159 <            txt += '    mv '+fileWithSuffix+' $RUNTIME_AREA\n'
1160 <            txt += '    cp $RUNTIME_AREA/'+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
1159 >            txt += '    mv '+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
1160 >            txt += '    ln -s $RUNTIME_AREA/'+output_file_num+' $RUNTIME_AREA/'+fileWithSuffix+'\n'
1161              txt += 'else\n'
1162              txt += '    exit_status=60302\n'
1163 <            txt += '    echo "ERROR: Problem with output file '+fileWithSuffix+'"\n'
1163 >            txt += '    echo "ERROR: Output file '+fileWithSuffix+' not found"\n'
1164              if common.scheduler.boss_scheduler_name == 'condor_g':
1165                  txt += '    if [ $middleware == OSG ]; then \n'
1166                  txt += '        echo "prepare dummy output file"\n'
1167                  txt += '        echo "Processing of job output failed" > $RUNTIME_AREA/'+output_file_num+'\n'
1168                  txt += '    fi \n'
1169              txt += 'fi\n'
1170 <        
1170 >
1171          for fileWithSuffix in (self.output_file):
1172              output_file_num = self.numberFile_(fileWithSuffix, '$NJob')
1173              txt += '\n'
1174              txt += '# check output file\n'
1175              txt += 'if [ -e ./'+fileWithSuffix+' ] ; then\n'
1176 <            txt += '    mv '+fileWithSuffix+' $RUNTIME_AREA\n'
1177 <            txt += '    cp $RUNTIME_AREA/'+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
1176 >            if (self.copy_data == 1):  # For OSG nodes, file is in $WORKING_DIR, should not be moved to $RUNTIME_AREA
1177 >                txt += '    mv '+fileWithSuffix+' '+output_file_num+'\n'
1178 >                txt += '    ln -s `pwd`/'+output_file_num+' $RUNTIME_AREA/'+fileWithSuffix+'\n'
1179 >            else:
1180 >                txt += '    mv '+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
1181 >                txt += '    ln -s $RUNTIME_AREA/'+output_file_num+' $RUNTIME_AREA/'+fileWithSuffix+'\n'
1182              txt += 'else\n'
1183              txt += '    exit_status=60302\n'
1184 <            txt += '    echo "ERROR: Problem with output file '+fileWithSuffix+'"\n'
1184 >            txt += '    echo "ERROR: Output file '+fileWithSuffix+' not found"\n'
1185              txt += '    echo "JOB_EXIT_STATUS = $exit_status"\n'
1186              txt += '    output_exit_status=$exit_status\n'
1187              if common.scheduler.boss_scheduler_name == 'condor_g':
# Line 1244 | Line 1193 | class Cmssw(JobType):
1193          file_list = []
1194          for fileWithSuffix in (self.output_file):
1195               file_list.append(self.numberFile_(fileWithSuffix, '$NJob'))
1196 <            
1196 >
1197          txt += 'file_list="'+string.join(file_list,' ')+'"\n'
1198 +        txt += '\n'
1199 +        txt += 'echo ">>> current directory (SOFTWARE_DIR): $SOFTWARE_DIR" \n'
1200 +        txt += 'echo ">>> current directory content:"\n'
1201 +        txt += 'ls \n'
1202 +        txt += '\n'
1203          txt += 'cd $RUNTIME_AREA\n'
1204 +        txt += 'echo ">>> current directory (RUNTIME_AREA):  $RUNTIME_AREA"\n'
1205          return txt
1206  
1207      def numberFile_(self, file, txt):
# Line 1264 | Line 1219 | class Cmssw(JobType):
1219              result = name + '_' + txt + "." + ext
1220          else:
1221              result = name + '_' + txt
1222 <        
1222 >
1223          return result
1224  
1225      def getRequirements(self, nj=[]):
1226          """
1227 <        return job requirements to add to jdl files
1227 >        return job requirements to add to jdl files
1228          """
1229          req = ''
1230          if self.version:
# Line 1291 | Line 1246 | class Cmssw(JobType):
1246          """ return the config filename """
1247          return self.name()+'.cfg'
1248  
1294    ### OLI_DANIELE
1249      def wsSetupCMSOSGEnvironment_(self):
1250          """
1251          Returns part of a job script which is prepares
1252          the execution environment and which is common for all CMS jobs.
1253          """
1254 <        txt = '\n'
1255 <        txt += '   echo "### SETUP CMS OSG  ENVIRONMENT ###"\n'
1256 <        txt += '   if [ -f $GRID3_APP_DIR/cmssoft/cmsset_default.sh ] ;then\n'
1257 <        txt += '      # Use $GRID3_APP_DIR/cmssoft/cmsset_default.sh to setup cms software\n'
1258 <        txt += '       export SCRAM_ARCH='+self.executable_arch+'\n'
1305 <        txt += '       source $GRID3_APP_DIR/cmssoft/cmsset_default.sh '+self.version+'\n'
1306 <        txt += '   elif [ -f $OSG_APP/cmssoft/cms/cmsset_default.sh ] ;then\n'
1254 >        txt = '    echo ">>> setup CMS OSG environment:"\n'
1255 >        txt += '    echo "set SCRAM ARCH to ' + self.executable_arch + '"\n'
1256 >        txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
1257 >        txt += '    echo "SCRAM_ARCH = $SCRAM_ARCH"\n'
1258 >        txt += '    if [ -f $OSG_APP/cmssoft/cms/cmsset_default.sh ] ;then\n'
1259          txt += '      # Use $OSG_APP/cmssoft/cms/cmsset_default.sh to setup cms software\n'
1260 <        txt += '       export SCRAM_ARCH='+self.executable_arch+'\n'
1261 <        txt += '       source $OSG_APP/cmssoft/cms/cmsset_default.sh '+self.version+'\n'
1262 <        txt += '   else\n'
1263 <        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'
1264 <        txt += '       echo "JOB_EXIT_STATUS = 10020"\n'
1265 <        txt += '       echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
1314 <        txt += '       dumpStatus $RUNTIME_AREA/$repo\n'
1315 <        txt += '       rm -f $RUNTIME_AREA/$repo \n'
1316 <        txt += '       echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1317 <        txt += '       echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1318 <        txt += '       exit 1\n'
1260 >        txt += '        source $OSG_APP/cmssoft/cms/cmsset_default.sh '+self.version+'\n'
1261 >        txt += '    else\n'
1262 >        txt += '        echo "SET_CMS_ENV 10020 ==> ERROR $OSG_APP/cmssoft/cms/cmsset_default.sh file not found"\n'
1263 >        txt += '        echo "JOB_EXIT_STATUS = 10020"\n'
1264 >        txt += '        echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
1265 >        txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
1266          txt += '\n'
1267 <        txt += '       echo "Remove working directory: $WORKING_DIR"\n'
1268 <        txt += '       cd $RUNTIME_AREA\n'
1269 <        txt += '       /bin/rm -rf $WORKING_DIR\n'
1270 <        txt += '       if [ -d $WORKING_DIR ] ;then\n'
1271 <        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'
1272 <        txt += '           echo "JOB_EXIT_STATUS = 10017"\n'
1273 <        txt += '           echo "JobExitCode=10017" | tee -a $RUNTIME_AREA/$repo\n'
1274 <        txt += '           dumpStatus $RUNTIME_AREA/$repo\n'
1275 <        txt += '           rm -f $RUNTIME_AREA/$repo \n'
1276 <        txt += '           echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1330 <        txt += '           echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1331 <        txt += '       fi\n'
1267 >        txt += '        cd $RUNTIME_AREA\n'
1268 >        txt += '        echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
1269 >        txt += '        echo ">>> Remove working directory: $WORKING_DIR"\n'
1270 >        txt += '        /bin/rm -rf $WORKING_DIR\n'
1271 >        txt += '        if [ -d $WORKING_DIR ] ;then\n'
1272 >        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'
1273 >        txt += '            echo "JOB_EXIT_STATUS = 10017"\n'
1274 >        txt += '            echo "JobExitCode=10017" | tee -a $RUNTIME_AREA/$repo\n'
1275 >        txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
1276 >        txt += '        fi\n'
1277          txt += '\n'
1278 <        txt += '       exit 1\n'
1279 <        txt += '   fi\n'
1278 >        txt += '        exit 1\n'
1279 >        txt += '    fi\n'
1280          txt += '\n'
1281 <        txt += '   echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'
1282 <        txt += '   echo " END SETUP CMS OSG  ENVIRONMENT "\n'
1281 >        txt += '    echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'
1282 >        txt += '    echo "SCRAM_ARCH = $SCRAM_ARCH"\n'
1283  
1284          return txt
1285 <
1285 >
1286      ### OLI_DANIELE
1287      def wsSetupCMSLCGEnvironment_(self):
1288          """
1289          Returns part of a job script which is prepares
1290          the execution environment and which is common for all CMS jobs.
1291          """
1292 <        txt  = '   \n'
1293 <        txt += '   echo " ### SETUP CMS LCG  ENVIRONMENT ### "\n'
1294 <        txt += '   if [ ! $VO_CMS_SW_DIR ] ;then\n'
1295 <        txt += '       echo "SET_CMS_ENV 10031 ==> ERROR CMS software dir not found on WN `hostname`"\n'
1296 <        txt += '       echo "JOB_EXIT_STATUS = 10031" \n'
1297 <        txt += '       echo "JobExitCode=10031" | tee -a $RUNTIME_AREA/$repo\n'
1298 <        txt += '       dumpStatus $RUNTIME_AREA/$repo\n'
1299 <        txt += '       rm -f $RUNTIME_AREA/$repo \n'
1300 <        txt += '       echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1301 <        txt += '       echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1302 <        txt += '       exit 1\n'
1303 <        txt += '   else\n'
1304 <        txt += '       echo "Sourcing environment... "\n'
1305 <        txt += '       if [ ! -s $VO_CMS_SW_DIR/cmsset_default.sh ] ;then\n'
1306 <        txt += '           echo "SET_CMS_ENV 10020 ==> ERROR cmsset_default.sh file not found into dir $VO_CMS_SW_DIR"\n'
1307 <        txt += '           echo "JOB_EXIT_STATUS = 10020"\n'
1308 <        txt += '           echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
1309 <        txt += '           dumpStatus $RUNTIME_AREA/$repo\n'
1310 <        txt += '           rm -f $RUNTIME_AREA/$repo \n'
1311 <        txt += '           echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1312 <        txt += '           echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1313 <        txt += '           exit 1\n'
1314 <        txt += '       fi\n'
1315 <        txt += '       echo "sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
1316 <        txt += '       source $VO_CMS_SW_DIR/cmsset_default.sh\n'
1317 <        txt += '       result=$?\n'
1318 <        txt += '       if [ $result -ne 0 ]; then\n'
1319 <        txt += '           echo "SET_CMS_ENV 10032 ==> ERROR problem sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
1320 <        txt += '           echo "JOB_EXIT_STATUS = 10032"\n'
1321 <        txt += '           echo "JobExitCode=10032" | tee -a $RUNTIME_AREA/$repo\n'
1322 <        txt += '           dumpStatus $RUNTIME_AREA/$repo\n'
1323 <        txt += '           rm -f $RUNTIME_AREA/$repo \n'
1379 <        txt += '           echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1380 <        txt += '           echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1381 <        txt += '           exit 1\n'
1382 <        txt += '       fi\n'
1383 <        txt += '   fi\n'
1384 <        txt += '   \n'
1385 <        txt += '   echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'
1386 <        txt += '   echo "### END SETUP CMS LCG ENVIRONMENT ###"\n'
1292 >        txt = '    echo ">>> setup CMS LCG environment:"\n'
1293 >        txt += '    echo "set SCRAM ARCH and BUILD_ARCH to ' + self.executable_arch + ' ###"\n'
1294 >        txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
1295 >        txt += '    export BUILD_ARCH='+self.executable_arch+'\n'
1296 >        txt += '    if [ ! $VO_CMS_SW_DIR ] ;then\n'
1297 >        txt += '        echo "SET_CMS_ENV 10031 ==> ERROR CMS software dir not found on WN `hostname`"\n'
1298 >        txt += '        echo "JOB_EXIT_STATUS = 10031" \n'
1299 >        txt += '        echo "JobExitCode=10031" | tee -a $RUNTIME_AREA/$repo\n'
1300 >        txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
1301 >        txt += '        exit 1\n'
1302 >        txt += '    else\n'
1303 >        txt += '        echo "Sourcing environment... "\n'
1304 >        txt += '        if [ ! -s $VO_CMS_SW_DIR/cmsset_default.sh ] ;then\n'
1305 >        txt += '            echo "SET_CMS_ENV 10020 ==> ERROR cmsset_default.sh file not found into dir $VO_CMS_SW_DIR"\n'
1306 >        txt += '            echo "JOB_EXIT_STATUS = 10020"\n'
1307 >        txt += '            echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
1308 >        txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
1309 >        txt += '            exit 1\n'
1310 >        txt += '        fi\n'
1311 >        txt += '        echo "sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
1312 >        txt += '        source $VO_CMS_SW_DIR/cmsset_default.sh\n'
1313 >        txt += '        result=$?\n'
1314 >        txt += '        if [ $result -ne 0 ]; then\n'
1315 >        txt += '            echo "SET_CMS_ENV 10032 ==> ERROR problem sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
1316 >        txt += '            echo "JOB_EXIT_STATUS = 10032"\n'
1317 >        txt += '            echo "JobExitCode=10032" | tee -a $RUNTIME_AREA/$repo\n'
1318 >        txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
1319 >        txt += '            exit 1\n'
1320 >        txt += '        fi\n'
1321 >        txt += '    fi\n'
1322 >        txt += '    \n'
1323 >        txt += '    echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'
1324          return txt
1325  
1326 <    ### FEDE FOR DBS OUTPUT PUBLICATION
1326 >    ### FEDE FOR DBS OUTPUT PUBLICATION
1327      def modifyReport(self, nj):
1328          """
1329 <        insert the part of the script that modifies the FrameworkJob Report
1329 >        insert the part of the script that modifies the FrameworkJob Report
1330          """
1331  
1332 <        txt = ''
1332 >        txt = ''
1333          try:
1334 <            publish_data = int(self.cfg_params['USER.publish_data'])          
1334 >            publish_data = int(self.cfg_params['USER.publish_data'])
1335          except KeyError:
1336              publish_data = 0
1337 <        if (publish_data == 1):  
1338 <            txt += 'echo "Modify Job Report" \n'
1402 <            #txt += 'chmod a+x $RUNTIME_AREA/'+self.version+'/ProdAgentApi/FwkJobRep/ModifyJobReport.py\n'
1337 >        if (publish_data == 1):
1338 >            txt += 'echo ">>> Modify Job Report:" \n'
1339              ################ FEDE FOR DBS2 #############################################
1340 <            txt += 'chmod a+x $SOFTWARE_DIR/ProdAgentApi/FwkJobRep/ModifyJobReport.py\n'
1340 >            #txt += 'chmod a+x $SOFTWARE_DIR/ProdAgentApi/FwkJobRep/ModifyJobReport.py\n'
1341 >            txt += 'chmod a+x $SOFTWARE_DIR/ProdCommon/ProdCommon/FwkJobRep/ModifyJobReport.py\n'
1342              #############################################################################
1406            #try:
1407            #    publish_data = int(self.cfg_params['USER.publish_data'])          
1408            #except KeyError:
1409            #    publish_data = 0
1343  
1344              txt += 'if [ -z "$SE" ]; then\n'
1345              txt += '    SE="" \n'
1346 <            txt += 'fi \n'
1346 >            txt += 'fi \n'
1347              txt += 'if [ -z "$SE_PATH" ]; then\n'
1348              txt += '    SE_PATH="" \n'
1349 <            txt += 'fi \n'
1350 <            txt += 'echo "SE = $SE"\n'
1349 >            txt += 'fi \n'
1350 >            txt += 'echo "SE = $SE"\n'
1351              txt += 'echo "SE_PATH = $SE_PATH"\n'
1352  
1420        #if (publish_data == 1):  
1421            #processedDataset = self.cfg_params['USER.processed_datasetname']
1353              processedDataset = self.cfg_params['USER.publish_data_name']
1354              txt += 'ProcessedDataset='+processedDataset+'\n'
1355              #### LFN=/store/user/<user>/processedDataset_PSETHASH
1356              txt += 'if [ "$SE_PATH" == "" ]; then\n'
1357              #### FEDE: added slash in LFN ##############
1358              txt += '    FOR_LFN=/copy_problems/ \n'
1359 <            txt += 'else \n'
1359 >            txt += 'else \n'
1360              txt += '    tmp=`echo $SE_PATH | awk -F \'store\' \'{print$2}\'` \n'
1361              #####  FEDE TO BE CHANGED, BECAUSE STORE IS HARDCODED!!!! ########
1362              txt += '    FOR_LFN=/store$tmp \n'
1363 <            txt += 'fi \n'
1363 >            txt += 'fi \n'
1364              txt += 'echo "ProcessedDataset = $ProcessedDataset"\n'
1365              txt += 'echo "FOR_LFN = $FOR_LFN" \n'
1366              txt += 'echo "CMSSW_VERSION = $CMSSW_VERSION"\n\n'
1367 <            #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'
1368 <            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'
1369 <            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'
1370 <            #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'
1371 <      
1367 >            #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'
1368 >            #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'
1369 >            txt += 'echo "$SOFTWARE_DIR/ProdCommon/ProdCommon/FwkJobRep/ModifyJobReport.py crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH"\n'
1370 >            txt += '$SOFTWARE_DIR/ProdCommon/ProdCommon/FwkJobRep/ModifyJobReport.py crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH\n'
1371 >
1372              txt += 'modifyReport_result=$?\n'
1373              txt += 'echo modifyReport_result = $modifyReport_result\n'
1374              txt += 'if [ $modifyReport_result -ne 0 ]; then\n'
# Line 1448 | Line 1379 | class Cmssw(JobType):
1379              txt += 'fi\n'
1380          else:
1381              txt += 'echo "no data publication required"\n'
1451            #txt += 'ProcessedDataset=no_data_to_publish \n'
1452            #### FEDE: added slash in LFN ##############
1453            #txt += 'FOR_LFN=/local/ \n'
1454            #txt += 'echo "ProcessedDataset = $ProcessedDataset"\n'
1455            #txt += 'echo "FOR_LFN = $FOR_LFN" \n'
1382          return txt
1383  
1384      def cleanEnv(self):
1385 <        ### OLI_DANIELE
1386 <        txt = ''
1461 <        txt += 'if [ $middleware == OSG ]; then\n'  
1385 >        txt = ''
1386 >        txt += 'if [ $middleware == OSG ]; then\n'
1387          txt += '    cd $RUNTIME_AREA\n'
1388 <        txt += '    echo "Remove working directory: $WORKING_DIR"\n'
1388 >        txt += '    echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
1389 >        txt += '    echo ">>> Remove working directory: $WORKING_DIR"\n'
1390          txt += '    /bin/rm -rf $WORKING_DIR\n'
1391          txt += '    if [ -d $WORKING_DIR ] ;then\n'
1392 <        txt += '              echo "SET_EXE 60999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after cleanup of WN"\n'
1393 <        txt += '              echo "JOB_EXIT_STATUS = 60999"\n'
1394 <        txt += '              echo "JobExitCode=60999" | tee -a $RUNTIME_AREA/$repo\n'
1395 <        txt += '              dumpStatus $RUNTIME_AREA/$repo\n'
1470 <        txt += '        rm -f $RUNTIME_AREA/$repo \n'
1471 <        txt += '        echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1472 <        txt += '        echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1392 >        txt += '        echo "SET_EXE 60999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after cleanup of WN"\n'
1393 >        txt += '        echo "JOB_EXIT_STATUS = 60999"\n'
1394 >        txt += '        echo "JobExitCode=60999" | tee -a $RUNTIME_AREA/$repo\n'
1395 >        txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
1396          txt += '    fi\n'
1397          txt += 'fi\n'
1398          txt += '\n'
# Line 1481 | Line 1404 | class Cmssw(JobType):
1404      def getParams(self):
1405          return self._params
1406  
1484    def setTaskid_(self):
1485        self._taskId = self.cfg_params['taskId']
1486        
1487    def getTaskid(self):
1488        return self._taskId
1489
1407      def uniquelist(self, old):
1408          """
1409          remove duplicates from a list
# Line 1501 | Line 1418 | class Cmssw(JobType):
1418          """
1419          check the dimension of the output files
1420          """
1421 <        txt = 'echo "*****************************************"\n'
1505 <        txt += 'echo "** Starting output sandbox limit check **"\n'
1506 <        txt += 'echo "*****************************************"\n'
1421 >        txt = 'echo ">>> Starting output sandbox limit check :"\n'
1422          allOutFiles = ""
1423          listOutFiles = []
1424 <        for fileOut in (self.output_file+self.output_file_sandbox):
1425 <             if fileOut.find('crab_fjr') == -1:
1426 <                 allOutFiles = allOutFiles + " " + self.numberFile_(fileOut, '$NJob')
1427 <                 listOutFiles.append(self.numberFile_(fileOut, '$NJob'))
1424 >        txt += 'stdoutFile=`ls *stdout` \n'
1425 >        txt += 'stderrFile=`ls *stderr` \n'
1426 >        if (self.return_data == 1):
1427 >            for fileOut in (self.output_file+self.output_file_sandbox):
1428 >                allOutFiles = allOutFiles + " " + self.numberFile_(fileOut, '$NJob') + " $stdoutFile $stderrFile"
1429 >        else:            
1430 >            for fileOut in (self.output_file_sandbox):
1431 >                txt += 'echo " '+fileOut+'";\n'
1432 >                allOutFiles = allOutFiles + " " + self.numberFile_(fileOut, '$NJob') + " $stdoutFile $stderrFile"
1433          txt += 'echo "OUTPUT files: '+str(allOutFiles)+'";\n'
1434          txt += 'ls -gGhrta;\n'
1435          txt += 'sum=0;\n'
# Line 1527 | Line 1447 | class Cmssw(JobType):
1447          txt += 'if [ $limit -lt $sum ]; then\n'
1448          txt += '    echo "WARNING: output files have to big size - something will be lost;"\n'
1449          txt += '    echo "         checking the output file sizes..."\n'
1530        """
1531        txt += '    dim=0;\n'
1532        txt += '    exclude=0;\n'
1533        txt += '    for files in '+str(allOutFiles)+' ; do\n'
1534        txt += '        sumTemp=0;\n'
1535        txt += '        for file2 in '+str(allOutFiles)+' ; do\n'
1536        txt += '            if [ $file != $file2 ]; then\n'
1537        txt += '                tt=`ls -gGrta $file2 | awk \'{ print $3 }\';`\n'
1538        txt += '                sumTemp=`expr $sumTemp + $tt`;\n'
1539        txt += '            fi\n'
1540        txt += '        done\n'
1541        txt += '        if [ $sumTemp -lt $limit ]; then\n'
1542        txt += '            if [ $dim -lt $sumTemp ]; then\n'
1543        txt += '                dim=$sumTemp;\n'
1544        txt += '                exclude=$file;\n'
1545        txt += '            fi\n'
1546        txt += '        fi\n'
1547        txt += '    done\n'
1548        txt += '    echo "Dimension calculated: $dim"; echo "File to exclude: $exclude";\n'
1549        """
1450          txt += '    tot=0;\n'
1451 <        txt += '    for file2 in '+str(allOutFiles)+' ; do\n'
1452 <        txt += '        tt=`ls -gGrta $file2 | awk \'{ print $3 }\';`\n'
1451 >        txt += '    for filefile in '+str(allOutFiles)+' ; do\n'
1452 >        txt += '        dimFile=`ls -gGrta $filefile | awk \'{ print $3 }\';`\n'
1453          txt += '        tot=`expr $tot + $tt`;\n'
1454 <        txt += '        if [ $limit -lt $tot ]; then\n'
1455 <        txt += '            tot=`expr $tot - $tt`;\n'
1456 <        txt += '            fileLast=$file;\n'
1457 <        txt += '            break;\n'
1458 <        txt += '        fi\n'
1459 <        txt += '    done\n'
1460 <        txt += '    echo "Dimension calculated: $tot"; echo "First file to exclude: $file";\n'
1461 <        txt += '    flag=0;\n'    
1562 <        txt += '    for filess in '+str(allOutFiles)+' ; do\n'
1563 <        txt += '        if [ $fileLast = $filess ]; then\n'
1564 <        txt += '            flag=1;\n'
1565 <        txt += '        fi\n'
1566 <        txt += '        if [ $flag -eq 1 ]; then\n'
1567 <        txt += '            rm -f $filess;\n'
1454 >        txt += '        if [ $limit -lt $dimFile ]; then\n'
1455 >        txt += '            echo "deleting file: $filefile";\n'
1456 >        txt += '            rm -f $filefile\n'
1457 >        txt += '        elif [ $limit -lt $tot ]; then\n'
1458 >        txt += '            echo "deleting file: $filefile";\n'
1459 >        txt += '            rm -f $filefile\n'
1460 >        txt += '        else\n'
1461 >        txt += '            echo "saving file: $filefile"\n'
1462          txt += '        fi\n'
1463          txt += '    done\n'
1464 +
1465          txt += '    ls -agGhrt;\n'
1466          txt += '    echo "WARNING: output files are too big in dimension: can not put in the output_sandbox.";\n'
1467          txt += '    echo "JOB_EXIT_STATUS = 70000";\n'
# Line 1574 | Line 1469 | class Cmssw(JobType):
1469          txt += 'else'
1470          txt += '    echo "Total Output dimension $sum is fine.";\n'
1471          txt += 'fi\n'
1472 <        txt += 'echo "*****************************************"\n'
1578 <        txt += 'echo "*** Ending output sandbox limit check ***"\n'
1579 <        txt += 'echo "*****************************************"\n'
1472 >        txt += 'echo "Ending output sandbox limit check"\n'
1473          return txt

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines