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

mozilla / relman-auto-nag / #5014

20 May 2024 01:16PM CUT coverage: 21.891%. Remained the same
#5014

push

coveralls-python

web-flow
Bump coveralls from 3.3.1 to 4.0.1

Bumps [coveralls](https://github.com/TheKevJames/coveralls-python) from 3.3.1 to 4.0.1.
- [Release notes](https://github.com/TheKevJames/coveralls-python/releases)
- [Changelog](https://github.com/TheKevJames/coveralls-python/blob/master/CHANGELOG.md)
- [Commits](https://github.com/TheKevJames/coveralls-python/compare/3.3.1...4.0.1)

---
updated-dependencies:
- dependency-name: coveralls
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

585 of 3463 branches covered (16.89%)

1933 of 8830 relevant lines covered (21.89%)

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