-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat: 添加部分环境变量以支持方便快捷获取data目录以及插件数据目录。 #1485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
类图:配置模块更新classDiagram
class `kirara_ai.config` {
<<Module>>
+DATA_PATH: string
+PLUGIN_PATH: string
}
class `kirara_ai.config.config_loader` {
<<Module>>
~CONFIG_FILE: string
}
`kirara_ai.config.config_loader` ..> `kirara_ai.config` : uses DATA_PATH
文件级别变更
提示和命令与 Sourcery 互动
自定义您的体验访问您的 仪表板 以:
获取帮助Original review guide in EnglishReviewer's GuideIntroduce environment variables (DATA_PATH and PLUGIN_PATH) for flexible data and plugin directory resolution and refactor the configuration loader to use DATA_PATH instead of a hardcoded path for config files. Sequence Diagram for Configuration File Path ResolutionsequenceDiagram
participant CL as ConfigLoader
participant OS as OperatingSystem
participant FS as FileSystem
activate CL
CL->>OS: Get DATA_PATH environment variable
activate OS
OS-->>CL: DATA_PATH value (e.g., "$PWD/data")
deactivate OS
CL->>OS: Construct path: os.path.join(DATA_PATH, "config.yaml")
activate OS
OS-->>CL: CONFIG_FILE path (e.g., "$PWD/data/config.yaml")
deactivate OS
CL->>FS: Read CONFIG_FILE from constructed path
activate FS
FS-->>CL: Configuration data
deactivate FS
deactivate CL
Class Diagram: Configuration Module UpdatesclassDiagram
class `kirara_ai.config` {
<<Module>>
+DATA_PATH: string
+PLUGIN_PATH: string
}
class `kirara_ai.config.config_loader` {
<<Module>>
~CONFIG_FILE: string
}
`kirara_ai.config.config_loader` ..> `kirara_ai.config` : uses DATA_PATH
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
MyPy 类型检查通过 ✅PR 修改的代码行通过了类型检查。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嘿 @teywat - 我已经审查了你的更改 - 这里有一些反馈:
- config_loader.py 使用了 os.path.join,但从未导入 os - 添加缺失的导入以避免运行时错误。
- 考虑在启动时验证或自动创建 DATA_PATH 和 PLUGIN_PATH,以防止“找不到目录”问题。
- 规范化 DATA_PATH 和 PLUGIN_PATH(例如,通过 os.path.expanduser 和 abspath)以正确处理相对路径或 ~ 扩展。
以下是我在审查期间查看的内容
- 🟢 一般问题:一切看起来都很好
- 🟢 安全性:一切看起来都很好
- 🟢 测试:一切看起来都很好
- 🟢 复杂性:一切看起来都很好
- 🟢 文档:一切看起来都很好
帮助我更有用!请点击每个评论上的 👍 或 👎,我将使用反馈来改进你的评论。
Original comment in English
Hey @teywat - I've reviewed your changes - here's some feedback:
- config_loader.py uses os.path.join but never imports os—add the missing import to avoid runtime errors.
- Consider validating or auto-creating DATA_PATH and PLUGIN_PATH at startup to prevent “directory not found” issues.
- Normalize DATA_PATH and PLUGIN_PATH (e.g. via os.path.expanduser and abspath) to handle relative paths or ~ expansions correctly.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
需要添加创建目录的功能吗? |
refactor: 重写了DATA_PATH部分。考虑到用户编写的DATA_PATH 可能使用相对路径,增加了绝对路径转换,避免未知bug
好的,这是翻译成中文的 pull request 总结:
Sourcery 总结
引入环境变量以实现灵活的数据和插件目录解析,并更新配置加载器以使用新的 DATA_PATH。
新特性:
增强功能:
Original summary in English
好的,这是翻译成中文的 pull request 总结:
Sourcery 总结
引入 DATA_PATH 和 PLUGIN_PATH 环境变量,以便灵活地定位数据和插件目录,并更新配置加载器以使用 DATA_PATH 加载 config.yaml。
新特性:
增强功能:
Original summary in English
Summary by Sourcery
Introduce DATA_PATH and PLUGIN_PATH environment variables to flexibly locate the data and plugin directories, and update the config loader to use DATA_PATH for loading config.yaml.
New Features:
Enhancements: