[Cleanup] Replace bare print() with logger and use specific exception types#2228
Open
Lidang-Jiang wants to merge 1 commit intovllm-project:mainfrom
Conversation
… types Replace 8 bare print() calls in production code with proper logger calls (5 files), and replace 2 generic `raise Exception` with RuntimeError/TypeError (2 files). Benchmark code and intentional file I/O print(file=f) calls are left unchanged. Motivation: Bare print() bypasses vLLM's logging configuration (log levels, formatters, handlers). Bare Exception prevents callers from catching specific error types. Signed-off-by: Lidang Jiang <lidangjiang@gmail.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Lidang-Jiang <lidangjiang@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace 8 bare
print()calls in production code with properloggercalls (5 files), and replace 2 genericraise Exceptionwith specific exception types (2 files).Motivation: Bare
print()bypasses vLLM's logging configuration (log levels, formatters, handlers). GenericExceptionprevents callers from catching specific error types.Benchmark code and intentional file I/O
print(file=f)calls are left unchanged.Changes
Exception types (2 files)
diffusion/diffusion_engine.py:102raise Exception(...)→raise RuntimeError(...)model_executor/models/cosyvoice3/utils.py:183raise Exception(...)→raise TypeError(...)print() → logger (5 files, 8 calls)
diffusion/attention/backends/ring/ring_utils.pyprint(f"ERROR...")→logger.error(...)diffusion/models/dreamid_omni/fusion.pyprint("Warning:...")→logger.warning(...)diffusion/models/hunyuan_image_3/hunyuan_image_3_tokenizer.pyprint(vars)→logger.debug(...)diffusion/models/hunyuan_image_3/hunyuan_image_3_transformer.pyprint(f"Skipping...")→logger.warning(...)model_executor/models/qwen3_tts/tokenizer_25hz/vq/core_vq.pyprint(f"VQ expire...")→logger.info(...)All new loggers use
from vllm.logger import init_loggerconsistent with the rest of the codebase. Lazy%sformatting is used instead of f-strings.Test plan
ruff checkpasses on all 7 modified filesruff format --checkpasses on all 7 modified files🤖 Generated with Claude Code