Skip to content

Commit f4623fc

Browse files
RoshaniNSujeethJinesh
authored andcommitted
Support custom Pathways args. (#364)
1 parent 7684ff1 commit f4623fc

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
@@ -46,6 +46,8 @@ def get_pathways_worker_args(args) -> str:
4646
- --resource_manager_address={rm_address}
4747
- --gcs_scratch_location={args.pathways_gcs_location}"""
4848
if args.use_pathways:
49+
if args.custom_pathways_worker_args:
50+
yaml = append_custom_pathways_args(yaml, args.custom_pathways_worker_args)
4951
return yaml.format(args=args, rm_address=get_rm_address(args))
5052
else:
5153
return ''
@@ -64,6 +66,10 @@ def get_pathways_proxy_args(args) -> str:
6466
- --gcs_scratch_location={args.pathways_gcs_location}"""
6567

6668
if args.use_pathways:
69+
if args.custom_pathways_proxy_server_args:
70+
yaml = append_custom_pathways_args(
71+
yaml, args.custom_pathways_proxy_server_args
72+
)
6773
return yaml.format(args=args, rm_address=get_rm_address(args))
6874
else:
6975
return ''
@@ -233,6 +239,8 @@ def get_pathways_rm_args(args, system: SystemCharacteristics) -> str:
233239
- --instance_count={instance_count}
234240
- --instance_type={instance_type}"""
235241
if args.use_pathways:
242+
if args.custom_pathways_server_args:
243+
yaml = append_custom_pathways_args(yaml, args.custom_pathways_server_args)
236244
return yaml.format(
237245
args=args,
238246
instance_count=args.num_slices,
@@ -242,6 +250,28 @@ def get_pathways_rm_args(args, system: SystemCharacteristics) -> str:
242250
return ''
243251

244252

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

src/xpk/parser/workload.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,39 @@ def set_workload_parsers(workload_parser):
256256
help='Names of storages the workload uses',
257257
)
258258

259+
workload_create_pathways_parser_optional_arguments.add_argument(
260+
'--custom-pathways-server-args',
261+
type=str,
262+
default=None,
263+
help=(
264+
'Provide custom Pathways server args as follows -'
265+
" --custom-pathways-server-args='--arg_1=xxx --arg2=yyy'"
266+
),
267+
required=False,
268+
)
269+
270+
workload_create_pathways_parser_optional_arguments.add_argument(
271+
'--custom-pathways-proxy-server-args',
272+
type=str,
273+
default=None,
274+
help=(
275+
'Provide custom Pathways proxy server args as follows -'
276+
" --custom-pathways-proxy-server-args='--arg_1=xxx --arg2=yyy'"
277+
),
278+
required=False,
279+
)
280+
281+
workload_create_pathways_parser_optional_arguments.add_argument(
282+
'--custom-pathways-worker-args',
283+
type=str,
284+
default=None,
285+
help=(
286+
'Provide custom Pathways worker args as follows -'
287+
" --custom-pathways-worker-args='--arg_1=xxx --arg2=yyy'"
288+
),
289+
required=False,
290+
)
291+
259292
add_shared_workload_create_required_arguments([
260293
workload_create_parser_required_arguments,
261294
workload_create_pathways_parser_required_arguments,

0 commit comments

Comments
 (0)