Пример #1
0
 def __str__(self):
     s = 'Worldcommunitygrid.org\nLast result returned: {0}\n'.format(self.lastResult)
     run = 'Run time {0:>20} total (#{2}), {1:>10} per day'.format(util.timedeltaToStr(self.runtime), 
                                                                   util.timedeltaToStr(self.runtimePerDay), 
                                                                   util.fmtNumber(self.runtimeRank))
     p   = 'Points   {0:>20} total (#{2}), {1:>10} per day'.format(util.fmtNumber(self.points), 
                                                                   util.fmtNumber(self.pointsPerDay, '.1f'), 
                                                                   util.fmtNumber(self.pointsRank))
     res = 'Results  {0:>20} total (#{2}), {1:>10} per day'.format(util.fmtNumber(self.results), 
                                                                   util.fmtNumber(self.resultsPerDay, '.1f'), 
                                                                   util.fmtNumber(self.resultsRank))
     s += '{:>10}\n{:>10}\n{:>10}\n'.format(run, p, res)
     return s
Пример #2
0
def plot_wuprop(fig, applications, badges, browser):
    ax = fig.add_subplot(111)

    labels = list()
    width = 0.75

    totalRuntime = datetime.timedelta(0)
    for ix, data in enumerate(applications):
        badgeLine = data[0]
        color = data[1]
        label = data[2]
        app = data[3]
        stat = app.statistics

        h = stat.wuRuntime.total_seconds()
        totalRuntime += stat.wuRuntime

        color, b = Badge_wuprop.getColor(h)

        kwargs = dict(width=width, color=color)

        ax.bar(ix, h, **kwargs)

        pending = stat.wuPending.total_seconds()
        ax.bar(ix, pending, bottom=h, alpha=0.75, **kwargs)
        h += pending

        pending, running, validation = app.pendingTime(include_elapsedCPUtime=False)
        for t, alpha in ((validation, 0.5), (running, 0.25), (pending, 0.125)):
            ax.bar(ix, t, bottom=h, alpha=alpha, **kwargs)
            h += t

        labels.append(label)

        days = badgeLine*60*60
        plt.axhline(days, color=color)

    for b in badges:
        for ix, value in enumerate(b.value):
            if value != 0:
                try:
                    showImage(ax, browser, (ix+1)*20,
                              value=value*3600, url=b.url,
                              frameon=False,
                              box_alignment=(0.5, 0.5))
                except Exception as e:
                    logger.error('Badge image failed with "%s"', e)
                    
    pos = np.arange(len(labels))
    ax.set_xticks(pos+width/2)
    ax.set_xticklabels(labels, rotation=17, horizontalalignment='right')

    ax.yaxis.set_major_formatter(formatter_timedelta)

    totalRuntime = util.timedeltaToStr(totalRuntime)
    fig.suptitle('{} applications, total runtime {}'.format(len(labels), totalRuntime))

    for mark in pos[::20][1:]:
        ax.axvline(mark)
    ax.set_ylim(ymin=0)         # Negative runtime values makes no sense
Пример #3
0
def plot_worldcommunitygrid(fig, browser, data):
    if data == None:
        return

    ax = fig.add_subplot(111)
    width = 0.75
    ix = 0
    labels = list()
    totalRuntime = 0
    for key in sorted(data):
        badge, runtime, pending, running, validation = data[key]

        kwargs = dict(color='k',
                      width=width)
        
        try:
            kwargs['color'] = badge.color
        except:
            pass

        height = runtime
        ax.bar(ix, height, **kwargs)

        if badge != '':
            try:
                showImage(ax, browser, ix,
                          value=badge.runtime, color=badge.color, url=badge.url,
                          frameon=False)
            except Exception as e:
                logger.error('Badge image failed with "%s"', e)

        logger.debug('app %s, pending, running, validation = %s, %s, %s', 
                     key, pending, running, validation)

        for t, alpha in ((validation, 0.5), (running, 0.25), (pending, 0.125)):
            ax.bar(ix, t, bottom=height, alpha=alpha, **kwargs)
            height += t

        totalRuntime += runtime + pending + running + validation
        labels.append(str(key))
        ix += 1

    pos = np.arange(len(labels))
    ax.set_xticks(pos+width/2)
    ax.set_xticklabels(labels, rotation=17, horizontalalignment='right')
    ax.set_xlabel('Application')

    ax.set_ylabel('Runtime')
    ax.yaxis.set_major_formatter(formatter_timedelta)

    totalRuntime = datetime.timedelta(seconds=totalRuntime)
    totalRuntime = util.timedeltaToStr(totalRuntime)
    fig.suptitle('{} worlcommunitygrid applications, total runtime {}'.format(len(labels), 
                                                                              totalRuntime))
