Skip to content

Commit 3dc0db7

Browse files
committed
feat(config): add explicit validation for required configuration fields
1 parent 2c9dfdf commit 3dc0db7

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

qlib/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,11 @@ def register_from_C(config, skip_register=True):
131131
if C.registered and skip_register:
132132
return
133133

134-
135-
C.set_conf_from_C(config)
136134

135+
C.set_conf_from_C(config)
137136

138-
C.validate()
137+
if not skip_register:
138+
C.validate()
139139

140140
if C.logging_config:
141141
set_log_with_config(C.logging_config)
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import pytest
2-
from qlib.config import C, Config
2+
3+
from qlib.config import Config
34

45

56
def test_missing_provider_uri_raises():
6-
77
default_conf = {
88
"provider_uri": None,
9-
"region": "us"
9+
"region": "us",
1010
}
1111

1212
cfg = Config(default_conf)
1313

1414
with pytest.raises(ValueError) as exc:
1515
cfg.validate()
1616

17-
assert "provider_uri must be set" in str(exc.value)
17+
assert "provider_uri must be set" in str(exc.value)

0 commit comments

Comments
 (0)