コード例 #1
0
ファイル: test_more.py プロジェクト: welinder/compmake
 def testDep2(self):
     ''' Testing advanced dependencies discovery (double) '''
     cf1 = comp(f1)
     cf2 = comp(f2, cf1, cf1)
     self.assertTrue(cf1.job_id in direct_children(cf2.job_id))
     self.assertEqual(1, len(direct_children(cf2.job_id)))
     self.assertEqual(1, len(direct_parents(cf1.job_id)))
コード例 #2
0
ファイル: details.py プロジェクト: welinder/compmake
def list_job_detail(job_id):
    #computation = get_computation(job_id)
    cache = get_job_cache(job_id)     
    parents = direct_parents(job_id)
    children = direct_children(job_id)
    up, reason = up_to_date(job_id)

    red = lambda x: colored(x, 'red')
    bold = lambda x:  colored(rjust(x + ' ', 15), attrs=['bold'])
    
    
    try:
        print bold('Job ID:') + '%s' % job_id 
        print bold('Status:') + '%s' % Cache.state2desc[cache.state]
        print bold('Uptodate:') + '%s (%s)' % (up, reason)
        print bold('Children:') + '%s' % ', '.join(children)
        print bold('Parents:') + '%s' % ', '.join(parents)
        
        if cache.state == Cache.DONE and cache.done_iterations > 1:
            print bold('Iterations:') + '%s' % cache.done_iterations 
            print bold('Wall Time:') + '%.4f s' % cache.walltime_used 
            print bold('CPU Time:') + '%.4f s' % cache.cputime_used
            print bold('Host:') + '%s' % cache.host

        if cache.state == Cache.IN_PROGRESS:
            print bold('Progress:') + '%s/%s' % \
                (cache.iterations_in_progress, cache.iterations_goal)
        

        if cache.state == Cache.FAILED:
            print red(cache.exception)
            print red(cache.backtrace)
            
        def display_with_prefix(buffer, prefix,
                                transform=lambda x:x, out=sys.stdout):
            for line in buffer.split('\n'):
                out.write('%s%s\n' % (prefix, transform(line)))
                
        if cache.captured_stdout:
            print "-----> captured stdout <-----"
            display_with_prefix(cache.captured_stdout, prefix='|',
                                transform=lambda x: colored(x, attrs=['dark']))
            
        if cache.captured_stderr:
            print "-----> captured stderr <-----"
            display_with_prefix(cache.captured_stdout, prefix='|',
                                transform=lambda x: colored(x, attrs=['dark']))
            
    except AttributeError:
        pass
コード例 #3
0
ファイル: uptodate.py プロジェクト: p-muller/compmake
def direct_uptodate_deps_inverse(job_id, db):
    """ Returns all jobs that have this as 
        a direct 'dependency'
        the jobs that are direct parents
        plus the jobs that were defined by it.
        
        Assumes that the job is DONE.
    """
    from compmake.jobs.queries import direct_parents
    dep_inv = direct_parents(job_id, db)
    from compmake.jobs.storage import get_job_cache
    # Not sure if need to be here --- added when doing graph-animation for jobs in progress
    if get_job_cache(job_id, db).state == Cache.DONE: 
        dep_inv.update(jobs_defined(job_id, db))
    return dep_inv 
コード例 #4
0
ファイル: uptodate.py プロジェクト: afcarl/compmake
def direct_uptodate_deps_inverse(job_id, db):
    """ Returns all jobs that have this as
        a direct 'dependency'
        the jobs that are direct parents
        plus the jobs that were defined by it.

        Assumes that the job is DONE.
    """
    from compmake.jobs.queries import direct_parents
    dep_inv = direct_parents(job_id, db)
    from compmake.jobs.storage import get_job_cache
    # Not sure if need to be here --- added when doing graph-animation for jobs in progress
    if get_job_cache(job_id, db).state == Cache.DONE:
        dep_inv.update(jobs_defined(job_id, db))
    return dep_inv
コード例 #5
0
ファイル: actions.py プロジェクト: p-muller/compmake
def clean_cache_relations(job_id, db):
    #print('cleaning cache relations for %r ' % job_id)

    # for all jobs that were done
    cache = get_job_cache(job_id, db)
    if cache.state == Cache.DONE:
        for parent in direct_parents(job_id, db):
            
            parent_job = get_job(parent, db)
            #print('  parent %r has dynamic %s' % (parent, parent_job.dynamic_children))
            if not job_id in parent_job.dynamic_children:
                #print('    skipping parent %r ' % parent)
                continue 
            else:
                dynamic_children = parent_job.dynamic_children[job_id]
                #print('    dynamic_children %s' % parent_job.dynamic_children)
                #print('    children %s' % parent_job.children)
                del parent_job.dynamic_children[job_id]
                parent_job.children = parent_job.children - dynamic_children
                set_job(parent, parent_job, db) 
コード例 #6
0
ファイル: parsing.py プロジェクト: welinder/compmake
def list_top_jobs():
    ''' Returns a list of jobs that are top-level targets.  '''
    from compmake.jobs.queries import direct_parents
    for job_id in all_jobs(): 
        if not direct_parents(job_id):
            yield job_id
コード例 #7
0
ファイル: uptodate.py プロジェクト: p-muller/compmake
    def direct_parents(self, job_id):
        from compmake.jobs.queries import direct_parents

        return direct_parents(job_id, db=self.db)
コード例 #8
0
ファイル: test_more.py プロジェクト: welinder/compmake
 def testDep3(self):
     ''' Testing advanced dependencies discovery in dicts'''
     cf1 = comp(f1)
     cf2 = comp(f2, [1, {'ciao': cf1}])
     self.assertTrue(cf1.job_id in direct_children(cf2.job_id))
     self.assertTrue(cf2.job_id in direct_parents(cf1.job_id))
コード例 #9
0
ファイル: test_more.py プロジェクト: welinder/compmake
 def testDep(self):
     ''' Testing advanced dependencies discovery '''
     cf1 = comp(f1)
     cf2 = comp(f2, cf1)
     self.assertTrue(cf1.job_id in direct_children(cf2.job_id))
     self.assertTrue(cf2.job_id in direct_parents(cf1.job_id))
コード例 #10
0
ファイル: uptodate.py プロジェクト: afcarl/compmake
    def direct_parents(self, job_id):
        from compmake.jobs.queries import direct_parents

        return direct_parents(job_id, db=self.db)