Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Yash Shah committed Oct 9, 2023
1 parent 1ca17b3 commit 172b31c
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions xpk/xpk.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@
"""

SystemCharacteristics = collections.namedtuple(
'SystemCharacteristcs',
'SystemCharacteristics',
[
'topology',
'vms_per_slice',
Expand All @@ -226,7 +226,7 @@
],
)

################### Subcomand Helper Functions #############
################### Subcommand Helper Functions #############

UserFacingNameToSystemCharacteristics = {
'v5litepod-16': SystemCharacteristics(
Expand All @@ -244,6 +244,18 @@
'v5litepod-256': SystemCharacteristics(
'16x16', 64, 'tpu-v5-lite-podslice', 'ct5lp-hightpu-4t', 4
),
'v4-8': SystemCharacteristics(
'2x2x1', 1,'gke_accelerator', 'ct4p-hightpu-4t', 4
),
'v4-16': SystemCharacteristics(
'2x2x2', 2,'gke_accelerator', 'ct4p-hightpu-4t', 4
),
'v4-32': SystemCharacteristics(
'2x2x4', 4,'gke_accelerator', 'ct4p-hightpu-4t', 4
),
'v4-64': SystemCharacteristics(
'2x4x4', 8,'gke_accelerator', 'ct4p-hightpu-4t', 4
),
}


Expand All @@ -257,10 +269,7 @@ def chunks(lst, n):
Returns:
List of n-sized chunks for lst.
"""
output = []
for i in range(0, len(lst), n):
output.append(lst[i : i + n])
return output
return [lst[i:i+n] for i in range(0, len(lst), n)]


def make_tmp_files(per_command_name):
Expand Down Expand Up @@ -554,10 +563,10 @@ def xpk_print(*args, **kwargs):


def xpk_exit(error_code):
"""Helper function to exit xpk with an associted error code.
"""Helper function to exit xpk with an associated error code.
Args:
error_code: If the code provided is zero, then no issues occured.
error_code: If the code provided is zero, then no issues occurred.
"""
if error_code == 0:
xpk_print('Exiting XPK cleanly')
Expand Down Expand Up @@ -718,7 +727,7 @@ def run_gke_node_pool_create_command(args, system_characteristics) -> int:
Args:
args: user provided arguments for running the command.
system_characteristics: System characteristics based on TPU type/toplology.
system_characteristics: System characteristics based on TPU type/topology.
Returns:
0 if successful and 1 otherwise.
Expand Down Expand Up @@ -1075,7 +1084,7 @@ def cluster_cacheimage(args) -> int:


def cluster_describe(args) -> int:
"""Function around cluster dewscribe.
"""Function around cluster describe.
Args:
args: user provided arguments for running the command.
Expand Down Expand Up @@ -1422,7 +1431,7 @@ def workload_name_type(value, pat=re.compile(r'[a-z]([-a-z0-9]*[a-z0-9])?')):
'--tpu-type',
type=str,
default='v5litepod-16',
help='The type of the TPU.',
help='The type of the TPU. v5litepod and v4 are the only supported types.',
required=True,
)

Expand All @@ -1432,14 +1441,14 @@ def workload_name_type(value, pat=re.compile(r'[a-z]([-a-z0-9]*[a-z0-9])?')):
type=str,
choices=['AS_NEEDED', 'PERIODIC'],
default='AS_NEEDED',
help='The maintenance policy of the cluster and repective clusters.',
help='The maintenance policy of the cluster and respective clusters.',
)
cluster_create_optional_arguments.add_argument(
'--gke-version',
type=str,
default='1.27.4-gke.900',
help=(
'The GKE version of the cluster and repective clusters. The default is'
'The GKE version of the cluster and respective clusters. The default is'
' "1.27.4-gke.900".'
),
)
Expand Down

0 comments on commit 172b31c

Please sign in to comment.