本文整理汇总了Python中WMCore.Services.WorkQueue.WorkQueue.WorkQueue.updateElements方法的典型用法代码示例。如果您正苦于以下问题:Python WorkQueue.updateElements方法的具体用法?Python WorkQueue.updateElements怎么用?Python WorkQueue.updateElements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WMCore.Services.WorkQueue.WorkQueue.WorkQueue
的用法示例。
在下文中一共展示了WorkQueue.updateElements方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testCompletedWorkflow
# 需要导入模块: from WMCore.Services.WorkQueue.WorkQueue import WorkQueue [as 别名]
# 或者: from WMCore.Services.WorkQueue.WorkQueue.WorkQueue import updateElements [as 别名]
def testCompletedWorkflow(self):
# test getWork
specName = "RerecoSpec"
specUrl = self.specGenerator.createReRecoSpec(specName, "file")
globalQ = globalQueue(DbName='workqueue_t',
QueueURL=self.testInit.couchUrl,
UnittestFlag=True)
self.assertTrue(globalQ.queueWork(specUrl, specName, "teamA") > 0)
wqApi = WorkQueueDS(self.testInit.couchUrl, 'workqueue_t')
# overwrite default - can't test with stale view
wqApi.defaultOptions = {'reduce': True, 'group': True}
# This only checks minimum client call not exactly correctness of return
# values.
self.assertEqual(wqApi.getTopLevelJobsByRequest(),
[{'total_jobs': 339, 'request_name': specName}])
results = wqApi.getJobsByStatusAndPriority()
self.assertEqual(results.keys(), ['Available'])
self.assertEqual(results['Available'].keys(), [8000])
self.assertTrue(results['Available'][8000]['sum'], 339)
result = wqApi.getElementsCountAndJobsByWorkflow()
self.assertEqual(len(result), 1)
self.assertEqual(result[specName]['Available']['Jobs'], 339)
data = wqApi.db.loadView('WorkQueue', 'elementsDetailByWorkflowAndStatus',
{'startkey': [specName], 'endkey': [specName, {}],
'reduce': False})
elements = [x['id'] for x in data.get('rows', [])]
wqApi.updateElements(*elements, Status='Canceled')
# load this view once again to make sure it will be updated in the next assert..
data = wqApi.db.loadView('WorkQueue', 'elementsDetailByWorkflowAndStatus',
{'startkey': [specName], 'endkey': [specName, {}],
'reduce': False})
self.assertEqual(len(wqApi.getCompletedWorkflow(stale=False)), 1)
self.assertEqual(wqApi.getJobsByStatusAndPriority().keys(), ['Canceled'])
示例2: main
# 需要导入模块: from WMCore.Services.WorkQueue.WorkQueue import WorkQueue [as 别名]
# 或者: from WMCore.Services.WorkQueue.WorkQueue.WorkQueue import updateElements [as 别名]
def main():
# FIXME update the workflow name here
wf = "mcremone_task_EXO-RunIISummer15wmLHEGS-04802__v1_T_170811_181808_305"
print("Looking for problematic inbox elements...")
wq = WorkQueue("https://cmsweb.cern.ch/couchdb/workqueue")
print("Workqueue config: server %s and db %s" % (wq.server.url, wq.db.name))
nonCancelableElements = ['Done', 'Canceled', 'Failed']
data = wq.db.loadView('WorkQueue', 'elementsDetailByWorkflowAndStatus',
{'startkey': [wf], 'endkey': [wf, {}], 'reduce': False})
elements = [x['id'] for x in data.get('rows', []) if x['key'][1] not in nonCancelableElements]
print("Found %d elements for wf %s" % (len(elements), wf))
total = 0
for eleSlice in grouper(elements, 100):
try:
wq.updateElements(*eleSlice, Status='CancelRequested')
except Exception as ex:
print("Exception happened, but keep going: %s" % str(ex))
else:
total += 100
print("Elements updated: %s" % total)
print("Done!")
sys.exit(0)