This is an automated email from the ASF dual-hosted git repository. jin pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph-ai.git
The following commit(s) were added to refs/heads/main by this push: new 8601058 fix(log): reduce 3rd-party library log output (#284) 8601058 is described below commit 860105829e7280c6484c1f0b2bef4e65cf6c8c5f Author: Zequan <63642221+zequan...@users.noreply.github.com> AuthorDate: Mon Jul 21 12:40:05 2025 +0200 fix(log): reduce 3rd-party library log output (#284) This PR fixes #244 by reducing excessive third-party library log output. --------- Co-authored-by: imbajin <j...@apache.org> --- .gitignore | 2 ++ README.md | 2 ++ hugegraph-llm/README.md | 2 ++ hugegraph-llm/src/hugegraph_llm/utils/log.py | 41 ++++++++++++++++++++++++---- pyproject.toml | 5 ++-- 5 files changed, 45 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 138ef2d..ec1743a 100644 --- a/.gitignore +++ b/.gitignore @@ -119,6 +119,8 @@ ipython_config.py # uv.lock contains resolved dependencies and is generally recommended to include in version control # for reproducible builds, but can be excluded if you prefer to resolve dependencies fresh uv.lock +# Local UV configuration file (for mirror settings) +uv.toml # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm __pypackages__/ diff --git a/README.md b/README.md index 9773bf9..1e8294f 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,8 @@ cd incubator-hugegraph-ai # 3. Install dependencies with workspace management # uv sync automatically creates venv (.venv) and installs base dependencies +# NOTE: If download is slow, uncomment mirror lines in pyproject.toml or use: uv config --global index.url https://pypi.tuna.tsinghua.edu.cn/simple +# Or create local uv.toml with mirror settings to avoid git diff (see uv.toml example in root) uv sync --extra llm # Install LLM-specific dependencies # Or install all optional dependencies: uv sync --all-extras diff --git a/hugegraph-llm/README.md b/hugegraph-llm/README.md index 24ffdc5..e988b5c 100644 --- a/hugegraph-llm/README.md +++ b/hugegraph-llm/README.md @@ -86,6 +86,8 @@ git clone https://github.com/apache/incubator-hugegraph-ai.git cd incubator-hugegraph-ai/hugegraph-llm # 4. Install dependencies and activate environment +# NOTE: If download is slow, uncomment mirror lines in ../pyproject.toml or use: uv config --global index.url https://pypi.tuna.tsinghua.edu.cn/simple +# Or create local uv.toml with mirror settings to avoid git diff (see uv.toml example in root) uv sync # Automatically creates .venv and installs dependencies source .venv/bin/activate # Activate once - all commands below assume this environment diff --git a/hugegraph-llm/src/hugegraph_llm/utils/log.py b/hugegraph-llm/src/hugegraph_llm/utils/log.py index f1116f7..7076869 100755 --- a/hugegraph-llm/src/hugegraph_llm/utils/log.py +++ b/hugegraph-llm/src/hugegraph_llm/utils/log.py @@ -23,6 +23,7 @@ LOG_DIR = "logs" os.makedirs(LOG_DIR, exist_ok=True) LOG_FILE = os.path.join(LOG_DIR, "llm-server.log") INFO = logging.INFO +WARNING = logging.WARNING # Initialize the root logger first with Rich handler root_logger = init_logger( @@ -44,16 +45,46 @@ log = init_logger( uvicorn_logger = logging.getLogger("uvicorn") uvicorn_logger.handlers.clear() uvicorn_logger.handlers.extend(root_logger.handlers) -uvicorn_logger.setLevel(INFO) +uvicorn_logger.setLevel(WARNING) # Change to WARNING to reduce output + +# Also configure uvicorn.access and uvicorn.error +uvicorn_access = logging.getLogger("uvicorn.access") +uvicorn_access.handlers.clear() +uvicorn_access.handlers.extend(root_logger.handlers) +uvicorn_access.setLevel(WARNING) # Only show warnings and errors + +uvicorn_error = logging.getLogger("uvicorn.error") +uvicorn_error.handlers.clear() +uvicorn_error.handlers.extend(root_logger.handlers) +uvicorn_error.setLevel(WARNING) # Only show warnings and errors # Configure Gradio logging -gradio_logger = logging.getLogger("gradio") -gradio_logger.handlers.clear() # remove default handlers -gradio_logger.handlers.extend(root_logger.handlers) -gradio_logger.setLevel(INFO) +# gradio_logger = logging.getLogger("gradio") +# gradio_logger.handlers.clear() # remove default handlers +# gradio_logger.handlers.extend(root_logger.handlers) +# gradio_logger.setLevel(WARNING) # Suppress `watchfiles` logging watchfiles_logger = logging.getLogger("watchfiles") watchfiles_logger.handlers.clear() watchfiles_logger.handlers.extend(root_logger.handlers) watchfiles_logger.setLevel(logging.ERROR) + +# Suppress third-party libraries logging +third_party_loggers = { + "httpx": WARNING, # HTTP client library (general HTTP requests) + "httpcore": WARNING, # HTTP core library + "faiss": WARNING, # Vector search library + "faiss.loader": WARNING, # Faiss loader + "apscheduler": WARNING, # Task scheduler + "apscheduler.scheduler": WARNING, + "apscheduler.executors": WARNING, + "pyhugegraph": INFO, # PyHugeGraph client + "urllib3": WARNING, # URL library + "requests": WARNING, # Requests library + "gradio": WARNING, # Already configured above +} + +for logger_name, log_level in third_party_loggers.items(): + logger = logging.getLogger(logger_name) + logger.setLevel(log_level) diff --git a/pyproject.toml b/pyproject.toml index c56108b..012a160 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,12 +59,13 @@ changelog = "https://github.com/apache/incubator-hugegraph-ai/releases" requires = ["hatchling"] build-backend = "hatchling.build" -# Comment explaining that this is an example and can be overridden +# NOTE: If you experience slow download speeds, uncomment the lines below to use mirror source # [[tool.uv.index]] # url = "https://pypi.tuna.tsinghua.edu.cn/simple" # Example mirror for users in China # default = true # -# Users can override this in their personal configuration with: uv config --global index.url https://pypi.org/simple +# Alternatively, configure globally: uv config --global index.url https://pypi.tuna.tsinghua.edu.cn/simple +# To reset to default: uv config --global index.url https://pypi.org/simple [tool.hatch.metadata] # Keep this if hatch is still used by submodules, otherwise remove allow-direct-references = true