sage.core.config
Filename : config.py Description : Short description of the file
Created on 2025-11-27 00:24:23
__author__ = Narenraju Nagarajan __copyright__ = Copyright 2025, Sage __license__ = MIT Licence __version__ = 0.0.1 __maintainer__ = Narenraju Nagarajan __affiliation__ = N/A __email__ = N/A __status__ = [‘inProgress’, ‘Archived’, ‘inUsage’, ‘Debugging’]
GitHub Repository: NULL
Documentation: NULL
Attributes
Classes
Base |
|
Base configuration class for Sage. |
Functions
|
Register the global training and data configuration objects. |
|
Return the globally registered training configuration. |
Return the globally registered data configuration. |
|
|
Class decorator that attaches |
Module Contents
- register_configs(cfg, data_cfg)[source]
Register the global training and data configuration objects.
Must be called once at the start of each run (typically inside
set_configs()in the run-specificconfig.py). All Sage modules that callget_cfg()orget_data_cfg()depend on this having been called first.- Parameters:
cfg (BaseConfig) – Wrapped training configuration (batch size, device, dtype, …).
data_cfg (BaseDataConfig) – Wrapped data configuration (file paths, sample rate, sequence length, …).
- get_cfg()[source]
Return the globally registered training configuration.
- Returns:
The configuration object registered via
register_configs().- Return type:
- Raises:
RuntimeError – If
register_configs()has not been called yet.
- get_data_cfg()[source]
Return the globally registered data configuration.
- Returns:
The data configuration object registered via
register_configs().- Return type:
- Raises:
RuntimeError – If
register_configs()has not been called yet.
- inject_configs(cfg_cls, data_cfg_cls)[source]
Class decorator that attaches
cfganddata_cfginstances to any class at construction time.This is an alternative to inheriting from
ConfiguredModulefor non-nn.Moduleclasses that still need access to the configuration.- Parameters:
- Returns:
A decorator that wraps the target class’s
__init__.- Return type:
Callable
Example
@inject_configs(MyCFG, MyDataCFG) class MyProcessor: def __init__(self): pass # self.cfg and self.data_cfg are already set
- class ConfiguredModule[source]
Bases:
torch.nn.ModuleBase
nn.Modulethat automatically attaches the globalcfganddata_cfgobjects toselfat construction time.Subclass this instead of
nn.Moduleto avoid callingget_cfg()andget_data_cfg()manually in every__init__.Initialize internal Module state, shared by both nn.Module and ScriptModule.