Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions nemo_run/cli/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
26 changes: 26 additions & 0 deletions test/cli/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down