diff --git a/nemo_run/cli/api.py b/nemo_run/cli/api.py index e05b921f..4d7ce553 100644 --- a/nemo_run/cli/api.py +++ b/nemo_run/cli/api.py @@ -1521,6 +1521,10 @@ def _add_executor_command( class CLITaskCommand(EntrypointCommand): _entrypoint = self + cmd_defaults = dict(cmd_defaults) if cmd_defaults else {} + if self.skip_confirmation: + cmd_defaults.setdefault("skip_confirmation", True) + return self.run_ctx_cls.cli_command( parent, self.name, diff --git a/test/cli/test_api.py b/test/cli/test_api.py index da359c12..7dc2b3c5 100644 --- a/test/cli/test_api.py +++ b/test/cli/test_api.py @@ -736,6 +736,32 @@ def test_parse_partial_function_call(self): assert partial.dummy.hidden == 100 assert partial.dummy.activation == "tanh" + @patch("typer.confirm", return_value=False) + @patch("nemo_run.dryrun_fn") + @patch("nemo_run.run") + def test_skip_confirmation_entrypoint_does_not_prompt( + self, mock_run, mock_dryrun_fn, mock_confirm, runner + ): + """@run.cli.entrypoint(skip_confirmation=True) must skip the confirmation prompt.""" + + @run.cli.entrypoint(namespace="test_skip_confirm", skip_confirmation=True) + def task(value: int = 1): + return value + + @run.cli.entrypoint(namespace="test_skip_confirm") + def other_task(value: int = 1): + return value + + app = typer.Typer() + other_task.cli_entrypoint.cli(app) + task.cli_entrypoint.cli(app) + + result = runner.invoke(app, ["task", "value=2"], env={"INCLUDE_WORKSPACE_FILE": "false"}) + + assert result.exit_code == 0, result.output + mock_confirm.assert_not_called() + mock_run.assert_called_once() + def test_with_factory(self, runner, app): # Test CLI execution with default factory result = runner.invoke(