{"record":{"id":"2a4b4ca1db57438d","repo":"HKUDS/Vibe-Trading","slug":"alpha-id-module-has-no-compute-function","errorCode":null,"errorMessage":"{alpha_id}: module has no compute() function","messagePattern":"(.+?): module has no compute\\(\\) function","errorType":"exception","errorClass":"RegistryError","httpStatus":null,"severity":"error","filePath":"agent/src/factors/registry.py","lineNumber":348,"sourceCode":"        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):\n            return cached\n        spec = importlib.util.spec_from_file_location(alpha.module_path, py_file)\n        if spec is None or spec.loader is None:\n            raise RegistryError(f\"{alpha.id}: could not build import spec for {py_file}\")","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/factors/registry.py#L330-L366","documentation":"The alpha module imported successfully but exposes no compute function. The registry contract requires each zoo module to define a public compute(panel) -> DataFrame; getattr(module, 'compute', None) returned None.","triggerScenarios":"compute(alpha_id, panel) on a module that renamed compute (e.g. _compute or compute_alpha), is a pure helper/util module, or has compute guarded by a failing conditional definition.","commonSituations":"Hand-written factors that don't follow the zoo template; refactors renaming compute; accidentally registering a non-factor module in the zoo directory.","solutions":["Add/rename the function to `def compute(panel: dict) -> pd.DataFrame` in the module","Exclude non-factor modules from registry scanning","Regenerate the module from the standard zoo template"],"exampleFix":"# before\ndef compute_alpha(panel):\n    ...\n# after\ndef compute(panel: dict) -> pd.DataFrame:\n    ...","handlingStrategy":"validation","validationCode":"import importlib\nmod = importlib.import_module(module_path)\nif not hasattr(mod, 'compute'): raise/skip","typeGuard":"def has_compute(module_path: str) -> bool:\n    return callable(getattr(importlib.import_module(module_path), 'compute', None))","tryCatchPattern":"try:\n    out = registry.compute(aid, panel)\nexcept RegistryError as e:\n    if 'no compute()' in str(e): skip(aid)\n    else: raise","preventionTips":["Use the zoo module template with compute(panel)","CI check: every zoo module exposes compute"],"tags":["contract","registry","module-structure"],"backgroundTag":"missing-entrypoint-function","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}