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.73 by gutsche, Sun Apr 8 18:39:51 2007 UTC vs.
Revision 1.108 by gutsche, Thu Jul 26 03:02:58 2007 UTC

# Line 2 | Line 2 | from JobType import JobType
2   from crab_logger import Logger
3   from crab_exceptions import *
4   from crab_util import *
5 + from BlackWhiteListParser import BlackWhiteListParser
6   import common
6 import PsetManipulator  
7 import DataDiscovery
8 import DataDiscovery_DBS2
9 import DataLocation
7   import Scram
8  
9 < import os, string, re, shutil, glob
9 > import os, string, glob
10  
11   class Cmssw(JobType):
12      def __init__(self, cfg_params, ncjobs):
13          JobType.__init__(self, 'CMSSW')
14          common.logger.debug(3,'CMSSW::__init__')
15  
19        # Marco.
16          self._params = {}
17          self.cfg_params = cfg_params
18  
19 +        # init BlackWhiteListParser
20 +        self.blackWhiteListParser = BlackWhiteListParser(cfg_params)
21 +
22          try:
23              self.MaxTarBallSize = float(self.cfg_params['EDG.maxtarballsize'])
24          except KeyError:
25 <            self.MaxTarBallSize = 100.0
25 >            self.MaxTarBallSize = 9.5
26  
27          # number of jobs requested to be created, limit obj splitting
28          self.ncjobs = ncjobs
# Line 36 | Line 35 | class Cmssw(JobType):
35          self.executable = ''
36          self.executable_arch = self.scram.getArch()
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  
41          self.datasetPath = '' #scrip use case Da
# Line 51 | Line 51 | class Cmssw(JobType):
51  
52          ## get DBS mode
53          try:
54 <            self.use_dbs_2 = int(self.cfg_params['CMSSW.use_dbs_2'])
54 >            self.use_dbs_1 = int(self.cfg_params['CMSSW.use_dbs_1'])
55          except KeyError:
56 <            self.use_dbs_2 = 0
56 >            self.use_dbs_1 = 0
57              
58          try:
59              tmp =  cfg_params['CMSSW.datasetpath']
# Line 74 | Line 74 | class Cmssw(JobType):
74              self.setParam_('dataset', 'None')
75              self.setParam_('owner', 'None')
76          else:
77 <            datasetpath_split = self.datasetPath.split("/")
78 <            self.setParam_('dataset', datasetpath_split[1])
79 <            self.setParam_('owner', datasetpath_split[-1])
80 <
77 >            try:
78 >                datasetpath_split = self.datasetPath.split("/")
79 >                # standard style
80 >                if self.use_dbs_1 == 1 :
81 >                    self.setParam_('dataset', datasetpath_split[1])
82 >                    self.setParam_('owner', datasetpath_split[-1])
83 >                else:
84 >                    self.setParam_('dataset', datasetpath_split[1])
85 >                    self.setParam_('owner', datasetpath_split[2])
86 >            except:
87 >                self.setParam_('dataset', self.datasetPath)
88 >                self.setParam_('owner', self.datasetPath)
89 >                
90          self.setTaskid_()
91          self.setParam_('taskId', self.cfg_params['taskId'])
92  
# Line 127 | Line 136 | class Cmssw(JobType):
136                      self.output_file.append(tmp)
137                      pass
138              else:
139 <                log.message("No output file defined: only stdout/err and the CRAB Framework Job Report will be available")
139 >                log.message("No output file defined: only stdout/err and the CRAB Framework Job Report will be available\n")
140                  pass
141              pass
142          except KeyError:
143 <            log.message("No output file defined: only stdout/err and the CRAB Framework Job Report will be available")
143 >            log.message("No output file defined: only stdout/err and the CRAB Framework Job Report will be available\n")
144              pass
145  
146          # script_exe file as additional file in inputSandbox
# Line 157 | Line 166 | class Cmssw(JobType):
166                  tmp = string.strip(tmp)
167                  dirname = ''
168                  if not tmp[0]=="/": dirname = "."
169 <                files = glob.glob(os.path.join(dirname, tmp))
169 >                files = []
170 >                if string.find(tmp,"*")>-1:
171 >                    files = glob.glob(os.path.join(dirname, tmp))
172 >                    if len(files)==0:
173 >                        raise CrabException("No additional input file found with this pattern: "+tmp)
174 >                else:
175 >                    files.append(tmp)
176                  for file in files:
177                      if not os.path.exists(file):
178                          raise CrabException("Additional input file not found: "+file)
179                      pass
180 <                    storedFile = common.work_space.shareDir()+file
181 <                    shutil.copyfile(file, storedFile)
182 <                    self.additional_inbox_files.append(string.strip(storedFile))
180 >                    # fname = string.split(file, '/')[-1]
181 >                    # storedFile = common.work_space.pathForTgz()+'share/'+fname
182 >                    # shutil.copyfile(file, storedFile)
183 >                    self.additional_inbox_files.append(string.strip(file))
184                  pass
185              pass
186              common.logger.debug(5,"Additional input files: "+str(self.additional_inbox_files))
# Line 222 | Line 238 | class Cmssw(JobType):
238          except KeyError:
239              self.sourceSeedVtx = None
240              common.logger.debug(5,"No vertex seed given")
241 +
242 +        try:
243 +            self.sourceSeedG4 = int(cfg_params['CMSSW.g4_seed'])
244 +        except KeyError:
245 +            self.sourceSeedG4 = None
246 +            common.logger.debug(5,"No g4 sim hits seed given")
247 +
248 +        try:
249 +            self.sourceSeedMix = int(cfg_params['CMSSW.mix_seed'])
250 +        except KeyError:
251 +            self.sourceSeedMix = None
252 +            common.logger.debug(5,"No mix seed given")
253 +
254          try:
255              self.firstRun = int(cfg_params['CMSSW.first_run'])
256          except KeyError:
257              self.firstRun = None
258              common.logger.debug(5,"No first run given")
259          if self.pset != None: #CarlosDaniele
260 <            self.PsetEdit = PsetManipulator.PsetManipulator(self.pset) #Daniele Pset
260 >            ver = string.split(self.version,"_")
261 >            if (int(ver[1])>=1 and int(ver[2])>=5):
262 >                import PsetManipulator150 as pp
263 >            else:
264 >                import PsetManipulator as pp
265 >            PsetEdit = pp.PsetManipulator(self.pset) #Daniele Pset
266  
267          #DBSDLS-start
268          ## Initialize the variables that are extracted from DBS/DLS and needed in other places of the code
# Line 250 | Line 284 | class Cmssw(JobType):
284                  self.jobSplittingForScript()
285              else:
286                  self.jobSplittingNoInput()
287 <        else:
287 >        else:
288              self.jobSplittingByBlocks(blockSites)
289  
290          # modify Pset
# Line 258 | Line 292 | class Cmssw(JobType):
292              try:
293                  if (self.datasetPath): # standard job
294                      # allow to processa a fraction of events in a file
295 <                    self.PsetEdit.inputModule("INPUT")
296 <                    self.PsetEdit.maxEvent("INPUTMAXEVENTS")
297 <                    self.PsetEdit.skipEvent("INPUTSKIPEVENTS")
295 >                    PsetEdit.inputModule("INPUT")
296 >                    PsetEdit.maxEvent("INPUTMAXEVENTS")
297 >                    PsetEdit.skipEvent("INPUTSKIPEVENTS")
298                  else:  # pythia like job
299 <                    self.PsetEdit.maxEvent(self.eventsPerJob)
299 >                    PsetEdit.maxEvent(self.eventsPerJob)
300                      if (self.firstRun):
301 <                        self.PsetEdit.pythiaFirstRun("INPUTFIRSTRUN")  #First Run
301 >                        PsetEdit.pythiaFirstRun("INPUTFIRSTRUN")  #First Run
302                      if (self.sourceSeed) :
303 <                        self.PsetEdit.pythiaSeed("INPUT")
303 >                        PsetEdit.pythiaSeed("INPUT")
304                          if (self.sourceSeedVtx) :
305 <                            self.PsetEdit.pythiaSeedVtx("INPUTVTX")
305 >                            PsetEdit.vtxSeed("INPUTVTX")
306 >                        if (self.sourceSeedG4) :
307 >                            self.PsetEdit.g4Seed("INPUTG4")
308 >                        if (self.sourceSeedMix) :
309 >                            self.PsetEdit.mixSeed("INPUTMIX")
310                  # add FrameworkJobReport to parameter-set
311 <                self.PsetEdit.addCrabFJR(self.fjrFileName)
312 <                self.PsetEdit.psetWriter(self.configFilename())
311 >                PsetEdit.addCrabFJR(self.fjrFileName)
312 >                PsetEdit.psetWriter(self.configFilename())
313              except:
314                  msg='Error while manipuliating ParameterSet: exiting...'
315                  raise CrabException(msg)
316  
317      def DataDiscoveryAndLocation(self, cfg_params):
318  
319 +        import DataDiscovery
320 +        import DataDiscovery_DBS2
321 +        import DataLocation
322          common.logger.debug(10,"CMSSW::DataDiscoveryAndLocation()")
323  
324          datasetPath=self.datasetPath
325  
326          ## Contact the DBS
327 <        common.logger.message("Contacting DBS...")
327 >        common.logger.message("Contacting Data Discovery Services ...")
328          try:
329  
330 <            if self.use_dbs_2 == 1 :
290 <                self.pubdata=DataDiscovery_DBS2.DataDiscovery_DBS2(datasetPath, cfg_params)
291 <            else :
330 >            if self.use_dbs_1 == 1 :
331                  self.pubdata=DataDiscovery.DataDiscovery(datasetPath, cfg_params)
332 +            else :
333 +                self.pubdata=DataDiscovery_DBS2.DataDiscovery_DBS2(datasetPath, cfg_params)
334              self.pubdata.fetchDBSInfo()
335  
336          except DataDiscovery.NotExistingDatasetError, ex :
# Line 311 | Line 352 | class Cmssw(JobType):
352              msg = 'ERROR ***: failed Data Discovery in DBS :  %s'%ex.getErrorMessage()
353              raise CrabException(msg)
354  
314        ## get list of all required data in the form of dbs paths  (dbs path = /dataset/datatier/owner)
315        common.logger.message("Required data are :"+self.datasetPath)
316
355          self.filesbyblock=self.pubdata.getFiles()
356          self.eventsbyblock=self.pubdata.getEventsPerBlock()
357          self.eventsbyfile=self.pubdata.getEventsPerFile()
358  
359          ## get max number of events
360          self.maxEvents=self.pubdata.getMaxEvents() ##  self.maxEvents used in Creator.py
323        common.logger.message("The number of available events is %s\n"%self.maxEvents)
361  
325        common.logger.message("Contacting DLS...")
362          ## Contact the DLS and build a list of sites hosting the fileblocks
363          try:
364              dataloc=DataLocation.DataLocation(self.filesbyblock.keys(),cfg_params)
# Line 340 | Line 376 | class Cmssw(JobType):
376                  allSites.append(oneSite)
377          allSites = self.uniquelist(allSites)
378  
379 <        common.logger.message("Sites ("+str(len(allSites))+") hosting part/all of dataset: "+str(allSites))
380 <        common.logger.debug(6, "List of Sites: "+str(allSites))
379 >        # screen output
380 >        common.logger.message("Requested dataset: " + datasetPath + " has " + str(self.maxEvents) + " events in " + str(len(self.filesbyblock.keys())) + " blocks.\n")
381 >
382          return sites
383      
384      def jobSplittingByBlocks(self, blockSites):
# Line 403 | Line 440 | class Cmssw(JobType):
440          jobCount = 0
441          list_of_lists = []
442  
443 +        # list tracking which jobs are in which jobs belong to which block
444 +        jobsOfBlock = {}
445 +
446          # ---- Iterate over the blocks in the dataset until ---- #
447          # ---- we've met the requested total # of events    ---- #
448          while ( (eventsRemaining > 0) and (blockCount < numBlocksInDataset) and (jobCount < totalNumberOfJobs)):
449              block = blocks[blockCount]
450              blockCount += 1
451 +            if block not in jobsOfBlock.keys() :
452 +                jobsOfBlock[block] = []
453              
454              if self.eventsbyblock.has_key(block) :
455                  numEventsInBlock = self.eventsbyblock[block]
# Line 457 | Line 499 | class Cmssw(JobType):
499                              common.logger.debug(3,"Job "+str(jobCount+1)+" can run over "+str(filesEventCount - jobSkipEventCount)+" events (last file in block).")
500                              self.jobDestination.append(blockSites[block])
501                              common.logger.debug(5,"Job "+str(jobCount+1)+" Destination: "+str(self.jobDestination[jobCount]))
502 +                            # fill jobs of block dictionary
503 +                            jobsOfBlock[block].append(jobCount+1)
504                              # reset counter
505                              jobCount = jobCount + 1
506                              totalEventCount = totalEventCount + filesEventCount - jobSkipEventCount
# Line 480 | Line 524 | class Cmssw(JobType):
524                          common.logger.debug(3,"Job "+str(jobCount+1)+" can run over "+str(eventsPerJobRequested)+" events.")
525                          self.jobDestination.append(blockSites[block])
526                          common.logger.debug(5,"Job "+str(jobCount+1)+" Destination: "+str(self.jobDestination[jobCount]))
527 +                        jobsOfBlock[block].append(jobCount+1)
528                          # reset counter
529                          jobCount = jobCount + 1
530                          totalEventCount = totalEventCount + eventsPerJobRequested
# Line 500 | Line 545 | class Cmssw(JobType):
545                          common.logger.debug(3,"Job "+str(jobCount+1)+" can run over "+str(eventsPerJobRequested)+" events.")
546                          self.jobDestination.append(blockSites[block])
547                          common.logger.debug(5,"Job "+str(jobCount+1)+" Destination: "+str(self.jobDestination[jobCount]))
548 +                        jobsOfBlock[block].append(jobCount+1)
549                          # increase counter
550                          jobCount = jobCount + 1
551                          totalEventCount = totalEventCount + eventsPerJobRequested
# Line 517 | Line 563 | class Cmssw(JobType):
563          self.ncjobs = self.total_number_of_jobs = jobCount
564          if (eventsRemaining > 0 and jobCount < totalNumberOfJobs ):
565              common.logger.message("Could not run on all requested events because some blocks not hosted at allowed sites.")
566 <        common.logger.message("\n"+str(jobCount)+" job(s) can run on "+str(totalEventCount)+" events.\n")
566 >        common.logger.message(str(jobCount)+" job(s) can run on "+str(totalEventCount)+" events.\n")
567          
568 +        # screen output
569 +        screenOutput = "List of jobs and available destination sites:\n\n"
570 +
571 +        blockCounter = 0
572 +        for block in blocks:
573 +            if block in jobsOfBlock.keys() :
574 +                blockCounter += 1
575 +                screenOutput += "Block %5i: jobs %20s: sites: %s\n" % (blockCounter,spanRanges(jobsOfBlock[block]),','.join(self.blackWhiteListParser.checkWhiteList(self.blackWhiteListParser.checkBlackList(blockSites[block],block),block)))
576 +
577 +        common.logger.message(screenOutput)
578 +
579          self.list_of_args = list_of_lists
580          return
581  
# Line 563 | Line 620 | class Cmssw(JobType):
620              ## Since there is no input, any site is good
621             # self.jobDestination.append(["Any"])
622              self.jobDestination.append([""]) #must be empty to write correctly the xml
623 <            args=''
623 >            args=[]
624              if (self.firstRun):
625                      ## pythia first run
626                  #self.list_of_args.append([(str(self.firstRun)+str(i))])
627 <                args=args+(str(self.firstRun)+str(i))
627 >                args.append(str(self.firstRun)+str(i))
628              else:
629                  ## no first run
630                  #self.list_of_args.append([str(i)])
631 <                args=args+str(i)
631 >                args.append(str(i))
632              if (self.sourceSeed):
633 +                args.append(str(self.sourceSeed)+str(i))
634                  if (self.sourceSeedVtx):
635 <                    ## pythia + vtx random seed
636 <                    #self.list_of_args.append([
637 <                    #                          str(self.sourceSeed)+str(i),
638 <                    #                          str(self.sourceSeedVtx)+str(i)
639 <                    #                          ])
640 <                    args=args+str(',')+str(self.sourceSeed)+str(i)+str(',')+str(self.sourceSeedVtx)+str(i)
641 <                else:
642 <                    ## only pythia random seed
643 <                    #self.list_of_args.append([(str(self.sourceSeed)+str(i))])
644 <                    args=args +str(',')+str(self.sourceSeed)+str(i)
645 <            else:
646 <                ## no random seed
589 <                if str(args)=='': args=args+(str(self.firstRun)+str(i))
590 <            arguments=args.split(',')
591 <            if len(arguments)==3:self.list_of_args.append([str(arguments[0]),str(arguments[1]),str(arguments[2])])
592 <            elif len(arguments)==2:self.list_of_args.append([str(arguments[0]),str(arguments[1])])
593 <            else :self.list_of_args.append([str(arguments[0])])
635 >                    ## + vtx random seed
636 >                    args.append(str(self.sourceSeedVtx)+str(i))
637 >                if (self.sourceSeedG4):
638 >                    ## + G4 random seed
639 >                    args.append(str(self.sourceSeedG4)+str(i))
640 >                if (self.sourceSeedMix):    
641 >                    ## + Mix random seed
642 >                    args.append(str(self.sourceSeedMix)+str(i))
643 >                pass
644 >            pass
645 >            self.list_of_args.append(args)
646 >        pass
647              
648 <     #   print self.list_of_args
648 >        # print self.list_of_args
649  
650          return
651  
# Line 687 | Line 740 | class Cmssw(JobType):
740          try: # create tar ball
741              tar = tarfile.open(self.tgzNameWithPath, "w:gz")
742              ## First find the executable
743 <            if (executable != ''):
743 >            if (self.executable != ''):
744                  exeWithPath = self.scram.findFile_(executable)
745                  if ( not exeWithPath ):
746                      raise CrabException('User executable '+executable+' not found')
# Line 697 | Line 750 | class Cmssw(JobType):
750                      # the exe is private, so we must ship
751                      common.logger.debug(5,"Exe "+exeWithPath+" to be tarred")
752                      path = swArea+'/'
753 <                    exe = string.replace(exeWithPath, path,'')
754 <                    tar.add(path+exe,executable)
753 >                    # distinguish case when script is in user project area or given by full path somewhere else
754 >                    if exeWithPath.find(path) >= 0 :
755 >                        exe = string.replace(exeWithPath, path,'')
756 >                        tar.add(path+exe,os.path.basename(executable))
757 >                    else :
758 >                        tar.add(exeWithPath,os.path.basename(executable))
759                      pass
760                  else:
761                      # the exe is from release, we'll find it on WN
# Line 729 | Line 786 | class Cmssw(JobType):
786              pa = os.environ['CRABDIR'] + '/' + 'ProdAgentApi'
787              if os.path.isdir(pa):
788                  tar.add(pa,paDir)
789 +
790 +            ### FEDE FOR DBS PUBLICATION
791 +            ## Add PRODCOMMON dir to tar
792 +            prodcommonDir = 'ProdCommon'
793 +            prodcommonPath = os.environ['CRABDIR'] + '/' + 'ProdCommon'
794 +            if os.path.isdir(prodcommonPath):
795 +                tar.add(prodcommonPath,prodcommonDir)
796 +            #############################    
797          
798              common.logger.debug(5,"Files added to "+self.tgzNameWithPath+" : "+str(tar.getnames()))
799              tar.close()
# Line 754 | Line 819 | class Cmssw(JobType):
819          
820          return
821          
822 +    def additionalInputFileTgz(self):
823 +        """
824 +        Put all additional files into a tar ball and return its name
825 +        """
826 +        import tarfile
827 +        tarName=  common.work_space.pathForTgz()+'share/'+self.additional_tgz_name
828 +        tar = tarfile.open(tarName, "w:gz")
829 +        for file in self.additional_inbox_files:
830 +            tar.add(file,string.split(file,'/')[-1])
831 +        common.logger.debug(5,"Files added to "+self.additional_tgz_name+" : "+str(tar.getnames()))
832 +        tar.close()
833 +        return tarName
834 +
835      def wsSetupEnvironment(self, nj):
836          """
837          Returns part of a job script which prepares
# Line 764 | Line 842 | class Cmssw(JobType):
842    
843          ## OLI_Daniele at this level  middleware already known
844  
845 +        txt += 'echo "### Firtst set SCRAM ARCH and BUILD_ARCH ###"\n'
846 +        txt += 'echo "Setting SCRAM_ARCH='+self.executable_arch+'"\n'
847 +        txt += 'export SCRAM_ARCH='+self.executable_arch+'\n'
848 +        txt += 'export BUILD_ARCH='+self.executable_arch+'\n'
849          txt += 'if [ $middleware == LCG ]; then \n'
850          txt += self.wsSetupCMSLCGEnvironment_()
851          txt += 'elif [ $middleware == OSG ]; then\n'
# Line 771 | Line 853 | class Cmssw(JobType):
853          txt += '    echo "Created working directory: $WORKING_DIR"\n'
854          txt += '    if [ ! -d $WORKING_DIR ] ;then\n'
855          txt += '        echo "SET_CMS_ENV 10016 ==> OSG $WORKING_DIR could not be created on WN `hostname`"\n'
856 <        txt += '        echo "JOB_EXIT_STATUS = 10016"\n'
857 <        txt += '        echo "JobExitCode=10016" | tee -a $RUNTIME_AREA/$repo\n'
858 <        txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
856 >        txt += '    echo "JOB_EXIT_STATUS = 10016"\n'
857 >        txt += '    echo "JobExitCode=10016" | tee -a $RUNTIME_AREA/$repo\n'
858 >        txt += '    dumpStatus $RUNTIME_AREA/$repo\n'
859          txt += '        rm -f $RUNTIME_AREA/$repo \n'
860          txt += '        echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
861          txt += '        echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
# Line 805 | Line 887 | class Cmssw(JobType):
887          txt += '        cd $RUNTIME_AREA\n'
888          txt += '        /bin/rm -rf $WORKING_DIR\n'
889          txt += '        if [ -d $WORKING_DIR ] ;then\n'
890 <        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'
891 <        txt += '            echo "JOB_EXIT_STATUS = 10018"\n'
892 <        txt += '            echo "JobExitCode=10018" | tee -a $RUNTIME_AREA/$repo\n'
893 <        txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
890 >        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'
891 >        txt += '            echo "JOB_EXIT_STATUS = 10018"\n'
892 >        txt += '            echo "JobExitCode=10018" | tee -a $RUNTIME_AREA/$repo\n'
893 >        txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
894          txt += '            rm -f $RUNTIME_AREA/$repo \n'
895          txt += '            echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
896          txt += '            echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
# Line 817 | Line 899 | class Cmssw(JobType):
899          txt += '   exit 1 \n'
900          txt += 'fi \n'
901          txt += 'echo "CMSSW_VERSION =  '+self.version+'"\n'
820        txt += 'export SCRAM_ARCH='+self.executable_arch+'\n'
902          txt += 'cd '+self.version+'\n'
903 +        ########## FEDE FOR DBS2 ######################
904 +        txt += 'SOFTWARE_DIR=`pwd`\n'
905 +        txt += 'echo SOFTWARE_DIR=$SOFTWARE_DIR \n'
906 +        ###############################################
907          ### needed grep for bug in scramv1 ###
908          txt += scram+' runtime -sh\n'
909          txt += 'eval `'+scram+' runtime -sh | grep -v SCRAMRT_LSB_JOBNAME`\n'
# Line 844 | Line 929 | class Cmssw(JobType):
929          txt += '        cd $RUNTIME_AREA\n'
930          txt += '        /bin/rm -rf $WORKING_DIR\n'
931          txt += '        if [ -d $WORKING_DIR ] ;then\n'
932 <        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'
933 <        txt += '            echo "JOB_EXIT_STATUS = 50114"\n'
934 <        txt += '            echo "JobExitCode=50114" | tee -a $RUNTIME_AREA/$repo\n'
935 <        txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
932 >        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'
933 >        txt += '            echo "JOB_EXIT_STATUS = 50114"\n'
934 >        txt += '            echo "JobExitCode=50114" | tee -a $RUNTIME_AREA/$repo\n'
935 >        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'
# Line 859 | Line 944 | class Cmssw(JobType):
944  
945          # Prepare job-specific part
946          job = common.job_list[nj]
947 +        ### FEDE FOR DBS OUTPUT PUBLICATION
948 +        if (self.datasetPath):
949 +            txt += '\n'
950 +            txt += 'DatasetPath='+self.datasetPath+'\n'
951 +
952 +            datasetpath_split = self.datasetPath.split("/")
953 +            
954 +            txt += 'PrimaryDataset='+datasetpath_split[1]+'\n'
955 +            txt += 'DataTier='+datasetpath_split[2]+'\n'
956 +            #txt += 'ProcessedDataset='+datasetpath_split[3]+'\n'
957 +            txt += 'ApplicationFamily=cmsRun\n'
958 +
959 +        else:
960 +            txt += 'DatasetPath=MCDataTier\n'
961 +            txt += 'PrimaryDataset=null\n'
962 +            txt += 'DataTier=null\n'
963 +            #txt += 'ProcessedDataset=null\n'
964 +            txt += 'ApplicationFamily=MCDataTier\n'
965          if self.pset != None: #CarlosDaniele
966              pset = os.path.basename(job.configFilename())
967              txt += '\n'
968 +            txt += 'cp  $RUNTIME_AREA/'+pset+' .\n'
969              if (self.datasetPath): # standard job
970                  #txt += 'InputFiles=$2\n'
971                  txt += 'InputFiles=${args[1]}\n'
972                  txt += 'MaxEvents=${args[2]}\n'
973                  txt += 'SkipEvents=${args[3]}\n'
974                  txt += 'echo "Inputfiles:<$InputFiles>"\n'
975 <                txt += 'sed "s#{\'INPUT\'}#$InputFiles#" $RUNTIME_AREA/'+pset+' > pset_tmp_1.cfg\n'
975 >                txt += 'sed "s#{\'INPUT\'}#$InputFiles#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
976                  txt += 'echo "MaxEvents:<$MaxEvents>"\n'
977 <                txt += 'sed "s#INPUTMAXEVENTS#$MaxEvents#" pset_tmp_1.cfg > pset_tmp_2.cfg\n'
977 >                txt += 'sed "s#INPUTMAXEVENTS#$MaxEvents#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
978                  txt += 'echo "SkipEvents:<$SkipEvents>"\n'
979 <                txt += 'sed "s#INPUTSKIPEVENTS#$SkipEvents#" pset_tmp_2.cfg > pset.cfg\n'
979 >                txt += 'sed "s#INPUTSKIPEVENTS#$SkipEvents#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
980              else:  # pythia like job
981 <                if (self.sourceSeed):
982 <                    txt += 'FirstRun=${args[1]}\n'
981 >                seedIndex=1
982 >                if (self.firstRun):
983 >                    txt += 'FirstRun=${args['+str(seedIndex)+']}\n'
984                      txt += 'echo "FirstRun: <$FirstRun>"\n'
985 <                    txt += 'sed "s#\<INPUTFIRSTRUN\>#$FirstRun#" $RUNTIME_AREA/'+pset+' > tmp_1.cfg\n'
986 <                else:
987 <                    txt += '# Copy untouched pset\n'
883 <                    txt += 'cp $RUNTIME_AREA/'+pset+' tmp_1.cfg\n'
985 >                    txt += 'sed "s#\<INPUTFIRSTRUN\>#$FirstRun#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
986 >                    seedIndex=seedIndex+1
987 >
988                  if (self.sourceSeed):
989 < #                    txt += 'Seed=$2\n'
990 <                    txt += 'Seed=${args[2]}\n'
991 <                    txt += 'echo "Seed: <$Seed>"\n'
992 <                    txt += 'sed "s#\<INPUT\>#$Seed#" tmp_1.cfg > tmp_2.cfg\n'
989 >                    txt += 'Seed=${args['+str(seedIndex)+']}\n'
990 >                    txt += 'sed "s#\<INPUT\>#$Seed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
991 >                    seedIndex=seedIndex+1
992 >                    ## the following seeds are not always present
993                      if (self.sourceSeedVtx):
994 < #                        txt += 'VtxSeed=$3\n'
891 <                        txt += 'VtxSeed=${args[3]}\n'
994 >                        txt += 'VtxSeed=${args['+str(seedIndex)+']}\n'
995                          txt += 'echo "VtxSeed: <$VtxSeed>"\n'
996 <                        txt += 'sed "s#INPUTVTX#$VtxSeed#" tmp_2.cfg > pset.cfg\n'
997 <                    else:
998 <                        txt += 'mv tmp_2.cfg pset.cfg\n'
999 <                else:
1000 <                    txt += 'mv tmp_1.cfg pset.cfg\n'
1001 <                   # txt += '# Copy untouched pset\n'
1002 <                   # txt += 'cp $RUNTIME_AREA/'+pset+' pset.cfg\n'
1003 <
996 >                        txt += 'sed "s#\<INPUTVTX\>#$VtxSeed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
997 >                        seedIndex += 1
998 >                    if (self.sourceSeedG4):
999 >                        txt += 'G4Seed=${args['+str(seedIndex)+']}\n'
1000 >                        txt += 'echo "G4Seed: <$G4Seed>"\n'
1001 >                        txt += 'sed "s#\<INPUTG4\>#$G4Seed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
1002 >                        seedIndex += 1
1003 >                    if (self.sourceSeedMix):
1004 >                        txt += 'mixSeed=${args['+str(seedIndex)+']}\n'
1005 >                        txt += 'echo "MixSeed: <$mixSeed>"\n'
1006 >                        txt += 'sed "s#\<INPUTMIX\>#$mixSeed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
1007 >                        seedIndex += 1
1008 >                    pass
1009 >                pass
1010 >            txt += 'mv -f '+pset+' pset.cfg\n'
1011  
1012          if len(self.additional_inbox_files) > 0:
1013 <            for file in self.additional_inbox_files:
1014 <                relFile = file.split("/")[-1]
1015 <                txt += 'if [ -e $RUNTIME_AREA/'+relFile+' ] ; then\n'
906 <                txt += '   cp $RUNTIME_AREA/'+relFile+' .\n'
907 <                txt += '   chmod +x '+relFile+'\n'
908 <                txt += 'fi\n'
1013 >            txt += 'if [ -e $RUNTIME_AREA/'+self.additional_tgz_name+' ] ; then\n'
1014 >            txt += '  tar xzvf $RUNTIME_AREA/'+self.additional_tgz_name+'\n'
1015 >            txt += 'fi\n'
1016              pass
1017  
1018          if self.pset != None: #CarlosDaniele
# Line 916 | Line 1023 | class Cmssw(JobType):
1023              txt += 'cat pset.cfg\n'
1024              txt += 'echo "****** end pset.cfg ********"\n'
1025              txt += '\n'
1026 +            ### FEDE FOR DBS OUTPUT PUBLICATION
1027 +            txt += 'PSETHASH=`EdmConfigHash < pset.cfg` \n'
1028 +            txt += 'echo "PSETHASH = $PSETHASH" \n'
1029 +            ##############
1030 +            txt += '\n'
1031              # txt += 'echo "***** cat pset1.cfg *********"\n'
1032              # txt += 'cat pset1.cfg\n'
1033              # txt += 'echo "****** end pset1.cfg ********"\n'
# Line 957 | Line 1069 | class Cmssw(JobType):
1069              txt += '   echo "Successful untar" \n'
1070              txt += 'fi \n'
1071              txt += '\n'
1072 <            txt += 'echo "Include ProdAgentApi in PYTHONPATH"\n'
1072 >            txt += 'echo "Include ProdAgentApi and PRODCOMMON in PYTHONPATH"\n'
1073              txt += 'if [ -z "$PYTHONPATH" ]; then\n'
1074 <            txt += '   export PYTHONPATH=ProdAgentApi\n'
1074 >            #### FEDE FOR DBS OUTPUT PUBLICATION
1075 >            txt += '   export PYTHONPATH=$SOFTWARE_DIR/ProdAgentApi:$SOFTWARE_DIR/ProdCommon\n'
1076 >            #txt += '   export PYTHONPATH=`pwd`/ProdAgentApi:`pwd`/ProdCommon\n'
1077 >            #txt += '   export PYTHONPATH=ProdAgentApi\n'
1078              txt += 'else\n'
1079 <            txt += '   export PYTHONPATH=ProdAgentApi:${PYTHONPATH}\n'
1079 >            txt += '   export PYTHONPATH=$SOFTWARE_DIR/ProdAgentApi:$SOFTWARE_DIR/ProdCommon:${PYTHONPATH}\n'
1080 >            #txt += '   export PYTHONPATH=`pwd`/ProdAgentApi:`pwd`/ProdCommon:${PYTHONPATH}\n'
1081 >            #txt += '   export PYTHONPATH=ProdAgentApi:${PYTHONPATH}\n'
1082 >            txt += 'echo "PYTHONPATH=$PYTHONPATH"\n'
1083 >            ###################  
1084              txt += 'fi\n'
1085              txt += '\n'
1086  
# Line 984 | Line 1103 | class Cmssw(JobType):
1103      def executableArgs(self):
1104          if self.scriptExe:#CarlosDaniele
1105              return   self.scriptExe + " $NJob"
1106 <        else:
1107 <            return " -p pset.cfg"
1106 >        else:
1107 >            # if >= CMSSW_1_5_X, add -e
1108 >            version_array = self.scram.getSWVersion().split('_')
1109 >            major = 0
1110 >            minor = 0
1111 >            try:
1112 >                major = int(version_array[1])
1113 >                minor = int(version_array[2])
1114 >            except:
1115 >                msg = "Cannot parse CMSSW version string: " + "_".join(version_array) + " for major and minor release number!"  
1116 >                raise CrabException(msg)
1117 >            if major >= 1 and minor >= 5 :
1118 >                return " -e -p pset.cfg"
1119 >            else:
1120 >                return " -p pset.cfg"
1121  
1122      def inputSandbox(self, nj):
1123          """
# Line 1003 | Line 1135 | class Cmssw(JobType):
1135          if not self.pset is None:
1136              inp_box.append(common.work_space.pathForTgz() + 'job/' + self.configFilename())
1137          ## additional input files
1138 <        for file in self.additional_inbox_files:
1139 <            inp_box.append(file)
1138 >        tgz = self.additionalInputFileTgz()
1139 >        inp_box.append(tgz)
1140          return inp_box
1141  
1142      def outputSandbox(self, nj):
# Line 1038 | Line 1170 | class Cmssw(JobType):
1170              output_file_num = self.numberFile_(fileWithSuffix, '$NJob')
1171              txt += '\n'
1172              txt += '# check output file\n'
1173 <            txt += 'ls '+fileWithSuffix+'\n'
1174 <            txt += 'ls_result=$?\n'
1175 <            txt += 'if [ $ls_result -ne 0 ] ; then\n'
1176 <            txt += '   echo "ERROR: Problem with output file"\n'
1173 >            # txt += 'ls '+fileWithSuffix+'\n'
1174 >            # txt += 'ls_result=$?\n'
1175 >            txt += 'if [ -e ./'+fileWithSuffix+' ] ; then\n'
1176 >            txt += '   mv '+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
1177 >            txt += 'else\n'
1178 >            txt += '   exit_status=60302\n'
1179 >            txt += '   echo "ERROR: Problem with output file '+fileWithSuffix+'"\n'
1180              if common.scheduler.boss_scheduler_name == 'condor_g':
1181                  txt += '    if [ $middleware == OSG ]; then \n'
1182                  txt += '        echo "prepare dummy output file"\n'
1183                  txt += '        echo "Processing of job output failed" > $RUNTIME_AREA/'+output_file_num+'\n'
1184                  txt += '    fi \n'
1050            txt += 'else\n'
1051            txt += '   cp '+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
1185              txt += 'fi\n'
1186 +        file_list = []
1187 +        for fileWithSuffix in (self.output_file):
1188 +             file_list.append(self.numberFile_(fileWithSuffix, '$NJob'))
1189 +        txt += 'file_list="'+string.join(file_list,' ')+'"\n'
1190        
1191          txt += 'cd $RUNTIME_AREA\n'
1192 <        txt += 'cd $RUNTIME_AREA\n'
1192 >        #### FEDE this is the cleanEnv function
1193          ### OLI_DANIELE
1194 <        txt += 'if [ $middleware == OSG ]; then\n'  
1195 <        txt += '    cd $RUNTIME_AREA\n'
1196 <        txt += '    echo "Remove working directory: $WORKING_DIR"\n'
1197 <        txt += '    /bin/rm -rf $WORKING_DIR\n'
1198 <        txt += '    if [ -d $WORKING_DIR ] ;then\n'
1199 <        txt += '        echo "SET_EXE 60999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after cleanup of WN"\n'
1200 <        txt += '        echo "JOB_EXIT_STATUS = 60999"\n'
1201 <        txt += '        echo "JobExitCode=60999" | tee -a $RUNTIME_AREA/$repo\n'
1202 <        txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
1203 <        txt += '        rm -f $RUNTIME_AREA/$repo \n'
1204 <        txt += '        echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1205 <        txt += '        echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1206 <        txt += '    fi\n'
1207 <        txt += 'fi\n'
1208 <        txt += '\n'
1194 >        #txt += 'if [ $middleware == OSG ]; then\n'  
1195 >        #txt += '    cd $RUNTIME_AREA\n'
1196 >        #txt += '    echo "Remove working directory: $WORKING_DIR"\n'
1197 >        #txt += '    /bin/rm -rf $WORKING_DIR\n'
1198 >        #txt += '    if [ -d $WORKING_DIR ] ;then\n'
1199 >        #txt += '        echo "SET_EXE 60999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after cleanup of WN"\n'
1200 >        #txt += '        echo "JOB_EXIT_STATUS = 60999"\n'
1201 >        #txt += '        echo "JobExitCode=60999" | tee -a $RUNTIME_AREA/$repo\n'
1202 >        #txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
1203 >        #txt += '        rm -f $RUNTIME_AREA/$repo \n'
1204 >        #txt += '        echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1205 >        #txt += '        echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1206 >        #txt += '    fi\n'
1207 >        #txt += 'fi\n'
1208 >        #txt += '\n'
1209  
1073        file_list = ''
1074        ## Add to filelist only files to be possibly copied to SE
1075        for fileWithSuffix in self.output_file:
1076            output_file_num = self.numberFile_(fileWithSuffix, '$NJob')
1077            file_list=file_list+output_file_num+' '
1078        file_list=file_list[:-1]
1079        txt += 'file_list="'+file_list+'"\n'
1210  
1211          return txt
1212  
# Line 1088 | Line 1218 | class Cmssw(JobType):
1218          # take away last extension
1219          name = p[0]
1220          for x in p[1:-1]:
1221 <           name=name+"."+x
1221 >            name=name+"."+x
1222          # add "_txt"
1223          if len(p)>1:
1224 <          ext = p[len(p)-1]
1225 <          result = name + '_' + txt + "." + ext
1224 >            ext = p[len(p)-1]
1225 >            result = name + '_' + txt + "." + ext
1226          else:
1227 <          result = name + '_' + txt
1227 >            result = name + '_' + txt
1228          
1229          return result
1230  
# Line 1107 | Line 1237 | class Cmssw(JobType):
1237              req='Member("VO-cms-' + \
1238                   self.version + \
1239                   '", other.GlueHostApplicationSoftwareRunTimeEnvironment)'
1240 +        ## SL add requirement for OS version only if SL4
1241 +        reSL4 = re.compile( r'slc4' )
1242 +        if self.executable_arch and reSL4.search(self.executable_arch):
1243 +            req+=' && Member("VO-cms-' + \
1244 +                 self.executable_arch + \
1245 +                 '", other.GlueHostApplicationSoftwareRunTimeEnvironment)'
1246  
1247          req = req + ' && (other.GlueHostNetworkAdapterOutboundIP)'
1248  
# Line 1126 | Line 1262 | class Cmssw(JobType):
1262          txt += '   echo "### SETUP CMS OSG  ENVIRONMENT ###"\n'
1263          txt += '   if [ -f $GRID3_APP_DIR/cmssoft/cmsset_default.sh ] ;then\n'
1264          txt += '      # Use $GRID3_APP_DIR/cmssoft/cmsset_default.sh to setup cms software\n'
1265 +        txt += '       export SCRAM_ARCH='+self.executable_arch+'\n'
1266          txt += '       source $GRID3_APP_DIR/cmssoft/cmsset_default.sh '+self.version+'\n'
1267          txt += '   elif [ -f $OSG_APP/cmssoft/cms/cmsset_default.sh ] ;then\n'
1268          txt += '      # Use $OSG_APP/cmssoft/cms/cmsset_default.sh to setup cms software\n'
1269 +        txt += '       export SCRAM_ARCH='+self.executable_arch+'\n'
1270          txt += '       source $OSG_APP/cmssoft/cms/cmsset_default.sh '+self.version+'\n'
1271          txt += '   else\n'
1272          txt += '       echo "SET_CMS_ENV 10020 ==> ERROR $GRID3_APP_DIR/cmssoft/cmsset_default.sh and $OSG_APP/cmssoft/cms/cmsset_default.sh file not found"\n'
# Line 1144 | Line 1282 | class Cmssw(JobType):
1282          txt += '       cd $RUNTIME_AREA\n'
1283          txt += '       /bin/rm -rf $WORKING_DIR\n'
1284          txt += '       if [ -d $WORKING_DIR ] ;then\n'
1285 <        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'
1286 <        txt += '            echo "JOB_EXIT_STATUS = 10017"\n'
1287 <        txt += '            echo "JobExitCode=10017" | tee -a $RUNTIME_AREA/$repo\n'
1288 <        txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
1289 <        txt += '            rm -f $RUNTIME_AREA/$repo \n'
1290 <        txt += '            echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1291 <        txt += '            echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1285 >        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'
1286 >        txt += '           echo "JOB_EXIT_STATUS = 10017"\n'
1287 >        txt += '           echo "JobExitCode=10017" | tee -a $RUNTIME_AREA/$repo\n'
1288 >        txt += '           dumpStatus $RUNTIME_AREA/$repo\n'
1289 >        txt += '           rm -f $RUNTIME_AREA/$repo \n'
1290 >        txt += '           echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1291 >        txt += '           echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1292          txt += '       fi\n'
1293          txt += '\n'
1294          txt += '       exit 1\n'
# Line 1209 | Line 1347 | class Cmssw(JobType):
1347          txt += '   echo "### END SETUP CMS LCG ENVIRONMENT ###"\n'
1348          return txt
1349  
1350 +    ### FEDE FOR DBS OUTPUT PUBLICATION
1351 +    def modifyReport(self, nj):
1352 +        """
1353 +        insert the part of the script that modifies the FrameworkJob Report
1354 +        """
1355 +
1356 +        txt = ''
1357 +        txt += 'echo "Modify Job Report" \n'
1358 +        #txt += 'chmod a+x $RUNTIME_AREA/'+self.version+'/ProdAgentApi/FwkJobRep/ModifyJobReport.py\n'
1359 +        ################ FEDE FOR DBS2 #############################################
1360 +        txt += 'chmod a+x $SOFTWARE_DIR/ProdAgentApi/FwkJobRep/ModifyJobReport.py\n'
1361 +        #############################################################################
1362 +        try:
1363 +            publish_data = int(self.cfg_params['USER.publish_data'])          
1364 +        except KeyError:
1365 +            publish_data = 0
1366 +
1367 +        txt += 'if [ -z "$SE" ]; then\n'
1368 +        txt += '    SE="" \n'
1369 +        txt += 'fi \n'
1370 +        txt += 'if [ -z "$SE_PATH" ]; then\n'
1371 +        txt += '    SE_PATH="" \n'
1372 +        txt += 'fi \n'
1373 +        txt += 'echo "SE = $SE"\n'
1374 +        txt += 'echo "SE_PATH = $SE_PATH"\n'
1375 +
1376 +        if (publish_data == 1):  
1377 +            #processedDataset = self.cfg_params['USER.processed_datasetname']
1378 +            processedDataset = self.cfg_params['USER.publish_data_name']
1379 +            txt += 'ProcessedDataset='+processedDataset+'\n'
1380 +            #### LFN=/store/user/<user>/processedDataset_PSETHASH
1381 +            txt += 'if [ "$SE_PATH" == "" ]; then\n'
1382 +            #### FEDE: added slash in LFN ##############
1383 +            txt += '    FOR_LFN=/copy_problems/ \n'
1384 +            txt += 'else \n'
1385 +            txt += '    tmp=`echo $SE_PATH | awk -F \'store\' \'{print$2}\'` \n'
1386 +            #####  FEDE TO BE CHANGED, BECAUSE STORE IS HARDCODED!!!! ########
1387 +            txt += '    FOR_LFN=/store$tmp \n'
1388 +            txt += 'fi \n'
1389 +            txt += 'echo "ProcessedDataset = $ProcessedDataset"\n'
1390 +            txt += 'echo "FOR_LFN = $FOR_LFN" \n'
1391 +            txt += 'echo "CMSSW_VERSION = $CMSSW_VERSION"\n\n'
1392 +            #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'
1393 +            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'
1394 +            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'
1395 +            #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'
1396 +      
1397 +            txt += 'modifyReport_result=$?\n'
1398 +            txt += 'echo modifyReport_result = $modifyReport_result\n'
1399 +            txt += 'if [ $modifyReport_result -ne 0 ]; then\n'
1400 +            txt += '    exit_status=1\n'
1401 +            txt += '    echo "ERROR: Problem with ModifyJobReport"\n'
1402 +            txt += 'else\n'
1403 +            txt += '    mv NewFrameworkJobReport.xml crab_fjr_$NJob.xml\n'
1404 +            txt += 'fi\n'
1405 +        else:
1406 +            txt += 'ProcessedDataset=no_data_to_publish \n'
1407 +            #### FEDE: added slash in LFN ##############
1408 +            txt += 'FOR_LFN=/local/ \n'
1409 +            txt += 'echo "ProcessedDataset = $ProcessedDataset"\n'
1410 +            txt += 'echo "FOR_LFN = $FOR_LFN" \n'
1411 +        return txt
1412 +
1413 +    def cleanEnv(self):
1414 +        ### OLI_DANIELE
1415 +        txt = ''
1416 +        txt += 'if [ $middleware == OSG ]; then\n'  
1417 +        txt += '    cd $RUNTIME_AREA\n'
1418 +        txt += '    echo "Remove working directory: $WORKING_DIR"\n'
1419 +        txt += '    /bin/rm -rf $WORKING_DIR\n'
1420 +        txt += '    if [ -d $WORKING_DIR ] ;then\n'
1421 +        txt += '              echo "SET_EXE 60999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after cleanup of WN"\n'
1422 +        txt += '              echo "JOB_EXIT_STATUS = 60999"\n'
1423 +        txt += '              echo "JobExitCode=60999" | tee -a $RUNTIME_AREA/$repo\n'
1424 +        txt += '              dumpStatus $RUNTIME_AREA/$repo\n'
1425 +        txt += '        rm -f $RUNTIME_AREA/$repo \n'
1426 +        txt += '        echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1427 +        txt += '        echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1428 +        txt += '    fi\n'
1429 +        txt += 'fi\n'
1430 +        txt += '\n'
1431 +        return txt
1432 +
1433      def setParam_(self, param, value):
1434          self._params[param] = value
1435  
# Line 1221 | Line 1442 | class Cmssw(JobType):
1442      def getTaskid(self):
1443          return self._taskId
1444  
1224 #######################################################################
1445      def uniquelist(self, old):
1446          """
1447          remove duplicates from a list

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines