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.9 by slacapra, Tue Jun 20 15:39:17 2006 UTC vs.
Revision 1.33 by mkirn, Fri Jul 28 18:19:34 2006 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 + import math
6   import common
7   import PsetManipulator  
8  
# Line 44 | Line 45 | class Cmssw(JobType):
45              log.debug(6, "CMSSW::CMSSW(): datasetPath = "+tmp)
46              if string.lower(tmp)=='none':
47                  self.datasetPath = None
48 +                self.selectNoInput = 1
49              else:
50                  self.datasetPath = tmp
51 +                self.selectNoInput = 0
52          except KeyError:
53              msg = "Error: datasetpath not defined "  
54              raise CrabException(msg)
# Line 109 | Line 112 | class Cmssw(JobType):
112  
113          # script_exe file as additional file in inputSandbox
114          try:
115 <           self.scriptExe = cfg_params['USER.script_exe']
116 <           self.additional_inbox_files.append(self.scriptExe)
115 >            self.scriptExe = cfg_params['USER.script_exe']
116 >            self.additional_inbox_files.append(self.scriptExe)
117 >            if self.scriptExe != '':
118 >               if not os.path.isfile(self.scriptExe):
119 >                  msg ="WARNING. file "+self.scriptExe+" not found"
120 >                  raise CrabException(msg)
121          except KeyError:
122             pass
116        if self.scriptExe != '':
117           if os.path.isfile(self.scriptExe):
118              pass
119           else:
120              log.message("WARNING. file "+self.scriptExe+" not found")
121              sys.exit()
123                    
124          ## additional input files
125          try:
126 <            tmpAddFiles = string.split(cfg_params['CMSSW.additional_input_files'],',')
126 >            tmpAddFiles = string.split(cfg_params['USER.additional_input_files'],',')
127              for tmp in tmpAddFiles:
128                  if not os.path.exists(tmp):
129                      raise CrabException("Additional input file not found: "+tmp)
130 <                tmp=string.strip(tmp)
130 <                self.additional_inbox_files.append(tmp)
130 >                self.additional_inbox_files.append(string.strip(tmp))
131                  pass
132              pass
133          except KeyError:
# Line 143 | Line 143 | class Cmssw(JobType):
143  
144          ## Events per job
145          try:
146 <            self.eventsPerJob =int( cfg_params['CMSSW.event_per_job'])
146 >            self.eventsPerJob =int( cfg_params['CMSSW.events_per_job'])
147              self.selectEventsPerJob = 1
148          except KeyError:
149              self.eventsPerJob = -1
150              self.selectEventsPerJob = 0
151      
152 <        if (self.selectFilesPerJob == self.selectEventsPerJob):
153 <            msg = 'Must define either files_per_jobs or event_per_job'
152 >        ## number of jobs
153 >        try:
154 >            self.theNumberOfJobs =int( cfg_params['CMSSW.number_of_jobs'])
155 >            self.selectNumberOfJobs = 1
156 >        except KeyError:
157 >            self.theNumberOfJobs = 0
158 >            self.selectNumberOfJobs = 0
159 >
160 >        ## source seed for pythia
161 >        try:
162 >            self.sourceSeed = int(cfg_params['CMSSW.pythia_seed'])
163 >        except KeyError:
164 >            self.sourceSeed = None
165 >            common.logger.debug(5,"No seed given")
166 >
167 >        try:
168 >            self.sourceSeedVtx = int(cfg_params['CMSSW.vtx_seed'])
169 >        except KeyError:
170 >            self.sourceSeedVtx = None
171 >            common.logger.debug(5,"No vertex seed given")
172 >
173 >        if not (self.selectFilesPerJob + self.selectEventsPerJob + self.selectNumberOfJobs == 1 ):
174 >            msg = 'Must define either files_per_jobs or events_per_job or number_of_jobs'
175              raise CrabException(msg)
176  
177          try:
# Line 204 | Line 225 | class Cmssw(JobType):
225          #DBSDLS-end          
226  
227          self.tgzNameWithPath = self.getTarBall(self.executable)
228 <
228 >    
229          ## Select Splitting
230 <        if self.selectFilesPerJob: self.jobSplittingPerFiles()
231 <        elif self.selectEventsPerJob: self.jobSplittingPerEvents()
230 >        if self.selectNoInput: self.jobSplittingNoInput()
231 >        elif self.selectFilesPerJob or self.selectEventsPerJob or self.selectNumberOfJobs: self.jobSplittingPerFiles()
232          else:
233              msg = 'Don\'t know how to split...'
234              raise CrabException(msg)
214        
215        self.PsetEdit.maxEvent(self.eventsPerJob) #Daniele  
216        self.PsetEdit.inputModule("INPUT") #Daniele  
217        self.PsetEdit.psetWriter(self.configFilename())
235  
236 +        # modify Pset
237 +        try:
238 +            if (self.datasetPath): # standard job
239 +                #self.PsetEdit.maxEvent(self.eventsPerJob)
240 +                # always process all events in a file
241 +                self.PsetEdit.maxEvent("-1")
242 +                self.PsetEdit.inputModule("INPUT")
243 +
244 +            else:  # pythia like job
245 +                self.PsetEdit.maxEvent(self.eventsPerJob)
246 +                if (self.sourceSeed) :
247 +                    self.PsetEdit.pythiaSeed("INPUT")
248 +                    if (self.sourceSeedVtx) :
249 +                        self.PsetEdit.pythiaSeedVtx("INPUTVTX")
250 +            self.PsetEdit.psetWriter(self.configFilename())
251 +        except:
252 +            msg='Error while manipuliating ParameterSet: exiting...'
253 +            raise CrabException(msg)
254  
255      def DataDiscoveryAndLocation(self, cfg_params):
256  
# Line 248 | Line 283 | class Cmssw(JobType):
283          common.logger.message("Required data are :"+self.datasetPath)
284  
285          filesbyblock=self.pubdata.getFiles()
286 + #        print filesbyblock
287          self.AllInputFiles=filesbyblock.values()
288          self.files = self.AllInputFiles        
289  
254        ## TEMP
255    #    self.filesTmp = filesbyblock.values()
256    #    self.files = []
257    #    locPath='rfio:cmsbose2.bo.infn.it:/flatfiles/SE00/cms/fanfani/ProdTest/'
258    #    locPath=''
259    #    tmp = []
260    #    for file in self.filesTmp[0]:
261    #        tmp.append(locPath+file)
262    #    self.files.append(tmp)
263        ## END TEMP
264
290          ## get max number of events
291          #common.logger.debug(10,"number of events for primary fileblocks %i"%self.pubdata.getMaxEvents())
292          self.maxEvents=self.pubdata.getMaxEvents() ##  self.maxEvents used in Creator.py
# Line 286 | Line 311 | class Cmssw(JobType):
311              msg = 'No sites hosting all the needed data! Exiting... '
312              raise CrabException(msg)
313  
314 <        common.logger.message("List of Sites hosting the data : "+str(sites))
314 >        common.logger.message("List of Sites ("+str(len(sites))+") hosting the data : "+str(sites))
315          common.logger.debug(6, "List of Sites: "+str(sites))
316          common.analisys_common_info['sites']=sites    ## used in SchedulerEdg.py in createSchScript
317          self.setParam_('TargetCE', ','.join(sites))
# Line 297 | Line 322 | class Cmssw(JobType):
322          Perform job splitting based on number of files to be accessed per job
323          """
324          common.logger.debug(5,'Splitting per input files')
300        common.logger.message('Required '+str(self.filesPerJob)+' files per job ')
325          common.logger.message('Required '+str(self.total_number_of_events)+' events in total ')
326 <
327 <        ## TODO: SL need to have (from DBS) a detailed list of how many events per each file
328 <        n_tot_files = (len(self.files[0]))
329 <        ## SL: this is wrong if the files have different number of events
306 <        evPerFile = int(self.maxEvents)/n_tot_files
307 <        
308 <        common.logger.debug(5,'Events per File '+str(evPerFile))
326 >        common.logger.message('Available '+str(self.maxEvents)+' events in total ')
327 >        common.logger.message('Required '+str(self.filesPerJob)+' files per job ')
328 >        common.logger.message('Required '+str(self.theNumberOfJobs)+' jobs in total ')
329 >        common.logger.message('Required '+str(self.eventsPerJob)+' events per job')
330  
331          ## if asked to process all events, do it
332          if self.total_number_of_events == -1:
333              self.total_number_of_events=self.maxEvents
313            self.total_number_of_jobs = int(n_tot_files)*1/int(self.filesPerJob)
314            common.logger.message(str(self.total_number_of_jobs)+' jobs will be created for all available events '+str(self.total_number_of_events)+' events')
315        
334          else:
335 <            self.total_number_of_files = int(self.total_number_of_events/evPerFile)
336 <            ## SL: if ask for less event than what is computed to be available on a
337 <            ##     file, process the first file anyhow.
338 <            if self.total_number_of_files == 0:
321 <                self.total_number_of_files = self.total_number_of_files + 1
322 <
323 <            common.logger.debug(5,'N files  '+str(self.total_number_of_files))
324 <
325 <            check = 0
326 <            
327 <            ## Compute the number of jobs
328 <            #self.total_number_of_jobs = int(n_tot_files)*1/int(self.filesPerJob)
329 <            self.total_number_of_jobs = int(self.total_number_of_files/self.filesPerJob)
330 <            common.logger.debug(5,'N jobs  '+str(self.total_number_of_jobs))
335 >            if self.total_number_of_events>self.maxEvents:
336 >                common.logger.message("Asked "+str(self.total_number_of_events)+" but only "+str(self.maxEvents)+" available.")
337 >                self.total_number_of_events=self.maxEvents
338 >            pass
339  
340 <            ## is there any remainder?
341 <            check = int(self.total_number_of_files) - (int(self.total_number_of_jobs)*self.filesPerJob)
340 >        ## TODO: SL need to have (from DBS) a detailed list of how many events per each file
341 >        n_tot_files = (len(self.files[0]))
342 >        ## SL: this is wrong if the files have different number of events
343 >        evPerFile = int(self.maxEvents)/n_tot_files
344  
345 <            common.logger.debug(5,'Check  '+str(check))
345 >        common.logger.debug(5,'Events per File '+str(evPerFile))
346  
347 +        ## compute job splitting parameters: filesPerJob, eventsPerJob and theNumberOfJobs
348 +        if self.selectFilesPerJob:
349 +            ## user define files per event.
350 +            filesPerJob = self.filesPerJob
351 +            eventsPerJob = filesPerJob*evPerFile
352 +            theNumberOfJobs = int(self.total_number_of_events*1./eventsPerJob)
353 +            check = int(self.total_number_of_events) - (theNumberOfJobs*eventsPerJob)
354              if check > 0:
355 <                self.total_number_of_jobs =  self.total_number_of_jobs + 1
355 >                theNumberOfJobs +=1
356 >                filesLastJob = int(check*1./evPerFile+0.5)
357                  common.logger.message('Warning: last job will be created with '+str(check)+' files')
358 +            else:
359 +                filesLastJob = filesPerJob
360  
361 <            common.logger.message(str(self.total_number_of_jobs)+' jobs will be created for a total of '+str((self.total_number_of_jobs-1)*self.filesPerJob*evPerFile + check*evPerFile)+' events')
362 <            pass
361 >        elif self.selectNumberOfJobs:
362 >            ## User select the number of jobs: last might be bigger to match request of events
363 >            theNumberOfJobs =  self.theNumberOfJobs
364 >
365 >            eventsPerJob = self.total_number_of_events/theNumberOfJobs
366 >            filesPerJob = int(eventsPerJob/evPerFile)
367 >            if (filesPerJob==0) : filesPerJob=1
368 >            check = int(self.total_number_of_events) - (int(theNumberOfJobs)*filesPerJob*evPerFile)
369 >            if not check == 0:
370 >                if check<0:
371 >                    missingFiles = int(check/evPerFile)
372 >                    additionalJobs = int(missingFiles/filesPerJob)
373 >                    #print missingFiles, additionalJobs
374 >                    theNumberOfJobs+=additionalJobs
375 >                    common.logger.message('Warning: will create only '+str(theNumberOfJobs)+' jobs')
376 >                    check = int(self.total_number_of_events) - (int(theNumberOfJobs)*filesPerJob*evPerFile)
377 >                    
378 >                if check >0 :
379 >                    filesLastJob = filesPerJob+int(check*1./evPerFile+0.5)
380 >                    common.logger.message('Warning: last job will be created with '+str(filesLastJob*evPerFile)+' events')
381 >                else:
382 >                    filesLastJob = filesPerJob
383 >            else:
384 >                filesLastJob = filesPerJob
385 >        elif self.selectEventsPerJob:
386 >            # SL case if asked events per job
387 >            ## estimate the number of files per job to match the user requirement
388 >            filesPerJob = int(float(self.eventsPerJob)/float(evPerFile))
389 >            if filesPerJob==0: filesPerJob=1
390 >            common.logger.debug(5,"filesPerJob "+str(filesPerJob))
391 >            if (filesPerJob==0): filesPerJob=1
392 >            eventsPerJob=filesPerJob*evPerFile
393 >            theNumberOfJobs = int(self.total_number_of_events)/int(eventsPerJob)
394 >            check = int(self.total_number_of_events) - (int(theNumberOfJobs)*eventsPerJob)
395 >            if not check == 0:
396 >                missingFiles = int(check/evPerFile)
397 >                additionalJobs = int(missingFiles/filesPerJob)
398 >                if ( additionalJobs>0) : theNumberOfJobs+=additionalJobs
399 >                check = int(self.total_number_of_events) - (int(theNumberOfJobs)*eventsPerJob)
400 >                if not check == 0:
401 >                    if (check <0 ):
402 >                        filesLastJob = filesPerJob+int(check*1./evPerFile-0.5)
403 >                    else:
404 >                        theNumberOfJobs+=1
405 >                        filesLastJob = int(check*1./evPerFile+0.5)
406 >
407 >                    common.logger.message('Warning: last job will be created with '+str(filesLastJob*evPerFile)+' events')
408 >                else:
409 >                    filesLastJob = filesPerJob
410 >            else:
411 >                filesLastJob = filesPerJob
412 >        
413 >        self.total_number_of_jobs = theNumberOfJobs
414 >
415 >        totalEventsToBeUsed=theNumberOfJobs*filesPerJob*evPerFile
416 >        if not check == 0:
417 >        #    print (theNumberOfJobs-1)*filesPerJob*evPerFile,filesLastJob*evPerFile
418 >            totalEventsToBeUsed=(theNumberOfJobs-1)*filesPerJob*evPerFile+filesLastJob*evPerFile
419 >
420 >        common.logger.message(str(self.total_number_of_jobs)+' jobs will be created, each for '+str(filesPerJob*evPerFile)+' events, for a total of '+str(totalEventsToBeUsed)+' events')
421  
422 +        totalFilesToBeUsed=filesPerJob*(theNumberOfJobs-1)+filesLastJob
423 +
424 +        ## set job arguments (files)
425          list_of_lists = []
426 <        for i in xrange(0, int(n_tot_files), self.filesPerJob):
426 >        lastFile=0
427 >        for i in range(0, int(totalFilesToBeUsed), filesPerJob)[:-1]:
428              parString = "\\{"
429              
430 <            params = self.files[0][i: i+self.filesPerJob]
430 >            lastFile=i+filesPerJob
431 >            params = self.files[0][i: lastFile]
432              for i in range(len(params) - 1):
433                  parString += '\\\"' + params[i] + '\\\"\,'
434              
435              parString += '\\\"' + params[len(params) - 1] + '\\\"\\}'
436 <            list_of_lists.append(parString)
436 >            list_of_lists.append([parString])
437              pass
438  
439 +        ## last job
440 +        parString = "\\{"
441 +        
442 +        params = self.files[0][lastFile: lastFile+filesLastJob]
443 +        for i in range(len(params) - 1):
444 +            parString += '\\\"' + params[i] + '\\\"\,'
445 +        
446 +        parString += '\\\"' + params[len(params) - 1] + '\\\"\\}'
447 +        list_of_lists.append([parString])
448 +        pass
449 +
450          self.list_of_args = list_of_lists
451 <        print self.list_of_args
451 >        # print self.list_of_args[0]
452          return
453  
454 <    def jobSplittingPerEvents(self):
454 >    def jobSplittingNoInput(self):
455          """
456          Perform job splitting based on number of event per job
457          """
458          common.logger.debug(5,'Splitting per events')
459          common.logger.message('Required '+str(self.eventsPerJob)+' events per job ')
460 +        common.logger.message('Required '+str(self.theNumberOfJobs)+' jobs in total ')
461          common.logger.message('Required '+str(self.total_number_of_events)+' events in total ')
462  
463 <        self.total_number_of_jobs = int(self.total_number_of_events/self.eventsPerJob)
464 <        
463 >        if (self.total_number_of_events < 0):
464 >            msg='Cannot split jobs per Events with "-1" as total number of events'
465 >            raise CrabException(msg)
466 >
467 >        if (self.selectEventsPerJob):
468 >            self.total_number_of_jobs = int(self.total_number_of_events/self.eventsPerJob)
469 >        elif (self.selectNumberOfJobs) :
470 >            self.total_number_of_jobs = self.theNumberOfJobs
471 >            self.eventsPerJob = int(self.total_number_of_events/self.total_number_of_jobs)
472 >
473          common.logger.debug(5,'N jobs  '+str(self.total_number_of_jobs))
474  
475          # is there any remainder?
# Line 374 | Line 477 | class Cmssw(JobType):
477  
478          common.logger.debug(5,'Check  '+str(check))
479  
480 +        common.logger.message(str(self.total_number_of_jobs)+' jobs will be created, each for '+str(self.eventsPerJob)+' for a total of '+str(self.total_number_of_jobs*self.eventsPerJob)+' events')
481          if check > 0:
482 <            common.logger.message('Warning: asked '+self.total_number_of_events+' but will do only '+(int(self.total_number_of_jobs)*self.eventsPerJob))
482 >            common.logger.message('Warning: asked '+str(self.total_number_of_events)+' but will do only '+str(int(self.total_number_of_jobs)*self.eventsPerJob))
483  
380        common.logger.message(str(self.total_number_of_jobs)+' jobs will be created for a total of '+str(self.total_number_of_jobs*self.eventsPerJob)+' events')
484  
485 +        # argument is seed number.$i
486          self.list_of_args = []
487          for i in range(self.total_number_of_jobs):
488 <            self.list_of_args.append(i)
489 <        print self.list_of_args
488 >            if (self.sourceSeed):
489 >                if (self.sourceSeedVtx):
490 >                    ## pythia + vtx random seed
491 >                    self.list_of_args.append([
492 >                                              str(self.sourceSeed)+str(i),
493 >                                              str(self.sourceSeedVtx)+str(i)
494 >                                              ])
495 >                else:
496 >                    ## only pythia random seed
497 >                    self.list_of_args.append([(str(self.sourceSeed)+str(i))])
498 >            else:
499 >                ## no random seed
500 >                self.list_of_args.append([str(i)])
501 >        #print self.list_of_args
502  
503          return
504  
# Line 397 | Line 513 | class Cmssw(JobType):
513              jobParams.append("")
514          
515          for job in range(njobs):
516 <            jobParams[job] = str(arglist[job])
516 >            jobParams[job] = arglist[job]
517 >            # print str(arglist[job])
518 >            # print jobParams[job]
519              common.jobDB.setArguments(job, jobParams[job])
520  
521          common.jobDB.save()
522          return
523      
524      def getJobTypeArguments(self, nj, sched):
525 <        return common.jobDB.arguments(nj)
525 >        result = ''
526 >        for i in common.jobDB.arguments(nj):
527 >            result=result+str(i)+" "
528 >        return result
529    
530      def numberOfJobs(self):
531          # Fabio
# Line 548 | Line 669 | class Cmssw(JobType):
669          txt += '        echo "JOB_EXIT_STATUS = 10016"\n'
670          txt += '        echo "JobExitCode=10016" | tee -a $RUNTIME_AREA/$repo\n'
671          txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
672 +        txt += '        rm -f $RUNTIME_AREA/$repo \n'
673 +        txt += '        echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
674 +        txt += '        echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
675          txt += '        exit 1\n'
676          txt += '    fi\n'
677          txt += '\n'
# Line 567 | Line 691 | class Cmssw(JobType):
691          txt += '   echo "JOB_EXIT_STATUS = 10034"\n'
692          txt += '   echo "JobExitCode=10034" | tee -a $RUNTIME_AREA/$repo\n'
693          txt += '   dumpStatus $RUNTIME_AREA/$repo\n'
694 +        txt += '   rm -f $RUNTIME_AREA/$repo \n'
695 +        txt += '   echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
696 +        txt += '   echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
697          ## OLI_Daniele
698          txt += '    if [ $middleware == OSG ]; then \n'
699          txt += '        echo "Remove working directory: $WORKING_DIR"\n'
# Line 577 | Line 704 | class Cmssw(JobType):
704          txt += '            echo "JOB_EXIT_STATUS = 10018"\n'
705          txt += '            echo "JobExitCode=10018" | tee -a $RUNTIME_AREA/$repo\n'
706          txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
707 +        txt += '            rm -f $RUNTIME_AREA/$repo \n'
708 +        txt += '            echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
709 +        txt += '            echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
710          txt += '        fi\n'
711          txt += '    fi \n'
712          txt += '   exit 1 \n'
# Line 590 | Line 720 | class Cmssw(JobType):
720          txt += "\n"
721          txt += "## number of arguments (first argument always jobnumber)\n"
722          txt += "\n"
723 <        txt += "narg=$#\n"
724 <        txt += "if [ $narg -lt 2 ]\n"
723 > #        txt += "narg=$#\n"
724 >        txt += "if [ $nargs -lt 2 ]\n"
725          txt += "then\n"
726 <        txt += "    echo 'SET_EXE_ENV 1 ==> ERROR Too few arguments' +$narg+ \n"
726 >        txt += "    echo 'SET_EXE_ENV 1 ==> ERROR Too few arguments' +$nargs+ \n"
727          txt += '    echo "JOB_EXIT_STATUS = 50113"\n'
728          txt += '    echo "JobExitCode=50113" | tee -a $RUNTIME_AREA/$repo\n'
729          txt += '    dumpStatus $RUNTIME_AREA/$repo\n'
730 +        txt += '    rm -f $RUNTIME_AREA/$repo \n'
731 +        txt += '    echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
732 +        txt += '    echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
733          ## OLI_Daniele
734          txt += '    if [ $middleware == OSG ]; then \n'
735          txt += '        echo "Remove working directory: $WORKING_DIR"\n'
# Line 607 | Line 740 | class Cmssw(JobType):
740          txt += '            echo "JOB_EXIT_STATUS = 50114"\n'
741          txt += '            echo "JobExitCode=50114" | tee -a $RUNTIME_AREA/$repo\n'
742          txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
743 +        txt += '            rm -f $RUNTIME_AREA/$repo \n'
744 +        txt += '            echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
745 +        txt += '            echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
746          txt += '        fi\n'
747          txt += '    fi \n'
748          txt += "    exit 1\n"
# Line 617 | Line 753 | class Cmssw(JobType):
753          job = common.job_list[nj]
754          pset = os.path.basename(job.configFilename())
755          txt += '\n'
756 <        txt += 'InputFiles=$2\n'
757 <        txt += 'echo "<$InputFiles>"\n'
758 <        #txt += 'echo sed "s#{\'INPUT\'}#$InputFiles#" $RUNTIME_AREA/'+pset+' \n'
759 <        txt += 'sed "s#{\'INPUT\'}#$InputFiles#" $RUNTIME_AREA/'+pset+' > pset.cfg\n'
760 <        #txt += 'sed "s#{\'INPUT\'}#${InputFiles}#" $RUNTIME_AREA/'+pset+' > pset1.cfg\n'
756 >        if (self.datasetPath): # standard job
757 >            #txt += 'InputFiles=$2\n'
758 >            txt += 'InputFiles=${args[1]}\n'
759 >            txt += 'echo "Inputfiles:<$InputFiles>"\n'
760 >            txt += 'sed "s#{\'INPUT\'}#$InputFiles#" $RUNTIME_AREA/'+pset+' > pset.cfg\n'
761 >        else:  # pythia like job
762 >            if (self.sourceSeed):
763 >                txt += 'Seed=$2\n'
764 >                txt += 'echo "Seed: <$Seed>"\n'
765 >                txt += 'sed "s#\<INPUT\>#$Seed#" $RUNTIME_AREA/'+pset+' > tmp.cfg\n'
766 >                if (self.sourceSeedVtx):
767 >                    txt += 'VtxSeed=$3\n'
768 >                    txt += 'echo "VtxSeed: <$VtxSeed>"\n'
769 >                    txt += 'sed "s#INPUTVTX#$VtxSeed#" tmp.cfg > pset.cfg\n'
770 >                else:
771 >                    txt += 'mv tmp.cfg pset.cfg\n'
772 >            else:
773 >                txt += '# Copy untouched pset\n'
774 >                txt += 'cp $RUNTIME_AREA/'+pset+' pset.cfg\n'
775 >
776  
777          if len(self.additional_inbox_files) > 0:
778              for file in self.additional_inbox_files:
779 <                txt += 'if [ -e $RUNTIME_AREA/'+file+' ] ; then\n'
780 <                txt += '   cp $RUNTIME_AREA/'+file+' .\n'
781 <                txt += '   chmod +x '+file+'\n'
779 >                relFile = file.split("/")[-1]
780 >                txt += 'if [ -e $RUNTIME_AREA/'+relFile+' ] ; then\n'
781 >                txt += '   cp $RUNTIME_AREA/'+relFile+' .\n'
782 >                txt += '   chmod +x '+relFile+'\n'
783                  txt += 'fi\n'
784              pass
785  
# Line 664 | Line 816 | class Cmssw(JobType):
816              txt += '       cd $RUNTIME_AREA\n'
817              txt += '       /bin/rm -rf $WORKING_DIR\n'
818              txt += '       if [ -d $WORKING_DIR ] ;then\n'
819 <            txt += '        echo "SET_EXE 50999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after Untarring .tgz file failed"\n'
820 <            txt += '        echo "JOB_EXIT_STATUS = 50999"\n'
821 <            txt += '        echo "JobExitCode=50999" | tee -a $RUNTIME_AREA/$repo\n'
822 <            txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
819 >            txt += '           echo "SET_EXE 50999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after Untarring .tgz file failed"\n'
820 >            txt += '           echo "JOB_EXIT_STATUS = 50999"\n'
821 >            txt += '           echo "JobExitCode=50999" | tee -a $RUNTIME_AREA/$repo\n'
822 >            txt += '           dumpStatus $RUNTIME_AREA/$repo\n'
823 >            txt += '           rm -f $RUNTIME_AREA/$repo \n'
824 >            txt += '           echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
825 >            txt += '           echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
826              txt += '       fi\n'
827              txt += '   fi \n'
828              txt += '   \n'
# Line 745 | Line 900 | class Cmssw(JobType):
900              txt += '\n'
901              txt += '# check output file\n'
902              txt += 'ls '+fileWithSuffix+'\n'
903 <            txt += 'exe_result=$?\n'
904 <            txt += 'if [ $exe_result -ne 0 ] ; then\n'
905 <            txt += '   echo "ERROR: No output file to manage"\n'
906 <            txt += '   echo "JOB_EXIT_STATUS = $exe_result"\n'
907 <            txt += '   echo "JobExitCode=60302" | tee -a $RUNTIME_AREA/$repo\n'
908 <            txt += '   dumpStatus $RUNTIME_AREA/$repo\n'
903 >            txt += 'ls_result=$?\n'
904 >            #txt += 'exe_result=$?\n'
905 >            txt += 'if [ $ls_result -ne 0 ] ; then\n'
906 >            txt += '   echo "ERROR: Problem with output file"\n'
907 >            #txt += '   echo "JOB_EXIT_STATUS = $exe_result"\n'
908 >            #txt += '   echo "JobExitCode=60302" | tee -a $RUNTIME_AREA/$repo\n'
909 >            #txt += '   dumpStatus $RUNTIME_AREA/$repo\n'
910              ### OLI_DANIELE
911              if common.scheduler.boss_scheduler_name == 'condor_g':
912                  txt += '    if [ $middleware == OSG ]; then \n'
# Line 764 | Line 920 | class Cmssw(JobType):
920          txt += 'cd $RUNTIME_AREA\n'
921          file_list=file_list[:-1]
922          txt += 'file_list="'+file_list+'"\n'
923 +        txt += 'cd $RUNTIME_AREA\n'
924          ### OLI_DANIELE
925          txt += 'if [ $middleware == OSG ]; then\n'  
926          txt += '    cd $RUNTIME_AREA\n'
# Line 774 | Line 931 | class Cmssw(JobType):
931          txt += '        echo "JOB_EXIT_STATUS = 60999"\n'
932          txt += '        echo "JobExitCode=60999" | tee -a $RUNTIME_AREA/$repo\n'
933          txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
934 +        txt += '        rm -f $RUNTIME_AREA/$repo \n'
935 +        txt += '        echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
936 +        txt += '        echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
937          txt += '    fi\n'
938          txt += 'fi\n'
939          txt += '\n'
# Line 804 | Line 964 | class Cmssw(JobType):
964          return job requirements to add to jdl files
965          """
966          req = ''
967 +        if common.analisys_common_info['sw_version']:
968 +            req='Member("VO-cms-' + \
969 +                 common.analisys_common_info['sw_version'] + \
970 +                 '", other.GlueHostApplicationSoftwareRunTimeEnvironment)'
971          if common.analisys_common_info['sites']:
808            if common.analisys_common_info['sw_version']:
809                req='Member("VO-cms-' + \
810                     common.analisys_common_info['sw_version'] + \
811                     '", other.GlueHostApplicationSoftwareRunTimeEnvironment)'
972              if len(common.analisys_common_info['sites'])>0:
973                  req = req + ' && ('
974                  for i in range(len(common.analisys_common_info['sites'])):
# Line 843 | Line 1003 | class Cmssw(JobType):
1003          txt += '       echo "JOB_EXIT_STATUS = 10020"\n'
1004          txt += '       echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
1005          txt += '       dumpStatus $RUNTIME_AREA/$repo\n'
1006 +        txt += '       rm -f $RUNTIME_AREA/$repo \n'
1007 +        txt += '       echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1008 +        txt += '       echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1009          txt += '       exit 1\n'
1010          txt += '\n'
1011          txt += '       echo "Remove working directory: $WORKING_DIR"\n'
# Line 853 | Line 1016 | class Cmssw(JobType):
1016          txt += '            echo "JOB_EXIT_STATUS = 10017"\n'
1017          txt += '            echo "JobExitCode=10017" | tee -a $RUNTIME_AREA/$repo\n'
1018          txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
1019 +        txt += '            rm -f $RUNTIME_AREA/$repo \n'
1020 +        txt += '            echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1021 +        txt += '            echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1022          txt += '       fi\n'
1023          txt += '\n'
1024          txt += '       exit 1\n'
# Line 876 | Line 1042 | class Cmssw(JobType):
1042          txt += '       echo "JOB_EXIT_STATUS = 10031" \n'
1043          txt += '       echo "JobExitCode=10031" | tee -a $RUNTIME_AREA/$repo\n'
1044          txt += '       dumpStatus $RUNTIME_AREA/$repo\n'
1045 +        txt += '       rm -f $RUNTIME_AREA/$repo \n'
1046 +        txt += '       echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1047 +        txt += '       echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1048          txt += '       exit 1\n'
1049          txt += '   else\n'
1050          txt += '       echo "Sourcing environment... "\n'
# Line 884 | Line 1053 | class Cmssw(JobType):
1053          txt += '           echo "JOB_EXIT_STATUS = 10020"\n'
1054          txt += '           echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
1055          txt += '           dumpStatus $RUNTIME_AREA/$repo\n'
1056 +        txt += '           rm -f $RUNTIME_AREA/$repo \n'
1057 +        txt += '           echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1058 +        txt += '           echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1059          txt += '           exit 1\n'
1060          txt += '       fi\n'
1061          txt += '       echo "sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
# Line 894 | Line 1066 | class Cmssw(JobType):
1066          txt += '           echo "JOB_EXIT_STATUS = 10032"\n'
1067          txt += '           echo "JobExitCode=10032" | tee -a $RUNTIME_AREA/$repo\n'
1068          txt += '           dumpStatus $RUNTIME_AREA/$repo\n'
1069 +        txt += '           rm -f $RUNTIME_AREA/$repo \n'
1070 +        txt += '           echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1071 +        txt += '           echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1072          txt += '           exit 1\n'
1073          txt += '       fi\n'
1074          txt += '   fi\n'
# Line 910 | Line 1085 | class Cmssw(JobType):
1085          txt += '       echo "JOB_EXIT_STATUS = 10033"\n'
1086          txt += '       echo "JobExitCode=10033" | tee -a $RUNTIME_AREA/$repo\n'
1087          txt += '       dumpStatus $RUNTIME_AREA/$repo\n'
1088 +        txt += '       rm -f $RUNTIME_AREA/$repo \n'
1089 +        txt += '       echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1090 +        txt += '       echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1091          txt += '       exit 1\n'
1092          txt += '   fi\n'
1093          txt += '   echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines