LightningIRSaveConfigCallback
- class lightning_ir.main.LightningIRSaveConfigCallback(parser: LightningArgumentParser, config: Namespace, config_filename: str = 'config.yaml', overwrite: bool = False, multifile: bool = False, save_to_log_dir: bool = True)[source]
Bases:
SaveConfigCallback
- __init__(parser: LightningArgumentParser, config: Namespace, config_filename: str = 'config.yaml', overwrite: bool = False, multifile: bool = False, save_to_log_dir: bool = True) None
Methods
setup
(trainer, pl_module, stage)Called when fit, validate, test, predict, or tune begins.
Attributes
- save_config(trainer: Trainer, pl_module: LightningModule, stage: str) None
Implement to save the config in some other place additional to the standard log_dir.
Example
- def save_config(self, trainer, pl_module, stage):
- if isinstance(trainer.logger, Logger):
config = self.parser.dump(self.config, skip_none=False) # Required for proper reproducibility trainer.logger.log_hyperparams({“config”: config})
Note
This method is only called on rank zero. This allows to implement a custom save config without having to worry about ranks or race conditions. Since it only runs on rank zero, any collective call will make the process hang waiting for a broadcast. If you need to make collective calls, implement the setup method instead.
- setup(trainer: Trainer, pl_module: LightningModule, stage: str) None [source]
Called when fit, validate, test, predict, or tune begins.