π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
rust/.cache cache place
laurensprieme36cf8de783a
diff --git a/.github/workflows/rust-lint.yml b/.github/workflows/rust-lint.ymlindex a3334bcb21..db55b3b276 100644--- a/.github/workflows/rust-lint.yml+++ b/.github/workflows/rust-lint.yml@@ -15,7 +15,6 @@ concurrency:env:RUSTFLAGS: -D warnings- ENTE_ML_ASSETS_CACHE_DIR: ${{ github.workspace }}/.ml-assets-cachejobs:lint:@@ -39,7 +38,7 @@ jobs:workspaces: rustshared-key: rust-workspacesave-if: false- cache-directories: .ml-assets-cache+ cache-directories: rust/.cache- run: cargo fmt --checkdiff --git a/.github/workflows/warm-caches.yml b/.github/workflows/warm-caches.ymlindex 3f729c703c..202d1720b0 100644--- a/.github/workflows/warm-caches.yml+++ b/.github/workflows/warm-caches.yml@@ -30,7 +30,6 @@ jobs:working-directory: rustenv:RUSTFLAGS: -D warnings- ENTE_ML_ASSETS_CACHE_DIR: ${{ github.workspace }}/.ml-assets-cachesteps:- name: Checkoutuses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0@@ -45,16 +44,11 @@ jobs:with:workspaces: rustshared-key: rust-workspace- cache-directories: .ml-assets-cache+ cache-directories: rust/.cache- run: cargo clippy --all-targets --locked- - run: cargo test --locked --workspace --features ente-photos/ml-assets --no-run-- # Downloads (or verifies) the ML test assets without running inference.- - run: cargo test --locked -p ente-photos --test ml_indexing --features ml-assets- env:- ENTE_ML_ASSETS_PREFETCH_ONLY: "1"+ - run: cargo test --locked --workspace --features ente-photos/ml-assets- run: cargo install cargo-audit --version 0.22.2 --lockeddiff --git a/infra/ml/test/README.md b/infra/ml/test/README.mdindex 6bb461129b..ee2ea72b60 100644--- a/infra/ml/test/README.md+++ b/infra/ml/test/README.md@@ -60,19 +60,10 @@ cargo test -p ente-photos --test ml_indexing --features ml-assets -- --nocaptureBy default the test downloads the external fixture manifest, fixture images,Python golden JSON, ONNX Runtime dynamic library, and ONNX models into-`rust/target/ml-assets-cache/`, with SHA-256 verification for every asset. For-local work against a checked-out fixture repo, point the test at the dataset-root:--```sh-ENTE_ML_ASSETS_REPO_DIR=/path/to/test-fixtures/ml/indexing/v1 \- cargo test -p ente-photos --test ml_indexing --features ml-assets -- --nocapture-```+`rust/.cache/`, with SHA-256 verification for every asset.Optional env vars:-- `ENTE_ML_ASSETS_CACHE_DIR`: override the download cache location (defaults to `rust/target/ml-assets-cache/`; CI points this at a persisted cache directory).-- `ENTE_ML_ASSETS_PREFETCH_ONLY=1`: download and verify all assets, then exit without running inference (used by the nightly cache-warming workflow).- `ENTE_ML_INDEXING_PRINT_STATS=1`: print a per-metric comparison summary (count, max observed value, threshold) even when the test passes; on failure the summary is always appended to the failure message.`infra/ml/test/ml_indexing/assets.json` locks the external manifest, Pythondiff --git a/rust/.gitignore b/rust/.gitignoreindex ea8c4bf7f3..718fbd9eb1 100644--- a/rust/.gitignore+++ b/rust/.gitignore@@ -1 +1,2 @@/target+/.cachediff --git a/rust/crates/photos/tests/ml_indexing.rs b/rust/crates/photos/tests/ml_indexing.rsindex 4344bdc405..2b14985e9d 100644--- a/rust/crates/photos/tests/ml_indexing.rs+++ b/rust/crates/photos/tests/ml_indexing.rs@@ -2,7 +2,7 @@ mod support;use anyhow::Result;use support::ml_indexing::{- ComparisonStats, MlIndexingTestContext, fail_if_any, prefetch_only, run_with_large_stack,+ ComparisonStats, MlIndexingTestContext, fail_if_any, run_with_large_stack,};#[test]@@ -12,9 +12,6 @@ fn rust_ml_matches_python_goldens() {fn run_ml_indexing_test() -> Result<()> {let context = MlIndexingTestContext::load()?;- if prefetch_only() {- return context.prefetch_all_fixtures();- }let runtime = context.prepare_runtime()?;let mut failures = context.validate_manifest_expectations()?;diff --git a/rust/crates/photos/tests/support/ml_indexing.rs b/rust/crates/photos/tests/support/ml_indexing.rsindex 8058771968..847e222b35 100644--- a/rust/crates/photos/tests/support/ml_indexing.rs+++ b/rust/crates/photos/tests/support/ml_indexing.rs@@ -25,7 +25,6 @@ const CLIP_EMBEDDING_DIM: usize = 512;const FACE_EMBEDDING_DIM: usize = 192;const FLOAT_TOLERANCE: f64 = 1e-8;const PRINT_STATS_ENV: &str = "ENTE_ML_INDEXING_PRINT_STATS";-const PREFETCH_ONLY_ENV: &str = "ENTE_ML_ASSETS_PREFETCH_ONLY";const DOWNLOAD_MAX_ATTEMPTS: usize = 4;const DOWNLOAD_RETRY_BASE_DELAY_MS: u64 = 500;@@ -156,15 +155,7 @@ struct MetricObservation {}fn should_print_stats() -> bool {- env_flag(PRINT_STATS_ENV)-}--pub(crate) fn prefetch_only() -> bool {- env_flag(PREFETCH_ONLY_ENV)-}--fn env_flag(name: &str) -> bool {- let Ok(value) = std::env::var(name) else {+ let Ok(value) = std::env::var(PRINT_STATS_ENV) else {return false;};let value = value.trim();@@ -179,7 +170,6 @@ pub(crate) struct MlIndexingTestContext {cache_dir: PathBuf,client: Client,golden_results: HashMap<String, ComparableResult>,- local_assets_root: Option<PathBuf>,manifest: FixtureManifest,runtime_config: MlRuntimeConfig,}@@ -189,22 +179,15 @@ impl MlIndexingTestContext {let repo_root = repo_root()?;let asset_lock = load_asset_lock(&repo_root)?;let cache_dir = cache_dir(&repo_root);- let local_assets_root = std::env::var_os("ENTE_ML_ASSETS_REPO_DIR").map(PathBuf::from);let client = Client::builder().user_agent("ente-rust-ml-indexing-test").build().context("build HTTP client")?;- let manifest_path = resolve_document_asset(- &client,- local_assets_root.as_deref(),- &cache_dir,- "manifest",- &asset_lock.manifest,- )?;+ let manifest_path =+ resolve_document_asset(&client, &cache_dir, "manifest", &asset_lock.manifest)?;let golden_path = resolve_document_asset(&client,- local_assets_root.as_deref(),&cache_dir,"python-golden",&asset_lock.python_golden,@@ -233,7 +216,6 @@ impl MlIndexingTestContext {cache_dir,client,golden_results,- local_assets_root,manifest,runtime_config,})@@ -359,13 +341,6 @@ impl MlIndexingTestContext {Ok(())}- pub(crate) fn prefetch_all_fixtures(&self) -> Result<()> {- for fixture in &self.manifest.files {- self.resolve_fixture(fixture)?;- }- Ok(())- }-fn manifest_file_ids(&self) -> Result<BTreeSet<String>> {let mut ids = BTreeSet::new();for file in &self.manifest.files {@@ -380,7 +355,6 @@ impl MlIndexingTestContext {fn resolve_fixture(&self, fixture: &FixtureFile) -> Result<PathBuf> {resolve_fixture_asset(&self.client,- self.local_assets_root.as_deref(),&self.cache_dir,&self.asset_lock.fixture_base_url,fixture,@@ -513,9 +487,7 @@ fn repo_root() -> Result<PathBuf> {}fn cache_dir(repo_root: &Path) -> PathBuf {- std::env::var_os("ENTE_ML_ASSETS_CACHE_DIR")- .map(PathBuf::from)- .unwrap_or_else(|| repo_root.join("rust/target/ml-assets-cache"))+ repo_root.join("rust/.cache")}fn load_asset_lock(repo_root: &Path) -> Result<AssetLock> {@@ -569,31 +541,21 @@ fn file_id_for_manifest_path(path: &str) -> Result<String> {fn resolve_document_asset(client: &Client,- local_assets_root: Option<&Path>,cache_dir: &Path,label: &str,asset: &DocumentAsset,) -> Result<PathBuf> {- if let Some(root) = local_assets_root {- return require_local_asset(root, &asset.path, &asset.sha256, label);- }-let target = cache_path_for(cache_dir, "documents", &asset.path, &asset.sha256)?;ensure_remote_asset(client, &asset.url, &asset.sha256, &target, label)}fn resolve_fixture_asset(client: &Client,- local_assets_root: Option<&Path>,cache_dir: &Path,fixture_base_url: &str,fixture: &FixtureFile,) -> Result<PathBuf> {let file_id = file_id_for_manifest_path(&fixture.path)?;- if let Some(root) = local_assets_root {- return require_local_asset(root, &fixture.path, &fixture.sha256, &file_id);- }-let url = Url::parse(fixture_base_url).with_context(|| format!("parse fixture base URL '{fixture_base_url}'"))?.join(&fixture.path)@@ -752,23 +714,6 @@ fn resolve_model_asset(ensure_remote_asset(client, &asset.url, &asset.sha256, &target, label)}-fn require_local_asset(- local_assets_root: &Path,- relative_path: &str,- expected_sha256: &str,- label: &str,-) -> Result<PathBuf> {- let path = local_assets_root.join(relative_path);- if !path.is_file() {- bail!(- "{label} is missing from local asset repo at {}",- path.display()- );- }- verify_file_sha256(&path, expected_sha256, label)?;- Ok(path)-}-enum DownloadAttemptError {Fatal(anyhow::Error),Retryable(anyhow::Error),