about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gemma.rs28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/gemma.rs b/src/gemma.rs
index 95289bc..d6d932f 100644
--- a/src/gemma.rs
+++ b/src/gemma.rs
@@ -545,6 +545,27 @@ pub async fn compute_ravanan(
         .collect::<Vec<_>>()
         .join(", ");
 
+    // One persistent cache directory per chromosome, reused across
+    // requests, so gemma-wrapper's content-hash cache actually gets hit
+    // on repeated identical requests -- unlike "." (each job's own
+    // hermetic CWL working directory under ravanan's --store, fresh
+    // every run), which never accumulates a cache at all. Keyed by
+    // chromosome, not shared, because gemma-wrapper's cache-hit hash
+    // does not vary with --chromosomes: a shared directory would let
+    // one chromosome's job silently reuse another's cached result.
+    let wrapper_cache_dir = Path::new(cache_dir).join("gemma-wrapper-cache");
+    let mut chr_cache_dirs = Vec::new();
+    for chr in &chromosomes {
+        let chr_cache_dir = wrapper_cache_dir.join(format!("chr-{chr}"));
+        std::fs::create_dir_all(&chr_cache_dir).map_err(GemmaError::Io)?;
+        chr_cache_dirs.push(chr_cache_dir);
+    }
+    let cache_dirs_yaml = chr_cache_dirs
+        .iter()
+        .map(|d| format!("\"{}\"", d.display()))
+        .collect::<Vec<_>>()
+        .join(", ");
+
     let inputs_yaml_path = Path::new(cache_dir).join(format!("{unique}-ravanan-inputs.yaml"));
     std::fs::write(
         &inputs_yaml_path,
@@ -553,7 +574,8 @@ pub async fn compute_ravanan(
              pheno_file: {{class: File, path: {}}}\n\
              snps_file: {{class: File, path: {snps_file}}}\n\
              lmm: \"{lmm}\"\n\
-             chromosomes: [{chromosomes_yaml}]\n",
+             chromosomes: [{chromosomes_yaml}]\n\
+             cache_dirs: [{cache_dirs_yaml}]\n",
             pheno_path.display(),
         ),
     )
@@ -581,8 +603,10 @@ pub async fn compute_ravanan(
     let chromosomes_note = format!(
         "Scattered gemma-wrapper over {} chromosome(s) via CWL scatter \
          (--chromosomes/--no-parallel per job, so GNU parallel is never \
-         invoked): {}",
+         invoked), each against its own persistent, chromosome-keyed \
+         --cache-dir under {}: {}",
         chromosomes.len(),
+        wrapper_cache_dir.display(),
         chromosomes.join(", "),
     );