From be9af02a770e78cc92c1d98a73ec4950c03fee03 Mon Sep 17 00:00:00 2001
From: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
Date: Fri, 27 Sep 2024 04:03:55 -0400
Subject: [PATCH] Cache fetch_epic using Snakemake's caching facility

---
 .gitlab-ci.yml                       | 1 +
 Snakefile                            | 1 +
 benchmarks/demp/config.yml           | 2 +-
 benchmarks/diffractive_vm/config.yml | 2 +-
 benchmarks/dis/config.yml            | 2 +-
 5 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 69db990a..ea63771b 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -99,6 +99,7 @@ common:setup:
     - ls -lrtha 
     - ln -s "${LOCAL_DATA_PATH}/sim_output" sim_output
     - ln -s "${LOCAL_DATA_PATH}/datasets/data" data
+    - mkdir -p "$SNAKEMAKE_OUTPUT_CACHE"
     - ls -lrtha
   retry:
     max: 2
diff --git a/Snakefile b/Snakefile
index 73b03c2b..4a4b743b 100644
--- a/Snakefile
+++ b/Snakefile
@@ -22,6 +22,7 @@ root -l -b -q -e '.L {input}+'
 rule fetch_epic:
     output:
         filepath="EPIC/{PATH}"
+    cache: True
     shell: """
 xrdcp root://dtn-eic.jlab.org//work/eic2/{output.filepath} {output.filepath}
 """
diff --git a/benchmarks/demp/config.yml b/benchmarks/demp/config.yml
index 1afda42d..b07fc789 100644
--- a/benchmarks/demp/config.yml
+++ b/benchmarks/demp/config.yml
@@ -9,7 +9,7 @@ demp:simulate:
   extends: .phy_benchmark
   timeout: 2 hours
   script:
-    - snakemake --cores 5 demp_run_locally
+    - snakemake --cache --cores 5 demp_run_locally
   retry:
     max: 2
     when:
diff --git a/benchmarks/diffractive_vm/config.yml b/benchmarks/diffractive_vm/config.yml
index 6353a610..a614dc89 100644
--- a/benchmarks/diffractive_vm/config.yml
+++ b/benchmarks/diffractive_vm/config.yml
@@ -13,7 +13,7 @@ diffractive_vm:simulate:
       - VM: jpsi
   timeout: 2 hours
   script:
-    - snakemake --cores 10 diffractive_vm_run_locally
+    - snakemake --cache --cores 10 diffractive_vm_run_locally
   retry:
     max: 2
     when:
diff --git a/benchmarks/dis/config.yml b/benchmarks/dis/config.yml
index b4ae5385..34f8157e 100644
--- a/benchmarks/dis/config.yml
+++ b/benchmarks/dis/config.yml
@@ -22,7 +22,7 @@ dis:simulate:
   timeout: 2 hours
   script:
     - |
-      snakemake --cores 1 \
+      snakemake --cache --cores 1 \
         results/epic_craterlake/dis/${EBEAM}on${PBEAM}/minQ2=${MINQ2}/dis_${EBEAM}x${PBEAM}_minQ2=${MINQ2}dis_electrons.json \
         results/epic_craterlake/dis/${EBEAM}on${PBEAM}/minQ2=${MINQ2}/jets/ \
         results/epic_craterlake/dis/${EBEAM}on${PBEAM}/minQ2=${MINQ2}/kinematics_correlations/ \
-- 
GitLab