feat: 支持源码模式运行脚本链#64
Conversation
|
Warning Review limit reached
More reviews will be available in 1 minute and 6 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
Walkthrough新增 变更详情源码模式 runner 命令实现
估算的代码审查工作量🎯 3 (Moderate) | ⏱️ ~20 分钟 小诗
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/script_chainer/utils/runner_utils.py (1)
41-41: 💤 Low value建议添加路径深度检查以增强健壮性。
当前实现假设文件始终位于仓库根目录下三级深度,如果文件位置发生变化或在异常环境下运行,
.parents[3]可能引发IndexError。🛡️ 建议的防御性检查
- repo_root = str(Path(__file__).resolve().parents[3]) + file_path = Path(__file__).resolve() + if len(file_path.parents) < 4: + raise RuntimeError(f"无法确定仓库根目录:文件路径 {file_path} 层级不足") + repo_root = str(file_path.parents[3])🤖 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/script_chainer/utils/runner_utils.py` at line 41, The current implementation directly accesses `.parents[3]` on the resolved path without validating that enough parent directories exist, which can raise an IndexError if the file is not at the expected depth or runs in certain environments. Add a defensive check before accessing `.parents[3]` to verify that the parents tuple has at least 4 elements (indices 0-3 are valid), and either handle the insufficient depth case gracefully (such as using a fallback value or raising a more informative error) or validate the file location at runtime to ensure it meets the expected directory structure requirements.
🤖 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/script_chainer/utils/runner_utils.py`:
- Around line 28-42: The module execution using python -m requires a complete
package hierarchy, but the src/__init__.py file is missing, which prevents src
from being recognized as a valid Python package. Create an empty __init__.py
file in the src/ directory to establish the proper package structure required
for the -m flag to work correctly with the command being constructed in the else
block that references sys.executable and the src.script_chainer.win_exe.launcher
module path.
---
Nitpick comments:
In `@src/script_chainer/utils/runner_utils.py`:
- Line 41: The current implementation directly accesses `.parents[3]` on the
resolved path without validating that enough parent directories exist, which can
raise an IndexError if the file is not at the expected depth or runs in certain
environments. Add a defensive check before accessing `.parents[3]` to verify
that the parents tuple has at least 4 elements (indices 0-3 are valid), and
either handle the insufficient depth case gracefully (such as using a fallback
value or raising a more informative error) or validate the file location at
runtime to ensure it meets the expected directory structure requirements.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5c7896ae-b989-452f-9d2f-d9320c77a9c3
📒 Files selected for processing (1)
src/script_chainer/utils/runner_utils.py
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/script_chainer/utils/runner_utils.py`:
- Around line 10-11: The call to get_path_under_work_dir on line 11 incorrectly
passes repo_root (an absolute path) as the first argument, but according to the
pattern of all other call sites in the repository, this function expects only
relative path segments. The function internally calls get_work_dir() for path
construction, so remove the repo_root parameter and pass only the relative path
components ("src", "script_chainer", "win_exe", "launcher.py") to
get_path_under_work_dir. This will fix the launcher path construction failure in
source code mode that causes build_runner_command to fail.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 505449ea-a990-43b8-b87c-256b079fbc8b
📒 Files selected for processing (1)
src/script_chainer/utils/runner_utils.py
|
@ShadowLemoon Could you help check this pr? |
|
@coderabbitai resume |
✅ Action performedReviews resumed. |
变更
build_runner_command新增源码模式支持:非 frozen 环境下, 获得项目的根路径后运行
python ${abspath}/OneDragon-ScriptChainer/src/script_chainer/win_exe/launcher.py --onedragon --chain ...价值
测试
进过测试,以下两种方式均成功在launcher中运行单个及全体脚本
uv run python src\script_chainer\win_exe\launcher.pyuv run python script_chainer\win_exe\launcher.pySummary by CodeRabbit
Summary by CodeRabbit