Пример #4
0
def plot(fig, projects):
    ax = fig.add_subplot(111)
    
    width = 0.8
    now = datetime.datetime.utcnow()
    norm = datetime.timedelta(days=7).total_seconds() # normalize colors to 7 days
    colormap = matplotlib.cm.get_cmap('hot')
    names = list()
    ix = 0
    totalRemaining = datetime.timedelta(0)
    for key, p in sorted(projects.items()):
        for task in p.tasks():
            try:
                r = task.remainingCPUtime.total_seconds()
                d = (task.deadline - now).total_seconds()
                c = task.elapsedCPUtime.total_seconds()
            except TypeError:
                continue

            totalRemaining += task.remainingCPUtime

            p = (d - r)/norm
            color = colormap(p)
            ax.barh(ix, r, height=width, color=color)
            ax.barh(ix, 1, height=1, left=d, color=color)
            ax.barh(ix, -c, height=width, color=color)
            if task.state_str == 'running': color = 'k'
            elif task.state_str == 'ready to report': color='g'
            else: color = 'b'
            ax.text(x = -c, y = ix + width/2,
                    s=task.fractionDone_str, horizontalalignment='right', fontsize=10, color=color)
            names.append(task.nameShort_str.replace('_', ' '))
            ix += 1

    plt.axvline(0, color='r', ls='--')
    plt.yticks(np.arange(len(names))+width/2, names)
    ax = plt.gca()
    ax.xaxis.set_major_formatter(formatter_timedelta)

    fig.suptitle('Time until deadline\nTotal work remaining %s' % util.timedeltaToStr(totalRemaining))
    ax.set_xlabel('Time')
    ax.set_ylabel('Task')

    for ix, labels in enumerate([ax.get_xticklabels(), ax.get_yticklabels()]):
        for label in labels:
            label.set_rotation(17)
            if ix == 0:
                label.set_ha('right')
            else:
                label.set_va('baseline')
Пример #5
0
def plot_worldcommunitygrid(fig, browser, data):
    if data == None:
        return

    ax = fig.add_subplot(111)
    width = 0.75
    ix = 0
    labels = list()
    totalRuntime = 0
    for key in sorted(data):
        badge, runtime, pending, running, validation = data[key]

        kwargs = dict(color='k',
                      width=width,
                      picker=True)
        
        try:
            kwargs['color'] = badge.color
        except:
            pass

        height = runtime
        ax.bar(ix, height, **kwargs)

        if badge != '':
            try:
                showImage(ax, browser, ix,
                          value=badge.runtime, color=badge.color, url=badge.url,
                          frameon=False)
            except Exception as e:
                logger.error('Badge image failed with "%s"', e)

        logger.debug('app %s, pending, running, validation = %s, %s, %s', 
                     key, pending, running, validation)

        for t, alpha in ((validation, 0.5), (running, 0.25), (pending, 0.125)):
            ax.bar(ix, t, bottom=height, alpha=alpha, **kwargs)
            height += t

        totalRuntime += runtime + pending + running + validation
        labels.append(str(key))
        ix += 1

    optional_logscale(ax)        
    pos = np.arange(len(labels))
    ax.set_xticks(pos+width/2)
    ax.set_xticklabels(labels, rotation=17, horizontalalignment='right')
    ax.set_xlabel('Application')

    ax.set_ylabel('Runtime')
    ax.yaxis.set_major_formatter(formatter_timedelta)
    for label in ax.get_xticklabels():  # make the xtick labels pickable
        label.set_picker(True)

    def onpick1(event):
        patch = event.artist
        print event, patch
        if isinstance(patch, Rectangle):
            print('onpick1 patch:', patch.get_path())
    fig.canvas.mpl_connect('pick_event', onpick1)
    
    #fig.canvas.mpl_connect('pick_event', onpick1)
    #ax.yaxis.set_major_locator(plt.MultipleLocator(3600*24*360))
    #import matplotlib
    

    totalRuntime = datetime.timedelta(seconds=totalRuntime)
    totalRuntime = util.timedeltaToStr(totalRuntime)
    fig.suptitle('{} worlcommunitygrid applications, total runtime {}'.format(len(labels), 
                                                                              totalRuntime))
Пример #6
0
 def wuPending_str(self):
     return util.timedeltaToStr(self.wuPending)
Пример #7
0
 def wuRuntime_str(self):
     return util.timedeltaToStr(self.wuRuntime)
Пример #8
0
 def runtime_str(self):
     return util.timedeltaToStr(self.runtime)