fix(config): enhance config path handling and add project root validation#262
fix(config): enhance config path handling and add project root validation#262imbajin merged 36 commits intoapache:mainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces project-root detection and enforces correct working directory for loading configuration files, updates associated paths, and enhances deployment documentation along with Dockerfile adjustments.
- Added
get_project_root()utility to identify the repo root - Enforced working-directory validation in
BasePromptConfig.ensure_yaml_file_exists() - Updated README and Dockerfiles for Docker-based deployment and build changes
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| utils/anchor.py | Added get_project_root() for locating project root directories |
| config/models/base_prompt_config.py | Implemented CWD check and exit on invalid directory |
| README.md | Added Docker deployment instructions |
| docker/Dockerfile.nk | Included jieba package in Nuitka build |
| docker/Dockerfile.llm | Swapped Poetry for uv-based venv setup and adjusted WORKDIR paths |
Comments suppressed due to low confidence (1)
hugegraph-llm/src/hugegraph_llm/config/models/base_prompt_config.py:53
- The variable
yaml_file_pathis not defined withinensure_yaml_file_exists(). Introduce a definition (e.g., usingget_project_root()along withF_NAME) before checking its existence.
if os.path.exists(yaml_file_path):
imbajin
left a comment
There was a problem hiding this comment.
Merge it first, should test the docker image soon
|
I followed the instructions from https://hugegraph.apache.org/cn/docs/quickstart/hugegraph-ai/ and ran the following command: cd ./hugegraph-llm/src
python3 -m hugegraph_llm.demo.rag_demo.appHowever, an error was reported stating that the program should not be run from the (hugegraph) try-agaaain@XiaoXin16Pro21:/workspace/LLM-Agent/incubator-hugegraph-ai/hugegraph-llm/src$ python -m hugegraph_llm.demo.rag_demo.app
[06/08/25 08:41:17] ERROR llm: Current working directory is not the project root. base_prompt_config.py:54
Please run this script from the project root directory:
/workspace/LLM-Agent/incubator-hugegraph-ai/hugegraph-llm
Current directory:
/workspace/LLM-Agent/incubator-hugegraph-ai/hugegraph-llm
/src How should I run the program correctly? |
@try-agaaain Apologize, the website is outdated & we'll update/sync it soon Please refer here to get the latest instruction & could also try docker images for it https://github.com/apache/incubator-hugegraph-ai/blob/main/hugegraph-llm/README.md |
Thanks a lot. |
Add Path Checking Logic for Configuration Files
Description
This PR introduces path validation logic to ensure the application is running from the correct project root directory. It adds a new utility function to determine the project root and implements checks to prevent configuration loading from incorrect working directories.
Changes
get_project_root()inhugegraph_llm/utils/anchor.pyto reliably determine the project root directorybase_prompt_config.pyto use the correct path structureBasePromptConfig.ensure_yaml_file_exists()Technical Details
src/hugegraph_llm/resources/demoTesting
Impact
This change improves the reliability of the application by ensuring configuration files are loaded from the correct location and provides better error handling for incorrect usage.