def get(allocationID=[]): """ __get__ returns the allocations associated to particular ID """ if(type(allocationID)!=list): allocationID=[str(allocationID)] if len(allocationID)==0: return if len(allocationID)==1: sqlStr="""SELECT id,events_missed,events_allocated,events_missed_cumul,events_processed,details,prod_mgr_url,workflow_id,allocation_spec_file FROM we_Allocation WHERE id="%s" """ %(str(allocationID[0])) else: sqlStr="""SELECT id,events_missed,events_allocated,events_missed_cumul,events_processed,details,prod_mgr_url,workflow_id,allocation_spec_file FROM we_Allocation WHERE id IN %s """ %(str(tuple(allocationID))) Session.execute(sqlStr) description=['id','events_missed','events_allocated','events_missed_cumul','events_processed','details','prod_mgr_url','workflow_id','allocation_spec_file'] result=Session.convert(description,Session.fetchall(),oneItem=False,decode=['details']) if len(result)==0: return None if len(result)==1: return result[0] return result
def get(workflowID=[]): """ __getWorkflows__ returns workflow entries """ if(type(workflowID)!=list): workflowID=[str(workflowID)] if len(workflowID)==0: return [] if len(workflowID)==1: sqlStr="""SELECT events_processed,id,owner,priority,prod_mgr_url, workflow_spec_file,workflow_type,max_sites FROM we_Workflow WHERE id="%s" """ %(str(workflowID[0])) else: sqlStr="""SELECT events_processed,id,owner,priority,prod_mgr_url, workflow_spec_file,workflow_type,max_sites FROM we_Workflow WHERE id IN %s """ %(str(tuple(workflowID))) Session.execute(sqlStr) description=['events_processed','id','owner','priority','prod_mgr_url',\ 'workflow_spec_file','workflow_type', 'max_sites'] result=Session.convert(description,Session.fetchall()) if len(result)==1: return result[0] return result
def hasMissingEvents(): sqlStr= """ SELECT we_Allocation.id,we_Allocation.events_missed,we_Allocation.events_missed_cumul,we_Allocation.events_processed,we_Allocation.details,we_Allocation.prod_mgr_url,we_Allocation.workflow_id,we_Allocation.allocation_spec_file FROM we_Allocation WHERE we_Allocation.id NOT IN (SELECT DISTINCT allocation_id FROM we_Job) AND events_missed > 0; """ Session.execute(sqlStr) description=['id','events_missed','events_missed_cumul','events_processed','details','prod_mgr_url','workflow_id','allocation_spec_file'] result=Session.convert(description,Session.fetchall(),oneItem=False,decode=['details']) if len(result)==0: return [] return result
def getNotDownloaded(): """ __getNotDownloaded__ returns the workflows this PA should work on but from which the workflow file has not been downloaded yet. """ sqlStr="""SELECT events_processed,id,priority,prod_mgr_url, workflow_spec_file,workflow_type FROM we_Workflow WHERE workflow_spec_file="not_downloaded" """ Session.execute(sqlStr) description=['events_processed','id','priority','prod_mgr_url',\ 'workflow_spec_file','workflow_type'] return Session.convert(description,Session.fetchall())
def getHighestPriority(nth=0): """ ___getHighestPriority___ gets the nth highest priority if exists. """ sqlStr="""SELECT events_processed,id,priority,prod_mgr_url, workflow_spec_file,workflow_type FROM we_Workflow ORDER by priority limit %s """ %(str(nth+1)) Session.execute(sqlStr) rows=Session.fetchall() if nth>(len(rows)-1): return [] row=rows[nth] description=['events_processed','id','priority','prod_mgr_url',\ 'workflow_spec_file','workflow_type'] return Session.convert(description,[row],True)
def getEventsProcessed(allocationID=[]): """ __getEventsProcessed__ returns the events processed sofar for a particular allocation """ if(type(allocationID)!=list): allocationID=[str(allocationID)] if len(allocationID)==0: return if len(allocationID)==1: sqlStr="""SELECT events_processed,id FROM we_Allocation WHERE id="%s" """ %(str(allocationID[0])) else: sqlStr="""SELECT events_processed,id FROM we_Allocation WHERE id IN %s """ %(str(tuple(allocationID))) description=['id','events_processed'] result=Session.convert(description,Session.fetchall()) if len(result)==0: return None if len(result)==1: return result[0] return result