本文整理汇总了Python中WMCore.Services.WorkQueue.WorkQueue.WorkQueue.cancelWorkflow方法的典型用法代码示例。如果您正苦于以下问题:Python WorkQueue.cancelWorkflow方法的具体用法?Python WorkQueue.cancelWorkflow怎么用?Python WorkQueue.cancelWorkflow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WMCore.Services.WorkQueue.WorkQueue.WorkQueue
的用法示例。
在下文中一共展示了WorkQueue.cancelWorkflow方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testCancelWorkGlobal
# 需要导入模块: from WMCore.Services.WorkQueue.WorkQueue import WorkQueue [as 别名]
# 或者: from WMCore.Services.WorkQueue.WorkQueue.WorkQueue import cancelWorkflow [as 别名]
def testCancelWorkGlobal(self):
"""Cancel work in global queue"""
# queue to global & pull to local
self.globalQueue.queueWork(self.processingSpec.specUrl())
self.globalQueue.updateLocationInfo()
self.assertEqual(self.localQueue.pullWork({'T2_XX_SiteA' : 1000}), 2)
syncQueues(self.localQueue)
work = self.localQueue.getWork({'T2_XX_SiteA' : 1000, 'T2_XX_SiteB' : 1000})
self.assertEqual(len(work), 2)
syncQueues(self.localQueue)
# cancel in global, and propagate down to local
#service = WorkQueueService({'endpoint': self.localQueue.backend.parentCouchUrl})
service = WorkQueueService(self.localQueue.backend.parentCouchUrlWithAuth)
service.cancelWorkflow(self.processingSpec.name())
#self.globalQueue.cancelWork(WorkflowName = self.spec.name())
self.globalQueue.performQueueCleanupActions()
self.assertEqual(len(self.globalQueue.statusInbox(status='CancelRequested')), 1)
self.assertEqual(len(self.globalQueue.status(status='CancelRequested')), 2)
syncQueues(self.localQueue)
self.assertEqual(len(self.localQueue.statusInbox(status='Canceled')), 2)
self.assertEqual(len(self.localQueue.status()), 0)
# check cancel propagated back to global
syncQueues(self.localQueue)
self.assertEqual(len(self.globalQueue.status(status='Canceled')), 2)
self.globalQueue.performQueueCleanupActions()
syncQueues(self.localQueue)
self.assertEqual(len(self.localQueue.statusInbox()), 0)
self.assertEqual(len(self.globalQueue.statusInbox(status='Canceled')), 1)
self.assertEqual(len(self.globalQueue.status()), 0)
self.globalQueue.deleteWorkflows(self.processingSpec.name())
# cancel work in global before it reaches a local queue
self.globalQueue.queueWork(self.spec.specUrl())
self.assertEqual(len(self.globalQueue.status(status='Available')), 1)
service.cancelWorkflow(self.spec.name())
self.globalQueue.performQueueCleanupActions()
self.assertEqual(len(self.globalQueue.status()), 0)
self.assertEqual(len(self.globalQueue.statusInbox(status='Canceled')), 1)
self.globalQueue.deleteWorkflows(self.spec.name())
示例2: Request
# 需要导入模块: from WMCore.Services.WorkQueue.WorkQueue import WorkQueue [as 别名]
# 或者: from WMCore.Services.WorkQueue.WorkQueue.WorkQueue import cancelWorkflow [as 别名]
#.........这里部分代码省略.........
# validate/update OutputDatasets after ProcessingString and AcquisionEra is updated
request_args['OutputDatasets'] = workload.listOutputDatasets()
validateOutputDatasets(request_args['OutputDatasets'], workload.getDbsUrl())
# legacy update schema to support ops script
loadRequestSchema(workload, request_args)
report = self.reqmgr_db_service.updateRequestProperty(workload.name(), request_args, dn)
workload.saveCouch(self.config.couch_host, self.config.couch_reqmgr_db)
return report
def _handleCascadeUpdate(self, workload, request_args, dn):
"""
only closed-out and announced has this option
"""
req_status = request_args["RequestStatus"]
# check whehter it is casecade option
if request_args["cascade"]:
cascade_list = self._retrieveResubmissionChildren(workload.name())
for req_name in cascade_list:
self.reqmgr_db_service.updateRequestStatus(req_name, req_status, dn)
# update original workflow status
report = self.reqmgr_db_service.updateRequestStatus(workload.name(), req_status, dn)
return report
def _handleOnlyStateTransition(self, workload, req_status, dn):
"""
It handles only the state transition. Special handling needed if a
request is aborted or force completed.
"""
if req_status in ["aborted", "force-complete"]:
# cancel the workflow first
self.gq_service.cancelWorkflow(workload.name())
#update the request status in couchdb
report = self.reqmgr_db_service.updateRequestStatus(workload.name(), req_status, dn)
return report
def _updateRequest(self, workload, request_args):
dn = cherrypy.request.user.get("dn", "unknown")
if workload is None:
(workload, request_args) = self.initialize_clone(request_args["OriginalRequestName"])
return self.post([workload, request_args])
if "RequestStatus" not in request_args:
report = self._handleNoStatusUpdate(workload, request_args)
else:
req_status = request_args["RequestStatus"]
# assignment-approved only allow Priority update
if len(request_args) == 2 and req_status == "assignment-approved":
report = self._handleAssignmentApprovedTransition(workload, request_args, dn)
elif len(request_args) > 1 and req_status == "assigned":
report = self._handleAssignmentStateTransition(workload, request_args, dn)
elif len(request_args) == 2 and req_status in ["closed-out", "announced"] and \
"cascade" in request_args:
report = self._handleCascadeUpdate(workload, request_args, dn)
elif len(request_args) == 1:
# If status chnage is to aborted, force-complete, rejected, ignore other argument
report = self._handleOnlyStateTransition(workload, req_status, dn)
else:
raise InvalidSpecParameterValue(
"can't update value except transition to assigned status: %s" % request_args)
if report == 'OK':
示例3: Request
# 需要导入模块: from WMCore.Services.WorkQueue.WorkQueue import WorkQueue [as 别名]
# 或者: from WMCore.Services.WorkQueue.WorkQueue.WorkQueue import cancelWorkflow [as 别名]
#.........这里部分代码省略.........
if ('SoftTimeout' in request_args) and ('GracePeriod' in request_args):
request_args['HardTimeout'] = request_args['SoftTimeout'] + request_args['GracePeriod']
if 'RequestPriority' in request_args:
self.gq_service.updatePriority(workload.name(), request_args['RequestPriority'])
if "total_jobs" in request_args:
# only GQ update this stats
# request_args should contain only 4 keys 'total_jobs', 'input_lumis', 'input_events', 'input_num_files'}
report = self.reqmgr_db_service.updateRequestStats(workload.name(), request_args)
# if is not just updating status
else:
req_status = request_args.get("RequestStatus", None)
if len(request_args) >= 1 and req_status == None:
try:
workload.updateArguments(request_args)
except Exception as ex:
msg = traceback.format_exc()
cherrypy.log("Error for request args %s: %s" % (request_args, msg))
raise InvalidSpecParameterValue(str(ex))
# trailing / is needed for the savecouchUrl function
workload.saveCouch(self.config.couch_host, self.config.couch_reqmgr_db)
elif (req_status in ["closed-out" "announced"]) and request_args.get("cascade", False):
cascade_list = self._retrieveResubmissionChildren(workload.name)
for req_name in cascade_list:
report = self.reqmgr_db_service.updateRequestStatus(req_name, req_status)
# If it is aborted or force-complete transition call workqueue to cancel the request
else:
if req_status == "aborted" or req_status == "force-complete":
self.gq_service.cancelWorkflow(workload.name())
report = self.reqmgr_db_service.updateRequestProperty(workload.name(), request_args, dn)
if report == 'OK':
return {workload.name(): "OK"}
else:
return {workload.name(): "ERROR"}
@restcall(formats=[('application/json', JSONFormat())])
def put(self, workload_pair_list):
"workloadPairList is a list of tuple containing (workload, requeat_args)"
report = []
for workload, request_args in workload_pair_list:
result = self._updateRequest(workload, request_args)
report.append(result)
return report
@restcall(formats=[('application/json', JSONFormat())])
def delete(self, request_name):
cherrypy.log("INFO: Deleting request document '%s' ..." % request_name)
try:
self.reqmgr_db.delete_doc(request_name)
except CouchError as ex:
msg = "ERROR: Delete failed."
cherrypy.log(msg + " Reason: %s" % ex)
raise cherrypy.HTTPError(404, msg)
# TODO
# delete should also happen on WMStats
cherrypy.log("INFO: Delete '%s' done." % request_name)
def _update_additional_request_args(self, workload, request_args):
"""
add to request_args properties which is not initially set from user.