Exemple #1
0
def count_resources(context, the_job):
    db = context.get_compmake_db()
    cache = get_job_cache(the_job, db=db)
    if cache.state != Cache.DONE:
        msg = 'The job %s was supposed to be finished: %s' % (the_job, cache) 
        raise Exception(msg)
    
    cq = CacheQueryDB(db)
    children = cq.tree_children_and_uodeps(the_job)
    check_isinstance(children, set)
    children.add(the_job)
    
    res = {}
    for j in children:
        res[j] = context.comp_dynamic(my_get_job_cache, j, extra_dep=[Promise(j)],
                                     job_id='count-%s-%s' % (the_job, j))
        
    return context.comp(finalize_result, res)