Skip to content

Commit

Permalink
Update Snakefile
Browse files Browse the repository at this point in the history
  • Loading branch information
zsweger authored Oct 3, 2024
1 parent 2af19d6 commit 188e639
Showing 1 changed file with 15 additions and 41 deletions.
56 changes: 15 additions & 41 deletions files/Snakefile
Original file line number Diff line number Diff line change
@@ -1,78 +1,53 @@
import os

from snakemake.remote.S3 import RemoteProvider as S3RemoteProvider
from snakemake.remote.HTTP import RemoteProvider as HTTPRemoteProvider


rule your_benchmark_compile:
input:
ROOT_BUILD_DIR_PREFIX + "benchmarks/your_benchmark/analysis/uchannelrho_cxx.so",


rule your_benchmark_compile_manual:
input:
tar=HTTPRemoteProvider().remote("https://github.com/tectonic-typesetting/tectonic/releases/download/tectonic%400.15.0/tectonic-0.15.0-x86_64-unknown-linux-musl.tar.gz"),
cls=workflow.source_path("bench.cls"),
tex=workflow.source_path("bench.tex"),
output:
temp("tectonic"),
cls_tmp=temp("bench.cls"),
pdf="results/bench.pdf",
shell: """
tar zxf {input.tar}
cp {input.cls} {output.cls_tmp} # copy to local directory
./tectonic {input.tex} --outdir="$(dirname {output.pdf})"
"""

# Set environment mode (local or eicweb)
ENV_MODE = os.getenv("ENV_MODE", "local") # Defaults to "local" if not set
# Output directory based on environment
OUTPUT_DIR = "../../sim_output/" if ENV_MODE == "eicweb" else "sim_output/"
# Benchmark directory based on environment
BENCH_DIR = "benchmarks/your_benchmark/" if ENV_MODE == "eicweb" else "./"

rule your_benchmark_campaign_reco_get:
output:
f"{OUTPUT_DIR}rho_10x100_uChannel_Q2of0to10_hiDiv.{{INDEX}}.eicrecon.tree.edm4eic.root",
f"{OUTPUT_DIR}rho_10x100_uChannel_Q2of0to10_hiDiv.{% raw %}{{INDEX}}{% endraw %}.eicrecon.tree.edm4eic.root",
shell: """
xrdcp root://dtn-eic.jlab.org//work/eic2/EPIC/RECO/24.07.0/epic_craterlake/EXCLUSIVE/UCHANNEL_RHO/10x100/rho_10x100_uChannel_Q2of0to10_hiDiv.{wildcards.INDEX}.eicrecon.tree.edm4eic.root {output}
"""


rule your_benchmark_analysis:
input:
script="benchmarks/your_benchmark/analysis/uchannelrho.cxx",
#script_compiled=ROOT_BUILD_DIR_PREFIX + "benchmarks/your_benchmark/analysis/uchannelrho_cxx.so",
data="../../sim_output/rho_10x100_uChannel_Q2of0to10_hiDiv_{INDEX}_eicrecon.edm4eic.root",
script=f"{BENCH_DIR}analysis/uchannelrho.cxx",
data=f"{OUTPUT_DIR}rho_10x100_uChannel_Q2of0to10_hiDiv.{% raw %}{{INDEX}}{% endraw %}.eicrecon.tree.edm4eic.root",
output:
plots="../../sim_output/campaign_24.07.0_{INDEX}_eicrecon.edm4eic/plots.root",
plots=f"{OUTPUT_DIR}campaign_24.07.0_{% raw %}{{INDEX}}{% endraw %}.eicrecon.tree.edm4eic/plots.root",
shell:
"""
mkdir -p $(dirname "{output.plots}")
root -l -b -q '{input.script}+("{input.data}","{output.plots}")'
"""


rule your_benchmark_combine:
input:
#lambda wildcards: [f"../../sim_output/campaign_24.07.0_{ix:04d}_eicrecon.edm4eic/plots.root" for ix in range(int(wildcards.NUM_FILES))],
lambda wildcards: expand(
"../../sim_output/campaign_24.07.0_{INDEX:04d}_eicrecon.edm4eic/plots.root",
f"{OUTPUT_DIR}campaign_24.07.0_{% raw %}{{INDEX:04d}}{% endraw %}.eicrecon.tree.edm4eic/plots.root",
INDEX=range(int(wildcards.N)),
),
wildcard_constraints:
N="\d+",
output:
"../../sim_output/campaign_24.07.0_combined_{N}files_eicrecon.edm4eic.plots.root",
f"{OUTPUT_DIR}campaign_24.07.0_combined_{% raw %}{{N}}{% endraw %}files.eicrecon.tree.edm4eic.plots.root",
shell:
"""
hadd {output} {input}
"""


ruleorder: your_benchmark_combine > your_benchmark_analysis


rule your_benchmark_plots:
input:
script="benchmarks/your_benchmark/macros/plot_rho_physics_benchmark.C",
plots="../../sim_output/campaign_24.07.0_combined_{N}files_eicrecon.edm4eic.plots.root",
script=f"{BENCH_DIR}macros/plot_rho_physics_benchmark.C",
plots=f"{OUTPUT_DIR}campaign_24.07.0_combined_{% raw %}{{N}}{% endraw %}files.eicrecon.tree.edm4eic.plots.root",
output:
"../../sim_output/campaign_24.07.0_combined_{N}files_eicrecon.edm4eic.plots_figures/benchmark_rho_mass.pdf",
f"{OUTPUT_DIR}campaign_24.07.0_combined_{% raw %}{{N}}{% endraw %}files.eicrecon.tree.edm4eic.plots_figures/benchmark_rho_mass.pdf",
shell:
"""
if [ ! -d "{input.plots}_figures" ]; then
Expand All @@ -82,5 +57,4 @@ else
echo "{input.plots}_figures directory already exists."
fi
root -l -b -q '{input.script}("{input.plots}")'
cat benchmark_output/*.json
"""

0 comments on commit 188e639

Please sign in to comment.