Exemplo n.º 1
0
def rate_ticket(ticket, **conf):
    rating = 0
    if ticket['spkgs']:
        return # can't handle these yet
    elif not ticket['patches']:
        return # nothing to do
    for dep in ticket['depends_on']:
        if isinstance(dep, basestring) and '.' in dep:
            if compare_version(conf['base'], dep) < 0:
                # Depends on a newer version of Sage than we're running.
                return None
    for author in ticket['authors']:
        if author not in conf['trusted_authors']:
            return
        rating += conf['bonus'].get(author, 0)
    for participant in ticket['participants']:
        rating += conf['bonus'].get(participant, 0) # doubled for authors
    rating += len(ticket['participants'])
    # TODO: remove condition
    if 'component' in ticket:
        rating += conf['bonus'].get(ticket['component'], 0)
    rating += conf['bonus'].get(ticket['status'], 0)
    rating += conf['bonus'].get(ticket['priority'], 0)
    rating += conf['bonus'].get(str(ticket['id']), 0)
    redundancy = (100,)
    prune_pending(ticket)
    if not ticket.get('retry'):
        for reports in current_reports(ticket, base=conf['base']):
            redundancy = min(redundancy, compare_machines(reports['machine'], conf['machine'], conf['machine_match']))
    if not redundancy[-1]:
        return # already did this one
    return redundancy, rating, -int(ticket['id'])
Exemplo n.º 2
0
 def rate_ticket(self, ticket):
     rating = 0
     if not ticket['spkgs'] and not ticket['patches']:
         return # nothing to do
     for dep in ticket['depends_on']:
         if isinstance(dep, basestring) and '.' in dep:
             if compare_version(self.base, dep) < 0:
                 # Depends on a newer version of Sage than we're running.
                 return None
     bonus = self.config['bonus']
     for author in ticket['authors'] or ticket['participants']:
         if author not in self.config['trusted_authors']:
             return
         rating += bonus.get(author, 0)
     for participant in ticket['participants']:
         rating += bonus.get(participant, 0) # doubled for authors
     rating += len(ticket['participants'])
     # TODO: remove condition
     if 'component' in ticket:
         rating += bonus.get(ticket['component'], 0)
     rating += bonus.get(ticket['status'], 0)
     rating += bonus.get(ticket['priority'], 0)
     rating += bonus.get(str(ticket['id']), 0)
     uniqueness = (100,)
     prune_pending(ticket)
     if not ticket.get('retry'):
         for report in self.current_reports(ticket, newer=True):
             uniqueness = min(uniqueness, compare_machines(report['machine'], self.config['machine'], self.config['machine_match']))
             if report['status'] != 'ApplyFailed':
                 rating += bonus.get("applies", 0)
             rating -= bonus.get("unique", 0)
     if not any(uniqueness):
         return # already did this one
     return uniqueness, rating, -int(ticket['id'])
Exemplo n.º 3
0
 def rate_ticket(self, ticket):
     rating = 0
     if not ticket.get('git_branch'):
         return
     bonus = self.config['bonus']
     for author in ticket['authors'] or ticket['participants']:
         if author not in self.config['trusted_authors']:
             return
         rating += bonus.get(author, 0)
     for participant in ticket['participants']:
         rating += bonus.get(participant, 0) # doubled for authors
     rating += len(ticket['participants'])
     # TODO: remove condition
     if 'component' in ticket:
         rating += bonus.get(ticket['component'], 0)
     rating += bonus.get(ticket['status'], 0)
     rating += bonus.get(ticket['priority'], 0)
     rating += bonus.get(str(ticket['id']), 0)
     uniqueness = (100,)
     prune_pending(ticket)
     if not ticket.get('retry'):
         for report in self.current_reports(ticket, newer=True):
             if report.get('git_base'):
                 try:
                     only_in_base = int(subprocess.check_output(["git", "rev-list", "--count", "%s..patchbot/base" % report['git_base']]))
                 except Exception:
                     # report['git_base'] not in our repo
                     only_in_base = -1
                 rating += bonus['behind'] * only_in_base
             report_uniqueness = compare_machines(report['machine'], self.config['machine'], self.config['machine_match'])
             if only_in_base and not any(report_uniqueness):
                 report_uniqueness = 0, 0, 0, 0, 1
             uniqueness = min(uniqueness, report_uniqueness)
             if report['status'] != 'ApplyFailed':
                 rating += bonus.get("applies", 0)
             rating -= bonus.get("unique", 0)
     if not any(uniqueness):
         return # already did this one
     return uniqueness, rating, -int(ticket['id'])
Exemplo n.º 4
0
    def rate_ticket(self, ticket):
        """
        Evaluate the interest to test this ticket.

        Return nothing when the ticket should not be tested.
        """
        rating = 0

        if not ticket.get('git_branch'):
            # do not test if there is no git branch
            return

        if ticket['milestone'] in ('sage-duplicate/invalid/wontfix',
                                   'sage-feature', 'sage-pending',
                                   'sage-wishlist'):
            # do not test if the milestone is not good
            return

        bonus = self.config['bonus']  # load the dict of bonus

        for author in ticket['authors']:
            # do not test if some author is not trusted
            if author not in self.config['trusted_authors']:
                return
            rating += 2 * bonus.get(author, 0)  # bonus for authors

        for participant in ticket['participants']:
            # do not test if some participant is not trusted ?
            if participant not in self.config['trusted_authors']:
                return
            rating += bonus.get(participant, 0)  # bonus for participants

        if 'component' in ticket:
            rating += bonus.get(ticket['component'], 0)  # bonus for components

        rating += bonus.get(ticket['status'], 0)
        rating += bonus.get(ticket['priority'], 0)
        rating += bonus.get(str(ticket['id']), 0)

        uniqueness = (100,)
        prune_pending(ticket)
        if not ticket.get('retry'):
            for report in self.current_reports(ticket, newer=True):
                if report.get('git_base'):
                    try:
                        only_in_base = int(subprocess.check_output(["git", "rev-list", "--count", "%s..patchbot/base" % report['git_base']]))
                    except Exception:
                        # report['git_base'] not in our repo
                        only_in_base = -1
                    rating += bonus['behind'] * only_in_base

                report_uniqueness = compare_machines(report['machine'], self.config['machine'], self.config['machine_match'])
                if only_in_base and not any(report_uniqueness):
                    report_uniqueness = (0, 0, 0, 0, 1)
                uniqueness = min(uniqueness, report_uniqueness)

                if report['status'] != 'ApplyFailed':
                    rating += bonus.get("applies", 0)
                rating -= bonus.get("unique", 0)

        if not any(uniqueness):
            return  # already did this one

        if ticket['id'] in self.to_skip:
            # are we still in the skip delay for this ticket ?
            if self.to_skip[ticket['id']] < time.time():
                del self.to_skip[ticket['id']]
            else:
                return

        return uniqueness, rating, -int(ticket['id'])