Backtest/joblib worker crash: AttributeError: No such registered in self._config
π Bug Description
During backtests that spawn joblib workers, fresh worker processes import Qlib and call config.register_from_C(g_config). That function checks C.registered before copying g_config. Because worker C._config lacks the key on first access, Config.getattr raises: AttributeError: No such registered in self._config
Proposed fix In qlib/config.py register_from_C: Replace: if C.registered and skip_register: With: if getattr(C, "registered", False) and skip_register: After merging g_config into the worker: self._config["registered"] = True
To Reproduce
qlib.backtest.report.PortfolioMetrics._cal_benchmark β qlib.utils.resam.get_higher_eq_freq_feature β D.features β DatasetD.dataset β dataset_processor β joblib.Parallel β qlib.data.data.inst_calculator β qlib.config.C.register_from_C qlib/config.py: register_from_C: if C.registered and skip_register: # raises AttributeError (key missing in worker)
Expected Behavior
Worker config should safely sync from the main process without assuming the key exists.
Environment
OS: Windows 11 Python: 3.10 Qlib: 0.9.7 Joblib: version bundled with Qlib deps Backend: default process-based Parallel
Additional Notes
This avoids needing user-side hacks or thread-only backends. Defaulting the flag to False on first access is consistent with intent and prevents the worker crash.
Hi, @maxilirator Thanks for reporting this issue and providing such a clear analysis and proposed fix β thatβs really helpful! π Could you please share the exact steps or a minimal example to reproduce this error? It would be great to know what specific backtest setup or script triggered the crash on your side, so we can verify and test the fix more effectively.