feat(cli): add data-designer --version#599
Conversation
Signed-off-by: Eric W. Tramel <eric.tramel@gmail.com>
Greptile SummaryAdds a
|
| Filename | Overview |
|---|---|
| packages/data-designer/src/data_designer/cli/main.py | Adds --version eager Typer option with callback, _is_version_request pre-parse guard to skip bootstrap, and the app_callback registration — logic is correct and idiomatic. |
| packages/data-designer/tests/cli/test_main.py | Adds four new test cases covering bootstrap skip, multi-flag detection, successful version output, and missing-package error path; existing test updated to pin sys.argv. |
Sequence Diagram
sequenceDiagram
participant U as User
participant M as main()
participant IVR as _is_version_request()
participant BS as ensure_cli_default_model_settings()
participant A as app() [Typer]
participant VC as _version_callback()
participant IM as importlib.metadata
U->>M: data-designer --version
M->>IVR: sys.argv[1:] = ["--version"]
IVR-->>M: True → skip bootstrap
M->>A: app()
A->>VC: eager callback(value=True)
VC->>IM: version("data-designer")
alt version found
IM-->>VC: "0.6.0"
VC->>U: typer.echo("0.6.0")
VC-->>A: raise typer.Exit(0)
else PackageNotFoundError
IM-->>VC: PackageNotFoundError
VC->>U: typer.echo(error, err=True)
VC-->>A: raise typer.Exit(1)
end
Note over M,BS: Normal command path
U->>M: data-designer create config.yaml
M->>IVR: sys.argv[1:] = ["create", "config.yaml"]
IVR-->>M: False → run bootstrap
M->>BS: ensure_cli_default_model_settings()
BS-->>M: done
M->>A: app()
A->>U: execute create command
Reviews (2): Last reviewed commit: "fix(cli): broaden version bootstrap guar..." | Re-trigger Greptile
Greptile SummaryThis PR adds a
|
| Filename | Overview |
|---|---|
| packages/data-designer/src/data_designer/cli/main.py | Adds --version eager Typer option, a _version_callback for metadata lookup, and a _is_version_request helper that skips bootstrap in main(). The helper only checks args[0], so --version appearing after other flags still triggers bootstrap. |
| packages/data-designer/tests/cli/test_main.py | Adds three new tests covering bootstrap-skip behaviour, successful version output, and the missing-package error path. All assertions are correct given the default CliRunner mixes stderr into result.output. |
Sequence Diagram
sequenceDiagram
participant User
participant main as main()
participant isvr as _is_version_request
participant bootstrap as ensure_cli_default_model_settings
participant app as Typer app
participant vc as _version_callback
participant meta as importlib.metadata
User->>main: "data-designer --version"
main->>isvr: "sys.argv[1:] = ['--version']"
isvr-->>main: True (skip bootstrap)
main->>app: app()
app->>vc: "is_eager=True, value=True"
vc->>meta: "version('data-designer')"
meta-->>vc: "0.6.0"
vc-->>User: echo version string
vc->>app: raise typer.Exit(0)
User->>main: "data-designer create config.yaml"
main->>isvr: "sys.argv[1:] = ['create', ...]"
isvr-->>main: False
main->>bootstrap: ensure_cli_default_model_settings()
main->>app: app()
app-->>User: run subcommand
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
packages/data-designer/src/data_designer/cli/main.py:31
**`_is_version_request` only matches `--version` at position 0**
If a user ever passes `--version` after another flag (e.g., `data-designer --config foo.yaml --version`), `args[0]` is not `"--version"`, so `_is_version_request` returns `False` and `ensure_cli_default_model_settings()` runs before Typer's eager callback exits. The version is still printed correctly (Typer's eager handling fires regardless), but the bootstrap runs unnecessarily. Using `"--version" in args` would make the guard consistent with Typer's own behaviour.
```suggestion
return "--version" in args
```
Reviews (1): Last reviewed commit: "feat(cli): add version flag" | Re-trigger Greptile
|
Thanks for putting this together, @eric-tramel — small, focused PR and a nice match to the intent in #597. SummaryAdds a top-level FindingsWarnings — Worth addressing
def _is_version_request(args: list[str]) -> bool:
return "--version" in argsSuggestions — Take it or leave it
What Looks Good
VerdictShip it (with nits) — the This review was generated by an AI assistant. |
Signed-off-by: Eric W. Tramel <eric.tramel@gmail.com>
|
Addressed the review feedback in
Re-ran:
|
📋 Summary
Adds a top-level
data-designer --versionflag so users and support workflows can quickly read the installeddata-designerpackage version. The version path usesimportlib.metadata.version("data-designer")and avoids default CLI model setup before exiting.🔗 Related Issue
Fixes #597
🔄 Changes
--versionoption that prints only the resolved package version.ensure_cli_default_model_settings()for top-level version requests in the console entrypoint.🧪 Testing
make testpasses (not run; focused CLI checks below)uv run --package data-designer pytest packages/data-designer/tests/cli/test_main.pyuv run --package data-designer data-designer --versionuv run ruff check packages/data-designer/src/data_designer/cli/main.py packages/data-designer/tests/cli/test_main.py✅ Checklist