Metric Logging (dagshub.logger)

class dagshub.logger.DAGsHubLogger(metrics_path: str = 'metrics.csv', should_log_metrics: bool = True, hparams_path: str = 'params.yml', should_log_hparams: bool = True, should_make_dirs: bool = True, eager_logging: bool = True)

A plain Python logger for your metrics and hyperparameters. The saved file format is plain and open - CSV for metrics files, YAML for hyperparameters. You can use this logger manually, or use one of our integrations with high-level libraries like Keras or pytorch-lightning.

__init__(metrics_path: str = 'metrics.csv', should_log_metrics: bool = True, hparams_path: str = 'params.yml', should_log_hparams: bool = True, should_make_dirs: bool = True, eager_logging: bool = True)
Parameters:
  • metrics_path – Where to save the single metrics CSV file.

  • should_log_metrics – Whether to log metrics at all. Should probably always be True.

  • hparams_path – Where to save the single hyperparameter YAML file.

  • should_log_hparams – Whether to log hyperparameters to a file. Should be False if you want to work with hyperparameters in a dependency file, rather than specifying them using command line arguments.

  • should_make_dirs – If true, the directory structure required by metrics_path and hparams_path will be created. Has no effect if the directory structure already exists.

  • eager_logging – If true, the logged metrics and hyperparams will be saved to file immediately. If false, the logger will wait until save() is called, and until then, will hold metrics and hyperparams in memory. Watch out not to run out of memory!

dagshub.logger.dagshub_logger(metrics_path: str = 'metrics.csv', should_log_metrics: bool = True, hparams_path: str = 'params.yml', should_log_hparams: bool = True, should_make_dirs: bool = True, eager_logging: bool = True) ContextManager[DAGsHubLogger]

Example usage:

with dagshub_logger() as logger:

logger.log_hyperparams( {‘lr’: 1e-3, ‘num_layers’: 42} )

logger.log_metrics( {‘loss’: 3.14, ‘val_loss’: 6.28} )

logger.log_metrics(acc=0.999)

Parameters:
  • metrics_path – Where to save the single metrics CSV file.

  • should_log_metrics – Whether to log metrics at all. Should probably always be True.

  • hparams_path – Where to save the single hyperparameter YAML file.

  • should_log_hparams – Whether to log hyperparameters to a file. Should be False if you want to work with hyperparameters in a dependency file, rather than specifying them using command line arguments.

  • should_make_dirs – If true, the directory structure required by metrics_path and hparams_path will be created. Has no effect if the directory structure already exists.

  • eager_logging – If true, the logged metrics and hyperparams will be saved to file immediately. If false, the logger will wait until save() is called, and until then, will hold metrics and hyperparams in memory. Watch out not to run out of memory!