def cloneWorkflow(workflow, user, group, verbose=True, backfill=False, testbed=False, memory=None, bwl=None): """ clones a workflow """ # Get info about the workflow to be cloned helper = reqMgrClient.retrieveSchema(workflow, reqmgrCouchURL) # Adapt schema and add original request to it try: cache = reqMgrClient.getWorkloadCache(url, workflow) except: cache = None schema = modifySchema(helper, workflow, user, group, cache, None, None, backfill, memory) schema['OriginalRequestName'] = workflow if verbose: pprint(schema) if bwl: if 'Task1' in schema: schema['Task1']['BlockWhitelist'] = bwl.split(',') else: schema['BlockWhitelist'] = bwl.split(',') print 'Submitting workflow' # Submit cloned workflow to ReqMgr if testbed: newWorkflow = reqMgrClient.submitWorkflow(url_tb, schema) else: newWorkflow = reqMgrClient.submitWorkflow(url, schema) if verbose: print "RESPONSE", newWorkflow # find the workflow name in response if newWorkflow: print 'Cloned workflow: ' + newWorkflow if verbose: print newWorkflow print 'Approving request response:' # TODO only for debug #response = reqMgrClient.setWorkflowSplitting(url, schema) # print "RESPONSE", response #schema['requestName'] = requestName #schema['splittingTask'] = '/%s/%s' % (requestName, taskName) #schema['splittingAlgo'] = splittingAlgo # Move the request to Assignment-approved if testbed: data = reqMgrClient.setWorkflowApproved(url_tb, newWorkflow) else: data = reqMgrClient.setWorkflowApproved(url, newWorkflow) if verbose: print data # return the name of new workflow return newWorkflow else: if verbose: print newWorkflow else: print "Couldn't clone the workflow." return None
def cloneWorkflow(workflow, user, group, verbose=True, backfill=False, testbed=False, memory=None, bwl=None): """ clones a workflow """ # Get info about the workflow to be cloned helper = reqMgrClient.retrieveSchema(workflow, reqmgrCouchURL) # Adapt schema and add original request to it try: cache = reqMgrClient.getWorkloadCache(url, workflow) except: cache = None schema = modifySchema(helper, workflow, user, group, cache, None, None, backfill, memory) schema['OriginalRequestName'] = workflow if verbose: pprint(schema) if bwl: if 'Task1' in schema: schema['Task1']['BlockWhitelist'] = bwl.split(',') else: schema['BlockWhitelist'] = bwl.split(',') print 'Submitting workflow' # Submit cloned workflow to ReqMgr if testbed: newWorkflow = reqMgrClient.submitWorkflow(url_tb, schema, reqmgr2 = True) else: newWorkflow = reqMgrClient.submitWorkflow(url, schema, reqmgr2 = True) if verbose: print "RESPONSE", newWorkflow # find the workflow name in response if newWorkflow: print 'Cloned workflow: ' + newWorkflow if verbose: print newWorkflow print 'Approving request response:' # TODO only for debug #response = reqMgrClient.setWorkflowSplitting(url, schema) # print "RESPONSE", response #schema['requestName'] = requestName #schema['splittingTask'] = '/%s/%s' % (requestName, taskName) #schema['splittingAlgo'] = splittingAlgo # Move the request to Assignment-approved if testbed: data = reqMgrClient.setWorkflowApproved(url_tb, newWorkflow) else: data = reqMgrClient.setWorkflowApproved(url, newWorkflow) if verbose: print data # return the name of new workflow return newWorkflow else: if verbose: print newWorkflow else: print "Couldn't clone the workflow." return None
def cloneWorkflow(workflow, user, group, verbose=False, backfill=False, testbed=False): """ clones a workflow """ # Get info about the workflow to be cloned helper = reqMgrClient.retrieveSchema(workflow, reqmgrCouchURL) # Adapt schema and add original request to it try: cache = reqMgrClient.getWorkloadCache(url, workflow) except: cache = None schema = modifySchema(helper, user, group, cache, backfill) schema['OriginalRequestName'] = workflow if verbose: pprint(schema) print 'Submitting workflow' # Sumbit cloned workflow to ReqMgr if testbed: response = reqMgrClient.submitWorkflow(url_tb, schema) else: response = reqMgrClient.submitWorkflow(url, schema) if verbose: print "RESPONSE", response # find the workflow name in response m = re.search("details\/(.*)\'", response) if m: newWorkflow = m.group(1) print 'Cloned workflow: ' + newWorkflow if verbose: print response print 'Approving request response:' # TODO only for debug #response = reqMgrClient.setWorkflowSplitting(url, schema) # print "RESPONSE", response #schema['requestName'] = requestName #schema['splittingTask'] = '/%s/%s' % (requestName, taskName) #schema['splittingAlgo'] = splittingAlgo # Move the request to Assignment-approved if testbed: data = reqMgrClient.setWorkflowApproved(url_tb, newWorkflow) else: data = reqMgrClient.setWorkflowApproved(url, newWorkflow) if verbose: print data # return the name of new workflow return newWorkflow else: if verbose: print response else: print "Couldn't clone the workflow." return None
def cloneWorkflow(workflow, user, group, verbose=False, backfill=False): """ clones a workflow """ # Get info about the workflow to be cloned helper = reqMgrClient.retrieveSchema(workflow, reqmgrCouchURL) # get info from reqMgr schema = modifySchema(helper, user, group, backfill) if verbose: pprint(schema) print 'Submitting workflow' # Sumbit cloned workflow to ReqMgr response = reqMgrClient.submitWorkflow(url, schema) if verbose: print "RESPONSE", response #find the workflow name in response m = re.search("details\/(.*)\'", response) if m: newWorkflow = m.group(1) print 'Cloned workflow: ' + newWorkflow if verbose: print response print 'Approving request response:' #TODO only for debug #response = reqMgrClient.setWorkflowSplitting(url, schema) #print "RESPONSE", response #schema['requestName'] = requestName #schema['splittingTask'] = '/%s/%s' % (requestName, taskName) #schema['splittingAlgo'] = splittingAlgo # Move the request to Assignment-approved data = reqMgrClient.setWorkflowApproved(url, newWorkflow) if verbose: print data #return the name of new workflow return newWorkflow else: if verbose: print response else: print "Couldn't clone the workflow." return None
def cloneWorkflow(workflow, user, group, verbose=False, backfill=False): """ clones a workflow """ # Get info about the workflow to be cloned helper = reqMgrClient.retrieveSchema(workflow) # get info from reqMgr schema = modifySchema(helper, user, group, backfill) if verbose: pprint(schema) print 'Submitting workflow' # Sumbit cloned workflow to ReqMgr response = reqMgrClient.submitWorkflow(url,schema) if verbose: print "RESPONSE", response #find the workflow name in response m = re.search("details\/(.*)\'",response) if m: newWorkflow = m.group(1) print 'Cloned workflow: '+newWorkflow if verbose: print response print 'Approving request response:' #TODO only for debug #response = reqMgrClient.setWorkflowSplitting(url, schema) #print "RESPONSE", response #schema['requestName'] = requestName #schema['splittingTask'] = '/%s/%s' % (requestName, taskName) #schema['splittingAlgo'] = splittingAlgo # Move the request to Assignment-approved data = reqMgrClient.setWorkflowApproved(url, newWorkflow) if verbose: print data #return the name of new workflow return newWorkflow else: if verbose: print response else: print "Couldn't clone the workflow." return None
def extendWorkflow(workflow, user, group, verbose=False, events=None, firstlumi=None): if events is None: events = getMissingEvents(workflow) events = int(events) if firstlumi is None: #get the last lumi of the dataset dataset = reqMgrClient.outputdatasetsWorkflow(url, workflow).pop() lastLumi = dbs3Client.getMaxLumi(dataset) firstlumi = lastLumi firstlumi = int(firstlumi) # Get info about the workflow to be cloned helper = reqMgrClient.retrieveSchema(workflow) schema = modifySchema(helper, workflow, user, group, events, firstlumi) schema['OriginalRequestName'] = workflow if verbose: pprint(schema) print 'Submitting workflow' # Sumbit cloned workflow to ReqMgr response = reqMgrClient.submitWorkflow(url,schema) if verbose: print "RESPONSE", response #find the workflow name in response m = re.search("details\/(.*)\'",response) if m: newWorkflow = m.group(1) print 'Cloned workflow: '+newWorkflow print 'Extended with', events, 'events' print response # Move the request to Assignment-approved print 'Approve request response:' data = reqMgrClient.setWorkflowApproved(url, newWorkflow) print data else: print response pass
def main(): # Check the arguements, get info from them if len(sys.argv) < 4: print "Usage:" print " ./resubmit WORKFLOW_NAME USER GROUP [EVENTS]" sys.exit(0) workflow = sys.argv[1] user = sys.argv[2] group = sys.argv[3] if len(sys.argv) > 4: events = int(sys.argv[4]) else: events = getMissingEvents(workflow) # Get info about the workflow to be cloned helper = reqMgrClient.retrieveSchema(workflow) schema = modifySchema(helper, workflow, user, group, events) print 'Submitting workflow' # Sumbit cloned workflow to ReqMgr response = reqMgrClient.submitWorkflow(url,schema) #find the workflow name in response m = re.search("details\/(.*)\'",response) if m: newWorkflow = m.group(1) print 'Cloned workflow: '+newWorkflow print 'Extended with', events, 'events' print response # Move the request to Assignment-approved print 'Approve request response:' data = reqMgrClient.setWorkflowApproved(url, newWorkflow) print data else: print response sys.exit(0)
elif value != None: schema[key] = value return schema if __name__ == "__main__": if len(sys.argv) != 4: print "Usage:" print " ./resubmit WORKFLOW_NAME USER GROUP" sys.exit(0) oldworkflow=sys.argv[1] user=sys.argv[2] group=sys.argv[3] url='cmsweb.cern.ch' #print "Going to attempt to resubmit %s..." % sys.argv[1] wfInfo = Workflow(oldworkflow) helper = retrieveSchema(oldworkflow) schema = modifySchema(helper, user, group, oldworkflow) schema['OriginalRequestName'] = oldworkflow #print schema newWorkflow = submitWorkflow(url, schema) approveRequest(url,newWorkflow) print 'Cloned workflow:',newWorkflow team = wfInfo.info["team"] if 'teams' in wfInfo.info: site = wfInfo.info['Site Whitelist'] activity = "reprocessing" era = wfInfo.info["AcquisitionEra"] procversion = wfInfo.info["ProcessingVersion"] procstring = wfInfo.info["ProcessingString"] lfn = wfInfo.info["MergedLFNBase"]
schema[key] = value return schema if __name__ == "__main__": if len(sys.argv) != 4: print "Usage:" print " ./resubmit WORKFLOW_NAME USER GROUP" sys.exit(0) oldworkflow = sys.argv[1] user = sys.argv[2] group = sys.argv[3] url = 'cmsweb.cern.ch' #print "Going to attempt to resubmit %s..." % sys.argv[1] wfInfo = Workflow(oldworkflow) helper = retrieveSchema(oldworkflow) schema = modifySchema(helper, user, group, oldworkflow) schema['OriginalRequestName'] = oldworkflow #print schema newWorkflow = submitWorkflow(url, schema) approveRequest(url, newWorkflow) print 'Cloned workflow:', newWorkflow team = wfInfo.info["team"] if 'teams' in wfInfo.info: site = wfInfo.info['Site Whitelist'] activity = "reprocessing" era = wfInfo.info["AcquisitionEra"] procversion = wfInfo.info["ProcessingVersion"] procstring = wfInfo.info["ProcessingString"] lfn = wfInfo.info["MergedLFNBase"]