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

mozilla / relman-auto-nag / #5650

27 Oct 2025 03:04PM UTC coverage: 20.694%. Remained the same
#5650

push

coveralls-python

marco-c
Use new bugbug deployment

426 of 3036 branches covered (14.03%)

0 of 1 new or added line in 1 file covered. (0.0%)

1943 of 9389 relevant lines covered (20.69%)

0.21 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

NEW
11
BUGBUG_HTTP_SERVER = os.environ.get("BUGBUG_HTTP_SERVER", "https://bugbug.moz.tools/")
×
12

13

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

19
    response.raise_for_status()
×
20

21
    return response.json()
×
22

23

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

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

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

44
    url = f"{BUGBUG_HTTP_SERVER}/{model}/predict/batch"
×
45

46
    json_response = {}
×
47

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

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

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

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

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

72
    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