classCometLogger(Logger):"""[Comet](https://www.comet.com/docs/v2/) Logger. Handles the logging for the Comet service. Inherits from Logger. """def__init__(self,config:omegaconf.OmegaConf,api_key:Optional[str]=None):"""Inits the CometLogger class. Args: config (omegaconf.OmegaConf): The experiment config file. It is automatically logged to Comet. api_key (Optional[str], optional): The COMET api key. If None, the API is inferred via the environment variables. Defaults to None. Raises: KeyError: If the `api_key` is None and the `COMET_API_KEY` environment variable is not set. """super().__init__()self.config=configifapi_keyisNone:ifos.environ.get("COMET_API_KEY")isNone:raiseKeyError("The COMET_API_KEY has not been set up as an environment variable. In order to add the ""COMET_API_KEY to the environment variables, run in your terminal: ""export COMET_API_KEY='YOUR_API_TOKEN'.")else:api_key=os.environ.get("COMET_API_KEY")self.experiment=Experiment(api_key=api_key,project_name="rot-mnist-20",display_summary_level=0,)self.log_parameters(config)self.log_code()deflog(self,item,step=None,epoch=None):self.experiment.log_metrics(item,step=step,epoch=epoch)deflog_figure(self,figure,name,step=None,epoch=None):self.experiment.log_image(figure,name=name,step=step)deflog_code(self):self.experiment.log_code(folder=get_original_source_code_root_dir())deflog_parameters(self,config:dict):self.experiment.log_parameters(convert_omegaconf_to_flat_dict(config))defterminate(self):pass
__init__(config,api_key=None)
Inits the CometLogger class.
Parameters:
Name
Type
Description
Default
config
omegaconf.OmegaConf
The experiment config file. It is automatically logged to Comet.
required
api_key
Optional[str]
The COMET api key. If None, the API is inferred via the environment
variables. Defaults to None.
None
Raises:
Type
Description
KeyError
If the api_key is None and the COMET_API_KEY environment variable is not set.
Source code in sequel/utils/loggers/comet_logger.py
def__init__(self,config:omegaconf.OmegaConf,api_key:Optional[str]=None):"""Inits the CometLogger class. Args: config (omegaconf.OmegaConf): The experiment config file. It is automatically logged to Comet. api_key (Optional[str], optional): The COMET api key. If None, the API is inferred via the environment variables. Defaults to None. Raises: KeyError: If the `api_key` is None and the `COMET_API_KEY` environment variable is not set. """super().__init__()self.config=configifapi_keyisNone:ifos.environ.get("COMET_API_KEY")isNone:raiseKeyError("The COMET_API_KEY has not been set up as an environment variable. In order to add the ""COMET_API_KEY to the environment variables, run in your terminal: ""export COMET_API_KEY='YOUR_API_TOKEN'.")else:api_key=os.environ.get("COMET_API_KEY")self.experiment=Experiment(api_key=api_key,project_name="rot-mnist-20",display_summary_level=0,)self.log_parameters(config)self.log_code()