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 an opportunistic PyPI-backed update notice to
|
| Filename | Overview |
|---|---|
| packages/data-designer/src/data_designer/cli/version_notice.py | New module implementing PyPI version lookup, schema-versioned atomic cache, PEP 440 comparison, and upgrade-command heuristic — all with fail-closed semantics. Logic and edge cases are correct. |
| packages/data-designer/src/data_designer/cli/main.py | Version callback split into TTY-gated two-phase flow; lazy imports keep startup fast; generic Exception catch around the notice fetch is intentional and correct for opportunistic behavior. |
| packages/data-designer/src/data_designer/cli/ui.py | Adds print_update_notice using Rich Text.assemble and Panel.fit with existing Nord theme colors — consistent with surrounding UI helpers. |
| packages/data-designer/tests/cli/test_version_notice.py | Comprehensive new test file covering 20+ scenarios including cache hit/expiry/schema mismatch, malformed payloads, prerelease opt-in, all upgrade-command branches, and opt-out paths. |
| packages/data-designer/tests/cli/test_main.py | Existing version test updated and four new integration-level tests added for the notice flow; patches target the correct module namespaces. |
| packages/data-designer/pyproject.toml | Adds packaging>=25,<27 as a direct runtime dependency; lock file updated successfully, confirming the constraint resolves. |
Sequence Diagram
sequenceDiagram
participant User
participant CLI as data-designer CLI
participant PyPI as PyPI JSON API
participant Cache as version-check.json
User->>CLI: data-designer --version
CLI->>CLI: importlib.metadata.version()
CLI->>User: print installed version (always)
CLI->>CLI: should_show_update_notice() → isatty()?
alt non-TTY stdout
CLI->>CLI: raise typer.Exit()
else TTY stdout
CLI->>Cache: read cached version
alt cache hit (fresh, schema match)
Cache-->>CLI: latest_version
else cache miss / expired
CLI->>PyPI: GET /pypi/data-designer/json (0.75s timeout)
alt network / parse error
PyPI-->>CLI: exception → None
else success
PyPI-->>CLI: releases payload
CLI->>CLI: filter yanked, parse versions
CLI->>Cache: atomic write (pid.tmp → rename)
end
end
CLI->>CLI: latest > installed?
alt update available
CLI->>CLI: select_upgrade_command()
CLI->>User: Rich panel with latest version + upgrade command
end
CLI->>CLI: raise typer.Exit()
end
Reviews (7): 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>
|
Thanks for putting this together, @eric-tramel — really nice attention to fail-closed behavior and cache hygiene throughout. SummaryAdds an opportunistic FindingsWarnings — Worth addressing
Suggestions — Take it or leave it
What Looks Good
VerdictNeeds changes — the private-API test coupling and the test gap around the suffix heuristic are worth addressing before merge; the |
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(682 passed)uv run --package data-designer pytest packages/data-designer/tests/cli/test_main.py packages/data-designer/tests/cli/test_version_notice.py(30 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