From cc2a202d296831d41d098a000dab1f7b8155315a Mon Sep 17 00:00:00 2001 From: whning Date: Fri, 5 Jun 2026 01:41:00 +0800 Subject: [PATCH] Fix register_from_C AttributeError in joblib workers (#2038) register_from_C is called from joblib worker processes, which are forked from the main process. In freshly spawned workers, the global config object C is a plain Config instance (not QlibConfig), so C.registered raises AttributeError because Config.__getattr__ falls through to raise when the key isn't in _config dict. The fix changes C.registered to getattr(C, 'registered', False), which returns False for plain Config instances where the attribute doesn't exist. This ensures the registration logic runs in worker processes rather than silently crashing. --- qlib/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qlib/config.py b/qlib/config.py index ae05037e2ff..97739db8641 100644 --- a/qlib/config.py +++ b/qlib/config.py @@ -112,7 +112,7 @@ def set_conf_from_C(self, config_c): def register_from_C(config, skip_register=True): from .utils import set_log_with_config # pylint: disable=C0415 - if C.registered and skip_register: + if getattr(C, "registered", False) and skip_register: return C.set_conf_from_C(config)