wandb - how to get it really silent (weights and biases)

6.9k views Asked by At

Working with Anaconda-Spyder (python 3.7), I installed the latest release of wandb (0.10.7) and try to use it with tensorflow (2.1.0) and keras (2.3.1). Since then, my console is polluted with lengthy comments due to wandb. So far I am using config and logs (not yet sweeps). It worked well for several runs BUT I cannot handle the outcome of my code that disappear in a flow of messages.

I'd like to get rid of these messages (or find an alternative to wandb...) Thanks in advance for your help ;-) Here is code to import the necessary libraries :

import os 
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'  
import numpy as np
import pandas as pd 
import tensorflow as tf 
from tensorflow import keras 
from tensorflow.keras.layers import Dropout, Dense, LSTM, Flatten, Activation from tensorflow.keras.layers import Concatenate
from tensorflow.keras import models from tensorflow.keras.models
import Sequential from tensorflow.keras.optimizers import Adam import
wandb os.environ["WANDB_SILENT"] = "true"
wandb.init(project="project_tsa")

Later on, I define the wandb config as follows:

wandb.init(config={"project_name":"project_tsa",
                   "architecture": "ResNet",
                   "load_weights": load_weights,
                   "epochs": epochs,
                   "batch_size": batch_size,
                   "iterations": iterat,
                   "dropout": dropout,
                   "learning_rate": learning,
                   "features": n_feature_maps,
                   "sequence": seq_length})

Eventually, I define several logs :

wandb.log({"precis_pos": precis})
wandb.log({"recall_pos": recall})
wandb.log({"sortino_pos": sharpe_all[4]})
wandb.log({"sortinogain_pos": (sharpe_all[4]-sharpe_all[3])})

As soon as wandb.init is present, I automatically get ten lines of warnings :

wandb: WARNING Calling wandb.login() after wandb.init() has no effect.
<IPython.core.display.HTML object>
VBox(children=(Label(value=' 0.00MB of 0.00MB uploaded (0.00MB deduped)\r'), FloatProgress(value=1.0, max=1.0)…
<IPython.core.display.HTML object>
<IPython.core.display.HTML object>
<IPython.core.display.HTML object>
<IPython.core.display.HTML object>
<IPython.core.display.HTML object>
wandb: WARNING Calling wandb.login() after wandb.init() has no effect.
<IPython.core.display.HTML object>
VBox(children=(Label(value=' 0.00MB of 0.00MB uploaded (0.00MB deduped)\r'), FloatProgress(value=0.0, max=1.0)…
<IPython.core.display.HTML object>
<IPython.core.display.HTML object>
<IPython.core.display.HTML object>
<IPython.core.display.HTML object>
<IPython.core.display.HTML object>

As soon as I define config (and even worse with the logs), the code ends with more than a hundred lines of warning.... Here are just a few as example :

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Anaconda3\lib\threading.py", line 926, in _bootstrap_inner
    self.run()
  File "D:\Anaconda3\lib\site-packages\wandb\filesync\upload_job.py", line 40, in run
    success = self.push()
  File "D:\Anaconda3\lib\site-packages\wandb\filesync\upload_job.py", line 88, in push
    _, upload_headers, result = self._api.upload_urls(project, [self.save_name])
  File "D:\Anaconda3\lib\site-packages\wandb\apis\normalize.py", line 62, in wrapper
    six.reraise(CommError, CommError(message, err), sys.exc_info()[2])
  File "D:\Anaconda3\lib\site-packages\six.py", line 702, in reraise
    raise value.with_traceback(tb)
  File "D:\Anaconda3\lib\site-packages\wandb\apis\normalize.py", line 24, in wrapper
    return func(*args, **kwargs)
  File "D:\Anaconda3\lib\site-packages\wandb\internal\internal_api.py", line 1039, in upload_urls
    run = query_result["model"]["bucket"]
wandb.errors.error.CommError: 'NoneType' object is not subscriptable

[SpyderKernelApp] WARNING | No such comm: 4562c8582bde4c50aedbd77151a94274
[SpyderKernelApp] WARNING | No such comm: 197a5ff2d95849a0bd7d021f29e5f90e
[SpyderKernelApp] WARNING | No such comm: c4ef2bdbcfb340e48c52099c8ac96dc1
[SpyderKernelApp] WARNING | No such comm: 8898f986226043bfed836c08517299cb
[SpyderKernelApp] WARNING | No such comm: 7fbb1deccf8c40629d95c57c6cbd2e6b
[SpyderKernelApp] WARNING | No such comm: 1531c7eb303c4957e97426051d48441b
1

There are 1 answers

0
ayush thakur On

Check out this colab notebook which shows that one can silent wandb logs.

  • From your code, I assume you are trying to silent the logs like this

    wandb os.environ["WANDB_SILENT"] = "true"
    

    however, the correct way is to

    os.environ["WANDB_SILENT"] = "true"
    
  • I also see that you are calling wandb.init twice. It should be called once. If you want to pass configs do like this at once.

    wandb.init(project= "project_tsa", 
               config={"architecture": "ResNet",
                       "load_weights": load_weights,
                       "epochs": epochs,
                       "batch_size": batch_size,
                       "iterations": iterat,
                       "dropout": dropout,
                       "learning_rate": learning,
                       "features": n_feature_maps,
                       "sequence": seq_length})
    
    
  • I also see this warning

    wandb: WARNING Calling wandb.login() after wandb.init() has no effect.
    

    If you are using a script to run your code you do not need to call wandb.login().

A good way to use W&B is

  • Install wandb if you haven't.
  • Set environment variables using os.environ. Here's the list of environment variables related to wandb.
  • import wandb
  • Call wandb.login() if you are on an interactive platform like Jupyter. You don't need to call this if using a script.
  • Instrument your code primarily with wandb.log. There are a plethora of useful APIs..
  • Call wandb.init once. You can pass in the configs there itself. Check out how to correctly pass configs here.
  • Call your training function.
  • Do wandb.finish() to close the run.