15 import Alignment.MillePedeAlignmentAlgorithm.mpslib.Mpslibclass
as mpslib
21 lib = mpslib.jobdatabase()
29 for i, arg
in enumerate(sys.argv):
42 maxJobs = int(maxJobs)
46 print "Usage:\n mps_fire.pl [-m[f]] [maxjobs]"
47 print "\nmaxjobs: Number of Mille jobs to be submitted (default is one)"
48 print "\nKnown options:";
49 print "\n -m Submit all setup Pede jobs, maxJobs is ignored."
50 print "\n -mf Force the submission of the Pede job in case"
51 print "\n some Mille jobs are not in the OK state.\n"
52 print "\n -h This help."
58 thePwd = subprocess.check_output(
'pwd', stderr=subprocess.STDOUT, shell=
True)
59 thePwd = thePwd.strip()
60 theJobData = thePwd+
'/jobData'
63 theJobName =
'mpalign'
64 if lib.addFiles !=
'':
65 theJobName = lib.addFiles
70 resources = lib.get_class(
'mille')
73 if 'cmscafspec' in resources:
74 print '\nWARNING:\n Running mille jobs on cmscafspec, intended for pede only!\n\n'
76 queue = queue.replace(
'cmscafspec',
'cmscaf')
77 resources =
'-q'+queue+
'-R cmscafspec'
78 resources =
'-q cmscafalcamille'
80 elif 'cmscaf' in resources:
82 resources =
'-q'+resources+
' -m g_cmscaf'
84 resources =
'-q '+resources
87 for i
in xrange(lib.nJobs):
88 if lib.JOBSTATUS[i] ==
'SETUP':
92 submission =
'bsub -J %s %s %s/%s/theScript.sh' % \
93 (theJobName, resources, theJobData, lib.JOBDIR[i])
95 result = subprocess.check_output(submission, stderr=subprocess.STDOUT, shell=
True)
97 result = result.strip()
100 match = re.search(
'Job <(\d+)> is submitted', result)
103 lib.JOBSTATUS[i] =
'SUBTD'
104 lib.JOBID[i] = int(match.group(1))
108 print 'Submission of %03d seems to have failed: %s' % (lib.JOBNUMBER[i],result)
115 resources = lib.get_class(
'pede')
116 if 'cmscafspec' in resources:
118 queue = queue.replace(
'cmscafspec',
'cmscaf')
119 resources =
'-q '+queue+
' -R cmscafspec'
120 resources =
'-q cmscafalcamille'
122 resources =
'-q '+resources
125 resources = resources+
' -R \"rusage[mem="%s"]\"' % str(lib.pedeMem)
129 for i
in xrange(lib.nJobs):
130 if lib.JOBSTATUS[i] !=
'OK':
131 if 'DISABLED' not in lib.JOBSTATUS[i]:
137 while i<len(lib.JOBDIR):
141 if lib.JOBSTATUS[i] !=
'SETUP':
142 print 'Merge job %d status %s not submitted.' % \
143 (jobNumFrom1, lib.JOBSTATUS[i])
144 elif (mergeOK != 1)
and (forceMerge != 1):
145 print 'Merge job',jobNumFrom1,
'not submitted since Mille jobs error/unfinished (Use -mf to force).'
148 Path =
'%s/%s' % (theJobData,lib.JOBDIR[i])
149 backupScriptPath = Path+
'/theScript.sh.bak'
150 scriptPath = Path+
'/theScript.sh'
156 if not os.path.isfile(backupScriptPath):
157 os.system(
'cp -p '+scriptPath+
' '+backupScriptPath)
160 command =
'cat '+backupScriptPath+
' | grep cmsRun | grep "\.py" | head -1 | awk \'{gsub("^.*cmsRun ","");print $1}\''
161 mergeCfg = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=
True)
162 command =
'basename '+mergeCfg
163 mergeCfg = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=
True)
164 mergeCfg = mergeCfg.replace(
'\n',
'')
167 backupCfgPath = Path+
'/%s.bak' % mergeCfg
168 cfgPath = Path+
'/%s' % mergeCfg
169 if not os.path.isfile(backupCfgPath):
170 os.system(
'cp -p '+cfgPath+
' '+backupCfgPath)
173 inCfgPath = theJobData+
'/'+lib.JOBDIR[lib.nJobs]+
'/the.py'
174 command =
'mps_merge.py -c '+inCfgPath+
' '+Path+
'/'+mergeCfg+
' '+Path+
' '+str(lib.nJobs)
178 command =
'mps_scriptm.pl -c '+lib.mergeScript+
' '+scriptPath+
' '+Path+
' '+mergeCfg+
' '+str(lib.nJobs)+
' '+lib.mssDir+
' '+lib.mssDirPool
183 if os.path.isfile(backupScriptPath):
184 os.system(
'cp -pf '+backupScriptPath+
' '+scriptPath)
187 command =
'cat '+scriptPath+
' | grep cmsRun | grep "\.py" | head -1 | awk \'{gsub("^.*cmsRun ","");print $1}\''
188 mergeCfg = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=
True)
189 command =
'basename '+mergeCfg
190 mergeCfg = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=
True)
191 mergeCfg = mergeCfg.replace(
'\n',
'')
194 backupCfgPath = Path+
'/%s.bak' % mergeCfg
195 cfgPath = Path+
'/%s' % mergeCfg
196 if os.path.isfile(backupCfgPath):
197 os.system(
'cp -pf '+backupCfgPath+
' '+cfgPath)
203 curJobName =
'm'+str(nMerge)+
'_'+theJobName
204 submission =
'bsub -J %s %s %s' % (curJobName,resources,scriptPath)
205 result = subprocess.check_output(submission, stderr=subprocess.STDOUT, shell=
True)
207 result = result.strip()
210 match = re.search(
'Job <(\d+)> is submitted', result)
213 lib.JOBSTATUS[i] =
'SUBTD'
214 lib.JOBID[i] = int(match.group(1))
216 print 'jobid is',lib.JOBID[i]
218 print 'Submission of merge job seems to have failed:',result