Reference for ultralytics/utils/events.py
Note
This file is available at https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/events.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!
ultralytics.utils.events.Events
Events()
Collect and send anonymous usage analytics with rate-limiting.
Event collection and transmission are enabled when sync is enabled in settings, the current process is rank -1 or 0, tests are not running, the environment is online, and the installation source is either pip or the official Ultralytics GitHub repository.
Attributes:
Name | Type | Description |
---|---|---|
url |
str
|
Measurement Protocol endpoint for receiving anonymous events. |
events |
list[dict]
|
In-memory queue of event payloads awaiting transmission. |
rate_limit |
float
|
Minimum time in seconds between POST requests. |
t |
float
|
Timestamp of the last transmission in seconds since the epoch. |
metadata |
dict
|
Static metadata describing runtime, installation source, and environment. |
enabled |
bool
|
Flag indicating whether analytics collection is active. |
Methods:
Name | Description |
---|---|
__call__ |
Queue an event and trigger a non-blocking send when the rate limit elapses. |
Source code in ultralytics/utils/events.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
|
__call__
__call__(cfg, device=None) -> None
Queue an event and flush the queue asynchronously when the rate limit elapses.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cfg
|
IterableSimpleNamespace
|
The configuration object containing mode and task information. |
required |
device
|
device | str
|
The device type (e.g., 'cpu', 'cuda'). |
None
|
Source code in ultralytics/utils/events.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
|
ultralytics.utils.events._post
_post(url: str, data: dict, timeout: float = 5.0) -> None
Send a one-shot JSON POST request.
Source code in ultralytics/utils/events.py
16 17 18 19 20 21 22 23 |
|