Refactor packaging pipeline#43
Conversation
…ersion package loading.
📝 WalkthroughWalkthroughAdds metadata-based package version reporting and a manually triggered GitHub Actions workflow that bumps versions, pushes a release branch, and opens a pull request targeting ChangesVersion and release automation
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant GitHubActions
participant uv
participant Repository
participant gh
GitHubActions->>uv: Bump selected version component
uv->>Repository: Update package version files
GitHubActions->>Repository: Commit and force-push release/vVERSION
GitHubActions->>gh: Create release pull request targeting main
gh->>Repository: Open pull request
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
.github/workflows/bump.yaml (1)
43-47: 📐 Maintainability & Code Quality | 🔵 TrivialConsider using a Personal Access Token (PAT) for PR creation.
Pull requests created using the default
GITHUB_TOKENwill not automatically trigger subsequent GitHub Actions workflows (such as CI test runs). If you rely on automated CI testing on release PRs, consider generating a PAT with the necessary permissions, storing it as a repository secret, and using it in place ofsecrets.GITHUB_TOKEN.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/bump.yaml around lines 43 - 47, Update the PR creation step using gh pr create to authenticate with a repository secret containing a PAT instead of secrets.GITHUB_TOKEN. Ensure the PAT has the required repository permissions and preserves the existing release PR creation behavior, including the main base, BRANCH head, title, and body.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/dstrack/__init__.py`:
- Around line 1-5: Update the module-level version initialization around
__version__ and importlib.metadata.version to catch PackageNotFoundError when
the dstrack distribution is unavailable, and assign a safe fallback version
instead of failing import. Keep the installed-package version path unchanged.
---
Nitpick comments:
In @.github/workflows/bump.yaml:
- Around line 43-47: Update the PR creation step using gh pr create to
authenticate with a repository secret containing a PAT instead of
secrets.GITHUB_TOKEN. Ensure the PAT has the required repository permissions and
preserves the existing release PR creation behavior, including the main base,
BRANCH head, title, and body.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 0a7e3a4f-5fbe-46f5-8829-921e54d186f9
📒 Files selected for processing (2)
.github/workflows/bump.yamlsrc/dstrack/__init__.py
| from importlib.metadata import version | ||
|
|
||
| from . import _logging as _logging | ||
|
|
||
| __version__ = "0.1.0" | ||
| __version__ = version("dstrack") |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Add a fallback for uninstalled environments.
If this module is imported without the package being installed (e.g., during local development without an editable install or in certain test environments), version("dstrack") will raise a PackageNotFoundError and crash the application. Catch this exception to provide a safe fallback.
🛡️ Proposed fix
-from importlib.metadata import version
+from importlib.metadata import PackageNotFoundError, version
from . import _logging as _logging
-__version__ = version("dstrack")
+try:
+ __version__ = version("dstrack")
+except PackageNotFoundError:
+ __version__ = "unknown"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| from importlib.metadata import version | |
| from . import _logging as _logging | |
| __version__ = "0.1.0" | |
| __version__ = version("dstrack") | |
| from importlib.metadata import PackageNotFoundError, version | |
| from . import _logging as _logging | |
| try: | |
| __version__ = version("dstrack") | |
| except PackageNotFoundError: | |
| __version__ = "unknown" |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/dstrack/__init__.py` around lines 1 - 5, Update the module-level version
initialization around __version__ and importlib.metadata.version to catch
PackageNotFoundError when the dstrack distribution is unavailable, and assign a
safe fallback version instead of failing import. Keep the installed-package
version path unchanged.
…n version cannot be infered from package import failure
Summary
Creates new GitHub action to bump package version, and adds dynamic version loading.
Changes
Test plan
uv run pytestpassesSummary by CodeRabbit
New Features
Bug Fixes