Skip to content

Commit f18b3b1

Browse files
ishachirimarfacebook-github-bot
authored andcommitted
Allow dryrun from cli in JSON launching case (#1135)
Summary: Dryrun is a frequent flag so allow that from CLI Reviewed By: nghuiqin Differential Revision: D83681938
1 parent 3b5df3a commit f18b3b1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

torchx/cli/cmd_run.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,12 +379,16 @@ def _get_torchx_stdin_args(
379379
if not args.stdin:
380380
return None
381381
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)
383383
return self._stdin_data_json
384384

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]:
386388
try:
387389
stdin_data_json = json.load(sys.stdin)
390+
if args and args.dryrun:
391+
stdin_data_json["dryrun"] = True
388392
if not isinstance(stdin_data_json, dict):
389393
logger.error(
390394
"Invalid JSON input for `torchx run` command. Expected a dictionary."
@@ -413,6 +417,8 @@ def verify_no_extra_args(self, args: argparse.Namespace) -> None:
413417
continue
414418
if action.dest == "help": # Skip help
415419
continue
420+
if action.dest == "dryrun": # Skip dryrun
421+
continue
416422

417423
current_value = getattr(args, action.dest, None)
418424
default_value = action.default

0 commit comments

Comments
 (0)