Repository: open-mmlab/mmdetection

Issue:
WandbLogger Hook Error
WandbLogger Hook error  

Code  
```
log_config = dict(
    interval=10,
    hooks=[
        dict(type='TensorboardLoggerHook'),
        dict(type='TextLoggerHook'),
        dict(type='MMDetWandbHook',
            init_kwargs={
                'project': PROJECT,
                'entity': ENTITY,
                'name': TAG,
                'config': {
                    'lr': 0.0025, 'batch_size':16
                },
                'tags': WANDB_TAGS
            },
            interval=1,
            log_checkpoint=False,
            log_checkpoint_metadata=True,
            num_eval_images=3,
            bbox_score_thr=0.3
        )
    ])
```

**Environment**
```
Python: 3.7.11 (default, Jul 27 2021, 14:32:16) [GCC 7.5.0]
CUDA available: True
GPU 0: Tesla V100-SXM2-16GB
CUDA_HOME: /usr/local/cuda-10.1
NVCC: Cuda compilation tools, release 10.1, V10.1.24
GCC: gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
PyTorch: 1.10.0+cu102
PyTorch compiling details: PyTorch built with:
  - GCC 7.3
  - C++ Version: 201402
  - Intel(R) oneAPI Math Kernel Library Version 2021.4-Product Build 20210904 for Intel(R) 64 architecture applications
  - Intel(R) MKL-DNN v2.2.3 (Git Hash 7336ca9f055cf1bfa13efb658fe15dc9b41f0740)
  - OpenMP 201511 (a.k.a. OpenMP 4.5)
  - LAPACK is enabled (usually provided by MKL)
  - NNPACK is enabled
  - CPU capability usage: AVX2
  - CUDA Runtime 10.2
  - NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_70,code=sm_70
  - CuDNN 7.6.5
  - Magma 2.5.2
  - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=10.2, CUDNN_VERSION=7.6.5, CXX_COMPILER=/opt/rh/devtoolset-7/root/usr/bin/c++, CXX_FLAGS= -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=1.10.0, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON, 

TorchVision: 0.11.1+cu102
OpenCV: 4.5.4
MMCV: 1.5.3
MMCV Compiler: GCC 7.3
MMCV CUDA Compiler: 10.2
MMDetection: 2.25.0+55d536e
```

**Error traceback**
```
Traceback (most recent call last):
  File "train.py", line 28, in <module>
    fire.Fire(launch)
  File "/home/james_sarmiento/anaconda3/envs/yl/lib/python3.7/site-packages/fire/core.py", line 141, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "/home/james_sarmiento/anaconda3/envs/yl/lib/python3.7/site-packages/fire/core.py", line 471, in _Fire
    target=component.__name__)
  File "/home/james_sarmiento/anaconda3/envs/yl/lib/python3.7/site-packages/fire/core.py", line 681, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "train.py", line 25, in launch
    train_detector(model, datasets, cfg, distributed=False, validate=True)
  File "/home/james_sarmiento/mmdetection/mmdetection/mmdet/apis/train.py", line 244, in train_detector
    runner.run(data_loaders, cfg.workflow)
  File "/home/james_sarmiento/anaconda3/envs/yl/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 111, in run
    self.call_hook('before_run')
  File "/home/james_sarmiento/anaconda3/envs/yl/lib/python3.7/site-packages/mmcv/runner/base_runner.py", line 309, in call_hook
    getattr(hook, fn_name)(self)
  File "/home/james_sarmiento/anaconda3/envs/yl/lib/python3.7/site-packages/mmcv/runner/dist_utils.py", line 135, in wrapper
    return func(*args, **kwargs)
  File "/home/james_sarmiento/mmdetection/mmdetection/mmdet/core/hook/wandblogger_hook.py", line 140, in before_run
    runner.meta.get('exp_name', None))
  File "/home/james_sarmiento/anaconda3/envs/yl/lib/python3.7/posixpath.py", line 94, in join
    genericpath._check_arg_types('join', a, *p)
  File "/home/james_sarmiento/anaconda3/envs/yl/lib/python3.7/genericpath.py", line 153, in _check_arg_types
    (funcname, s.__class__.__name__)) from None
TypeError: join() argument must be str or bytes, not 'NoneType'
```



Discussion:
Hey @sarmientoj24 this seems like a quick fix.

```
        # Save and Log config.
        if runner.meta is not None and runner.meta.get('exp_name', None) is not None:
            src_cfg_path = osp.join(runner.work_dir,
                                    runner.meta.get('exp_name', None))
            if osp.exists(src_cfg_path):
                self.wandb.save(src_cfg_path, base_path=runner.work_dir)
                self._update_wandb_config(runner)
        else:
            runner.logger.warning('No meta information found in the runner. ')

```
I will make a PR to fix this. 

Resolving patch:
diff --git a/mmdet/core/hook/wandblogger_hook.py b/mmdet/core/hook/wandblogger_hook.py
--- a/mmdet/core/hook/wandblogger_hook.py
+++ b/mmdet/core/hook/wandblogger_hook.py
@@ -135,7 +135,8 @@ def before_run(self, runner):
         super(MMDetWandbHook, self).before_run(runner)
 
         # Save and Log config.
-        if runner.meta is not None:
+        if runner.meta is not None and runner.meta.get('exp_name',
+                                                       None) is not None:
             src_cfg_path = osp.join(runner.work_dir,
                                     runner.meta.get('exp_name', None))
             if osp.exists(src_cfg_path):


Test patch: