Skip to content

Commit 81004f7

Browse files
SujeethJineshlukebaumannRoshaniN
authored
Sync main commits with develop branch (#379)
* Update the pod_name query for pathways workloads (#362) * Support custom Pathways args. (#364) * Remove Pathways specific args from workload create flow. (#365) * Remove Pathways specific optional args from workload create. * Deprecate --use-pathways from workload create, set it in create-pathways. * Remove --enable-pathways from cluster create flow. * Adding --use-pathways and --enable-pathways args - they are used to determine Pathways flows. --------- Co-authored-by: Luke Baumann <lukebaumann@users.noreply.github.com> Co-authored-by: Roshani Narasimhan <roshanin@google.com>
1 parent d4ac54a commit 81004f7

File tree

4 files changed

+115
-75
lines changed

4 files changed

+115
-75
lines changed

src/xpk/commands/workload.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -412,14 +412,6 @@ def workload_create(args) -> None:
412412
k8s_api_client = setup_k8s_env(args)
413413
create_k8s_service_account(XPK_SA, 'default')
414414

415-
if args.headless:
416-
xpk_print(
417-
'Please use kubectl port forwarding to connect to the Pathways proxy.'
418-
' kubectl get pods kubectl port-forward <proxy-pod-name> 29000:29000'
419-
' JAX_PLATFORMS=proxy JAX_BACKEND_TARGET=grpc://127.0.0.1:29000 python'
420-
" -c 'import pathwaysutils; import jax; print(jax.devices())'"
421-
)
422-
423415
workload_exists = check_if_workload_exists(args)
424416

425417
if workload_exists:

src/xpk/core/pathways.py

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ def get_pathways_worker_args(args) -> str:
4343
- --resource_manager_address={rm_address}
4444
- --gcs_scratch_location={args.pathways_gcs_location}"""
4545
if args.use_pathways:
46+
if args.custom_pathways_worker_args:
47+
yaml = append_custom_pathways_args(yaml, args.custom_pathways_worker_args)
4648
return yaml.format(args=args, rm_address=get_rm_address(args))
4749
else:
4850
return ''
@@ -61,6 +63,10 @@ def get_pathways_proxy_args(args) -> str:
6163
- --gcs_scratch_location={args.pathways_gcs_location}"""
6264

6365
if args.use_pathways:
66+
if args.custom_pathways_proxy_server_args:
67+
yaml = append_custom_pathways_args(
68+
yaml, args.custom_pathways_proxy_server_args
69+
)
6470
return yaml.format(args=args, rm_address=get_rm_address(args))
6571
else:
6672
return ''
@@ -204,15 +210,12 @@ def ensure_pathways_workload_prerequisites(args, system) -> bool:
204210

205211
def get_pathways_unified_query_link(args) -> str:
206212
"""Get the unified query link for the pathways workload."""
207-
pw_suffixes = ['main', 'rm', 'proxy']
208-
pw_pod_names = [f'"{args.workload}-{suffix}-0"' for suffix in pw_suffixes]
209-
pw_pod_names_query = '%20OR%20'.join(pw_pod_names + ['worker-0-0'])
210213
query_params = (
211214
'resource.type%3D"k8s_container"%0A'
212215
f'resource.labels.project_id%3D"{args.project}"%0A'
213216
f'resource.labels.location%3D"{zone_to_region(args.zone)}"%0A'
214217
f'resource.labels.cluster_name%3D"{args.cluster}"%0A'
215-
f'resource.labels.pod_name:{pw_pod_names_query}%0A'
218+
f'resource.labels.pod_name:"{args.workload}-"%0A'
216219
'severity>%3DDEFAULT'
217220
)
218221

@@ -233,6 +236,8 @@ def get_pathways_rm_args(args, system: SystemCharacteristics) -> str:
233236
- --instance_count={instance_count}
234237
- --instance_type={instance_type}"""
235238
if args.use_pathways:
239+
if args.custom_pathways_server_args:
240+
yaml = append_custom_pathways_args(yaml, args.custom_pathways_server_args)
236241
return yaml.format(
237242
args=args,
238243
instance_count=args.num_slices,
@@ -242,6 +247,28 @@ def get_pathways_rm_args(args, system: SystemCharacteristics) -> str:
242247
return ''
243248

244249

250+
def append_custom_pathways_args(yaml, custom_args) -> str:
251+
"""Append custom Pathways args to the YAML with proper indentation.
252+
253+
Args:
254+
yaml (string): existing yaml containing args
255+
256+
Returns:
257+
yaml (string): yaml with additional args appended.
258+
"""
259+
second_line = yaml.split('\n')[1]
260+
if (
261+
not second_line
262+
): # to cover edge case if only one arg remains, we would have to look at the entire YAML in this case.
263+
return yaml
264+
# Calculate the indentation based on the second line of existing YAML.
265+
indentation = ' ' * (len(second_line) - len(second_line.lstrip()))
266+
custom_args = custom_args.split(' ')
267+
for arg in custom_args:
268+
yaml += '\n' + indentation + '- ' + arg
269+
return yaml
270+
271+
245272
def get_user_workload_for_pathways(
246273
args,
247274
system: SystemCharacteristics,

src/xpk/parser/cluster.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,10 @@ def set_cluster_parser(cluster_parser):
9494
'--enable-pathways',
9595
action='store_true',
9696
help=(
97-
'DEPRECATING SOON!!! Please use `xpk cluster create-pathways`.'
98-
' Enable cluster to accept Pathways workloads.'
97+
'Please use `xpk cluster create-pathways` instead to'
98+
' enable cluster to accept Pathways workloads.'
9999
),
100100
)
101-
102101
### Autoprovisioning arguments specific to "cluster create"
103102
cluster_create_autoprovisioning_arguments = (
104103
cluster_create_parser.add_argument_group(

src/xpk/parser/workload.py

Lines changed: 82 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,7 @@ def set_workload_parsers(workload_parser):
6767
'Arguments for configuring autoprovisioning.',
6868
)
6969
)
70-
workload_pathways_workload_arguments = workload_create_parser.add_argument_group(
71-
'Pathways Image Arguments',
72-
'If --use-pathways is provided, user wants to set up a'
73-
'Pathways workload on xpk.',
74-
)
70+
7571
workload_vertex_tensorboard_arguments = (
7672
workload_create_parser.add_argument_group(
7773
'Vertex Tensorboard Arguments',
@@ -157,6 +153,15 @@ def set_workload_parsers(workload_parser):
157153
),
158154
)
159155

156+
workload_create_parser_optional_arguments.add_argument(
157+
'--use-pathways',
158+
action='store_true',
159+
help=(
160+
'Please use `xpk workload create-pathways` instead to'
161+
' create Pathways workloads.'
162+
),
163+
)
164+
160165
# Autoprovisioning workload arguments
161166
workload_create_autoprovisioning_arguments.add_argument(
162167
'--on-demand',
@@ -184,16 +189,6 @@ def set_workload_parsers(workload_parser):
184189
),
185190
)
186191

187-
# Pathways workload arguments
188-
workload_pathways_workload_arguments.add_argument(
189-
'--use-pathways',
190-
action='store_true',
191-
help=(
192-
'DECRATING SOON!!! Please use `xpk workload create-pathways` instead.'
193-
' Provide this argument to create Pathways workloads.'
194-
),
195-
)
196-
197192
# "workload create-pathways" command parser.
198193
workload_create_pathways_parser = workload_subcommands.add_parser(
199194
'create-pathways', help='Create a new job.'
@@ -236,6 +231,45 @@ def set_workload_parsers(workload_parser):
236231
help='The tpu type to use, v5litepod-16, etc.',
237232
)
238233

234+
### "workload create-pathways" Optional arguments, specific to Pathways
235+
workload_create_pathways_parser_optional_arguments.add_argument(
236+
'--headless',
237+
action='store_true',
238+
help=(
239+
'Please provide this argument to create Pathways workloads in'
240+
' headless mode. This arg can only be used in `xpk workload'
241+
' create-pathways`.'
242+
),
243+
)
244+
workload_create_pathways_parser_optional_arguments.add_argument(
245+
'--proxy-server-image',
246+
type=str,
247+
default=(
248+
'us-docker.pkg.dev/cloud-tpu-v2-images/pathways/proxy_server:latest'
249+
),
250+
help=(
251+
'Please provide the proxy server image for Pathways. This arg can'
252+
' only be used in `xpk workload create-pathways`.'
253+
),
254+
)
255+
workload_create_pathways_parser_optional_arguments.add_argument(
256+
'--server-image',
257+
type=str,
258+
default='us-docker.pkg.dev/cloud-tpu-v2-images/pathways/server:latest',
259+
help=(
260+
'Please provide the server image for Pathways. This arg can only be'
261+
' used in `xpk workload create-pathways`.'
262+
),
263+
)
264+
workload_create_pathways_parser_optional_arguments.add_argument(
265+
'--pathways-gcs-location',
266+
type=str,
267+
default='gs://cloud-pathways-staging/tmp',
268+
help=(
269+
'Please provide the GCS location to store Pathways artifacts. This'
270+
' arg can only be used in `xpk workload create-pathways`.'
271+
),
272+
)
239273
workload_create_pathways_parser_optional_arguments.add_argument(
240274
'--command',
241275
type=str,
@@ -256,6 +290,39 @@ def set_workload_parsers(workload_parser):
256290
help='Names of storages the workload uses',
257291
)
258292

293+
workload_create_pathways_parser_optional_arguments.add_argument(
294+
'--custom-pathways-server-args',
295+
type=str,
296+
default=None,
297+
help=(
298+
'Provide custom Pathways server args as follows -'
299+
" --custom-pathways-server-args='--arg_1=xxx --arg2=yyy'"
300+
),
301+
required=False,
302+
)
303+
304+
workload_create_pathways_parser_optional_arguments.add_argument(
305+
'--custom-pathways-proxy-server-args',
306+
type=str,
307+
default=None,
308+
help=(
309+
'Provide custom Pathways proxy server args as follows -'
310+
" --custom-pathways-proxy-server-args='--arg_1=xxx --arg2=yyy'"
311+
),
312+
required=False,
313+
)
314+
315+
workload_create_pathways_parser_optional_arguments.add_argument(
316+
'--custom-pathways-worker-args',
317+
type=str,
318+
default=None,
319+
help=(
320+
'Provide custom Pathways worker args as follows -'
321+
" --custom-pathways-worker-args='--arg_1=xxx --arg2=yyy'"
322+
),
323+
required=False,
324+
)
325+
259326
add_shared_workload_create_required_arguments([
260327
workload_create_parser_required_arguments,
261328
workload_create_pathways_parser_required_arguments,
@@ -542,51 +609,6 @@ def add_shared_workload_create_optional_arguments(args_parsers):
542609
' conditions.'
543610
),
544611
)
545-
custom_parser.add_argument(
546-
'--headless',
547-
action='store_true',
548-
help=(
549-
'Please provide this argument to create Pathways workloads in'
550-
' headless mode. This arg can only be used in `xpk workload'
551-
' create-pathways`(preferred) or `xpk workload create'
552-
' --use-pathways.` (--use-pathways will be deprecated soon).'
553-
),
554-
)
555-
custom_parser.add_argument(
556-
'--proxy-server-image',
557-
type=str,
558-
default=(
559-
'us-docker.pkg.dev/cloud-tpu-v2-images/pathways/proxy_server:latest'
560-
),
561-
help=(
562-
'Please provide the proxy server image for Pathways. This arg can'
563-
' only be used in `xpk workload create-pathways`(preferred) or `xpk'
564-
' workload create --use-pathways.` (--use-pathways will be'
565-
' deprecated soon).'
566-
),
567-
)
568-
custom_parser.add_argument(
569-
'--server-image',
570-
type=str,
571-
default='us-docker.pkg.dev/cloud-tpu-v2-images/pathways/server:latest',
572-
help=(
573-
'Please provide the server image for Pathways. This arg can only be'
574-
' used in `xpk workload create-pathways`(preferred) or `xpk'
575-
' workload create --use-pathways.` (--use-pathways will be'
576-
' deprecated soon).'
577-
),
578-
)
579-
custom_parser.add_argument(
580-
'--pathways-gcs-location',
581-
type=str,
582-
default='gs://cloud-pathways-staging/tmp',
583-
help=(
584-
'Please provide the GCS location to store Pathways artifacts. This'
585-
' arg can only be used in `xpk workload create-pathways`(preferred)'
586-
' or `xpk workload create --use-pathways.` (--use-pathways will be'
587-
' deprecated soon).'
588-
),
589-
)
590612
custom_parser.add_argument(
591613
'--ramdisk-directory',
592614
type=str,

0 commit comments

Comments
 (0)