hpcaitech/Open-Sora · error · ValueError
Invalid logging level: {level}
Error message
Invalid logging level: {level} What it means
This ValueError is thrown by log_message in opensora/utils/logger.py when the level argument is not one of the supported logging levels: 'debug', 'info', 'warning', 'error', or 'print'. The function dispatches on exact string matches of level, and any other value falls through to the else branch and raises. It exists to catch typos or unsupported level names in code that logs messages.
Source
Thrown at opensora/utils/logger.py:90
def log_message(*args, level: str = "info"):
"""
Log a message to the logger.
Args:
*args: The message to log.
level (str): The logging level.
"""
logger = logging.getLogger(__name__)
if level == "info":
logger.info(*args)
elif level == "warning":
logger.warning(*args)
elif level == "error":
logger.error(*args)
elif level == "print":
print(*args)
else:
raise ValueError(f"Invalid logging level: {level}")
View on GitHub (pinned to 7ad6a96a13)
Solutions
- Set level to one of the exact supported strings: "debug", "info", "warning", "error", or "print"
- Check for case/typo issues such as "WARN" vs "warning" or "warn" vs "warning"
- If you need a default, pass level="info" explicitly rather than None
- If you need more levels, extend the dispatcher in opensora/utils/logger.py to map them before raising
Example fix
# before
log_message("training started", level="warn")
# after
log_message("training started", level="warning") Defensive patterns
Strategy: validation
Validate before calling
VALID_LEVELS = {"debug", "info", "warning", "error", "print"}
if level not in VALID_LEVELS:
level = "info" # or raise your own clear error before calling Type guard
def is_valid_log_level(level: str) -> bool:
return level in {"debug", "info", "warning", "error", "print"} Try / catch
try:
log_message(msg, level=level)
except ValueError:
logger.warning(msg) # fall back to standard level Prevention
- Centralize log level strings as constants/enums instead of inline strings
- Validate level once at config load time, not at every log call
When it happens
Trigger: Calling log_message(*args, level="notice"), level="WARN", level="critical", or any string not in {debug, info, warning, error, print}. Also triggered when level is None (e.g. a caller passes level=None as a default instead of "info"). Callers include set_group_size, print_load_warning, load_checkpoint, process_and_save, log_cuda_memory, log_cuda_max_memory.
Common situations: A developer adds a new logging call copying another library's level names ('warn', 'fatal', 'trace') which OpenSora doesn't recognize; or a config file / CLI flag supplies a logging level string that is forwarded unvalidated to log_message.
Related errors
- Unsupported dtype {dtype}
- Unknown optimizer: {optimizer_name}
- Unknown plugin {plugin}
- type {type(data)} cannot be converted to tensor.
- type {type(data)} cannot be converted to ndarray.
AI-assisted analysis of hpcaitech/Open-Sora@7ad6a96a13 (2026-08-28).
Data as JSON: /api/errors/e5d64c4ede4febf5.
Report an issue: GitHub.