cyto_dl.utils.template_utils module#

cyto_dl.utils.template_utils.close_loggers() None[source]#

Makes sure all loggers closed properly (prevents logging failure during multirun).

cyto_dl.utils.template_utils.extras(cfg: DictConfig) None[source]#

Applies optional utilities before the task is started.

Utilities: - Ignoring python warnings - Setting tags from command line - Rich config printing

cyto_dl.utils.template_utils.get_metric_value(metric_dict: dict, metric_name: str) float[source]#

Safely retrieves value of the metric logged in LightningModule.

cyto_dl.utils.template_utils.instantiate_callbacks(callbacks_cfg: DictConfig) List[Callback][source]#

Instantiates callbacks from config.

cyto_dl.utils.template_utils.instantiate_loggers(logger_cfg: DictConfig) List[Logger][source]#

Instantiates loggers from config.

cyto_dl.utils.template_utils.log_hyperparameters(object_dict: dict) None[source]#

Controls which config parts are saved by lightning loggers.

Additionally saves: - Number of model parameters

cyto_dl.utils.template_utils.save_file(path: str, content: str) None[source]#

Save file in rank zero mode (only on one process in multi-GPU setup).

cyto_dl.utils.template_utils.task_wrapper(task_func: Callable) Callable[source]#

Optional decorator that wraps the task function in extra utilities.

Makes multirun more resistant to failure.

Utilities: - Calling the utils.extras() before the task is started - Calling the utils.close_loggers() after the task is finished - Logging the exception if occurs - Logging the task total execution time - Logging the output dir