about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorPjotr <wrk@bosa.lan>2026-10-15 14:29:49 +0000
committerPjotr <wrk@bosa.lan>2026-10-15 14:29:49 +0000
commitfcfb9e12d996be1520af74e8521367916d2e8041 (patch)
tree3d93c8565cdde3a42a34a2deb8709fff276fa3e7 /src
parent7f56f54622c704840c34e2b8f289bdb5220e9975 (diff)
downloadgenenetwork4-fcfb9e12d996be1520af74e8521367916d2e8041.tar.gz
gemma: give each scattered chromosome its own persistent cache dir
--cache-dir "." pointed every scattered job at its own hermetic CWL
working directory (fresh under ravanan's --store every run), so
gemma-wrapper's cache was never actually reused across requests.
Point it instead at <ravanan_cache_dir>/gemma-wrapper-cache/chr-<N>,
one persistent directory per chromosome -- not a single shared
directory, because gemma-wrapper's cache-hit hash does not vary with
--chromosomes, so sharing one directory would let one chromosome's
job silently reuse another's cached result.

Also drops gwa.cwl's InitialWorkDirRequirement staging hack: since
kinship and gwa for the same chromosome now point at the same
persistent cache_dir, gemma-wrapper finds the kinship step's archive
there directly, no staging needed.

Confirmed via a real integration run (BXD fixtures) that gemma-wrapper
itself unconditionally re-executes GEMMA regardless of whether a
matching cached archive already exists -- --cache-dir is only used to
hand results between gemma-wrapper's own pipeline stages within one
request, not to skip recomputation across requests. So this fixes a
real latent bug (archive-glob collisions once a chromosome's cache
directory holds more than one request's output) but does not, on its
own, speed up repeated identical requests; verified the direct
/compute/gemma path shows the same lack of cross-request speedup.
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(", "),
     );