ray.air.integrations.comet.CometLoggerCallback#

class ray.air.integrations.comet.CometLoggerCallback(online: bool = True, tags: Optional[List[str]] = None, save_checkpoints: bool = False, **experiment_kwargs)[source]#

Bases: ray.tune.logger.logger.LoggerCallback

CometLoggerCallback for logging Tune results to Comet.

Comet (https://comet.ml/site/) is a tool to manage and optimize the entire ML lifecycle, from experiment tracking, model optimization and dataset versioning to model production monitoring.

This Ray Tune LoggerCallback sends metrics and parameters to Comet for tracking.

In order to use the CometLoggerCallback you must first install Comet via pip install comet_ml

Then set the following environment variables export COMET_API_KEY=<Your API Key>

Alternatively, you can also pass in your API Key as an argument to the CometLoggerCallback constructor.

CometLoggerCallback(api_key=<Your API Key>)

Parameters
  • online – Whether to make use of an Online or Offline Experiment. Defaults to True.

  • tags – Tags to add to the logged Experiment. Defaults to None.

  • save_checkpoints – If True, model checkpoints will be saved to Comet ML as artifacts. Defaults to False.

  • **experiment_kwargs – Other keyword arguments will be passed to the constructor for comet_ml.Experiment (or OfflineExperiment if online=False).

Please consult the Comet ML documentation for more information on the Experiment and OfflineExperiment classes: https://comet.ml/site/

Example:

from ray.air.integrations.comet import CometLoggerCallback
tune.run(
    train,
    config=config
    callbacks=[CometLoggerCallback(
        True,
        ['tag1', 'tag2'],
        workspace='my_workspace',
        project_name='my_project_name'
        )]
)
log_trial_start(trial: ray.tune.experiment.trial.Trial)[source]#

Initialize an Experiment (or OfflineExperiment if self.online=False) and start logging to Comet.

Parameters

trial – Trial object.

log_trial_result(iteration: int, trial: ray.tune.experiment.trial.Trial, result: Dict)[source]#

Log the current result of a Trial upon each iteration.

log_trial_save(trial: ray.tune.experiment.trial.Trial)[source]#

Handle logging when a trial saves a checkpoint.

Parameters

trial – Trial object.

log_trial_end(trial: ray.tune.experiment.trial.Trial, failed: bool = False)[source]#

Handle logging when a trial ends.

Parameters
  • trial – Trial object.

  • failed – True if the Trial finished gracefully, False if it failed (e.g. when it raised an exception).