Skip to content
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

Support GCP custom instance types hybrid autoscaling #3376

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions workflows/pipe-common/pipeline/hpc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,22 @@ def get_run_id_from_host(self, host):

def extract_family_from_instance_type(self, cloud_provider, instance_type):
if cloud_provider == CloudProvider.aws():
search = re.search('^(\w+)\..*', instance_type)
return search.group(1) if search else None
search = re.search('^(\\w+)\\..*', instance_type)
if search:
return search.group(1)
elif cloud_provider == CloudProvider.gcp():
search = re.search('^(?!custom)(\w+-(?!custom)\w+)-?.*', instance_type)
return search.group(1) if search else None
search = re.search('^(\\w*-?custom)-\\w+-\\w+$', instance_type)
if search:
return search.group(1)
search = re.search('^(gpu-\\w*-?custom)-\\w+-\\w+(-\\w+)-\\w+$', instance_type)
if search:
return search.group(1) + search.group(2)
search = re.search('^(\\w+-\\w+)-?\\w*(-?\\w*)', instance_type)
if search:
return search.group(1) + search.group(2)
elif cloud_provider == CloudProvider.azure():
# will return Bms for Standard_B1ms or Dsv3 for Standard_D2s_v3 instance types
search = re.search('^([a-zA-Z]+)\d+(.*)', instance_type.split('_', 1)[1].replace('_', ''))
return search.group(1) + search.group(2) if search else None
else:
return None
search = re.search('^([a-zA-Z]+)\\d+(.*)', instance_type.split('_', 1)[1].replace('_', ''))
if search:
return search.group(1) + search.group(2)
return None
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,14 @@ def test_gcp_familes():
assert utils.extract_family_from_instance_type(CloudProvider.gcp(), "n2-highcpu-2") == "n2-highcpu"
assert utils.extract_family_from_instance_type(CloudProvider.gcp(), "n2d-highcpu-128") == "n2d-highcpu"
assert utils.extract_family_from_instance_type(CloudProvider.gcp(), "e2-small") == "e2-small"
assert utils.extract_family_from_instance_type(CloudProvider.gcp(), "custom-12-16") is None
assert utils.extract_family_from_instance_type(CloudProvider.gcp(), "gpu-custom-4-16384-k80-1") is None
assert utils.extract_family_from_instance_type(CloudProvider.gcp(), "c3-standard-4") == "c3-standard"
assert utils.extract_family_from_instance_type(CloudProvider.gcp(), "c3-standard-4-lssd") == "c3-standard-lssd"
assert utils.extract_family_from_instance_type(CloudProvider.gcp(), "a2-highgpu-1g") == "a2-highgpu"
assert utils.extract_family_from_instance_type(CloudProvider.gcp(), "a2-ultragpu-4g") == "a2-ultragpu"
assert utils.extract_family_from_instance_type(CloudProvider.gcp(), "custom-12-16384") == "custom"
assert utils.extract_family_from_instance_type(CloudProvider.gcp(), "n2-custom-12-16384") == "n2-custom"
assert utils.extract_family_from_instance_type(CloudProvider.gcp(), "gpu-custom-4-16384-k80-1") == "gpu-custom-k80"
assert utils.extract_family_from_instance_type(CloudProvider.gcp(), "gpu-n2-custom-4-16384-k80-1") == "gpu-n2-custom-k80"


def test_azure_familes():
Expand Down
Loading