From e84d92d52cb67927c8ceb3f2d34833788e66ec18 Mon Sep 17 00:00:00 2001 From: Accusys Date: Sun, 4 Oct 2026 19:31:51 +0800 Subject: [PATCH] fix: remove hardcoded path in facenet_embedding.swift (A-4.2) Problem: - L24 had hardcoded model path as default_value - Would cause D-4 failure (strings shows dev path) Solution: - Remove default_value - Add runtime resolution: 1. CLI --model argument 2. MOMENTRY_MODELS_DIR env var 3. Sibling of binary (models/facenet512.mlpackage) Impact: - Swift CLI now portable - No dev path strings in binary - D-4 Gate condition satisfied Verification: grep shows 0 hardcoded paths --- .../swift_processors/facenet_embedding.swift | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/scripts/swift_processors/facenet_embedding.swift b/scripts/swift_processors/facenet_embedding.swift index 0f97774b..b8be98c4 100644 --- a/scripts/swift_processors/facenet_embedding.swift +++ b/scripts/swift_processors/facenet_embedding.swift @@ -21,14 +21,27 @@ struct FaceNetEmbedding: ParsableCommand { var uuid: String = "" @Option(name: .long, help: "FaceNet model path (mlpackage directory)") - var model: String = "/Users/accusys/momentry_core/models/facenet512.mlpackage" + var model: String = "" mutating func run() throws { let startTime = Date() print("[FaceNet] Loading FaceNet CoreML model...") + // Resolve model path: CLI arg > env var > sibling of binary + let modelPath: String + if !model.isEmpty { + modelPath = model + } else if let envPath = ProcessInfo.processInfo.environment["MOMENTRY_MODELS_DIR"] { + modelPath = envPath + "/facenet512.mlpackage" + } else { + // Fallback: sibling of current binary + let exePath = CommandLine.arguments[0] + let exeDir = URL(fileURLWithPath: exePath).deletingLastPathComponent() + modelPath = exeDir.appendingPathComponent("models/facenet512.mlpackage").path + } + // Load FaceNet CoreML model - let modelPackageURL = URL(fileURLWithPath: model) + let modelPackageURL = URL(fileURLWithPath: modelPath) let modelURL = modelPackageURL.appendingPathComponent("Data/com.apple.CoreML/model.mlmodel") guard FileManager.default.fileExists(atPath: modelURL.path) else {