Backtest/joblib worker crash: AttributeError: No such registered in self._config
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 48.7k
- Forks
- 7.7k
- PR merge metrics
- No merged PRs in 30d
Description
🐛 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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in qlib/config.py at register_from_C and reproduce the failure through the joblib.Parallel worker path described in the issue. Verify that a fresh worker can sync g_config without raising AttributeError and that the backtest worker completes successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100