Overview
Concrete tool for loading SDV logging configuration and managing logger lifecycle provided by the SDV library.
Description
The sdv.logging.utils module provides three public functions: get_sdv_logger_config reads the SDV logger configuration from a YAML file (sdv_logger_config.yml) stored in the user data directory or the package directory, handling permission and OS errors gracefully. disable_single_table_logger is a context manager that temporarily removes all handlers from the SingleTableSynthesizer logger (used by multi-table synthesizers to suppress duplicate logging during inner single-table fits). load_logfile_dataframe reads an SDV CSV log file into a pandas DataFrame with the correct column headers.
Usage
Use get_sdv_logger_config when initializing loggers (called internally by get_sdv_logger). Use disable_single_table_logger when running multi-table fits that internally fit single-table models. Use load_logfile_dataframe to analyze SDV log output programmatically.
Code Reference
Source Location
Signature
def get_sdv_logger_config() -> dict:
"""Return a dictionary with the logging configuration."""
...
@contextlib.contextmanager
def disable_single_table_logger():
"""Temporarily disables logging for the single table synthesizers."""
...
def load_logfile_dataframe(logfile: str) -> pd.DataFrame:
"""Load the SDV logfile as a pandas DataFrame with correct column headers."""
...
Import
from sdv.logging.utils import (
get_sdv_logger_config,
disable_single_table_logger,
load_logfile_dataframe,
)
I/O Contract
Inputs (get_sdv_logger_config)
| Name |
Type |
Required |
Description
|
| (none) |
— |
— |
Reads from sdv_logger_config.yml in user data dir or package dir
|
Outputs (get_sdv_logger_config)
| Name |
Type |
Description
|
| logger_conf |
dict |
Logger configuration dictionary parsed from YAML
|
Inputs (load_logfile_dataframe)
| Name |
Type |
Required |
Description
|
| logfile |
str |
Yes |
Path to the SDV log CSV file
|
Outputs (load_logfile_dataframe)
| Name |
Type |
Description
|
| df |
pd.DataFrame |
DataFrame with columns: LEVEL, EVENT, TIMESTAMP, SYNTHESIZER CLASS NAME, SYNTHESIZER ID, TOTAL NUMBER OF TABLES, TOTAL NUMBER OF ROWS, TOTAL NUMBER OF COLUMNS
|
Usage Examples
Loading Logger Config
from sdv.logging.utils import get_sdv_logger_config
config = get_sdv_logger_config()
print(config.get('log_registry')) # 'local' or None
print(config.get('loggers', {}).keys())
Disabling Single Table Logger
from sdv.logging.utils import disable_single_table_logger
# Used internally during multi-table fitting
with disable_single_table_logger():
# Single-table logger is silenced here
synthesizer._fit_table(table_name, table_data)
Loading Log Data
from sdv.logging.utils import load_logfile_dataframe
df = load_logfile_dataframe('sdv_logs.csv')
print(df.head())
# Shows: LEVEL, EVENT, TIMESTAMP, SYNTHESIZER CLASS NAME, ...
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.