{"record":{"id":"29430ccd8d53fa32","repo":"HKUDS/Vibe-Trading","slug":"alpha-id-import-failed-exc","errorCode":null,"errorMessage":"{alpha_id}: import failed: {exc}","messagePattern":"(.+?): import failed: (.+?)","errorType":"exception","errorClass":"RegistryError","httpStatus":null,"severity":"error","filePath":"agent/src/factors/registry.py","lineNumber":344,"sourceCode":"            SkipAlpha: required column / sector tag absent in panel.\n            RegistryError: import/compute failed or output failed sanity checks.\n        \"\"\"\n        alpha = self.get(alpha_id)\n        meta = alpha.meta\n\n        missing = [c for c in meta.get(\"columns_required\", []) if c not in panel]\n        if missing:\n            raise SkipAlpha(f\"{alpha_id}: panel missing required columns {missing}\")\n        missing_extra = [c for c in meta.get(\"extras_required\", []) if c not in panel]\n        if missing_extra:\n            raise SkipAlpha(f\"{alpha_id}: panel missing extras {missing_extra}\")\n        if meta.get(\"requires_sector\") and \"sector\" not in panel:\n            raise SkipAlpha(f\"{alpha_id}: panel missing sector tag\")\n\n        try:\n            module = self._load_module(alpha)\n        except Exception as exc:  # noqa: BLE001 — isolate import failure\n            raise RegistryError(f\"{alpha_id}: import failed: {exc}\") from exc\n\n        compute_fn = getattr(module, \"compute\", None)\n        if compute_fn is None:\n            raise RegistryError(f\"{alpha_id}: module has no compute() function\")\n\n        try:\n            result = compute_fn(panel)\n        except Exception as exc:  # noqa: BLE001 — isolate compute failure\n            raise RegistryError(f\"{alpha_id}: compute() raised: {exc}\") from exc\n\n        return self._validate_output(alpha_id, result, panel)\n\n    def _load_module(self, alpha: Alpha) -> ModuleType:\n        if not self._use_filesystem_loader:\n            return importlib.import_module(alpha.module_path)\n        py_file = self._py_paths[alpha.id]\n        cached = sys.modules.get(alpha.module_path)\n        if cached is not None and getattr(cached, \"__file__\", None) == str(py_file):","sourceCodeStart":326,"sourceCodeEnd":362,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/factors/registry.py#L326-L362","documentation":"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.","triggerScenarios":"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).","commonSituations":"Vendored zoo modules depending on packages not installed in the env; partial file writes/corruption in the zoo; Python version incompatibility in generated code.","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"],"exampleFix":"# before\nout = registry.compute('alpha_042', panel)  # ImportError: No module named 'talib'\n# after\npip install TA-Lib\nout = registry.compute('alpha_042', panel)","handlingStrategy":"try-catch","validationCode":"import importlib\ntry:\n    importlib.import_module(registry.get(alpha_id).module_path)\nexcept Exception as e:\n    skip(alpha_id, f'import fails: {e}')","typeGuard":null,"tryCatchPattern":"try:\n    out = registry.compute(aid, panel)\nexcept RegistryError as e:\n    if 'import failed' in str(e): skip(aid, e.__cause__)\n    else: raise","preventionTips":["Pin all factor dependencies in the environment","Smoke-import new zoo modules in CI"],"tags":["import","dependency","registry"],"backgroundTag":"module-import-failed","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}