Skip to content

Commit

Permalink
Do not default to n1-standard-4 if cpu or ram is specified
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 449887413
Change-Id: I14d72ef8cc98d7cad84b8ac730634f59b4f4a5aa
GitOrigin-RevId: dbfca7713bb4e297bd1a14ff486a0c2e86d9a634
  • Loading branch information
andrewluchen authored and kibergus committed May 30, 2022
1 parent d84ccda commit 27979f2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion xmanager/cloud/vertex.py
Expand Up @@ -341,7 +341,9 @@ def launch(experiment_title: str, work_unit_name: str,

def cpu_ram_to_machine_type(cpu: Optional[int], ram: Optional[int]) -> str:
"""Convert a cpu and memory spec into a machine type."""
if cpu is None or ram is None:
cpu = cpu or 0
ram = ram or 0
if cpu + ram == 0:
return 'n1-standard-4'

optimal_machine_type = ''
Expand Down
7 changes: 7 additions & 0 deletions xmanager/cloud/vertex_test.py
Expand Up @@ -170,10 +170,17 @@ def test_cpu_ram_to_machine_type_highmem(self):
self.assertEqual('n1-highmem-64',
vertex.cpu_ram_to_machine_type(1, 415 * xm.GiB))

def test_cpu_ram_to_machine_type_mem_only(self):
self.assertEqual('n1-highmem-64',
vertex.cpu_ram_to_machine_type(None, 415 * xm.GiB))

def test_cpu_ram_to_machine_type_highcpu(self):
self.assertEqual('n1-highcpu-64',
vertex.cpu_ram_to_machine_type(63, 1 * xm.GiB))

def test_cpu_ram_to_machine_type_cpu_only(self):
self.assertEqual('n1-highcpu-64', vertex.cpu_ram_to_machine_type(63, None))

def test_cpu_ram_to_machine_type_too_high(self):
with self.assertRaises(ValueError):
vertex.cpu_ram_to_machine_type(1000, 1000)
Expand Down

0 comments on commit 27979f2

Please sign in to comment.