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
2 changes: 1 addition & 1 deletion docs/guides/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ Train a model using the specified configuration.
│ --dryrun Print the scheduler request without submitting
│ --factory -f TEXT Predefined factory to use [default: None]
│ --load -l TEXT Load a factory from a directory [default: None]
│ --yaml -y TEXT Path to a YAML file to load [default: None]
│ --yaml TEXT Path to a YAML file to load [default: None]
│ --repl -r Enter interactive mode
│ --detach Detach from the run
│ --yes,--no-confirm -y Skip confirmation before execution
Expand Down
4 changes: 1 addition & 3 deletions nemo_run/cli/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,9 +890,7 @@ def command(
load: Optional[str] = typer.Option(
None, "--load", "-l", help="Load a factory from a directory"
),
yaml: Optional[str] = typer.Option(
None, "--yaml", "-y", help="Path to a YAML file to load"
),
yaml: Optional[str] = typer.Option(None, "--yaml", help="Path to a YAML file to load"),
repl: bool = typer.Option(False, "--repl", "-r", help="Enter interactive mode"),
detach: bool = typer.Option(False, "--detach", help="Detach from the run"),
skip_confirmation: bool = typer.Option(
Expand Down
20 changes: 20 additions & 0 deletions test/cli/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1918,3 +1918,23 @@ class TestExtractConstituentTypes:
def test_various_type_hints(self, type_hint, expected_types):
"""Test get_underlying_types with various type hints."""
assert extract_constituent_types(type_hint) == expected_types


class TestShortFlagCollision:
"""Regression test for issue #559: -y was bound to both --yaml and --yes."""

def test_short_flag_y_belongs_only_to_yes(self):
@run.cli.entrypoint
def dummy_task(yaml: Optional[str] = typer.Option(None, "--yaml", help="YAML file")):
return yaml

app = typer.Typer()
RunContext.cli_command(app, "task", dummy_task)
params = typer.main.get_command(app).params

opts = {param.name: param.opts for param in params}
assert opts["yaml"] == ["--yaml"]
assert "-y" in opts["skip_confirmation"]

shorts = [opt for param in params for opt in param.opts if len(opt) == 2]
assert len(shorts) == len(set(shorts)), f"duplicate short flags: {shorts}"