utils
Utility module for RecNextEval library.
This module provides a set of general utility functions used throughout RecNextEval. It includes utilities for file handling, configuration, matrix operations, and logging.
Utility Functions¶
General-purpose utility functions that support library operations:
create_config_yaml: Create configuration YAML filesafe_dir: Safely manage directory operationsadd_columns_to_csr_matrix: Add columns to sparse matrixadd_rows_to_csr_matrix: Add rows to sparse matrixarg_to_str: Convert arguments to string representationdf_to_sparse: Convert DataFrame to sparse matrixto_binary: Convert data to binary formatto_tuple: Convert data to tuple formatProgressBar: Progress bar utility for tracking operations
Path Utilities¶
Directory and path management functions:
get_cache_dir: Get cache directory pathget_data_dir: Get data directory pathget_logs_dir: Get logs directory pathget_repo_root: Get repository root directorysafe_dir: Safely create and manage directories
Logging Control¶
Functions to control logging level and warning suppression:
log_level: Get current logging levellog_level_by_name: Set logging level by name (DEBUG, INFO, WARNING, ERROR)prepare_logger: Initialize logger for RecNextEvalsuppress_warnings: Suppress all Python warningssuppress_specific_warnings: Suppress specific warning types
Logging Example¶
import logging
import warnings
import recnexteval
# Set log level to INFO
recnexteval.log_level_by_name("INFO")
# Suppress all warnings
recnexteval.suppress_warnings(suppress=True)
# Log information
logger = logging.getLogger("recnexteval")
logger.info("This is an informational message.")
# Warnings will be suppressed
warnings.warn("This warning will not appear.")
Configuration¶
create_config_yaml: Generate configuration YAML file for RecNextEval