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

mozilla / relman-auto-nag / #4514

pending completion
#4514

push

coveralls-python

suhaibmujahid
Some cleanup

641 of 3228 branches covered (19.86%)

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

1817 of 8049 relevant lines covered (22.57%)

0.23 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

8
import requests
×
9

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

14

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

20
    response.raise_for_status()
×
21

22
    return response.json()
×
23

24

25
def get_bug_ids_classification(model, bug_ids, retry_count=21, retry_sleep=7):
×
26
    if len(bug_ids) == 0:
×
27
        return {}
×
28

29
    url = f"{BUGBUG_HTTP_SERVER}/{model}/predict/batch"
×
30

31
    # Copy the bug ids to avoid mutating it
32
    bug_ids = set(map(int, bug_ids))
×
33

34
    json_response = {}
×
35

36
    for _ in range(retry_count):
×
37
        response = classification_http_request(url, list(bug_ids))
×
38

39
        # Check which bug ids are ready
40
        for bug_id, bug_data in response["bugs"].items():
×
41
            if not bug_data.get("ready", True):
×
42
                continue
×
43

44
            # The bug is ready, add it to the json_response and pop it
45
            # up from the current batch
46
            # The http service returns strings for backward compatibility reasons
47
            bug_ids.remove(int(bug_id))
×
48
            json_response[bug_id] = bug_data
×
49

50
        if len(bug_ids) == 0:
×
51
            break
×
52
        else:
53
            time.sleep(retry_sleep)
×
54

55
    else:
56
        total_sleep = retry_count * retry_sleep
×
57
        msg = f"Couldn't get {len(bug_ids)} bug classifications in {total_sleep} seconds, aborting"
×
58
        raise Exception(msg)
×
59

60
    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