diff --git a/docs/source/configuration_file.rst b/docs/source/configuration_file.rst index 021e212d5..261cf0570 100644 --- a/docs/source/configuration_file.rst +++ b/docs/source/configuration_file.rst @@ -173,8 +173,7 @@ without an account, since the metrics are logged on Tensorboard by default. "A private key used to sync the local wandb folder with the wandb dashboard accessible through the browser.\n", "The API key can be found from the browser in your WandB Account's Settings, under the section ``API Keys``.\n", "Note that once it is successfully authenticated, a message would be printed in the terminal notifying\n", - "that the API key is stored in the ``.netrc`` file in the ``/home`` folder. From then on, the value in this key-value\n", - "pair in the config file could be omitted, like ``'wandb_api_key': ''``" + "that the API key is stored in the ``.netrc`` file in the ``/home`` folder. ], "type": "string" } diff --git a/ivadomed/utils.py b/ivadomed/utils.py index 5a6c3f8ef..0b43f4724 100644 --- a/ivadomed/utils.py +++ b/ivadomed/utils.py @@ -35,7 +35,19 @@ def __str__(self): def initialize_wandb(wandb_params): + """Initializes WandB and based upon the parameters sets it up or disables it for experimental tracking + + Args: + wandb_params (dict): wandb parameters + + Returns: + bool, wandb_tracking: True if wandb tracking is enabled + """ try: + # raise an error if the key is empty + if not bool(wandb_params[WandbKW.WANDB_API_KEY].strip()): + raise ValueError() + # Log on to WandB (assuming that the API Key is correct) # if not, login would raise an exception for the cases invalid API key and not found wandb.login(key=wandb_params[WandbKW.WANDB_API_KEY], anonymous='allow', timeout=60)