{"record":{"id":"61d08c6620fdce7a","repo":"ruvnet/RuView","slug":"weights-file-not-found-weights-path","errorCode":null,"errorMessage":"weights file not found: {weights_path}","messagePattern":"weights file not found: (.+?)","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"scripts/export-onnx.py","lineNumber":72,"sourceCode":"            if name == \"__metadata__\":\n                continue\n            start, end = meta[\"data_offsets\"]\n            shape = meta[\"shape\"]\n            dtype = meta[\"dtype\"]\n            assert dtype == \"F32\", f\"unsupported dtype {dtype} for {name}\"\n            f.seek(8 + header_len + start)\n            buf = f.read(end - start)\n            arr = np.frombuffer(buf, dtype=np.float32).copy().reshape(shape)\n            out[name] = torch.from_numpy(arr)\n    return out\n\n\ndef main() -> None:\n    weights_path = Path(sys.argv[1]) if len(sys.argv) > 1 else Path(\"pose_v1.safetensors\")\n    out_path = Path(sys.argv[2]) if len(sys.argv) > 2 else Path(\"pose_v1.onnx\")\n\n    if not weights_path.exists():\n        raise SystemExit(f\"weights file not found: {weights_path}\")\n\n    print(f\"reading {weights_path}\")\n    tensors = load_safetensors(weights_path)\n    print(f\"  found {len(tensors)} tensors: {sorted(tensors.keys())}\")\n\n    model = PoseNet()\n    # Map safetensors names (enc.c1.weight, head.fc1.weight, ...) to module params\n    mapping = {\n        \"enc.c1.weight\": \"c1.weight\",\n        \"enc.c1.bias\": \"c1.bias\",\n        \"enc.c2.weight\": \"c2.weight\",\n        \"enc.c2.bias\": \"c2.bias\",\n        \"enc.c3.weight\": \"c3.weight\",\n        \"enc.c3.bias\": \"c3.bias\",\n        \"head.fc1.weight\": \"fc1.weight\",\n        \"head.fc1.bias\": \"fc1.bias\",\n        \"head.fc2.weight\": \"fc2.weight\",\n        \"head.fc2.bias\": \"fc2.bias\",","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/scripts/export-onnx.py#L54-L90","documentation":"scripts/export-onnx.py converts the PoseNet safetensors checkpoint to ONNX. It takes the weights path from sys.argv[1], defaulting to ./pose_v1.safetensors relative to the current working directory, and raises SystemExit with this message when the path does not exist. In this repository the trained checkpoint actually lives at v2/crates/cog-pose-estimation/cog/artifacts/pose_v1.safetensors, so running the script from the repo root without arguments fails.","triggerScenarios":"Running `python scripts/export-onnx.py` from a directory that does not contain pose_v1.safetensors; passing a relative weights path from a different cwd; typo or stale path after the artifacts moved.","commonSituations":"Executing the script from the repo root instead of the artifacts directory; a fresh clone where the training artifact has not been produced/downloaded yet; CI job that assumes cwd-relative defaults.","solutions":["Pass the checkpoint explicitly: `python scripts/export-onnx.py v2/crates/cog-pose-estimation/cog/artifacts/pose_v1.safetensors pose_v1.onnx`","Or run the script from the directory containing the weights so the default resolves","Locate the file first: `find . -name 'pose_v1.safetensors'` if you are unsure where the artifact is","If no checkpoint exists, produce or fetch the training artifact before exporting (the script cannot start from random init)"],"exampleFix":"# before\npython scripts/export-onnx.py  # SystemExit: weights file not found: pose_v1.safetensors\n\n# after\npython scripts/export-onnx.py \\\n  v2/crates/cog-pose-estimation/cog/artifacts/pose_v1.safetensors \\\n  v2/crates/cog-pose-estimation/cog/artifacts/pose_v1.onnx","handlingStrategy":"validation","validationCode":"from pathlib import Path\nweights = Path(\"v2/crates/cog-pose-estimation/cog/artifacts/pose_v1.safetensors\")\nassert weights.exists(), f\"checkpoint missing: {weights}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass the weights path explicitly instead of relying on the cwd-relative default","In CI/artifact scripts, resolve the checkpoint from the repo root, not the working directory","Fail fast with your own exists() check so the message names the expected artifact location"],"tags":["onnx","safetensors","export","file-not-found","python","scripts","cli-args"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}