From 6a54bb7cb123716d7915fa9e4db4b89c5f031383 Mon Sep 17 00:00:00 2001 From: Ayush Chaurasia Date: Thu, 29 Jul 2021 02:55:15 +0530 Subject: [PATCH] W&B: More improvements and refactoring (#4205) * Improve docstrings and run names * default wandb login prompt with timeout * return key * Update api_key check logic * Properly support zipped dataset feature * update docstring * Revert tuorial change * extend changes to log_dataset * add run name * bug fix * bug fix * Update comment * fix import check * remove unused import * Hardcore .yaml file extension * reduce code * Reformat using pycharm * Remove redundant try catch * More refactoring and bug fixes * retry * Reformat using pycharm * respect LOGGERS include list Co-authored-by: Glenn Jocher --- utils/loggers/__init__.py | 8 ++++---- utils/loggers/wandb/wandb_utils.py | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/utils/loggers/__init__.py b/utils/loggers/__init__.py index 027cef4d283a..603837d57052 100644 --- a/utils/loggers/__init__.py +++ b/utils/loggers/__init__.py @@ -48,12 +48,12 @@ def start(self): self.tb = SummaryWriter(str(s)) # W&B - try: - assert 'wandb' in self.include and wandb - run_id = torch.load(self.weights).get('wandb_id') if self.opt.resume else None + if wandb and 'wandb' in self.include: + wandb_artifact_resume = isinstance(self.opt.resume, str) and self.opt.resume.startswith('wandb-artifact://') + run_id = torch.load(self.weights).get('wandb_id') if self.opt.resume and not wandb_artifact_resume else None self.opt.hyp = self.hyp # add hyperparameters self.wandb = WandbLogger(self.opt, run_id) - except: + else: self.wandb = None return self diff --git a/utils/loggers/wandb/wandb_utils.py b/utils/loggers/wandb/wandb_utils.py index ba2d830df07b..c978e3ea838d 100644 --- a/utils/loggers/wandb/wandb_utils.py +++ b/utils/loggers/wandb/wandb_utils.py @@ -158,11 +158,12 @@ def __init__(self, opt, run_id, job_type='Training'): self.data_dict = check_dataset(opt.data) self.setup_training(opt) - # write data_dict to config. useful for resuming from artifacts if not self.wandb_artifact_data_dict: self.wandb_artifact_data_dict = self.data_dict - self.wandb_run.config.update({'data_dict': self.wandb_artifact_data_dict}, - allow_val_change=True) + # write data_dict to config. useful for resuming from artifacts. Do this only when not resuming. + if not opt.resume: + self.wandb_run.config.update({'data_dict': self.wandb_artifact_data_dict}, + allow_val_change=True) if self.job_type == 'Dataset Creation': self.data_dict = self.check_and_upload_dataset(opt)