• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / relman-auto-nag / #5255

11 Oct 2024 03:14PM CUT coverage: 21.55% (-0.1%) from 21.646%
#5255

push

coveralls-python

jgraham
Add a rule to sync [webcompat:sightline] whiteboard entry

This should be set on all bugs that are part of the webcompat metrics
set, and by no bugs that aren't.

This initial approach just gets all the bugs that are either in that
set or have the whiteboard entry, and implements the logic to update
them in the client. Given that we expect initially to have ~700 bugs
in that set, this means we need to set the maximum number of bugs to
update to something rather high.

426 of 2886 branches covered (14.76%)

0 of 54 new or added lines in 3 files covered. (0.0%)

12 existing lines in 1 file now uncovered.

1941 of 9007 relevant lines covered (21.55%)

0.22 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/bugbot/bugbug_utils.py
1
# This Source Code Form is subject to the terms of the Mozilla Public
2
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
3
# You can obtain one at http://mozilla.org/MPL/2.0/.
4

5
import os
×
6
import time
×
7
from typing import Iterable
×
8

9
import requests
×
10

11
BUGBUG_HTTP_SERVER = os.environ.get(
×
12
    "BUGBUG_HTTP_SERVER", "https://bugbug.herokuapp.com/"
13
)
14

15

16
def classification_http_request(url, bug_ids):
×
17
    response = requests.post(
×
18
        url, headers={"X-Api-Key": "autonag"}, json={"bugs": bug_ids}
19
    )
20

21
    response.raise_for_status()
×
22

23
    return response.json()
×
24

25

26
def get_bug_ids_classification(
×
27
    model: str, bugs: Iterable, retry_count: int = 21, retry_sleep: int = 10
28
):
29
    """Get the classification for a list of bug ids.
30

31
    Args:
32
        model: The model to use for the classification.
33
        bug_ids: The list of bug ids to classify, if a dictionary is passed, the
34
            keys will be used as bug ids.
35
        retry_count: The number of times to retry the request.
36
        retry_sleep: The number of seconds to sleep between retries.
37

38
    Returns:
39
        A dictionary with the bug ids as keys and the classification as values.
40
    """
41
    # Copy the bug ids to avoid mutating it
42
    bug_ids = set(map(int, bugs))
×
43
    if len(bug_ids) == 0:
×
44
        return {}
×
45

46
    url = f"{BUGBUG_HTTP_SERVER}/{model}/predict/batch"
×
47

48
    json_response = {}
×
49

50
    for _ in range(retry_count):
×
51
        response = classification_http_request(url, list(bug_ids))
×
52

53
        # Check which bug ids are ready
54
        for bug_id, bug_data in response["bugs"].items():
×
55
            if not bug_data.get("ready", True):
×
56
                continue
×
57

58
            # The bug is ready, add it to the json_response and pop it
59
            # up from the current batch
60
            # The http service returns strings for backward compatibility reasons
61
            bug_ids.remove(int(bug_id))
×
62
            json_response[bug_id] = bug_data
×
63

64
        if len(bug_ids) == 0:
×
65
            break
×
66
        else:
67
            time.sleep(retry_sleep)
×
68

69
    else:
70
        total_sleep = retry_count * retry_sleep
×
71
        msg = f"Couldn't get {len(bug_ids)} bug classifications in {total_sleep} seconds, aborting"
×
72
        raise Exception(msg)
×
73

74
    return json_response
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc