From c1255cfd972ab62d38d7c543d6cf0684248c6f69 Mon Sep 17 00:00:00 2001 From: Ayush Chaurasia Date: Wed, 13 Oct 2021 07:32:16 +0000 Subject: [PATCH 1/2] fix dpp with wandb disabled --- utils/loggers/__init__.py | 8 +++++++- utils/loggers/wandb/wandb_utils.py | 10 ---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/utils/loggers/__init__.py b/utils/loggers/__init__.py index 0750be6c8828..b14d747c2abb 100644 --- a/utils/loggers/__init__.py +++ b/utils/loggers/__init__.py @@ -5,6 +5,8 @@ import warnings from threading import Thread +import pkg_resources as pkg +import os import torch from torch.utils.tensorboard import SummaryWriter @@ -15,15 +17,19 @@ from utils.torch_utils import de_parallel LOGGERS = ('csv', 'tb', 'wandb') # text-file, TensorBoard, Weights & Biases +RANK = int(os.getenv('RANK', -1)) try: import wandb assert hasattr(wandb, '__version__') # verify package import not local dir + if pkg.parse_version(wandb.__version__) >= pkg.parse_version('0.12.2') and RANK in [0, -1]: + wandb_login_success = wandb.login(timeout=30) + if not wandb_login_success: + wandb = None except (ImportError, AssertionError): wandb = None - class Loggers(): # YOLOv5 Loggers class def __init__(self, save_dir=None, weights=None, opt=None, hyp=None, logger=None, include=LOGGERS): diff --git a/utils/loggers/wandb/wandb_utils.py b/utils/loggers/wandb/wandb_utils.py index 92fdd27bb004..39b802e9655e 100644 --- a/utils/loggers/wandb/wandb_utils.py +++ b/utils/loggers/wandb/wandb_utils.py @@ -20,16 +20,6 @@ from utils.general import check_dataset, check_file RANK = int(os.getenv('RANK', -1)) - -try: - import wandb - - assert hasattr(wandb, '__version__') # verify package import not local dir - if pkg.parse_version(wandb.__version__) >= pkg.parse_version('0.12.2') and RANK in [0, -1]: - wandb.login(timeout=30) -except (ImportError, AssertionError): - wandb = None - WANDB_ARTIFACT_PREFIX = 'wandb-artifact://' From d12564462c03f1730680a4c37449056bee2e4e2d Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Wed, 13 Oct 2021 16:04:26 -0700 Subject: [PATCH 2/2] PyCharm reformat --- utils/loggers/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/utils/loggers/__init__.py b/utils/loggers/__init__.py index b14d747c2abb..b698c3d2db45 100644 --- a/utils/loggers/__init__.py +++ b/utils/loggers/__init__.py @@ -3,11 +3,11 @@ Logging utils """ +import os import warnings from threading import Thread -import pkg_resources as pkg -import os +import pkg_resources as pkg import torch from torch.utils.tensorboard import SummaryWriter @@ -30,6 +30,7 @@ except (ImportError, AssertionError): wandb = None + class Loggers(): # YOLOv5 Loggers class def __init__(self, save_dir=None, weights=None, opt=None, hyp=None, logger=None, include=LOGGERS):