Chenguang is currently a PhD candidate in computer science.
by Chenguang Xiao
For some reason you want to transfer from tensorboard to wandb, then you will suffer from this problem where there are already some tensorboard runs with configs to be uploaded to wandb.
There are some official tutorial in wandb related about this
They corresponding to two ways to sync tensorboard enents to wandb:
There we use the wandb python api to solve it.
from glob import glob
import yaml
import wandb
# root path include multiple runs folders
root = "root/to/runs/"
project = "your-project-name"
entity = "your-wandb-entity"
# all subfolders (runs)
fds = glob(root + "*")
# wandb session
api = wandb.Api()
for fd in fds:
# define run is same as folder name
name = fd.split("/")[-1]
# get tensorboard and config file path
tb_path = glob(fd + "/events.out.tfevents.*")[0]
cf_path = glob(fd + "/config.yaml")[0]
# sync tensorboard to wandb
run = api.sync_tensorboard(
root_dir=tb_path,
run_id=name,
project=project,
entity=entity,
)
# update config to wandb
with open(cf_path) as f:
config = yaml.load(f, Loader=yaml.FullLoader)
run.config = config
run.update()
The key is use of two Api api.sync_tensorboard
( ) and run.update()
.
api.sync_tensorboard
, ensure the wandb group runs correctly.run.update()
after setting the configs of the run.