climart/utils/utils.py
def extras(config) -> None:
    """A couple of optional utilities, controlled by main config file:
    - disabling warnings
    - easier access to debug mode
    - forcing debug friendly configuration
    - forcing multi-gpu friendly configuration

    Credits go to: https://github.com/ashleve/lightning-hydra-template

    Modifies DictConfig in place.
    """

    log = get_logger()
    check_config_values(config)

    # Create working dir if it does not exist yet
    if config.get('work_dir'):
        os.makedirs(name=config.get("work_dir"), exist_ok=True)

    # disable python warnings if <config.ignore_warnings=True>
    if config.get("ignore_warnings"):
        log.info("Disabling python warnings! <config.ignore_warnings=True>")
        warnings.filterwarnings("ignore")

    # set <config.trainer.fast_dev_run=True> if <config.debug=True>
    if config.get("debug"):
        log.info("Running in debug mode! <config.debug=True>")
        config.trainer.fast_dev_run = True

    # force debugger friendly configuration if <config.trainer.fast_dev_run=True>
    if config.trainer.get("fast_dev_run"):
        log.info("Forcing debugger friendly configuration! <config.trainer.fast_dev_run=True>")
        # Debuggers don't like GPUs or multiprocessing
        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

    # force multi-gpu friendly configuration if <config.trainer.accelerator=ddp>
    accelerator = config.trainer.get("accelerator")
    if accelerator in ["ddp", "ddp_spawn", "dp", "ddp2"]:
        log.info(f"Forcing ddp friendly configuration! <config.trainer.accelerator={accelerator}>")
        if config.datamodule.get("num_workers"):
            config.datamodule.num_workers = 0
        if config.datamodule.get("pin_memory"):
            config.datamodule.pin_memory = False

    if "logger" in config.keys() and config.logger.get("wandb"):
        import wandb
        wandb_id = wandb.util.generate_id()
        config.logger.wandb.id = wandb_id
        group_name = get_group_name(config)
        config.logger.wandb.group = group_name if len(group_name) < 128 else group_name[:128]
        config.logger.wandb.name = get_detailed_name(config) + '_' + time.strftime('%Hh%Mm_on_%b_%d') + '_' + wandb_id
A couple of optional utilities, controlled by main config file:
    - disabling warnings
    - easier access to debug mode
    - forcing debug friendly configuration
    - forcing multi-gpu friendly configuration

    Credits go to: https://github.com/ashleve/lightning-hydra-template

    Modifies DictConfig in place.
    
A couple of optional utilities, controlled by main config file:
disabling warnings
easier access to debug mode
forcing debug friendly configuration
forcing multi-gpu friendly configuration



Modifies DictConfig in place.
A couple of optional utilities controlled by main config file : disabling warnings easier access to debug mode forcing debug friendly configuration forcing multi - gpu friendly configuration Modifies DictConfig in place .
def extras(config) -> None:
    log = get_logger()
    check_config_values(config)
    if config.get('work_dir'):
        os.makedirs(name=config.get("work_dir"), exist_ok=True)
    if config.get("ignore_warnings"):
        log.info("Disabling python warnings! <config.ignore_warnings=True>")
        warnings.filterwarnings("ignore")
    if config.get("debug"):
        log.info("Running in debug mode! <config.debug=True>")
        config.trainer.fast_dev_run = True
    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
    accelerator = config.trainer.get("accelerator")
    if accelerator in ["ddp", "ddp_spawn", "dp", "ddp2"]:
        log.info(f"Forcing ddp friendly configuration! <config.trainer.accelerator={accelerator}>")
        if config.datamodule.get("num_workers"):
            config.datamodule.num_workers = 0
        if config.datamodule.get("pin_memory"):
            config.datamodule.pin_memory = False
    if "logger" in config.keys() and config.logger.get("wandb"):
        import wandb
        wandb_id = wandb.util.generate_id()
        config.logger.wandb.id = wandb_id
        group_name = get_group_name(config)
        config.logger.wandb.group = group_name if len(group_name) < 128 else group_name[:128]
        config.logger.wandb.name = get_detailed_name(config) + '_' + time.strftime('%Hh%Mm_on_%b_%d') + '_' + wandb_id
def extras ( config ) -> None : log = get_logger ( ) check_config_values ( config ) if config . get ( 'work_dir' ) : os . makedirs ( name = config . get ( "work_dir" ) , exist_ok = True ) if config . get ( "ignore_warnings" ) : log . info ( "Disabling python warnings! <config.ignore_warnings=True>" ) warnings . filterwarnings ( "ignore" ) if config . get ( "debug" ) : log . info ( "Running in debug mode! <config.debug=True>" ) config . trainer . fast_dev_run = True 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 accelerator = config . trainer . get ( "accelerator" ) if accelerator in [ "ddp" , "ddp_spawn" , "dp" , "ddp2" ] : log . info ( f"Forcing ddp friendly configuration! <config.trainer.accelerator={accelerator}>" ) if config . datamodule . get ( "num_workers" ) : config . datamodule . num_workers = 0 if config . datamodule . get ( "pin_memory" ) : config . datamodule . pin_memory = False if "logger" in config . keys ( ) and config . logger . get ( "wandb" ) : import wandb wandb_id = wandb . util . generate_id ( ) config . logger . wandb . id = wandb_id group_name = get_group_name ( config ) config . logger . wandb . group = group_name if len ( group_name ) < 128 else group_name [ : 128 ] config . logger . wandb . name = get_detailed_name ( config ) + '_' + time . strftime ( '%Hh%Mm_on_%b_%d' ) + '_' + wandb_id
A couple of optional utilities, controlled by main config file:
 disabling warnings
 easier access to debug mode
 forcing debug friendly configuration
 forcing multi-gpu friendly configuration
A couple of optional utilities controlled by main config file : disabling warnings easier access to debug mode forcing debug friendly configuration forcing multi - gpu friendly configuration
"""A couple of optional utilities, controlled by main config file:
    - disabling warnings
    - easier access to debug mode
    - forcing debug friendly configuration
    - forcing multi-gpu friendly configuration

    Credits go to: https://github.com/ashleve/lightning-hydra-template

    Modifies DictConfig in place.
    """ # Create working dir if it does not exist yet # disable python warnings if <config.ignore_warnings=True> # set <config.trainer.fast_dev_run=True> if <config.debug=True> # force debugger friendly configuration if <config.trainer.fast_dev_run=True> # Debuggers don't like GPUs or multiprocessing # force multi-gpu friendly configuration if <config.trainer.accelerator=ddp>
config