Reference for ultralytics/hub/google/__init__.py
Note
This file is available at https://github.com/ultralytics/ultralytics/blob/main/ultralytics/hub/google/__init__.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!
ultralytics.hub.google.GCPRegions
GCPRegions()
A class for managing and analyzing Google Cloud Platform (GCP) regions.
This class provides functionality to initialize, categorize, and analyze GCP regions based on their geographical location, tier classification, and network latency.
Attributes:
Name | Type | Description |
---|---|---|
regions |
Dict[str, Tuple[int, str, str]]
|
A dictionary of GCP regions with their tier, city, and country. |
Methods:
Name | Description |
---|---|
tier1 |
Returns a list of tier 1 GCP regions. |
tier2 |
Returns a list of tier 2 GCP regions. |
lowest_latency |
Determines the GCP region(s) with the lowest network latency. |
Examples:
>>> from ultralytics.hub.google import GCPRegions
>>> regions = GCPRegions()
>>> lowest_latency_region = regions.lowest_latency(verbose=True, attempts=3)
>>> print(f"Lowest latency region: {lowest_latency_region[0][0]}")
Source code in ultralytics/hub/google/__init__.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
|
lowest_latency
lowest_latency(
top: int = 1,
verbose: bool = False,
tier: Optional[int] = None,
attempts: int = 1,
) -> List[Tuple[str, float, float, float, float]]
Determines the GCP regions with the lowest latency based on ping tests.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
top
|
int
|
Number of top regions to return. |
1
|
verbose
|
bool
|
If True, prints detailed latency information for all tested regions. |
False
|
tier
|
int | None
|
Filter regions by tier (1 or 2). If None, all regions are tested. |
None
|
attempts
|
int
|
Number of ping attempts per region. |
1
|
Returns:
Type | Description |
---|---|
List[Tuple[str, float, float, float, float]]
|
List of tuples containing region information and |
List[Tuple[str, float, float, float, float]]
|
latency statistics. Each tuple contains (region, mean_latency, std_dev, min_latency, max_latency). |
Examples:
>>> regions = GCPRegions()
>>> results = regions.lowest_latency(top=3, verbose=True, tier=1, attempts=2)
>>> print(results[0][0]) # Print the name of the lowest latency region
Source code in ultralytics/hub/google/__init__.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
tier1
tier1() -> List[str]
Returns a list of GCP regions classified as tier 1 based on predefined criteria.
Source code in ultralytics/hub/google/__init__.py
76 77 78 |
|
tier2
tier2() -> List[str]
Returns a list of GCP regions classified as tier 2 based on predefined criteria.
Source code in ultralytics/hub/google/__init__.py
80 81 82 |
|