Skip to content

Commit 445a6d5

Browse files
committed
Support custom Pathways args.
1 parent 3e4b0d2 commit 445a6d5

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

src/xpk/core/pathways.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ def get_pathways_worker_args(args) -> str:
4444
- --resource_manager_address={rm_address}
4545
- --gcs_scratch_location={args.pathways_gcs_location}"""
4646
if args.use_pathways:
47+
if args.custom_pathways_worker_args:
48+
yaml = append_custom_pathways_args(yaml, args.custom_pathways_worker_args)
4749
return yaml.format(args=args, rm_address=get_rm_address(args))
4850
else:
4951
return ''
@@ -62,6 +64,10 @@ def get_pathways_proxy_args(args) -> str:
6264
- --gcs_scratch_location={args.pathways_gcs_location}"""
6365

6466
if args.use_pathways:
67+
if args.custom_pathways_proxy_server_args:
68+
yaml = append_custom_pathways_args(
69+
yaml, args.custom_pathways_proxy_server_args
70+
)
6571
return yaml.format(args=args, rm_address=get_rm_address(args))
6672
else:
6773
return ''
@@ -200,6 +206,8 @@ def get_pathways_rm_args(args, system: SystemCharacteristics) -> str:
200206
- --instance_count={instance_count}
201207
- --instance_type={instance_type}"""
202208
if args.use_pathways:
209+
if args.custom_pathways_server_args:
210+
yaml = append_custom_pathways_args(yaml, args.custom_pathways_server_args)
203211
return yaml.format(
204212
args=args,
205213
instance_count=args.num_slices,
@@ -209,6 +217,28 @@ def get_pathways_rm_args(args, system: SystemCharacteristics) -> str:
209217
return ''
210218

211219

220+
def append_custom_pathways_args(yaml, custom_args) -> str:
221+
"""Append custom Pathways args to the YAML with proper indentation.
222+
223+
Args:
224+
yaml (string): existing yaml containing args
225+
226+
Returns:
227+
yaml (string): yaml with additional args appended.
228+
"""
229+
second_line = yaml.split('\n')[1]
230+
if (
231+
not second_line
232+
): # to cover edge case if only one arg remains, we would have to look at the entire YAML in this case.
233+
return yaml
234+
# Calculate the indentation based on the second line of existing YAML.
235+
indentation = ' ' * (len(second_line) - len(second_line.lstrip()))
236+
custom_args = custom_args.split(' ')
237+
for arg in custom_args:
238+
yaml += '\n' + indentation + '- ' + arg
239+
return yaml
240+
241+
212242
def get_user_workload_for_pathways(args, system: SystemCharacteristics) -> str:
213243
"""
214244
Create a user workload container for Pathways.

src/xpk/parser/workload.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,39 @@ def set_workload_parsers(workload_parser):
244244
required=False,
245245
)
246246

247+
workload_create_pathways_parser_optional_arguments.add_argument(
248+
'--custom-pathways-server-args',
249+
type=str,
250+
default=None,
251+
help=(
252+
'Provide custom Pathways server args as follows -'
253+
" --custom-pathways-server-args='--arg_1=xxx --arg2=yyy'"
254+
),
255+
required=False,
256+
)
257+
258+
workload_create_pathways_parser_optional_arguments.add_argument(
259+
'--custom-pathways-proxy-server-args',
260+
type=str,
261+
default=None,
262+
help=(
263+
'Provide custom Pathways proxy server args as follows -'
264+
" --custom-pathways-proxy-server-args='--arg_1=xxx --arg2=yyy'"
265+
),
266+
required=False,
267+
)
268+
269+
workload_create_pathways_parser_optional_arguments.add_argument(
270+
'--custom-pathways-worker-args',
271+
type=str,
272+
default=None,
273+
help=(
274+
'Provide custom Pathways worker args as follows -'
275+
" --custom-pathways-worker-args='--arg_1=xxx --arg2=yyy'"
276+
),
277+
required=False,
278+
)
279+
247280
add_shared_workload_create_required_arguments([
248281
workload_create_parser_required_arguments,
249282
workload_create_pathways_parser_required_arguments,

0 commit comments

Comments
 (0)