File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -379,12 +379,16 @@ def _get_torchx_stdin_args(
379
379
if not args .stdin :
380
380
return None
381
381
if self ._stdin_data_json is None :
382
- self ._stdin_data_json = self .torchx_json_from_stdin ()
382
+ self ._stdin_data_json = self .torchx_json_from_stdin (args )
383
383
return self ._stdin_data_json
384
384
385
- def torchx_json_from_stdin (self ) -> Dict [str , Any ]:
385
+ def torchx_json_from_stdin (
386
+ self , args : Optional [argparse .Namespace ] = None
387
+ ) -> Dict [str , Any ]:
386
388
try :
387
389
stdin_data_json = json .load (sys .stdin )
390
+ if args and args .dryrun :
391
+ stdin_data_json ["dryrun" ] = True
388
392
if not isinstance (stdin_data_json , dict ):
389
393
logger .error (
390
394
"Invalid JSON input for `torchx run` command. Expected a dictionary."
@@ -413,6 +417,8 @@ def verify_no_extra_args(self, args: argparse.Namespace) -> None:
413
417
continue
414
418
if action .dest == "help" : # Skip help
415
419
continue
420
+ if action .dest == "dryrun" : # Skip dryrun
421
+ continue
416
422
417
423
current_value = getattr (args , action .dest , None )
418
424
default_value = action .default
Original file line number Diff line number Diff line change @@ -393,12 +393,17 @@ def test_verify_no_extra_args_stdin_with_scheduler(self) -> None:
393
393
394
394
def test_verify_no_extra_args_stdin_with_boolean_flags (self ) -> None :
395
395
"""Test that boolean flags conflict with stdin."""
396
- boolean_flags = ["--dryrun" , "-- wait" , "--log" , "--tee_logs" ]
396
+ boolean_flags = ["--wait" , "--log" , "--tee_logs" ]
397
397
for flag in boolean_flags :
398
398
args = self .parser .parse_args (["--stdin" , flag ])
399
399
with self .assertRaises (SystemExit ):
400
400
self .cmd_run .verify_no_extra_args (args )
401
401
402
+ def test_verify_no_extra_args_stdin_dryrun_pass (self ) -> None :
403
+ """Test that dryrun is allowed."""
404
+ args = self .parser .parse_args (["--stdin" , "--dryrun" ])
405
+ self .cmd_run .verify_no_extra_args (args )
406
+
402
407
def test_verify_no_extra_args_stdin_with_value_args (self ) -> None :
403
408
"""Test that arguments with values conflict with stdin."""
404
409
args = self .parser .parse_args (["--stdin" , "--workspace" , "/custom/path" ])
You can’t perform that action at this time.
0 commit comments