Example #1
0
def manager_succeeded(event):
    if event.kwargs['nothing_to_do']:
        info('Nothing to do.')
    else:
        ntargets = len(event.kwargs['all_targets'])
        ndone = len(event.kwargs['done'])
        nfailed = len(event.kwargs['failed'])
        nblocked = len(event.kwargs['blocked'])
        if ntargets:
            s = 'Processed %d jobs (' % ntargets 
            ss = []
            if ndone:
                ss.append('%d done' % ndone)
            if nfailed:
                ss.append('%d failed' % nfailed)
            if nblocked:
                ss.append('%d blocked' % nblocked)
            s += ", ".join(ss)
            s += ').'
            if nfailed:
                error(s)
            else:
                info(s)
Example #2
0
def manager_succeeded(event):
    if event.kwargs['nothing_to_do']:
        info('Nothing to do.')
    else:
        ntargets = len(event.kwargs['all_targets'])
        ndone = len(event.kwargs['done'])
        nfailed = len(event.kwargs['failed'])
        nblocked = len(event.kwargs['blocked'])
        if ntargets:
            s = 'Processed %d jobs (' % ntargets
            ss = []
            if ndone:
                ss.append('%d done' % ndone)
            if nfailed:
                ss.append('%d failed' % nfailed)
            if nblocked:
                ss.append('%d blocked' % nblocked)
            s += ", ".join(ss)
            s += ').'
            if nfailed:
                error(s)
            else:
                info(s)
Example #3
0
def clean_other_jobs(context):
    """ Cleans jobs not defined in the session """
    #print('cleaning other jobs. Defined: %r' %
    # context.get_jobs_defined_in_this_session())
    db = context.get_compmake_db()
    if get_compmake_status() == CompmakeConstants.compmake_status_slave:
        return
#     from .console import ask_question
# 
#     answers = {'a': 'a', 'n': 'n', 'y': 'y', 'N': 'N'}
# 
#     if is_interactive_session():
#         clean_all = False
#     else:
#         clean_all = True

    # logger.info('Cleaning all jobs not defined in this session.'
    #                ' Previous: %d' % len(defined_now))

    from compmake.ui import info
    
    todelete = set()
    
    for job_id in all_jobs(force_db=True, db=db):
        if not context.was_job_defined_in_this_session(job_id):
            # it might be ok if it was not defined by ['root']
            job = get_job(job_id, db=db)
            if job.defined_by != ['root']:
                # keeping this around
                continue
            
            who = job.defined_by[1:]
            if who:
                defined = ' (defined by %s)' % "->".join(who)
            else:
                defined = ""

            info('Job %r not defined in this session%s; cleaning.' 
                 % (job_id,defined))
# 
#             if not clean_all:
#                 # info('Job %s defined-by %s' % (job_id, job.defined_by))
#                 text = ('Found spurious job %s; cleaning? '
#                         '[y]es, [a]ll, [n]o, [N]one ' % job_id)
#                 answer = ask_question(text, allowed=answers)
# 
#                 if answer == 'n':
#                     continue
# 
#                 if answer == 'N':
#                     break
# 
#                 if answer == 'a':
#                     clean_all = True
#             else:
#                 pass
#                 #logger.info('Cleaning job: %r (defined by %s)' % (job_id,
#                 # job.defined_by))

            
            todelete.add(job_id)
    delete_jobs_recurse_definition(todelete, db)
Example #4
0
def console_ending(event, context):  # @UnusedVariable
    from compmake.ui import info
    info("Thanks for using Compmake. "
          "Please report problems to %s" % 
          compmake_colored(compmake_issues_url, attrs=['bold']))
Example #5
0
def console_ending(event, context):  # @UnusedVariable
    from compmake.ui import info
    info("Thanks for using Compmake. "
         "Please report problems to %s" %
         compmake_colored(compmake_issues_url, attrs=['bold']))
