{"record":{"id":"6f3916c0c53b6960","repo":"deepfakes/faceswap","slug":"error-reading-from-filename-err-strerror","errorCode":null,"errorMessage":"Error reading from '{filename}': {err.strerror}","messagePattern":"Error reading from '(.+?)': (.+?)","errorType":"exception","errorClass":"FaceswapError","httpStatus":null,"severity":"error","filePath":"lib/serializer.py","lineNumber":114,"sourceCode":"        data: varies\n            The data in a python object format\n\n        Example\n        ------\n        >>> serializer = get_serializer('json')\n        >>> json_file = '/path/to/json/file.json'\n        >>> data = serializer.load(json_file)\n        \"\"\"\n        logger.debug(\"filename: %s\", filename)\n        try:\n            with open(filename, self._read_option) as s_file:\n                data = s_file.read()\n                logger.debug(\"stored data type: %s\", type(data))\n                retval = self.unmarshal(data)\n\n        except IOError as err:\n            msg = f\"Error reading from '{filename}': {err.strerror}\"\n            raise FaceswapError(msg) from err\n        logger.debug(\"data type: %s\", type(retval))\n        return retval\n\n    def marshal(self, data):\n        \"\"\" Serialize an object\n\n        Parameters\n        ----------\n        data: varies\n            The data that is to be serialized\n\n        Returns\n        -------\n        data: varies\n            The data in a the serialized data format\n\n        Example\n        ------","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/deepfakes/faceswap/blob/f530cb7508ae670f6474f8a7d9c4df94705cf96b/lib/serializer.py#L96-L132","documentation":"Serializer.load wraps file-read IOErrors: the serialized file could not be opened or read (missing file, permission denied, path is a directory). Raised as FaceswapError with the OS strerror and the exact filename requested.","triggerScenarios":"Loading a state/alignments/model-settings file that does not exist yet (e.g. resuming a session whose files were moved), unreadable files, or pointing load at a directory.","commonSituations":"Resume-after-crash flows where the state file was never written; renamed/moved training folders; wrong filename typos; permission changes after copying between machines.","solutions":["Verify the file exists with os.path.isfile before calling load.","Restore or relocate the missing file to the expected path.","Fix read permissions on the file and its directory."],"exampleFix":"import os\nfrom lib.serializer import get_serializer\n\n# before\ndata = get_serializer('json').load('/out/state.json')  # missing -> FaceswapError\n\n# after\nif not os.path.isfile('/out/state.json'):\n    raise SystemExit('state file missing, cannot resume')\ndata = get_serializer('json').load('/out/state.json')","handlingStrategy":"validation","validationCode":"import os\n\nassert os.path.isfile(filename), f'state file not found: {filename}'\ndata = serializer.load(filename)","typeGuard":null,"tryCatchPattern":"try:\n    data = serializer.load(filename)\nexcept FaceswapError as err:\n    if 'Error reading' in str(err):\n        data = default_state  # start fresh if state file unreadable\n    else:\n        raise","preventionTips":["Check isfile before load, especially in resume flows.","Back up state files after each successful run.","Keep training folders self-contained so relative state paths resolve."],"tags":["io","filesystem","serialization","validation"],"backgroundTag":null,"analyzedSha":"f530cb7508ae670f6474f8a7d9c4df94705cf96b","analyzedAt":"2026-08-15T02:59:26.626Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}