Example #1
0
def getJobSummaryByWorkflow(couchConfig):
    """
    gets the job status information by workflow

    example
    {"rows":[
        {"key":["MonteCarlo-v10"],"value":{"pending":11,"running":0,"cooloff":0,"success":0,"failure":0}},
        {"key":["MonteCarlo-v11"],"value":{"pending":22,"running":0,"cooloff":0,"success":0,"failure":0}},
        {"key":["MonteCarlo-v6"],"value":{"pending":1,"running":0,"cooloff":0,"success":0,"failure":0}},
        {"key":["MonteCarlo-v8"],"value":{"pending":7,"running":0,"cooloff":0,"success":0,"failure":0}}
     ]}
    """
    try:
        couchDBBase = CouchDBConnectionBase(couchConfig)
        changeStateDB = couchDBBase.getCouchJobsDB()
    except:
        #TODO log the error in the server
        #If the server is down it doesn't throw CouchError,
        #Need to distinquish between server down and CouchError
        return [{"error": 'Couch connection error'}]

    options = {"group": True, "group_level": 1, "stale": "ok"}
    result = changeStateDB.loadView("JobDump", "statusByWorkflowName", options)

    quotedJobsDBName = couchDBBase.getCouchDBName() + "%2Fjobs"
    quotedFWJRDBName = couchDBBase.getCouchDBName() + "%2Ffwjrs"

    couchDocBase = couchDBBase.getCouchDBHtmlBase(quotedFWJRDBName, "FWJRDump",
                                                  "workflowSummary")
    # reformat to match other type. (not very performative)
    formatted = []
    for item in result['rows']:
        dictItem = {}
        dictItem['request_name'] = item['key'][0]
        dictItem.update(item['value'])
        dictItem['couch_doc_base'] = "%s/%s" % (couchDocBase, item['key'][0])
        options = {
            'startkey': '["%s"]' % item['key'][0],
            'endkey': '["%s",{}]' % item['key'][0],
            "reduce": "false",
            "stale": "ok"
        }

        dictItem['couch_job_info_base'] = couchDBBase.getCouchDBHtmlBase(
            quotedJobsDBName,
            "JobDump",
            "replace_to_Jobs",
            'statusByWorkflowName',
            options=options,
            type="list")

        formatted.append(dictItem)

    return formatted
Example #2
0
def getJobSummaryByWorkflow(couchConfig):
    """
    gets the job status information by workflow

    example
    {"rows":[
        {"key":["MonteCarlo-v10"],"value":{"pending":11,"running":0,"cooloff":0,"success":0,"failure":0}},
        {"key":["MonteCarlo-v11"],"value":{"pending":22,"running":0,"cooloff":0,"success":0,"failure":0}},
        {"key":["MonteCarlo-v6"],"value":{"pending":1,"running":0,"cooloff":0,"success":0,"failure":0}},
        {"key":["MonteCarlo-v8"],"value":{"pending":7,"running":0,"cooloff":0,"success":0,"failure":0}}
     ]}
    """
    try:
        couchDBBase = CouchDBConnectionBase(couchConfig)
        changeStateDB = couchDBBase.getCouchJobsDB()
    except:
        #TODO log the error in the server
        #If the server is down it doesn't throw CouchError,
        #Need to distinquish between server down and CouchError
        return [{"error": 'Couch connection error'}]

    options = {"group": True, "group_level": 1, "stale": "ok"}
    result = changeStateDB.loadView("JobDump", "statusByWorkflowName",
                                    options)    

    quotedJobsDBName = couchDBBase.getCouchDBName() + "%2Fjobs"
    quotedFWJRDBName = couchDBBase.getCouchDBName() + "%2Ffwjrs"
    
    couchDocBase = couchDBBase.getCouchDBHtmlBase(quotedFWJRDBName, "FWJRDump",
                                                  "workflowSummary")
    # reformat to match other type. (not very performative)
    formatted = []
    for item in result['rows']:
        dictItem = {}
        dictItem['request_name'] = item['key'][0]
        dictItem.update(item['value'])
        dictItem['couch_doc_base'] = "%s/%s" % (couchDocBase, item['key'][0])
        options = {'startkey':'["%s"]' % item['key'][0],
                   'endkey':'["%s",{}]' % item['key'][0],
                   "reduce": "false",
                   "stale": "ok"}
    
        dictItem['couch_job_info_base'] = couchDBBase.getCouchDBHtmlBase(quotedJobsDBName,
                                                                         "JobDump", "replace_to_Jobs", 
                                                                         'statusByWorkflowName', options = options,
                                                                         type = "list")
        
        formatted.append(dictItem)

    return formatted