Skip to content

Commit 79a39f9

Browse files
scalibyDannyLiCom
authored andcommitted
Enable sub-slicing for cluster create-pathways (#740)
feat: enable sub-slicing for cluster create-pathways
1 parent c13f0f1 commit 79a39f9

File tree

2 files changed

+81
-8
lines changed

2 files changed

+81
-8
lines changed

src/xpk/parser/cluster.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,7 @@ def set_cluster_create_parser(cluster_create_parser: ArgumentParser):
150150
' enable cluster to accept Pathways workloads.'
151151
),
152152
)
153-
if FeatureFlags.SUB_SLICING_ENABLED:
154-
cluster_create_optional_arguments.add_argument(
155-
'--sub-slicing',
156-
action='store_true',
157-
help='Whether to set up cluster to support sub-slicing',
158-
)
153+
add_sub_slicing_arguments(cluster_create_optional_arguments)
159154

160155
autoprovisioning_arguments = cluster_create_parser.add_argument_group(
161156
'Autoprovisioning Arguments',
@@ -232,6 +227,7 @@ def set_cluster_create_pathways_parser(
232227
add_shared_cluster_create_optional_arguments(
233228
cluster_create_pathways_optional_arguments
234229
)
230+
add_sub_slicing_arguments(cluster_create_pathways_optional_arguments)
235231

236232
autoprovisioning_arguments = (
237233
cluster_create_pathways_parser.add_argument_group(
@@ -365,7 +361,9 @@ def set_cluster_create_ray_parser(cluster_create_ray_parser: ArgumentParser):
365361
)
366362
add_resource_limits(cluster_create_resource_limits)
367363

368-
cluster_create_ray_parser.set_defaults(func=cluster_create_ray_cluster)
364+
cluster_create_ray_parser.set_defaults(
365+
func=cluster_create_ray_cluster, sub_slicing=False
366+
)
369367

370368

371369
def set_cluster_delete_parser(cluster_delete_parser: ArgumentParser):
@@ -594,6 +592,15 @@ def set_cluster_adapt_parser(cluster_adapt_parser: ArgumentParser):
594592
cluster_adapt_parser.set_defaults(func=cluster_adapt)
595593

596594

595+
def add_sub_slicing_arguments(parser_or_group: ParserOrArgumentGroup):
596+
if FeatureFlags.SUB_SLICING_ENABLED:
597+
parser_or_group.add_argument(
598+
'--sub-slicing',
599+
action='store_true',
600+
help='Whether to set up cluster to support sub-slicing',
601+
)
602+
603+
597604
def add_autoprovisioning_arguments(parser_or_group: ParserOrArgumentGroup):
598605
parser_or_group.add_argument(
599606
'--enable-autoprovisioning',

src/xpk/parser/cluster_test.py

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"""
1616

1717
import argparse
18-
from xpk.parser.cluster import set_cluster_create_parser
18+
from xpk.parser.cluster import set_cluster_create_parser, set_cluster_create_pathways_parser, set_cluster_create_ray_parser
1919
import pytest
2020
from ..utils.feature_flags import FeatureFlags
2121

@@ -64,3 +64,69 @@ def test_cluster_create_sub_slicing_can_be_set():
6464
)
6565

6666
assert args.sub_slicing is True
67+
68+
69+
def test_cluster_create_pathways_sub_slicing_is_hidden_with_flag_off():
70+
FeatureFlags.SUB_SLICING_ENABLED = False
71+
parser = argparse.ArgumentParser()
72+
73+
set_cluster_create_pathways_parser(parser)
74+
help_str = parser.format_help()
75+
76+
assert "--sub-slicing" not in help_str
77+
78+
79+
def test_cluster_create_pathways_sub_slicing_is_shown_with_flag_on():
80+
parser = argparse.ArgumentParser()
81+
82+
set_cluster_create_pathways_parser(parser)
83+
help_str = parser.format_help()
84+
85+
assert "--sub-slicing" in help_str
86+
87+
88+
def test_cluster_create_pathways_sub_slicing_is_false_by_default():
89+
parser = argparse.ArgumentParser()
90+
91+
set_cluster_create_pathways_parser(parser)
92+
args = parser.parse_args(
93+
["--cluster", "test-cluster", "--tpu-type", "test-tpu"]
94+
)
95+
96+
assert args.sub_slicing is False
97+
98+
99+
def test_cluster_create_pathways_sub_slicing_can_be_set():
100+
parser = argparse.ArgumentParser()
101+
102+
set_cluster_create_pathways_parser(parser)
103+
args = parser.parse_args(
104+
["--cluster", "test-cluster", "--tpu-type", "test-tpu", "--sub-slicing"]
105+
)
106+
107+
assert args.sub_slicing is True
108+
109+
110+
def test_cluster_create_ray_sub_slicing_is_hidden():
111+
parser = argparse.ArgumentParser()
112+
113+
set_cluster_create_ray_parser(parser)
114+
help_str = parser.format_help()
115+
116+
assert "--sub-slicing" not in help_str
117+
118+
119+
def test_cluster_create_ray_sub_slicing_is_false():
120+
parser = argparse.ArgumentParser()
121+
122+
set_cluster_create_ray_parser(parser)
123+
args = parser.parse_args([
124+
"--cluster",
125+
"test-cluster",
126+
"--tpu-type",
127+
"test-tpu",
128+
"--ray-version",
129+
"1.0.0",
130+
])
131+
132+
assert args.sub_slicing is False

0 commit comments

Comments
 (0)