-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Skylark init caches Azure regions & SKU availability #339
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
|
||
@staticmethod | ||
def lookup_valid_instance(region: str, instance_name: str) -> Optional[str]: | ||
# todo this should query the Azure API for available SKUs | ||
available_regions = { | ||
"Standard_D32_v5": [ | ||
"australiaeast", | ||
"canadacentral", | ||
"eastus", | ||
"eastus2", | ||
"francecentral", | ||
"germanywestcentral", | ||
"japaneast", | ||
"koreacentral", | ||
"northcentralus", | ||
"northeurope", | ||
"uksouth", | ||
"westeurope", | ||
"westus", | ||
"westus2", | ||
"westus3", | ||
], | ||
"Standard_D32_v4": [ | ||
"australiaeast", | ||
"brazilsouth", | ||
"canadacentral", | ||
"centralindia", | ||
"eastasia", | ||
"eastus", | ||
"francecentral", | ||
"germanywestcentral", | ||
"japaneast", | ||
"koreacentral", | ||
"northcentralus", | ||
"northeurope", | ||
"norwayeast", | ||
"southafricanorth", | ||
"swedencentral", | ||
"switzerlandnorth", | ||
"uaenorth", | ||
"uksouth", | ||
"westeurope", | ||
"westus", | ||
"westus3", | ||
], | ||
} | ||
if region in available_regions["Standard_D32_v5"] and instance_name == "Standard_D32_v5": | ||
sku_mapping = AzureAuthentication.get_sku_mapping() | ||
if instance_name == "Standard_D32_v5" and "Standard_D32_v5" in sku_mapping[region]: | ||
return "Standard_D32_v5" | ||
elif region in available_regions["Standard_D32_v4"] and instance_name == "Standard_D32_v5": | ||
elif instance_name == "Standard_D32_v4" and "Standard_D32_v4" in sku_mapping[region]: | ||
return "Standard_D32_v4" | ||
else: | ||
logger.error(f"Cannot confirm availability of {instance_name} in {region}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want to support changing the core counts on Azure since at the moment, we provision very beefy 32 core instances but get similar performance with 8 cores for some regions (https://azureprice.net/). An alternative design:
@staticmethod
def lookup_valid_instance(region: str, instance_name: str) -> Optional[str]:
sku_mapping = AzureAuthentication.get_sku_mapping()
if instance_name in sku_mapping[region]:
return instance_name
match = re.match(r"^(?P<base_name>.*)_v(?P<version>\d+)$", instance_name)
if match:
base_name = match.group("base_name")
for version in range(int(match.group("version")), 0, -1):
test_instance_name = f"{base_name}_v{version}" if version > 1 else base_name
if test_instance_name in sku_mapping[region]:
logger.fs.warning(f"[azure] Instance {instance_name} not found in region {region} but was able to find a similar instance {test_instance_name}")
return test_instance_name
logger.fs.error(f"[azure] Instance {instance_name} not found in region {region} and could not infer a similar instance name.")
return None
skylark/compute/azure/azure_auth.py
Outdated
|
||
|
||
@staticmethod | ||
def get_region_config(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add types: def get_region_config() -> List[string]:
skylark/compute/azure/azure_auth.py
Outdated
return region_list | ||
|
||
@staticmethod | ||
def get_sku_mapping(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add types: def get_sku_mapping() -> Dict[str, List[str]]
* Azure caches enabled regions * SKU availability cached * Azure lookup instance uses cached SKU mapping * Generalized azure instance type lookup
No description provided.