{"record":{"id":"b6074a2969f0dfec","repo":"immich-app/immich","slug":"model-path-must-point-to-an-existing-file","errorCode":null,"errorMessage":"model_path must point to an existing file!","messagePattern":"model_path must point to an existing file!","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"machine-learning/immich_ml/sessions/ann/loader.py","lineNumber":107,"sourceCode":"            libann.destroy(self.ann)\n            self.ann = None\n\n    def __del__(self) -> None:\n        if self.ann is not None:\n            libann.destroy(self.ann)\n            self.ann = None\n\n    def load(\n        self,\n        model_path: str,\n        fast_math: bool = True,\n        fp16: bool = False,\n        cached_network_path: str | None = None,\n    ) -> int:\n        if not model_path.endswith((\".armnn\", \".tflite\", \".onnx\")):\n            raise ValueError(\"model_path must be a file with extension .armnn, .tflite or .onnx\")\n        if not exists(model_path):\n            raise ValueError(\"model_path must point to an existing file!\")\n\n        save_cached_network = False\n        if cached_network_path is not None and not exists(cached_network_path):\n            save_cached_network = True\n            # create empty model cache file\n            open(cached_network_path, \"a\").close()\n\n        net_id: int = libann.load(\n            self.ann,\n            model_path.encode(),\n            fast_math,\n            fp16,\n            save_cached_network,\n            cached_network_path.encode() if cached_network_path is not None else None,\n        )\n        if net_id < 0:\n            raise ValueError(\"Cannot load model!\")\n","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/immich-app/immich/blob/199723261c6ffa897fec8ccdaea6359e39c37cc3/machine-learning/immich_ml/sessions/ann/loader.py#L89-L125","documentation":"Raised by Ann.load() immediately after the extension check, when os.path.exists(model_path) is False. The extension was acceptable but the file is not on disk at the given location. Unlike [240] (which uses Path.is_file and goes through the high-level model loader), this is the lower-level Ann.load guard for direct callers.","triggerScenarios":"Calling Ann.load() with a well-formed path to a file that has not been downloaded/copied yet, that lives on an unmounted volume, or whose parent directory was cleaned. Also triggered by relative paths resolved against an unexpected working directory.","commonSituations":"Model download step failed or was skipped before invoking Ann.load; volume mount missing in the container; path typo or wrong model_dir; running as a user without read permission on the file (exists() returns False for unreadable parent in some setups); race where the file is still being written.","solutions":["Verify the file exists at the exact absolute path in the error using `ls -l`.","Ensure the download/copy step that produces the model file completed before Ann.load is called.","Use an absolute path; if you must use a relative one, confirm the process working directory.","Check container volume mounts and that the model directory is mounted read/write as needed.","Confirm the current user has read permission on the file and traverse permission on its parent directories."],"exampleFix":"# before\nann.load('/data/models/model.armnn')   # ValueError: must point to an existing file\n# (file was never copied into the container)\n\n# after\n# docker-compose volume mount exposes the file\nann.load('/models/model.armnn')\n# or guard before calling:\nfrom os.path import exists\nif not exists(model_path):\n    raise FileNotFoundError(model_path)","handlingStrategy":"validation","validationCode":"from os.path import exists, isfile\n\ndef validate_armnn_file_exists(model_path: str) -> None:\n    if not (exists(model_path) and isfile(model_path)):\n        raise FileNotFoundError(f\"{model_path} does not exist or is not a regular file\")\n\n# call before Ann.load():\nvalidate_armnn_file_exists(model_path)","typeGuard":"from os.path import isfile\n\ndef is_armnn_file_present(model_path: str) -> bool:\n    return isinstance(model_path, str) and isfile(model_path)","tryCatchPattern":"try:\n    net_id = ann.load(model_path)\nexcept ValueError as e:\n    if 'existing file' in str(e):\n        raise FileNotFoundError(model_path) from e\n    raise","preventionTips":["Run download/copy steps to completion and assert the file exists before invoking Ann.load.","Prefer absolute paths to avoid working-directory surprises in containers.","In startup scripts, `ls -l` the model directory and fail fast if expected files are absent."],"tags":["armnn","filesystem","validation","paths"],"backgroundTag":null,"analyzedSha":"199723261c6ffa897fec8ccdaea6359e39c37cc3","analyzedAt":"2026-08-12T04:54:27.085Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}