A high-performance inference engine for AI models
update macos root dir
eugeneb3d7a5e4f706
diff --git a/scripts/download_test_model.sh b/scripts/download_test_model.shindex 93be2ace0..c0a521358 100755--- a/scripts/download_test_model.sh+++ b/scripts/download_test_model.sh@@ -10,10 +10,11 @@ if [[ "$(uname)" != "Darwin" ]]; thenfi# Optional first argument specifies the root directory where the model-# should be stored. Defaults to the SDK cache path.+# should be stored. Defaults to <project-root>/../mirai_models# Usage: bash download_test_model.sh [ROOT_DIR]-ROOT_DIR="${1:-$HOME/Library/Caches/com.mirai.sdk.storage}"+PROJECT_ROOT="$(cd "$(dirname "$0")/.." && pwd)"+ROOT_DIR="${1:-$PROJECT_ROOT/../mirai_models}"MODEL_DIR="$ROOT_DIR/Meta-Llama-3.2-1B-Instruct-float16"diff --git a/uzu/src/storage.rs b/uzu/src/storage.rsindex 40c532369..0d6f3ae30 100644--- a/uzu/src/storage.rs+++ b/uzu/src/storage.rs@@ -1,5 +1,8 @@use std::path::PathBuf;+use objc2::rc::Retained;+use objc2_foundation::{NSHomeDirectory, NSString};+/// `NSSearchPathDirectory` values (Darwin) so they can be passed directly to/// `NSFileManager::URLsForDirectory:inDomains:` via an `as u64` cast.#[repr(u64)]@@ -94,7 +97,18 @@ pub fn user_domain_path(dir: NSSearchPathDirectory) -> PathBuf {/// * other: `$HOME/.cache/<STORAGE_DIR_NAME>`pub fn storage_path() -> PathBuf {#[cfg(target_os = "macos")]- let base = user_domain_path(NSSearchPathDirectory::Caches);+ let base = {+ // In a sandboxed macOS application, NSHomeDirectory() returns+ // `~/Library/Containers/<bundle-id>/Data`. Persist model files inside+ // the app-scoped caches directory to comply with sandbox rules:+ // `~/Library/Containers/<bundle-id>/Data/Library/Caches/…`.+ let home: String = unsafe {+ let ns_str: Retained<NSString> = NSHomeDirectory();+ ns_str.to_string()+ };++ PathBuf::from(&home).join("Library").join("Caches")+ };#[cfg(target_os = "ios")]let base = user_domain_path(NSSearchPathDirectory::Documents);diff --git a/uzu/tests/common/mod.rs b/uzu/tests/common/mod.rsindex 4a7c3519c..c3f87d60c 100644--- a/uzu/tests/common/mod.rs+++ b/uzu/tests/common/mod.rs@@ -1,17 +1,19 @@#![allow(dead_code)]use std::path::PathBuf;-use uzu::storage::storage_path;-pub const MODEL_DIR_NAME: &str = "Meta-Llama-3.2-1B-Instruct-float16";pub const MODEL_FILE_NAME: &str = "model.safetensors";pub const TRACES_FILE_NAME: &str = "traces.safetensors";pub fn get_test_model_path() -> PathBuf {- let path = storage_path().join(MODEL_DIR_NAME);+ let path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))+ .join("..")+ .join("..")+ .join("mirai_models")+ .join(MODEL_DIR_NAME);if !path.exists() {panic!(- "Test model not found at {:?}. Please make sure the model is downloaded to the SDK storage area.",+ "Test model not found at {:?}. Run `bash scripts/download_test_model.sh` to fetch it.",path);}