Repository: wandb/wandb

Issue:
[CLI] Wrong exception being thrown when empty config-defaults.yaml file is present in the working dir.
**Description**
When wunning wandb.init() with an empty config-defaults.yaml file in the working directory a non informative error is thrown.
By looking at the code in the anaconda environment folder what looks to be happening is that the file is considered as a valid config file but then when loading the yaml info None is returned by the loading function which results in an exception being thrown later.

**Wandb features**
wandb.init()

**How to reproduce**
```
conda create --name test
conda activate test
conda install -c conda-forge wandb
python
import wandb
wandb.init()
```
**Environment**
- OS: Ubuntu 18.04.6
- Environment: Anaconda
- Python Version: 3.9.7

[test.zip](https://github.com/wandb/client/files/7562809/test.zip)


Discussion:
Aidan Donohue commented: 
Taking a look

Hey @Dan8991, I agree that we could have a better error message. I'll file a ticket for this.

Resolving patch:
diff --git a/wandb/sdk/lib/config_util.py b/wandb/sdk/lib/config_util.py
--- a/wandb/sdk/lib/config_util.py
+++ b/wandb/sdk/lib/config_util.py
@@ -4,6 +4,7 @@
 import os
 
 import six
+import wandb
 from wandb.errors import Error
 from wandb.util import load_yaml
 import yaml
@@ -108,6 +109,11 @@ def dict_from_config_file(filename, must_exist=False):
         loaded = load_yaml(conf_file)
     except yaml.parser.ParserError:
         raise ConfigError("Invalid YAML in config yaml")
+    if loaded is None:
+        wandb.termwarn(
+            "Found an empty default config file (config-defaults.yaml). Proceeding with no defaults."
+        )
+        return None
     config_version = loaded.pop("wandb_version", None)
     if config_version is not None and config_version != 1:
         raise ConfigError("Unknown config version")


Test patch:
diff --git a/tests/wandb_config_test.py b/tests/wandb_config_test.py
--- a/tests/wandb_config_test.py
+++ b/tests/wandb_config_test.py
@@ -99,10 +99,23 @@ def test_locked_no_sideeffect(consolidated, config):
     assert consolidated == dict(config)
 
 
-def test_load_config_default():
+def test_load_config_default(runner):
     test_path = "config-defaults.yaml"
     yaml_dict = {"epochs": {"value": 32}, "size_batch": {"value": 32}}
-    with open(test_path, "w") as f:
-        yaml.dump(yaml_dict, f, default_flow_style=False)
-    config = wandb_sdk.Config()
-    assert dict(config) == dict(epochs=32, size_batch=32)
+    with runner.isolated_filesystem():
+        with open(test_path, "w") as f:
+            yaml.dump(yaml_dict, f, default_flow_style=False)
+        config = wandb_sdk.Config()
+        assert dict(config) == dict(epochs=32, size_batch=32)
+
+
+def test_load_empty_config_default(runner, capsys):
+    test_path = "config-defaults.yaml"
+    with runner.isolated_filesystem():
+        with open(test_path, "w") as f:
+            pass
+        _ = wandb_sdk.Config()
+        err_log = capsys.readouterr().err
+        warn_msg = "wandb: WARNING Found an empty default config file (config-defaults.yaml). Proceeding with no defaults."
+        print(err_log)
+        assert warn_msg in err_log