2 from crab
import Crab,common,parseOptions,CrabException
3 from crabStatusFromReport
import crabStatusFromReport
7 Computes jobs summary for given task 9 taskId =
str(up_task[
'name'])
10 task_unique_name =
str(up_task[
'name'])
15 for job
in up_task.jobs :
16 id =
str(job.runningJob[
'jobId'])
17 jobStatus =
str(job.runningJob[
'statusScheduler'])
18 jobState =
str(job.runningJob[
'state'])
19 dest =
str(job.runningJob[
'destination']).
split(
':')[0]
20 exe_exit_code =
str(job.runningJob[
'applicationReturnCode'])
21 job_exit_code =
str(job.runningJob[
'wrapperReturnCode'])
22 ended =
str(job[
'closed'])
24 if dest ==
'None' : dest =
'' 25 if exe_exit_code ==
'None' : exe_exit_code =
'' 26 if job_exit_code ==
'None' : job_exit_code =
'' 27 if job.runningJob[
'state'] ==
'SubRequested' : jobStatus =
'Submitting' 28 if job.runningJob[
'state'] ==
'Terminated': jobStatus =
'Done' 30 if jobStatus
in summary: summary[jobStatus] += 1
31 else: summary[jobStatus] = 1
34 for item
in summary: summary[item] = 100.*summary[item]/nJobs
39 "Computes jobs summary for given task" 41 taskId =
str(up_task[
'name'])
42 task_unique_name =
str(up_task[
'name'])
47 for job
in up_task.jobs :
48 id =
str(job.runningJob[
'jobId'])
49 jobStatus =
str(job.runningJob[
'statusScheduler'])
50 dest =
str(job.runningJob[
'destination']).
split(
':')[0]
51 exe_exit_code =
str(job.runningJob[
'applicationReturnCode'])
52 job_exit_code =
str(job.runningJob[
'wrapperReturnCode'])
53 ended =
str(job[
'standardInput'])
55 if dest ==
'None' : dest =
'' 56 if exe_exit_code ==
'None' : exe_exit_code =
'' 57 if job_exit_code ==
'None' : job_exit_code =
'' 60 if jobStatus
in summary: summary[jobStatus] += 1
61 else: summary[jobStatus] = 1
64 for item
in summary: summary[item] = 100.*summary[item]/nJobs
68 computeSummary = computeSummaryCRAB260
74 task = common._db.getTask()
75 upTask = common.scheduler.queryEverything(task[
'id'])
76 return computeSummary(upTask)
84 upTask = common._db.getTask()
85 return computeSummary(upTask)
88 # Add method to Status classes 91 Status.Status.summary = summaryStandAlone 92 StatusServer.StatusServer.summary = summaryServer 97 options = parseOptions(options)
102 crab.initialize_(options)
104 if action: result =
action(crab)
106 print 'Log file is %s%s.log'%(common.work_space.logDir(),common.prog_name)
107 except CrabException
as e:
112 if (common.logger): common.logger.delete()
114 if result:
return result
118 options = parseOptions(options)
125 if action: result =
action(crab)
129 except CrabException
as e:
130 print '\n' + common.prog_name +
': ' +
str(e) +
'\n' 135 if result:
return result
142 options = [
'-create',
'-cfg',crabCfg_name]
144 project =
crabAction(options,
lambda crab: common.work_space.topDir())
151 options = [
'-submit',
'-c',project]
158 options = [
'-status']
161 options.append(project)
166 xml = crab.cfg_params.get(
"USER.xml_report",
'')
167 return common.work_space.shareDir() + xml
176 doneStatus = ['Done','Done (success)','Cleared','Retrieved'] 177 failedStatus = ['Aborted','Done (failed)','Killed','Cancelled'] 178 ignoreStatus = ['Created'] 180 doneStatus = [
'SD',
'E']
181 failedStatus = [
'A',
'DA',
'K']
182 runningStatus = [
'R'] 189 if key
in doneStatus: sumDone += status[key]
190 if key
in failedStatus: sumFailed += status[key]
191 if key
in runningStatus: sumRunning += status[key]
192 if key
in ignoreStatus: sumIgnore += status[key]
195 fracDone = 100.0*sumDone/(100.0 - sumIgnore)
196 fracFailed = 100.0*sumFailed/(100.0 - sumIgnore)
197 fracRun = 100.0*sumRunning/(100.0 - sumIgnore)
199 result = {
'Finished':fracDone,
209 print "Percentage of jobs per status:" 210 maxLength =
max( [len(x)
for x
in status] )
212 print "%*s: %.0f%%" % (maxLength,item,status[item])
217 print "Relative percentage finished: %.0f%%" % statusNew[
'Finished']
218 print "Relative percentage failed : %.0f%%" % statusNew[
'Failed']
219 print "Relative percentage running : %.0f%%" % statusNew[
'Running']
226 if statusNew[
'Finished'] >= threshold: finished =
True 231 options = [
'-getoutput']
234 options.append(project)
253 pythonpathenv = os.environ[
'PYTHONPATH']
254 pythonpathbegin = pythonpathenv.split(
':')[0].rstrip(
'/')
255 pythonpathend = pythonpathenv.split(
':')[-1].rstrip(
'/')
257 indexBegin = sys.path.index(pythonpathbegin)
258 if 'CRABPSETPYTHON' in os.environ: sys.path.insert( indexBegin, os.environ[
'CRABPSETPYTHON'] )
259 if 'CRABDLSAPIPYTHON' in os.environ: sys.path.insert( indexBegin, os.environ[
'CRABDLSAPIPYTHON'] )
260 if 'CRABDBSAPIPYTHON' in os.environ: sys.path.insert( indexBegin, os.environ[
'CRABDBSAPIPYTHON'] )
262 if os.environ[
'SCRAM_ARCH'].
find(
'32') != -1
and 'CRABPYSQLITE' in os.environ:
263 sys.path.insert( indexBegin, os.environ[
'CRABPYSQLITE'] )
264 elif os.environ[
'SCRAM_ARCH'].
find(
'64') != -1
and 'CRABPYSQLITE64' in os.environ:
265 sys.path.insert( indexBegin, os.environ[
'CRABPYSQLITE64'] )
267 indexEnd = sys.path.index(pythonpathend) + 1
268 if 'CRABPYTHON' in os.environ:
269 if indexEnd >= len(sys.path): sys.path.append( os.environ[
'CRABPYTHON'] )
270 else: sys.path.insert( indexEnd, os.environ[
'CRABPYTHON'] )
275 os.environ[
'VOMS_PROXY_INFO_DONT_VERIFY_AC'] =
'1' 280 export LD_LIBRARY_PATH=${GLITE_LOCATION}/lib:${LD_LIBRARY_PATH} 281 export VOMS_PROXY_INFO_DONT_VERIFY_AC=1 287 warnings.simplefilter(
"ignore", RuntimeWarning)
295 if 'DBSCMD_HOME' in os.environ:
296 badPaths.append(
'/'.
join(os.environ[
'DBSCMD_HOME'].
split(
'/')[:-1]))
297 if 'DBS_CLIENT_CONFIG' in os.environ:
298 del os.environ[
'DBS_CLIENT_CONFIG']
300 def pathIsGood(checkPath):
302 Filter function for badPaths 304 for badPath
in badPaths:
305 if checkPath.find(badPath) != -1:
309 sys.path =
filter(pathIsGood, sys.path)
311 def run(project = None, threshold = 95.0):
317 if __name__ ==
'__main__':
321 if opt[:8] ==
'project=':
323 print "Running on CRAB project",project
324 if opt[:10] ==
'threshold=':
325 threshold =
float(opt[10:])
326 print "Using threshold",threshold
328 run(project,threshold)
def run(project=None, threshold=95.0)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
def initCrabEnvironment()
def crabCreate(dir='.', crabCfg_name='crab.cfg')
def summaryStandAlone(self)
def crabAction(options, action=None)
def crabActionCRAB251(options, action=None)
def computeSummaryCRAB260(up_task)
def computeSummaryCRAB251(up_task)
static std::string join(char **cmd)
def checkStatus(project, threshold=95.0)
def convertStatus(status)
def crabWatch(action, project=None, threshold=95.0)