How to find out if wandb is initialized?

61 Views Asked by At

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?

1

There are 1 best solutions below

1
jraufeisen On BEST ANSWER

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).