HKUDS/Vibe-Trading · error · RegistryError
{alpha_id}: import failed: {exc}
Error message
{alpha_id}: import failed: {exc} What it means
compute() imports the alpha module (via importlib) and wraps any import-time exception as RegistryError('import failed'). The chained __cause__ holds the real error: ImportError, SyntaxError, or an exception raised at module top level.
Source
Thrown at agent/src/factors/registry.py:344
SkipAlpha: required column / sector tag absent in panel.
RegistryError: import/compute failed or output failed sanity checks.
"""
alpha = self.get(alpha_id)
meta = alpha.meta
missing = [c for c in meta.get("columns_required", []) if c not in panel]
if missing:
raise SkipAlpha(f"{alpha_id}: panel missing required columns {missing}")
missing_extra = [c for c in meta.get("extras_required", []) if c not in panel]
if missing_extra:
raise SkipAlpha(f"{alpha_id}: panel missing extras {missing_extra}")
if meta.get("requires_sector") and "sector" not in panel:
raise SkipAlpha(f"{alpha_id}: panel missing sector tag")
try:
module = self._load_module(alpha)
except Exception as exc: # noqa: BLE001 — isolate import failure
raise RegistryError(f"{alpha_id}: import failed: {exc}") from exc
compute_fn = getattr(module, "compute", None)
if compute_fn is None:
raise RegistryError(f"{alpha_id}: module has no compute() function")
try:
result = compute_fn(panel)
except Exception as exc: # noqa: BLE001 — isolate compute failure
raise RegistryError(f"{alpha_id}: compute() raised: {exc}") from exc
return self._validate_output(alpha_id, result, panel)
def _load_module(self, alpha: Alpha) -> ModuleType:
if not self._use_filesystem_loader:
return importlib.import_module(alpha.module_path)
py_file = self._py_paths[alpha.id]
cached = sys.modules.get(alpha.module_path)
if cached is not None and getattr(cached, "__file__", None) == str(py_file):View on GitHub (pinned to 80ffdda44c)
Solutions
- Inspect exc.__cause__ for the real traceback and fix that (install dep, fix syntax)
- Re-generate or restore the alpha module file
- Verify with `python -c "import module.path"` outside the registry
Example fix
# before
out = registry.compute('alpha_042', panel) # ImportError: No module named 'talib'
# after
pip install TA-Lib
out = registry.compute('alpha_042', panel) Defensive patterns
Strategy: try-catch
Validate before calling
import importlib
try:
importlib.import_module(registry.get(alpha_id).module_path)
except Exception as e:
skip(alpha_id, f'import fails: {e}') Try / catch
try:
out = registry.compute(aid, panel)
except RegistryError as e:
if 'import failed' in str(e): skip(aid, e.__cause__)
else: raise Prevention
- Pin all factor dependencies in the environment
- Smoke-import new zoo modules in CI
When it happens
Trigger: compute(alpha_id, panel) where the module has a bad import (missing dependency), a syntax error, or top-level code that raises (e.g. reading a missing file at import).
Common situations: Vendored zoo modules depending on packages not installed in the env; partial file writes/corruption in the zoo; Python version incompatibility in generated code.
Related errors
- {alpha.id}: could not build import spec for {py_file}
- tushare not installed: {exc}
- futu-api is not installed; run `pip install futu-api`.
- tigeropen is not installed; run `pip install tigeropen`.
- unknown zoo {v!r}; expected one of {sorted(_VALID_ZOOS)}
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/29430ccd8d53fa32.
Report an issue: GitHub.