feat(cli): show version update notice#602
Conversation
Signed-off-by: Eric W. Tramel <eric.tramel@gmail.com>
Signed-off-by: Eric W. Tramel <eric.tramel@gmail.com>
PR #602 Review —
|
Greptile SummaryThis PR adds a TTY-gated, PyPI-backed update notice to The implementation is well-structured and carefully hardened: atomic cache writes with
|
| Filename | Overview |
|---|---|
| packages/data-designer/src/data_designer/cli/version_notice.py | New module implementing PyPI version check with cache, env-var opt-out, prerelease handling, and upgrade command detection — all well-guarded against network/parse failures. |
| packages/data-designer/src/data_designer/cli/main.py | _version_callback extended to show update notice only on TTY; bare-except used intentionally to keep version output usable if notice lookup fails. |
| packages/data-designer/src/data_designer/cli/ui.py | Adds print_update_notice() rendering a Rich Panel with version and upgrade command; straightforward addition to the existing ui helpers. |
| packages/data-designer/tests/cli/test_version_notice.py | Comprehensive test suite covering newer/current/invalid versions, opt-out, cache hit/expiry/schema mismatch, prerelease handling, malformed payloads, and all upgrade command heuristics. |
| packages/data-designer/tests/cli/test_main.py | Existing version tests updated; four new integration tests added covering TTY/non-TTY paths, notice rendering, and lookup failure graceful degradation. |
| packages/data-designer/pyproject.toml | Adds packaging>=25,<27 as a direct runtime dependency for PEP 440 version comparison. |
Sequence Diagram
sequenceDiagram
participant User
participant CLI as data-designer --version
participant TTY as isatty() check
participant Cache as version-check.json
participant PyPI as PyPI JSON API
participant UI as Rich Panel
User->>CLI: data-designer --version
CLI->>CLI: importlib.metadata.version()
CLI->>User: echo installed_version (plain text)
CLI->>TTY: stdout.isatty()?
alt not TTY (pipe/script)
TTY-->>CLI: False
CLI->>User: Exit (no notice)
else TTY (interactive terminal)
TTY-->>CLI: True
CLI->>CLI: check DISABLE_VERSION_CHECK env
CLI->>Cache: read version-check.json
alt cache fresh (< 6h)
Cache-->>CLI: cached latest_version
else cache miss/expired
CLI->>PyPI: GET /pypi/data-designer/json (0.75s timeout)
PyPI-->>CLI: releases payload
CLI->>Cache: atomic write (pid.tmp → rename)
end
CLI->>CLI: latest > installed?
alt newer version available
CLI->>CLI: select_upgrade_command()
CLI->>UI: print_update_notice(latest, cmd)
UI->>User: Rich Panel (update CTA)
end
CLI->>User: Exit
end
Reviews (4): Last reviewed commit: "Merge branch 'main' into codex/issue-598..." | Re-trigger Greptile
Signed-off-by: Eric W. Tramel <eric.tramel@gmail.com>
Signed-off-by: Eric W. Tramel <eric.tramel@gmail.com>
📋 Summary
Adds a PyPI-backed update notice to
data-designer --versionwhile preserving the installed version as the first output line. The notice is intentionally opportunistic: scripted/non-TTY output, local development versions, network failures, malformed PyPI data, and cache failures all skip the CTA instead of disrupting version output.🔗 Related Issue
Fixes #598
🔄 Changes
DATA_DESIGNER_DISABLE_VERSION_CHECK, andDATA_DESIGNER_VERSION_CHECK_PRERELEASES.data-designer --versionremains script-friendly.uv tool upgrade data-designerby default,uv add --upgrade data-designerfor project environments, andpipx upgrade data-designerfor pipx installs.uv/toolsare not misclassified as uv-tool installs.packagingas a direct runtime dependency for PEP 440 version comparison.Usage Examples
Local development checkout output, captured from this branch:
Opted-out version check output, captured from this branch:
Interactive update-available rendering, captured from the CLI
--versionpath with the installed version set to0.5.10and latest version set to0.5.11for deterministic output:🧪 Testing
make testpasses (not run; interface package suite run instead)make check-interfacemake test-interface(675 passed)uv run --package data-designer data-designer --versionDATA_DESIGNER_DISABLE_VERSION_CHECK=1 uv run --package data-designer data-designer --version--versionupdate-available rendering run✅ Checklist