nxbench package

Subpackages

Submodules

nxbench.cli module

nxbench.cli.main()[source]

nxbench.log module

class nxbench.log.LoggerConfig(name, level='INFO', handlers=<factory>)[source]

Bases: object

Configuration for a single logger.

Parameters:
__init__(name, level='INFO', handlers=<factory>)
Parameters:
Return type:

None

handlers: list[LoggingHandlerConfig]
level: str = 'INFO'
name: str
class nxbench.log.LoggingConfig(loggers=<factory>)[source]

Bases: object

Configuration for all loggers.

Parameters:

loggers (list[LoggerConfig])

__init__(loggers=<factory>)
Parameters:

loggers (list[LoggerConfig])

Return type:

None

loggers: list[LoggerConfig]
class nxbench.log.LoggingHandlerConfig(handler_type, level='INFO', formatter='%(asctime)s - %(name)s - %(levelname)s - %(message)s', log_file=None, rotate_logs=True, backup_count=7, when='midnight')[source]

Bases: object

Configuration for a single logging handler.

Parameters:
  • handler_type (str)

  • level (str)

  • formatter (str)

  • log_file (str | None)

  • rotate_logs (bool)

  • backup_count (int)

  • when (str)

__init__(handler_type, level='INFO', formatter='%(asctime)s - %(name)s - %(levelname)s - %(message)s', log_file=None, rotate_logs=True, backup_count=7, when='midnight')
Parameters:
  • handler_type (str)

  • level (str)

  • formatter (str)

  • log_file (str | None)

  • rotate_logs (bool)

  • backup_count (int)

  • when (str)

Return type:

None

backup_count: int = 7
formatter: str = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
handler_type: str
level: str = 'INFO'
log_file: str | None = None
rotate_logs: bool = True
when: str = 'midnight'
class nxbench.log.NxBenchConfig(active=False, verbosity_level=0, backend_name='nxbench', backend_params=<factory>, logging_config=<factory>)[source]

Bases: Config

Configuration for NetworkX that controls behaviors such as how to use backends and logging.

Parameters:
__init__(active=False, verbosity_level=0, backend_name='nxbench', backend_params=<factory>, logging_config=<factory>)
Parameters:
Return type:

None

__post_init__()[source]

Set environment variables based on initialized fields.

active: bool = False
backend_name: str = 'nxbench'
backend_params: dict
logging_config: LoggingConfig
notify_observers(name, value)[source]

Notify all registered observers about a configuration change.

Parameters:
  • name (str) – The name of the configuration parameter that changed.

  • value (Any) – The new value of the configuration parameter.

Return type:

None

register_observer(callback)[source]

Register an observer callback to be notified on configuration changes.

Parameters:

callback (Callable[[str, any], None]) – A function that accepts two arguments: the name of the configuration parameter that changed and its new value.

Return type:

None

set_verbosity_level(level)[source]

Set the verbosity level (0-2). 2=DEBUG, 1=INFO, 0=NO logging.

Return type:

None

Parameters:

level (int)

verbosity_level: int = 0
nxbench.log.create_handler(handler_cfg)[source]

Create a logging handler based on the handler configuration.

Return type:

Handler | None

Parameters:

handler_cfg (LoggingHandlerConfig)

nxbench.log.disable_logger(logger_name)[source]

Disables the logger by removing all handlers.

Return type:

None

Parameters:

logger_name (str)

nxbench.log.get_default_logger()[source]

Return a default logger instance for simple logging.

Return type:

Logger

nxbench.log.on_config_change(name, value)[source]

Handle configuration changes.

Parameters:
  • name (str) – The name of the configuration parameter that changed.

  • value (any) – The new value of the configuration parameter.

Return type:

None

nxbench.log.setup_logger(logger_cfg)[source]

Set up a single logger based on LoggerConfig.

Return type:

None

Parameters:

logger_cfg (LoggerConfig)

nxbench.log.setup_logger_from_config(logging_config)[source]

Set up all loggers based on the provided LoggingConfig.

Return type:

None

Parameters:

logging_config (LoggingConfig)

nxbench.log.update_logger(name, action, value=None)[source]

Update a specific logger based on action.

Return type:

None

Parameters: