{"record":{"id":"e148e993b07a0add","repo":"datawhalechina/hello-agents","slug":"self-data-path","errorCode":null,"errorMessage":"数据文件不存在: {self.data_path}","messagePattern":"数据文件不存在: (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"code/chapter12/data_generation/human_verification_ui.py","lineNumber":32,"sourceCode":"class HumanVerificationUI:\n    \"\"\"人工验证界面\"\"\"\n    \n    def __init__(self, data_path: str):\n        \"\"\"\n        初始化验证界面\n        \n        Args:\n            data_path: 生成数据的JSON文件路径\n        \"\"\"\n        self.data_path = data_path\n        self.problems = self._load_problems()\n        self.current_index = 0\n        self.verifications = self._load_verifications()\n        \n    def _load_problems(self) -> List[Dict[str, Any]]:\n        \"\"\"加载题目数据\"\"\"\n        if not os.path.exists(self.data_path):\n            raise FileNotFoundError(f\"数据文件不存在: {self.data_path}\")\n        \n        with open(self.data_path, 'r', encoding='utf-8') as f:\n            return json.load(f)\n    \n    def _load_verifications(self) -> Dict[str, Any]:\n        \"\"\"加载已有的验证结果\"\"\"\n        verification_path = self.data_path.replace(\".json\", \"_verifications.json\")\n        \n        if os.path.exists(verification_path):\n            with open(verification_path, 'r', encoding='utf-8') as f:\n                return json.load(f)\n        \n        return {}\n    \n    def _save_verifications(self):\n        \"\"\"保存验证结果\"\"\"\n        verification_path = self.data_path.replace(\".json\", \"_verifications.json\")\n        ","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/datawhalechina/hello-agents/blob/606a07d341a47be773fab7f4b71177f53f96b2c3/code/chapter12/data_generation/human_verification_ui.py#L14-L50","documentation":"FileNotFoundError raised by the HumanVerificationUI constructor when the JSON data file passed as data_path does not exist on disk. The class immediately loads problems at construction time, so instantiation fails fast on a bad path.","triggerScenarios":"Passing a path to a dataset that was never generated (e.g. running the verification UI before aime_generator.py wrote its output); wrong filename or relative path evaluated from a different working directory; data written to another folder.","commonSituations":"Skipping the generation step in the chapter's workflow; running the UI from the repo root while the JSON lives in code/chapter12/data_generation/output/; moving generated files after a cleanup.","solutions":["Run the data generation script first so the JSON file exists at the expected path","Use an absolute path (e.g. built from os.path.dirname(__file__)) instead of a bare relative filename","Verify the path with os.path.exists before constructing the UI"],"exampleFix":"# before\nui = HumanVerificationUI('aime_problems.json')  # relative -> may miss\n\n# after\nimport os\npath = os.path.join(os.path.dirname(__file__), 'aime_problems.json')\nif not os.path.exists(path):\n    raise SystemExit(f'Run the generator first; missing {path}')\nui = HumanVerificationUI(path)","handlingStrategy":"validation","validationCode":"import os\n\ndef ensure_data_file(path: str) -> str:\n    path = os.path.abspath(path)\n    if not os.path.exists(path):\n        raise SystemExit(f'{path} not found — run the generator script first')\n    return path","typeGuard":null,"tryCatchPattern":"try:\n    ui = HumanVerificationUI(path)\nexcept FileNotFoundError as e:\n    raise SystemExit(f'{e} — generate the dataset or fix the path')","preventionTips":["Build data paths from __file__, not from the current working directory","Make the verification step depend on the generation step in your pipeline/script","Fail with the resolved absolute path so users can see which location was checked"],"tags":["file-io","path","data-pipeline"],"backgroundTag":null,"analyzedSha":"606a07d341a47be773fab7f4b71177f53f96b2c3","analyzedAt":"2026-08-14T22:57:27.446Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}