File size: 652 Bytes
b7ed8cd e757304 c6541c4 126580f 48c784d c6541c4 48c784d c6541c4 48c784d 8b32a10 c6541c4 48c784d b7ed8cd c6541c4 dd73c60 b7ed8cd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import wandb
import os
from util import Config, RandomCode
class Wandb:
def __init__(self, config: Config):
self.__dict__ = dict(config.__dict__)
if self.entity == '' or self.project == '' or self.api_key == '':
raise ValueError('Missing required values for either Entity, Project or API Key')
if self.name == '':
self.name = 'run-' + RandomCode()
os.environ['WANDB_API_KEY'] = self.api_key
wandb.init(project=self.project, entity=self.entity, name=self.name, reinit=True)
def __call__(self, args):
wandb.log(args)
def __exit__(self):
wandb.finish() |