本文整理汇总了Python中utils.campaignInfo函数的典型用法代码示例。如果您正苦于以下问题:Python campaignInfo函数的具体用法?Python campaignInfo怎么用?Python campaignInfo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了campaignInfo函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: closor
def closor(url, specific=None, options=None):
if userLock(): return
mlock = moduleLock()
if mlock(): return
up = componentInfo(soft=['mcm','wtc'])
if not up.check(): return
UC = unifiedConfiguration()
CI = campaignInfo()
BI = batchInfo()
CloseI = closeoutInfo()
all_late_files = []
jump_the_line = options.announce if options else False
if jump_the_line:
print "announce option is on. Checking on things on-going ready to be announced"
wfs = session.query(Workflow).filter(Workflow.status.contains('announce')).filter(sqlalchemy.not_(Workflow.status.contains('announced'))).all()
else:
print "regular option. Checking on things done and to be announced"
wfs = session.query(Workflow).filter(Workflow.status=='close').all()
if specific:
wfs = [wfo for wfo in wfs if specific in wfo.name]
wfs_n = [w.name for w in wfs]
print "unique names?"
print len(set(wfs_n)) == len(wfs_n)
held = set()
print len(wfs),"closing"
random.shuffle( wfs )
max_per_round = UC.get('max_per_round').get('closor',None)
if options.limit: max_per_round = options.limit
if max_per_round:
## order them by priority
all_closedout = sorted(getWorkflows(url, 'closed-out', details=True), key = lambda r : r['RequestPriority'])
all_closedout = [r['RequestName'] for r in all_closedout]
def rank( wfn ):
return all_closedout.index( wfn ) if wfn in all_closedout else 0
wfs = sorted( wfs, key = lambda wfo : rank( wfo.name ),reverse=True)
wfs = wfs[:max_per_round]
batch_go = {}
batch_warnings = defaultdict(set)
batch_goodness = UC.get("batch_goodness")
closers = []
print len(wfs),"closing"
th_start = time.mktime(time.gmtime())
for iwfo,wfo in enumerate(wfs):
if specific and not specific in wfo.name: continue
closers.append( CloseBuster(
wfo = wfo,
url = url,
CI = CI,
UC = UC,
jump_the_line = jump_the_line,
batch_goodness = batch_goodness,
batch_go = batch_go,
#stats = stats,
batch_warnings = batch_warnings,
all_late_files = all_late_files,
held = held,
))
run_threads = ThreadHandler( threads = closers,
n_threads = options.threads,
sleepy = 10,
timeout = None,
verbose = True,
label = 'closor')
run_threads.start()
## waiting on all to complete
while run_threads.is_alive():
#print "Waiting on closing threads",time.asctime(time.gmtime())
time.sleep(5)
JC = JIRAClient() if up.status.get('jira',False) else None
print len(run_threads.threads),"finished thread to gather information from"
failed_threads = 0
for to in run_threads.threads:
if to.failed:
failed_threads += 1
continue
if to.outs:
for outO in to.outs:
out = outO.datasetname
odb = session.query(Output).filter(Output.datasetname==out).first()
#.........这里部分代码省略.........
开发者ID:CMSCompOps,项目名称:WmAgentScripts,代码行数:101,代码来源:closor.py
示例2: assignor
def assignor(url ,specific = None, talk=True, options=None):
if userLock(): return
if duplicateLock(): return
if not componentInfo().check(): return
UC = unifiedConfiguration()
CI = campaignInfo()
#SI = siteInfo()
SI = global_SI()
#NLI = newLockInfo()
#if not NLI.free() and not options.go: return
LI = lockInfo()
if not LI.free() and not options.go: return
n_assigned = 0
n_stalled = 0
wfos=[]
fetch_from = []
if specific or options.early:
fetch_from.extend(['considered','staging'])
if specific:
fetch_from.extend(['considered-tried'])
fetch_from.extend(['staged'])
if options.from_status:
fetch_from = options.from_status.split(',')
print "Overriding to read from",fetch_from
for status in fetch_from:
wfos.extend(session.query(Workflow).filter(Workflow.status==status).all())
## in case of partial, go for fetching a list from json ?
#if options.partial and not specific:
# pass
dataset_endpoints = json.loads(open('%s/dataset_endpoints.json'%monitor_dir).read())
aaa_mapping = json.loads(open('%s/equalizor.json'%monitor_pub_dir).read())['mapping']
all_stuck = set()
all_stuck.update( json.loads( open('%s/stuck_transfers.json'%monitor_dir).read() ))
all_stuck.update( getAllStuckDataset())
max_per_round = UC.get('max_per_round').get('assignor',None)
max_cpuh_block = UC.get('max_cpuh_block')
random.shuffle( wfos )
for wfo in wfos:
if options.limit and (n_stalled+n_assigned)>options.limit:
break
if max_per_round and (n_stalled+n_assigned)>max_per_round:
break
if specific:
if not any(map(lambda sp: sp in wfo.name,specific.split(','))): continue
#if not specific in wfo.name: continue
print "\n\n"
wfh = workflowInfo( url, wfo.name)
if options.priority and int(wfh.request['RequestPriority']) < options.priority:
continue
options_text=""
if options.early: options_text+=", early option is ON"
if options.partial:
options_text+=", partial option is ON"
options_text+=", good fraction is %.2f"%options.good_enough
wfh.sendLog('assignor',"%s to be assigned%s"%(wfo.name, options_text))
## the site whitelist takes into account siteInfo, campaignInfo, memory and cores
(lheinput,primary,parent,secondary, sites_allowed) = wfh.getSiteWhiteList()
output_tiers = list(set([o.split('/')[-1] for o in wfh.request['OutputDatasets']]))
is_stuck = (all_stuck & primary)
if is_stuck:
wfh.sendLog('assignor',"%s are stuck input"%(','.join( is_stuck)))
## check if by configuration we gave it a GO
no_go = False
if not wfh.go(log=True) and not options.go:
no_go = True
allowed_secondary = {}
assign_parameters = {}
check_secondary = False
for campaign in wfh.getCampaigns():
if campaign in CI.campaigns:
assign_parameters.update( CI.campaigns[campaign] )
if campaign in CI.campaigns and 'secondaries' in CI.campaigns[campaign]:
if CI.campaigns[campaign]['secondaries']:
allowed_secondary.update( CI.campaigns[campaign]['secondaries'] )
check_secondary = True
if campaign in CI.campaigns and 'banned_tier' in CI.campaigns[campaign]:
#.........这里部分代码省略.........
开发者ID:prozober,项目名称:WmAgentScripts,代码行数:101,代码来源:assignor.py
示例3: recoveror
def recoveror(url,specific,options=None):
if userLock('recoveror'): return
up = componentInfo()
CI = campaignInfo()
UC = unifiedConfiguration()
def make_int_keys( d ):
for code in d:
d[int(code)] = d.pop(code)
error_codes_to_recover = UC.get('error_codes_to_recover')
error_codes_to_block = UC.get('error_codes_to_block')
error_codes_to_notify = UC.get('error_codes_to_notify')
make_int_keys( error_codes_to_recover )
make_int_keys( error_codes_to_block )
make_int_keys( error_codes_to_notify )
wfs = session.query(Workflow).filter(Workflow.status == 'assistance-recovery').all()
if specific:
wfs.extend( session.query(Workflow).filter(Workflow.status == 'assistance-manual').all() )
for wfo in wfs:
if specific and not specific in wfo.name:continue
if not specific and 'manual' in wfo.status: continue
wfi = workflowInfo(url, wfo.name, deprecated=True) ## need deprecated info for mergedlfnbase
## need a way to verify that this is the first round of ACDC, since the second round will have to be on the ACDC themselves
all_errors = None
try:
wfi.getSummary()
all_errors = wfi.summary['errors']
except:
pass
print '-'*100
print "Looking at",wfo.name,"for recovery options"
if not len(all_errors):
print "\tno error for",wfo.name
task_to_recover = defaultdict(list)
message_to_ops = ""
message_to_user = ""
recover=True
if 'LheInputFilese' in wfi.request and wfi.request['LheInputFiles']:
## we do not try to recover pLHE
recover = False
if 'Campaign' in wfi.request:
c = wfi.request['Campaign']
if c in CI.campaigns and 'recover' in CI.campaigns[c]:
recover=CI.campaigns[c]['recover']
for task,errors in all_errors.items():
print "\tTask",task
## collect all error codes and #jobs regardless of step at which it occured
all_codes = []
for name, codes in errors.items():
if type(codes)==int: continue
all_codes.extend( [(int(code),info['jobs'],name,list(set([e['type'] for e in info['errors']])),list(set([e['details'] for e in info['errors']])) ) for code,info in codes.items()] )
all_codes.sort(key=lambda i:i[1], reverse=True)
sum_failed = sum([l[1] for l in all_codes])
for errorCode,njobs,name,types,details in all_codes:
rate = 100*njobs/float(sum_failed)
#print ("\t\t %10d (%6s%%) failures with error code %10d (%"+str(max_legend)+"s) at stage %s")%(njobs, "%4.2f"%rate, errorCode, legend, name)
print ("\t\t %10d (%6s%%) failures with error code %10d (%30s) at stage %s")%(njobs, "%4.2f"%rate, errorCode, ','.join(types), name)
added_in_recover=False
#if options.go:
# force the recovery of any task with error ?
if errorCode in error_codes_to_recover:
## the error code is registered
for case in error_codes_to_recover[errorCode]:
match = case['details']
matched= (match==None)
if not matched:
matched=False
for detail in details:
if match in detail:
print "[recover] Could find keyword",match,"in"
print 50*"#"
print detail
print 50*"#"
matched = True
break
if matched and rate > case['rate']:
print "\t\t => we should be able to recover that", case['legend']
task_to_recover[task].append( (code,case) )
added_in_recover=True
message_to_user = ""
#.........这里部分代码省略.........
开发者ID:julianbadillo,项目名称:WmAgentScripts,代码行数:101,代码来源:recoveror.py
示例4: checkor
def checkor(url, spec=None, options=None):
if userLock(): return
if duplicateLock() and not options.go: return
fDB = closeoutInfo()
UC = unifiedConfiguration()
use_mcm = True
up = componentInfo(mcm=use_mcm, soft=['mcm'])
if not up.check(): return
use_mcm = up.status['mcm']
def time_point(label="",sub_lap=False):
now = time.mktime(time.gmtime())
nows = time.asctime(time.gmtime())
print "Time check (%s) point at : %s"%(label, nows)
print "Since start: %s [s]"% ( now - time_point.start)
if sub_lap:
print "Sub Lap : %s [s]"% ( now - time_point.sub_lap )
time_point.sub_lap = now
else:
print "Lap : %s [s]"% ( now - time_point.lap )
time_point.lap = now
time_point.sub_lap = now
time_point.sub_lap = time_point.lap = time_point.start = time.mktime(time.gmtime())
runnings = session.query(Workflow).filter(Workflow.status == 'away').all()
standings = session.query(Workflow).filter(Workflow.status.startswith('assistance')).all()
## intersect with what is actually in completed status in request manager now
all_completed = set(getWorkflows(url, 'completed' ))
wfs=[]
if options.strict:
## the one which were running and now have completed
print "strict option is on: checking workflows that freshly completed"
wfs.extend( filter(lambda wfo: wfo.name in all_completed , runnings))
if options.update:
print "update option is on: checking workflows that have not completed yet"
wfs.extend( filter(lambda wfo: not wfo.name in all_completed , runnings))
if options.clear:
print "clear option is on: checking workflows that are ready to toggle closed-out"
wfs.extend( filter(lambda wfo: 'custodial' in wfo.status, standings))
if options.review:
print "review option is on: checking the workflows that needed intervention"
wfs.extend( filter(lambda wfo: not 'custodial' in wfo.status, standings))
## what is left out are the wf which were running and ended up aborted/failed/...
custodials = defaultdict(list) #sites : dataset list
transfers = defaultdict(list) #sites : dataset list
invalidations = [] #a list of files
SI = siteInfo()
CI = campaignInfo()
mcm = McMClient(dev=False) if use_mcm else None
def get_campaign(output, wfi):
## this should be a perfect matching of output->task->campaign
campaign = None
era = None
wf_campaign = None
if 'Campaign' in wfi.request: wf_campaign = wfi.request['Campaign']
try:
era = output.split('/')[2].split('-')[0]
except:
era = None
if wfi.isRelval():
campaign = wf_campaign
else:
campaign = era if era else wf_campaign
return campaign
## retrieve bypass and onhold configuration
bypasses = []
forcings = []
overrides = getForceCompletes()
holdings = []
actors = UC.get('allowed_bypass')
for bypassor,email in actors:
bypass_file = '/afs/cern.ch/user/%s/%s/public/ops/bypass.json'%(bypassor[0],bypassor)
if not os.path.isfile(bypass_file):
#sendLog('checkor','no file %s',bypass_file)
continue
try:
bypasses.extend( json.loads(open(bypass_file).read()))
except:
sendLog('checkor',"cannot get by-passes from %s for %s"%(bypass_file ,bypassor))
sendEmail("malformated by-pass information","%s is not json readable"%(bypass_file), destination=[email])
holding_file = '/afs/cern.ch/user/%s/%s/public/ops/onhold.json'%(bypassor[0],bypassor)
#.........这里部分代码省略.........
开发者ID:dabercro,项目名称:WmAgentScripts,代码行数:101,代码来源:checkor.py
示例5: completor
def completor(url, specific):
use_mcm = True
up = componentInfo(mcm=use_mcm, soft=['mcm'])
if not up.check(): return
use_mcm = up.status['mcm']
if use_mcm:
mcm = McMClient(dev=False)
CI = campaignInfo()
SI = siteInfo()
UC = unifiedConfiguration()
wfs = []
wfs.extend( session.query(Workflow).filter(Workflow.status == 'away').all() )
wfs.extend( session.query(Workflow).filter(Workflow.status.startswith('assistance')).all() )
## just take it in random order so that not always the same is seen
random.shuffle( wfs )
max_per_round = UC.get('max_per_round').get('completor',None)
if max_per_round and not specific: wfs = wfs[:max_per_round]
## by workflow a list of fraction / timestamps
completions = json.loads( open('%s/completions.json'%monitor_dir).read())
good_fractions = {}
timeout = {}
for c in CI.campaigns:
if 'force-complete' in CI.campaigns[c]:
good_fractions[c] = CI.campaigns[c]['force-complete']
if 'force-timeout' in CI.campaigns[c]:
timeout[c] = CI.campaigns[c]['force-timeout']
long_lasting = {}
overrides = getForceCompletes()
if use_mcm:
## add all workflow that mcm wants to get force completed
mcm_force = mcm.get('/restapi/requests/forcecomplete')
## assuming this will be a list of actual prepids
overrides['mcm'] = mcm_force
print "can force complete on"
print json.dumps( good_fractions ,indent=2)
print json.dumps( overrides, indent=2)
max_force = UC.get("max_force_complete")
#wfs_no_location_in_GQ = set()
#block_locations = defaultdict(lambda : defaultdict(list))
#wfs_no_location_in_GQ = defaultdict(list)
set_force_complete = set()
for wfo in wfs:
if specific and not specific in wfo.name: continue
print "looking at",wfo.name
## get all of the same
wfi = workflowInfo(url, wfo.name)
pids = wfi.getPrepIDs()
skip=False
if not any([c in wfo.name for c in good_fractions]): skip=True
for user,spec in overrides.items():
if wfi.request['RequestStatus']!='force-complete':
if any(s in wfo.name for s in spec) or (wfo.name in spec) or any(pid in spec for pid in pids) or any(s in pids for s in spec):
sendEmail('force-complete requested','%s is asking for %s to be force complete'%(user,wfo.name))
wfi = workflowInfo(url, wfo.name)
forceComplete(url , wfi )
skip=True
wfi.notifyRequestor("The workflow %s was force completed by request of %s"%(wfo.name,user), do_batch=False)
wfi.sendLog('completor','%s is asking for %s to be force complete'%(user,wfo.name))
break
if wfo.status.startswith('assistance'): skip = True
if skip:
continue
priority = wfi.request['RequestPriority']
if not 'Campaign' in wfi.request: continue
if not wfi.request['RequestStatus'] in ['acquired','running-open','running-closed']: continue
c = wfi.request['Campaign']
if not c in good_fractions: continue
good_fraction = good_fractions[c]
ignore_fraction = 2.
lumi_expected = None
event_expected = None
if not 'TotalInputEvents' in wfi.request:
if 'RequestNumEvents' in wfi.request:
event_expected = wfi.request['RequestNumEvents']
else:
print "truncated, cannot do anything"
continue
else:
#.........这里部分代码省略.........
开发者ID:AndrewLevin,项目名称:WmAgentScripts,代码行数:101,代码来源:completor.py
示例6: assignor
def assignor(url ,specific = None, talk=True, options=None):
if userLock(): return
if duplicateLock(): return
if not componentInfo().check(): return
UC = unifiedConfiguration()
CI = campaignInfo()
SI = global_SI
#LI = lockInfo()
NLI = newLockInfo()
n_assigned = 0
n_stalled = 0
wfos=[]
if specific or options.early:
wfos.extend( session.query(Workflow).filter(Workflow.status=='considered').all())
wfos.extend( session.query(Workflow).filter(Workflow.status=='staging').all())
if specific:
wfos.extend( session.query(Workflow).filter(Workflow.status=='considered-tried').all())
wfos.extend(session.query(Workflow).filter(Workflow.status=='staged').all())
dataset_endpoints = json.loads(open('%s/dataset_endpoints.json'%monitor_dir).read())
max_per_round = UC.get('max_per_round').get('assignor',None)
max_cpuh_block = UC.get('max_cpuh_block')
random.shuffle( wfos )
for wfo in wfos:
if options.limit and (n_stalled+n_assigned)>options.limit:
break
if max_per_round and (n_stalled+n_assigned)>max_per_round:
break
if specific:
if not any(map(lambda sp: sp in wfo.name,specific.split(','))): continue
#if not specific in wfo.name: continue
print "\n\n"
wfh = workflowInfo( url, wfo.name)
wfh.sendLog('assignor',"%s to be assigned"%wfo.name)
## the site whitelist takes into account siteInfo, campaignInfo, memory and cores
(lheinput,primary,parent,secondary, sites_allowed) = wfh.getSiteWhiteList()
## check if by configuration we gave it a GO
no_go = False
allowed_secondary = set()
for campaign in wfh.getCampaigns():
if not CI.go( campaign ):
wfh.sendLog('assignor',"No go for %s"%campaign)
if not options.go:
n_stalled+=1
no_go = True
break
if campaign in CI.campaigns and 'secondaries' in CI.campaigns[campaign]:
allowed_secondary.update( CI.campaigns[campaign]['secondaries'] )
if (secondary and allowed_secondary) and (set(secondary)&allowed_secondary!=set(secondary)):
wfh.sendLog('assignor','%s is not an allowed secondary'%(', '.join(set(secondary)-allowed_secondary)))
#sendEmail('secondary not allowed','%s is not an allowed secondary'%( ', '.join(set(secondary)-allowed_secondary)))
sendLog('assignor','%s is not an allowed secondary'%(', '.join(set(secondary)-allowed_secondary)), level='critical')
if not options.go:
n_stalled+=1
no_go = True
if no_go:
continue
## check on current status for by-passed assignment
if wfh.request['RequestStatus'] !='assignment-approved':
if not options.test:
wfh.sendLog('assignor',"setting %s away and skipping"%wfo.name)
## the module picking up from away will do what is necessary of it
wfo.wm_status = wfh.request['RequestStatus']
wfo.status = 'away'
session.commit()
continue
else:
print wfo.name,wfh.request['RequestStatus']
## retrieve from the schema, dbs and reqMgr what should be the next version
version=wfh.getNextVersion()
if not version:
if options and options.ProcessingVersion:
version = options.ProcessingVersion
else:
wfh.sendLog('assignor',"cannot decide on version number")
n_stalled+=1
wfo.status = 'trouble'
session.commit()
continue
original_sites_allowed = copy.deepcopy( sites_allowed )
wfh.sendLog('assignor',"Site white list %s"%sorted(sites_allowed))
override_sec_location = CI.get(wfh.request['Campaign'], 'SecondaryLocation', [])
blocks = []
if 'BlockWhitelist' in wfh.request:
#.........这里部分代码省略.........
开发者ID:amaltaro,项目名称:WmAgentScripts,代码行数:101,代码来源:assignor.py
示例7: completor
def completor(url, specific):
CI = campaignInfo()
wfs = []
wfs.extend(session.query(Workflow).filter(Workflow.status == "away").all())
##wfs.extend( session.query(Workflow).filter(Workflow.status.startswith('assistance')).all() )
## just take it in random order
random.shuffle(wfs)
## by workflow a list of fraction / timestamps
completions = json.loads(open("completions.json").read())
good_fractions = {}
for c in CI.campaigns:
if "force-complete" in CI.campaigns[c]:
good_fractions[c] = CI.campaigns[c]["force-complete"]
print "can force complete on"
print json.dumps(good_fractions, indent=2)
for wfo in wfs:
if specific and not specific in wfo.name:
continue
if not any([c in wfo.name for c in good_fractions]):
continue
print "looking at", wfo.name
## get all of the same
wfi = workflowInfo(url, wfo.name)
if not "Campaign" in wfi.request:
continue
c = wfi.request["Campaign"]
if not c in good_fractions:
continue
good_fraction = good_fractions[c]
ignore_fraction = 2.0
lumi_expected = None
event_expected = None
if not "TotalInputEvents" in wfi.request:
if "RequestNumEvents" in wfi.request:
event_expected = wfi.request["RequestNumEvents"]
else:
continue
else:
lumi_expected = wfi.request["TotalInputLumis"]
event_expected = wfi.request["TotalInputEvents"]
now = time.mktime(time.gmtime()) / (60 * 60 * 24.0)
running_log = filter(
lambda change: change["Status"] in ["running-open", "running-closed"], wfi.request["RequestTransition"]
)
if not running_log:
print "\tHas no running log"
# cannot figure out when the thing started running
continue
then = running_log[-1]["UpdateTime"] / (60.0 * 60.0 * 24.0)
delay = now - then ## in days
(w, d) = divmod(delay, 7)
print "\t" * int(w) + "Running since", delay, "[days]"
if delay <= 4:
continue
if delay >= 7:
sendEmail("long lasting workflow", "%s has been running for %s days" % (wfo.name, delay))
percent_completions = {}
for output in wfi.request["OutputDatasets"]:
if not output in completions:
completions[output] = {"injected": None, "checkpoints": [], "workflow": wfo.name}
## get completion fraction
event_count, lumi_count = getDatasetEventsAndLumis(dataset=output)
lumi_completion = 0.0
event_completion = 0.0
if lumi_expected:
lumi_completion = lumi_count / float(lumi_expected)
if event_expected:
event_completion = event_count / float(event_expected)
# take the less optimistic
percent_completions[output] = min(lumi_completion, event_completion)
completions[output]["checkpoints"].append((now, event_completion))
if all([percent_completions[out] >= good_fraction for out in percent_completions]):
print "all is above", good_fraction, "for", wfo.name
print json.dumps(percent_completions, indent=2)
else:
print "\t", percent_completions.values(), "not over bound", good_fraction
# print json.dumps( percent_completions, indent=2 )
continue
if all([percent_completions[out] >= ignore_fraction for out in percent_completions]):
print "all is done, just wait a bit"
continue
for output in percent_completions:
#.........这里部分代码省略.........
开发者ID:bbockelm,项目名称:WmAgentScripts,代码行数:101,代码来源:completor.py
示例8: htmlor
#.........这里部分代码省略.........
def display_time( sec ):
m, s = divmod(sec, 60)
h, m = divmod(m, 60)
dis=""
if h:
dis += "%d [h] "%h
if h or m:
dis += "%d [m] "%m
if h or m or s:
dis += "%d [s]"%s
return dis
html_doc.write("Module running time<ul>\n")
for m,spends in per_module.items():
avg = sum(spends)/float(len(spends))
lasttime = spends[-1]
html_doc.write("<li>%s : last %s, avg %s</li>\n"%( m, display_time(lasttime), display_time(avg)))
html_doc.write("</ul>")
html_doc.write("Last running <pre>%s</pre><br>"%( os.popen("tac %s/logs/running | head -5"%monitor_dir).read() ))
html_doc.write("Order in cycle <pre>%s</pre><br>"%( '\n'.join(map(lambda l : l.split('/')[-1].replace('.py',''), filter(lambda l : not l.startswith('#') and 'Unified' in l and 'py' in l.split('/')[-1], open('%s/WmAgentScripts/cycle.sh'%base_dir).read().split('\n')))) ))
html_doc.write("</div>\n")
lap ( 'done with jobs' )
text=""
count=0
for (c,info) in campaignInfo().campaigns.items():
#if 'go' in info and info['go']:
text+="<li>%s <br> <pre>%s</pre> </li>"%( c, json.dumps( info, indent=2))
count+=1
html_doc.write("""Campaign configuration
<a href="javascript:showhide('campaign')">[Click to show/hide]</a>
<br>
<div id="campaign" style="display:none;">
<br>
<ul>
%s
</ul></div>
"""%(text))
text=""
count=0
n_column = 4
SI = siteInfo()
date1 = time.strftime('%Y-%m-%d+%H:%M', time.gmtime(time.mktime(time.gmtime())-(15*24*60*60)) ) ## 15 days
date2 = time.strftime('%Y-%m-%d+%H:%M', time.gmtime())
for t in SI.types():
text+="<li>%s<table border=1>"%t
c=0
for site in getattr(SI,t):
cpu = SI.cpu_pledges[site] if site in SI.cpu_pledges else 'N/A'
disk = SI.disk[SI.CE_to_SE(site)] if SI.CE_to_SE(site) in SI.disk else 'N/A'
if c==0:
text+="<tr>"
if not disk:
ht_disk = '<font color=red>Disk available: %s</font>'%disk
else:
ht_disk = 'Disk available: %s'%disk
开发者ID:areinsvo,项目名称:WmAgentScripts,代码行数:67,代码来源:htmlor.py
示例9: checkor
def checkor(url, spec=None, options=None):
if userLock(): return
if duplicateLock(): return
fDB = closeoutInfo()
UC = unifiedConfiguration()
use_mcm = True
up = componentInfo(mcm=use_mcm, soft=['mcm'])
if not up.check(): return
use_mcm = up.status['mcm']
wfs=[]
if options.new:
## get all in running and check
## you want to intersect with what is completed !
if options.strict:
completed_wfi = getWorkflows(url, status='completed')
for wfo in session.query(Workflow).filter(Workflow.status == 'away').all():
if wfo.name in completed_wfi:
wfs.append( wfo )
else:
print wfo.name,"is not completed"
sendLog('checkor','%s is not completed'%( wfo.name))
else:
wfs.extend( session.query(Workflow).filter(Workflow.status == 'away').all() )
if options.current:
## recheck those already there, probably to just pass them along
wfs.extend( session.query(Workflow).filter(Workflow.status== 'assistance').all() )
if options.old:
## than get all in need for assistance
wfs.extend( session.query(Workflow).filter(Workflow.status.startswith('assistance-')).all() )
custodials = defaultdict(list) #sites : dataset list
transfers = defaultdict(list) #sites : dataset list
invalidations = [] #a list of files
SI = global_SI
CI = campaignInfo()
mcm = McMClient(dev=False)
def get_campaign(output, wfi):
campaign = None
try:
campaign = output.split('/')[2].split('-')[0]
except:
if 'Campaign' in wfi.request:
campaign = wfi.request['Campaign']
return campaign
## retrieve bypass and onhold configuration
bypasses = []
holdings = []
#try:
# already_notified = json.loads(open('already_notifified.json').read())
#except:
# print "no record of already notified workflow. starting fresh"
# already_notified = []
for bypassor,email in [('vlimant','[email protected]'),('jen_a','[email protected]')]:
bypass_file = '/afs/cern.ch/user/%s/%s/public/ops/bypass.json'%(bypassor[0],bypassor)
if not os.path.isfile(bypass_file):
#sendLog('checkor','no file %s',bypass_file)
continue
try:
bypasses.extend( json.loads(open(bypass_file).read()))
except:
sendLog('checkor',"cannot get by-passes from %s for %s"%(bypass_file ,bypassor))
sendEmail("malformated by-pass information","%s is not json readable"%(bypass_file), destination=[email])
holding_file = '/afs/cern.ch/user/%s/%s/public/ops/onhold.json'%(bypassor[0],bypassor)
if not os.path.isfile(holding_file):
#sendLog('checkor',"no file %s"%holding_file)
continue
try:
holdings.extend( json.loads(open(holding_file).read()))
except:
sendLog('checkor',"cannot get holdings from %s for %s"%(holding_file, bypassor))
sendEmail("malformated by-pass information","%s is not json readable"%(holding_file), destination=[email])
## once this was force-completed, you want to bypass
for rider,email in [('vlimant','[email protected]'),('jen_a','[email protected]'),('srimanob','[email protected]')]:
rider_file = '/afs/cern.ch/user/%s/%s/public/ops/forcecomplete.json'%(rider[0],rider)
if not os.path.isfile(rider_file):
print "no file",rider_file
#sendLog('checkor',"no file %s"%rider_file)
continue
try:
bypasses.extend( json.loads(open( rider_file ).read() ) )
except:
sendLog('checkor',"cannot get force complete list from %s"%rider)
sendEmail("malformated force complet file","%s is not json readable"%rider_file, destination=[email])
if use_mcm:
mcm_force = mcm.get('/restapi/requests/forcecomplete')
bypasses.extend( mcm_force )
#.........这里部分代码省略.........
开发者ID:amaltaro,项目名称:WmAgentScripts,代码行数:101,代码来源:checkor.py
示例10: htmlor
#.........这里部分代码省略.........
lines_lastweek.sort()
html_doc.write("""Output produced <a href=https://dmytro.web.cern.ch/dmytro/cmsprodmon/requests.php?in_disagreement=1 target=_blank>disagreements</a> (%d)
<a href="javascript:showhide('output')">[Click to show/hide]</a>
<br>
<div id="output" style="display:none;">
<br>
<ul>
<li> Last week (%d) </li><a href="javascript:showhide('output_lastweek')">[Click to show/hide]</a><div id="output_lastweek" style="display:none;"><ul>
%s
</ul></div>
<li> This week (%d) </li><a href="javascript:showhide('output_thisweek')">[Click to show/hide]</a><div id="output_thisweek" style="display:none;"><ul>
%s
</ul></div></div>
"""%( len(lines_lastweek)+len(lines_thisweek),
len(lines_lastweek),
'\n'.join(lines_lastweek),
len(lines_thisweek),
'\n'.join(lines_thisweek))
)
html_doc.write("""Job installed
<a href="javascript:showhide('acron')">[Click to show/hide]</a>
<br>
<div id="acron" style="display:none;">
<br>
<pre>
%s
</pre></div>
"""%(os.popen('acrontab -l | grep Unified').read()))
text=""
count=0
for (c,info) in campaignInfo().campaigns.items():
#if 'go' in info and info['go']:
text+="<li>%s <br> <pre>%s</pre> </li>"%( c, json.dumps( info, indent=2))
count+=1
html_doc.write("""Campaign configuration
<a href="javascript:showhide('campaign')">[Click to show/hide]</a>
<br>
<div id="campaign" style="display:none;">
<br>
<ul>
%s
</ul></div>
"""%(text))
text=""
count=0
n_column = 4
SI = siteInfo()
for t in SI.types():
#text+="<li>%s<ul>"%t
#for site in getattr(SI,t):
# text+="<li><a href=http://hcc-briantest.unl.edu/prodview/%s>%s<a/> </li>"%( site, site)
# text+='<a href="http://hcc-briantest.unl.edu/prodview/%s" target="_blank"><img src="http://hcc-briantest.unl.edu/prodview/graphs/%s/daily" style="height:50px"></a>'%(site,site)
#text+="</ul></li>"
text+="<li>%s<table border=1>"%t
c=0
for site in getattr(SI,t):
cpu = SI.cpu_pledges[site] if site in SI.cpu_pledges else 'N/A'
disk = SI.disk[SI.CE_to_SE(site)] if SI.CE_to_SE(site) in SI.disk else 'N/A'
if c==0:
text+="<tr>"
开发者ID:lucacopa,项目名称:WmAgentScripts,代码行数:67,代码来源:htmlor.py
示例11: checkor
def checkor(url, spec=None, options=None):
fDB = closeoutInfo()
if userLock():
return
if duplicateLock():
return
UC = unifiedConfiguration()
use_mcm = True
up = componentInfo(mcm=use_mcm, soft=["mcm"])
if not up.check():
return
use_mcm = up.status["mcm"]
wfs = []
if options.fetch:
## get all in running and check
wfs.extend(session.query(Workflow).filter(Workflow.status == "away").all())
wfs.extend(session.query(Workflow).filter(Workflow.status == "assistance").all())
if options.nofetch:
## than get all in need for assistance
wfs.extend(session.query(Workflow).filter(Workflow.status.startswith("assistance-")).all())
custodials = defaultdict(list) # sites : dataset list
transfers = defaultdict(list) # sites : dataset list
invalidations = [] # a list of files
SI = global_SI
CI = campaignInfo()
mcm = McMClient(dev=False)
def get_campaign(output, wfi):
campaign = None
try:
campaign = output.split("/")[2].split("-")[0]
except:
if "Campaign" in wfi.request:
campaign = wfi.request["Campaign"]
return campaign
by_passes = []
holdings = []
for bypassor, email in [
("jbadillo", "[email protected]"),
("vlimant", "[email protected]"),
("jen_a", "[email protected]"),
]:
bypass_file = "/afs/cern.ch/user/%s/%s/public/ops/bypass.json" % (bypassor[0], bypassor)
if not os.path.isfile(bypass_file):
print "no file", bypass_file
continue
try:
by_passes.extend(json.loads(open(bypass_file).read()))
except:
print "cannot get by-passes from", bypass_file, "for", bypassor
sendEmail("malformated by-pass information", "%s is not json readable" % (bypass_file), destination=[email])
holding_file = "/afs/cern.ch/user/%s/%s/public/ops/onhold.json" % (bypassor[0], bypassor)
if not os.path.isfile(holding_file):
print "no file", holding_file
continue
try:
holdings.extend(json.loads(open(holding_file).read()))
except:
print "cannot get holdings from", holding_file, "for", bypassor
sendEmail(
"malformated by-pass information", "%s is not json readable" % (holding_file), destination=[email]
)
total_running_time = 5.0 * 60.0
sleep_time = max(0.5, total_running_time / len(wfs))
for wfo in wfs:
if spec and not (spec in wfo.name):
continue
time.sleep(sleep_time)
print "checking on", wfo.name
## get info
wfi = workflowInfo(url, wfo.name)
## make sure the wm status is up to date.
# and send things back/forward if necessary.
wfo.wm_status = wfi.request["RequestStatus"]
if wfo.wm_status == "closed-out":
## manually closed-out
print wfo.name, "is already", wfo.wm_status
wfo.status = "close"
session.commit()
continue
elif wfo.wm_status in [
"failed",
"aborted",
"aborted-archived",
"rejected",
"rejected-archived",
"aborted-completed",
]:
## went into trouble
wfo.status = "trouble"
#.........这里部分代码省略.........
开发者ID:bbockelm,项目名称:WmAgentScripts,代码行数:101,代码来源:checkor.py
示例12: equalizor
def equalizor(url , specific = None, options=None):
up = componentInfo(mcm=False, soft=['mcm'])
if not up.check(): return
if not specific:
workflows = getWorkflows(url, status='running-closed', details=True)
workflows.extend(getWorkflows(url, status='running-open', details=True))
## start from scratch
modifications = defaultdict(dict)
## define regionality site => fallback allowed. feed on an ssb metric ??
mapping = defaultdict(list)
reversed_mapping = defaultdict(list)
regions = defaultdict(list)
SI = siteInfo()
CI = campaignInfo()
UC = unifiedConfiguration()
for site in SI.sites_ready:
region = site.split('_')[1]
if not region in ['US','DE','IT']: continue
regions[region] = [region]
def site_in_depletion(s):
return True
if s in SI.sites_pressure:
(m, r, pressure) = SI.sites_pressure[s]
if float(m) < float(r):
print s,m,r,"lacking pressure"
return True
else:
print s,m,r,"pressure"
pass
return False
for site in SI.sites_ready:
region = site.split('_')[1]
## fallback to the region, to site with on-going low pressure
mapping[site] = [fb for fb in SI.sites_ready if any([('_%s_'%(reg) in fb and fb!=site and site_in_depletion(fb))for reg in regions[region]]) ]
use_T0 = ('T0_CH_CERN' in UC.get("site_for_overflow"))
if options.t0: use_T0 = True
#if options.augment : use_T0 = True
use_HLT = ('T2_CH_CERN_HLT' in UC.get("site_for_overflow"))
if options.hlt: use_HLT = True
#if options.augment : use_HLT=True
if use_HLT:
mapping['T2_CH_CERN'].append('T2_CH_CERN_HLT')
if use_T0:
mapping['T2_CH_CERN'].append('T0_CH_CERN')
#mapping['T1_FR_CCIN2P3'].append('T0_CH_CERN')
#mapping['T2_IT_Legnaro'].append('T1_IT_CNAF')
for reg in ['IT','DE','UK']:
mapping['T2_CH_CERN'].extend([fb for fb in SI.sites_ready if '_%s_'%reg in fb])
## make them appear as OK to use
force_sites = []
## overflow CERN to underutilized T1s
upcoming = json.loads( open('%s/GQ.json'%monitor_dir).read())
for possible in SI.sites_T1s:
if not possible in upcoming:
mapping['T2_CH_CERN'].append(possible)
## remove add-hoc sites from overflow mapping
prevent_sites = ['T2_US_Purdue']
for prevent in prevent_sites:
if prevent in mapping: mapping.pop( prevent )
for src in mapping:
for prevent in prevent_sites:
if prevent in mapping[src]:
mapping[src].remove( prevent )
## create the reverse mapping for the condor module
for site,fallbacks in mapping.items():
for fb in fallbacks:
reversed_mapping[fb].append(site)
## this is the fallback mapping
print "Direct mapping : site => overflow"
print json.dumps( mapping, indent=2)
print "Reverse mapping : dest <= from origin"
print json.dumps( reversed_mapping, indent=2)
altered_tasks = set()
def running_idle( wfi , task_name):
gmon = wfi.getGlideMon()
#print gmon
if not gmon: return (0,0)
if not task_name in gmon: return (0,0)
return (gmon[task_name]['Running'], gmon[task_name]['Idle'])
def needs_action( wfi, task, min_idled = 100, pressure = 0.2):
#.........这里部分代码省略.........
开发者ID:amaltaro,项目名称:WmAgentScripts,代码行数:101,代码来源:equalizor.py
示例13: closor
def closor(url, specific=None):
CI = campaignInfo()
## manually closed-out workflows should get to close with checkor
for wfo in session.query(Workflow).filter(Workflow.status=='close').all():
if specific and not specific in wfo.name: continue
## what is the expected #lumis
wl = getWorkLoad(url, wfo.name)
wfo.wm_status = wl['RequestStatus']
if wl['RequestStatus'] in ['announced','normal-archived']:
## manually announced ??
wfo.status = 'done'
wfo.wm_status = wl['RequestStatus']
print wfo.name,"is done already",wfo.wm_status
session.commit()
if not 'TotalInputLumis' in wl:
print wfo.name,"has not been assigned yet"
continue
expected_lumis = wl['TotalInputLumis']
## what are the outputs
outputs = wl['OutputDatasets']
## check whether the number of lumis is as expected for each
all_OK = []
#print outputs
if len(outputs):
print wfo.
|
请发表评论