Example #6
0
def graph(job_list, context, filename='compmake-graph',
          filter='dot', format='png',  # @ReservedAssignment
          label='id', color=True,
          cluster=False, processing=set()):
    """

        Creates a graph of the given targets and dependencies.

        Usage:

            @: graph filename=filename label=[id,function,none] color=[0|1] format=png filter=[dot|circo|...]

        Options:

            filename:  name of generated filename in the dot format
            label='none','id','function'
            color=[0|1]: whether to color the nodes
            filter=[dot,circo,twopi,...]  which algorithm to use to arrange
                       the nodes. The best choice depends on
                       the topology of your
                       computation. The default is 'dot'
                       (hierarchy top-bottom).
            format=[png,...]  The output file format.
    """
    possible = ['none', 'id', 'function']
    if not label in possible:
        msg = 'Invalid label method %r not in %r.' % (label, possible)
        raise ValueError(msg)

    db = context.get_compmake_db()
    if not job_list:
        job_list = list(top_targets(db))

    print('jobs: %s' % job_list)
    print('processing: %s' % processing)
    print('Importing gvgen')

    try:
#        import gvgen
        pass
    except:
        gvgen_url = 'https://github.com/stricaud/gvgen'
        msg = ('To use the "graph" command you have to install the "gvgen" '
               'package from %s') % gvgen_url
        raise UserError(msg)

    print('Getting all jobs in tree')

    cq = CacheQueryDB(db)
    job_list = set(job_list)
    # all the dependencies
    job_list.update(cq.tree(job_list))

    # plus all the jobs that were defined by them
    job_list.update(definition_closure(job_list, db))

    job_list = set(job_list)

#     print('closure: %s' % sorted(job_list))

    if cluster:
        ggraph = create_graph2_clusters(cq, job_list, label=label, color=color,
                                        processing=processing)
    else:
        ggraph = create_graph1(cq, job_list, label=label, color=color,
                               processing=processing)
    print('Writing graph on %r.' % filename)
    # TODO: add check?
    with open(filename, 'w') as f:
        ggraph.dot(f)

    print('Running rendering')
    output = filename + '.' + format
    cmd_line = '%s %s -T%s -o%s' % (filter, filename, format, output)
    print('  %s' % cmd_line)
    try:
        os.system(cmd_line)
    except:
        msg = "Could not run dot (cmdline='%s') Make sure graphviz is " \
              "installed" % cmd_line
        raise UserError(msg)  # XXX maybe not UserError

    info("Written output on files %s, %s." % (filename, output))
Example #7
0
def clean_other_jobs(context):
    """ Cleans jobs not defined in the session """
    #print('cleaning other jobs. Defined: %r' %
    # context.get_jobs_defined_in_this_session())
    db = context.get_compmake_db()
    if get_compmake_status() == CompmakeConstants.compmake_status_slave:
        return


#     from .console import ask_question
#
#     answers = {'a': 'a', 'n': 'n', 'y': 'y', 'N': 'N'}
#
#     if is_interactive_session():
#         clean_all = False
#     else:
#         clean_all = True

# logger.info('Cleaning all jobs not defined in this session.'
#                ' Previous: %d' % len(defined_now))

    from compmake.ui import info

    todelete = set()

    for job_id in all_jobs(force_db=True, db=db):
        if not context.was_job_defined_in_this_session(job_id):
            # it might be ok if it was not defined by ['root']
            job = get_job(job_id, db=db)
            if job.defined_by != ['root']:
                # keeping this around
                continue

            who = job.defined_by[1:]
            if who:
                defined = ' (defined by %s)' % "->".join(who)
            else:
                defined = ""

            info('Job %r not defined in this session%s; cleaning.' %
                 (job_id, defined))
            #
            #             if not clean_all:
            #                 # info('Job %s defined-by %s' % (job_id, job.defined_by))
            #                 text = ('Found spurious job %s; cleaning? '
            #                         '[y]es, [a]ll, [n]o, [N]one ' % job_id)
            #                 answer = ask_question(text, allowed=answers)
            #
            #                 if answer == 'n':
            #                     continue
            #
            #                 if answer == 'N':
            #                     break
            #
            #                 if answer == 'a':
            #                     clean_all = True
            #             else:
            #                 pass
            #                 #logger.info('Cleaning job: %r (defined by %s)' % (job_id,
            #                 # job.defined_by))

            todelete.add(job_id)
    delete_jobs_recurse_definition(todelete, db)