Search code examples
pythonmachine-learningwandb

How to find out if wandb is initialized?


At the start of my application, I initialize a connection to WeightsAndBiases via

run = wandb.init(project="...")

Later on, I would like to check if a wandb run has been initialized. Is there a way to do this without passing the run object around?


Solution

  • The currently active run object can be accessed via wandb.run. It will be None if no run is initialised.

    if wandb.run is not None:
        print("There is an active connection to wandb")
    

    It is guaranteed that there is at most one active wandb.Run object in any process (source).