Skip to content

Commit

Permalink
[Misc] Raise a more informative exception in add/remove_logger (vllm-…
Browse files Browse the repository at this point in the history
  • Loading branch information
Yard1 authored Sep 3, 2024
1 parent 6d646d0 commit 652c83b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions vllm/engine/llm_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -1671,11 +1671,19 @@ def _get_last_sampled_token_ids(
return None

def add_logger(self, logger_name: str, logger: StatLoggerBase) -> None:
if not self.log_stats:
raise RuntimeError(
"Stat logging is disabled. Set `disable_log_stats=False` "
"argument to enable.")
if logger_name in self.stat_loggers:
raise KeyError(f"Logger with name {logger_name} already exists.")
self.stat_loggers[logger_name] = logger

def remove_logger(self, logger_name: str) -> None:
if not self.log_stats:
raise RuntimeError(
"Stat logging is disabled. Set `disable_log_stats=False` "
"argument to enable.")
if logger_name not in self.stat_loggers:
raise KeyError(f"Logger with name {logger_name} does not exist.")
del self.stat_loggers[logger_name]
Expand Down

0 comments on commit 652c83b

Please sign in to comment.