def getRequest(requestId): """ _getRequest_ Get the full details of the request to be passed to the PM. Includes - All basic request information from DB - Teams the request has been assigned to - Priority per assigned team - URL to download the workflow spec from TODO: Add download URL for the workflow spec. Follow up with FVL what needs to be added here """ request = GetRequest.getRequest(requestId) assigned = GetRequest.getRequestAssignments(requestId) for team in assigned: team['TeamPriority'] += request['RequestPriority'] request['Assignments'] = assigned return request
def requestsWithStatus(status): requestIds = theseIds = ListRequests.listRequestsByStatus(status).values() requests = [] for requestId in requestIds: request = GetRequest.getRequest(requestId) request = prepareForTable(request) requests.append(request) return requests
def getMostRecentOutputForPrepID(self, prepID): """Return the datasets produced by the most recently submitted request with this prep ID""" requestIDs = GetRequest.getRequestByPrepID(prepID) # most recent will have the largest ID requestID = max(requestIDs) request = GetRequest.getRequest(requestID) helper = Utilities.loadWorkload(request) return helper.listOutputDatasets()
def getOutputForPrepID(self, prepID): """Return the datasets produced by this prep ID. in a dict of requestName:dataset list""" requestIDs = GetRequest.getRequestByPrepID(prepID) result = {} for requestID in requestIDs: request = GetRequest.getRequest(requestID) requestName = request["RequestName"] helper = Utilities.loadWorkload(request) result[requestName] = helper.listOutputDatasets() return result
def getAssignment(self, teamName=None, request=None): """ If a team name is passed in, get all assignments for that team. If a request is passed in, return a list of teams the request is assigned to """ # better to use ReqMgr/RequestDB/Interface/ProdSystem/ProdMgrRetrieve? #requestIDs = ProdMgrRetrieve.findAssignedRequests(teamName) # Maybe now assigned to team is same as assigned to ProdMgr result = [] if teamName != None: requestIDs = ListRequests.listRequestsByTeam(teamName, "assigned").values() requests = [GetRequest.getRequest(reqID) for reqID in requestIDs] # put highest priorities first requests.sort(key=lambda r: r['RequestPriority'], reverse=True) # return list of tuples, since we need sorting result = [[req['RequestName'], req['RequestWorkflow']] for req in requests] elif request != None: result = GetRequest.getAssignmentsByName(request) return result
def getMostRecentOutputForPrepID(self, prepID): """Return the datasets produced by the most recently submitted request with this prep ID""" requestIDs = sorted(GetRequest.getRequestByPrepID(prepID)) # most recent will have the largest ID requestIDs.reverse() request = None # Go through each request in order from largest to smallest # looking for the first non-failed/non-canceled request for requestID in requestIDs: request = GetRequest.getRequest(requestID) rejectList = ['aborted', 'failed', 'rejected', 'epic-failed'] requestStatus = request.get("RequestStatus", 'aborted').lower() if requestStatus not in rejectList: break if request != None: helper = Utilities.loadWorkload(request) return helper.listOutputDatasets() else: return []