Refactoring configs (#248)
- make every run be an experiment by default - deprecate `mode` configs - introduce `debug` configs - introduce `log_dir` configs - remove unnecessary utilities from `utils.extras()` - add config flag for skipping training - update README.md
This commit is contained in:
1 parent
2ff8e053bf
commit
19f5454d13
27 files changed
+210
-238
No files matched your search
+3
-28
@@ -31,12 +31,7 @@ def get_logger(name=__name__) -> logging.Logger:
|
||||
|
||||
|
||||
def extras(config: DictConfig) -> None:
|
||||
"""A couple of optional utilities, controlled by main config file:
|
||||
- disabling warnings
|
||||
- forcing debug friendly configuration
|
||||
- verifying experiment name is set when running in experiment mode
|
||||
|
||||
Modifies DictConfig in place.
|
||||
"""Optional utilities, controlled by hydra config.
|
||||
|
||||
Args:
|
||||
config (DictConfig): Configuration composed by Hydra.
|
||||
@@ -49,26 +44,6 @@ def extras(config: DictConfig) -> None:
|
||||
log.info("Disabling python warnings! <config.ignore_warnings=True>")
|
||||
warnings.filterwarnings("ignore")
|
||||
|
||||
# verify experiment name is set when running in experiment mode
|
||||
if config.get("experiment_mode") and not config.get("name"):
|
||||
log.info(
|
||||
"Running in experiment mode without the experiment name specified! "
|
||||
"Use `python run.py mode=exp name=experiment_name`"
|
||||
)
|
||||
log.info("Exiting...")
|
||||
exit()
|
||||
|
||||
# force debugger friendly configuration if <config.trainer.fast_dev_run=True>
|
||||
# debuggers don't like GPUs and multiprocessing
|
||||
if config.trainer.get("fast_dev_run"):
|
||||
log.info("Forcing debugger friendly configuration! <config.trainer.fast_dev_run=True>")
|
||||
if config.trainer.get("gpus"):
|
||||
config.trainer.gpus = 0
|
||||
if config.datamodule.get("pin_memory"):
|
||||
config.datamodule.pin_memory = False
|
||||
if config.datamodule.get("num_workers"):
|
||||
config.datamodule.num_workers = 0
|
||||
|
||||
|
||||
@rank_zero_only
|
||||
def print_config(
|
||||
@@ -122,7 +97,7 @@ def log_hyperparameters(
|
||||
callbacks: List[pl.Callback],
|
||||
logger: List[pl.loggers.LightningLoggerBase],
|
||||
) -> None:
|
||||
"""This method controls which parameters from Hydra config are saved by Lightning loggers.
|
||||
"""Controls which hyperparameters are saved by Lightning loggers.
|
||||
|
||||
Additionaly saves:
|
||||
- number of model parameters
|
||||
@@ -130,7 +105,7 @@ def log_hyperparameters(
|
||||
|
||||
hparams = {}
|
||||
|
||||
# choose which parts of hydra config will be saved to loggers
|
||||
# choose which parts of hydra config are saved by loggers
|
||||
hparams["trainer"] = config["trainer"]
|
||||
hparams["model"] = config["model"]
|
||||
hparams["datamodule"] = config["datamodule"]
|
||||
|
||||
Reference in new issue
Block a user