Warning, /detector_benchmarks/Snakefile is written in an unsupported language. File is not indexed.
0001 configfile: "snakemake.yml"
0002
0003 import functools
0004 import os
0005 from snakemake.logging import logger
0006
0007
0008 @functools.cache
0009 def get_spack_package_hash(package_name):
0010 import json
0011 try:
0012 ver_info = json.loads(subprocess.check_output(["spack", "find", "--json", package_name]))
0013 return ver_info[0]["package_hash"]
0014 except FileNotFoundError as e:
0015 logger.warning("Spack is not installed")
0016 return ""
0017 except subprocess.CalledProcessError as e:
0018 print(e)
0019 return ""
0020
0021
0022 @functools.cache
0023 def find_epic_libraries():
0024 import ctypes.util
0025 # if library is not found (not avaliable) we return an empty list to let DAG still evaluate
0026 libs = []
0027 lib = ctypes.util.find_library("epic")
0028 if lib is not None:
0029 libs.append(os.environ["DETECTOR_PATH"] + "/../../lib/" + lib)
0030 return libs
0031
0032
0033 include: "benchmarks/backgrounds/Snakefile"
0034 include: "benchmarks/backwards_ecal/Snakefile"
0035 include: "benchmarks/barrel_ecal/Snakefile"
0036 include: "benchmarks/calo_pid/Snakefile"
0037 include: "benchmarks/ecal_gaps/Snakefile"
0038 include: "benchmarks/material_scan/Snakefile"
0039 include: "benchmarks/tracking_performances/Snakefile"
0040 include: "benchmarks/tracking_performances_dis/Snakefile"
0041 include: "benchmarks/lfhcal/Snakefile"
0042 include: "benchmarks/zdc_lyso/Snakefile"
0043 include: "benchmarks/zdc_neutron/Snakefile"
0044 include: "benchmarks/insert_muon/Snakefile"
0045 include: "benchmarks/zdc_lambda/Snakefile"
0046 include: "benchmarks/zdc_photon/Snakefile"
0047 include: "benchmarks/zdc_pi0/Snakefile"
0048 include: "benchmarks/zdc_sigma/Snakefile"
0049 include: "benchmarks/insert_neutron/Snakefile"
0050 include: "benchmarks/insert_tau/Snakefile"
0051 include: "benchmarks/femc_electron/Snakefile"
0052 include: "benchmarks/femc_photon/Snakefile"
0053 include: "benchmarks/femc_pi0/Snakefile"
0054
0055 use_s3 = config["remote_provider"].lower() == "s3"
0056 use_xrootd = config["remote_provider"].lower() == "xrootd"
0057
0058
0059 def get_remote_path(path):
0060 if use_s3:
0061 return f"s3https://eics3.sdcc.bnl.gov:9000/eictest/{path}"
0062 elif use_xrootd:
0063 return f"root://dtn-eic.jlab.org//work/eic2/{path}"
0064 else:
0065 raise runtime_exception('Unexpected value for config["remote_provider"]: {config["remote_provider"]}')
0066
0067
0068 rule fetch_epic:
0069 output:
0070 filepath="EPIC/{PATH}"
0071 params:
0072 # wildcards are not included in hash for caching, we need to add them as params
0073 PATH=lambda wildcards: wildcards.PATH
0074 cache: True
0075 retries: 3
0076 shell: """
0077 xrdcp --debug 2 root://dtn-eic.jlab.org//work/eic2/{output.filepath} {output.filepath}
0078 """ if use_xrootd else """
0079 mc cp S3/eictest/{output.filepath} {output.filepath}
0080 """ if use_s3 else f"""
0081 echo 'Unexpected value for config["remote_provider"]: {config["remote_provider"]}'
0082 exit 1
0083 """
0084
0085
0086 rule warmup_run:
0087 output:
0088 "warmup/{DETECTOR_CONFIG}.edm4hep.root",
0089 message: "Ensuring that calibrations/fieldmaps are available for {wildcards.DETECTOR_CONFIG}"
0090 shell: """
0091 set -m # monitor mode to prevent lingering processes
0092 exec ddsim \
0093 --runType batch \
0094 --numberOfEvents 1 \
0095 --compactFile "$DETECTOR_PATH/{wildcards.DETECTOR_CONFIG}.xml" \
0096 --outputFile "{output}" \
0097 --enableGun
0098 """
0099
0100
0101 rule matplotlibrc:
0102 output:
0103 ".matplotlibrc",
0104 run:
0105 with open(output[0], "wt") as fp:
0106 fp.write("backend: Agg\n")
0107 # interactive mode prevents plt.show() from blocking
0108 fp.write("interactive : True\n")
0109
0110
0111 rule org2py:
0112 input:
0113 notebook=workflow.basedir + "/{NOTEBOOK}.org",
0114 converter=workflow.source_path("benchmarks/common/org2py.awk"),
0115 output:
0116 "{NOTEBOOK}.py"
0117 shell:
0118 """
0119 awk -f {input.converter} {input.notebook} > {output}
0120 """
0121
0122
0123 rule metadata:
0124 output:
0125 "results/metadata.json"
0126 shell:
0127 """
0128 cat > {output} <<EOF
0129 {{
0130 "CI_COMMIT_REF_NAME": "${{CI_COMMIT_REF_NAME:-}}",
0131 "CI_COMMIT_SHA": "${{CI_COMMIT_SHA:-}}",
0132 "CI_PIPELINE_ID": "${{CI_PIPELINE_ID:-}}",
0133 "CI_PIPELINE_SOURCE": "${{CI_PIPELINE_SOURCE:-}}",
0134 "CI_PROJECT_ID": "${{CI_PROJECT_ID:-}}",
0135 "PIPELINE_NAME": "${{PIPELINE_NAME:-}}"
0136 }}
0137 EOF
0138 # validate JSON
0139 jq '.' {output}
0140 """