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
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
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
tier1
Returns a list of GCP regions classified as tier 1 based on predefined criteria.
tier2
Returns a list of GCP regions classified as tier 2 based on predefined criteria.