diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e04baac6eafb22470ba00c5b55e20260712589b1..a861fc7b7a49fd50851fa3713990ba3430153b91 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,8 +6,6 @@ variables: JUGGLER_VERSION: "v4.1.0" NPDET_VERSION: "v1.1.0" EICD_VERSION: "v1.1.0" - DETECTOR_VERSION: "canyonlands-v1.1" - IP6_VERSION: "v0.6.0" AFTERBURNER_VERSION: "v0.1.0" ## Spack github version @@ -235,6 +233,7 @@ jug_xl:default: variables: BUILD_IMAGE: "jug_xl" script: + - cp detectors.yaml containers/jug - docker build -t ${CI_REGISTRY_IMAGE}/${BUILD_IMAGE}:${INTERNAL_TAG} -f containers/jug/xl.Dockerfile --build-arg INTERNAL_TAG=${INTERNAL_TAG} @@ -242,8 +241,6 @@ jug_xl:default: --build-arg NPDET_VERSION=${NPDET_VERSION} --build-arg EICD_VERSION=${EICD_VERSION} --build-arg AFTERBURNER_VERSION=${AFTERBURNER_VERSION} - --build-arg DETECTOR_VERSION=${DETECTOR_VERSION} - --build-arg IP6_VERSION=${IP6_VERSION} --build-arg JUG_VERSION=${INTERNAL_TAG}-$(git rev-parse HEAD) containers/jug - !reference [.build, script] @@ -263,10 +260,12 @@ jug_xl:nightly: variables: BUILD_IMAGE: "jug_xl" script: + - cp detectors.yaml containers/jug - docker build -t ${CI_REGISTRY_IMAGE}/${BUILD_IMAGE}:${NIGHTLY_TAG} -f containers/jug/xl.Dockerfile --build-arg INTERNAL_TAG=${INTERNAL_TAG} --build-arg JUG_VERSION=nightly-$(date +%Y-%m-%d_%H-%M-%S)-${INTERNAL_TAG}-$(git rev-parse HEAD) + --build-arg NIGHTLY=1 containers/jug - | PUSH_FLAG="" diff --git a/containers/jug/setup_detectors.py b/containers/jug/setup_detectors.py new file mode 100755 index 0000000000000000000000000000000000000000..b732766d9cefb636a5ef2bcd460d4075dfdd56c5 --- /dev/null +++ b/containers/jug/setup_detectors.py @@ -0,0 +1,161 @@ +#!/usr/bin/env python3 + +import os +import yaml +import argparse + +DETECTOR_REPO_GROUP = 'https://eicweb.phy.anl.gov/EIC/detectors' +DETECTOR_ENV =''' +#!/bin/sh +export DETECTOR={detector} +export DETECTOR_PATH={data_prefix} +export DETECTOR_VERSION={version} +export BEAMLINE_CONFIG={ip} +export BEAMLINE_CONFIG_VERSION={ip_version} +## note: we will phase out the JUGGLER_* flavor of variables in the future +export JUGGLER_DETECTOR=$DETECTOR +export JUGGLER_DETECTOR_VERSION=$DETECTOR_VERSION +export JUGGLER_DETECTOR_PATH=$DETECTOR_PATH +export JUGGLER_BEAMLINE_CONFIG=$BEAMLINE_CONFIG +export JUGGLER_BEAMLINE_CONFIG_VERSION=$BEAMLINE_CONFIG_VERSION +export JUGGLER_INSTALL_PREFIX=/usr/local''' + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument( + '-p', '--prefix', + dest='prefix', + default='/opt/detector', + help='Main detector prefix') + parser.add_argument( + '-c', '--config', + dest='config', + default='detectors.yaml', + help='Detector configuration file') + parser.add_argument('--nightly', action='store_true', dest='nightly', + help='Store nightly snapshot (will also be set as default)') + args = parser.parse_args() + + print('Installing detector configuration from {} to {}'.format(args.config, + args.prefix)) + if args.nightly: + print(' --> Nightly requested, will default configurations to nightly') + else: + print(' --> Regular run, nightly snapshot will NOT be installed') + + print(' --> Loading detector configuration') + default_found = False + default_detector = '' + default_version = '' + with open(args.config) as f: + data=yaml.load(f, Loader=yaml.FullLoader) + detectors=data['detectors'] + for det in detectors: + if not args.nightly and 'nightly' in detectors[det]: + del detectors[det]['nightly'] + for branch in detectors[det]: + cfg = detectors[det][branch] + default_str = '' + if not default_found: + if args.nightly and branch == 'nightly': + default_str = ' (default)' + default_detector = det + default_version = 'nightly' + default_found = True + elif not args.nightly and 'default' in cfg and cfg['default']: + default_str = ' (default)' + default_detector = det + default_version = cfg['version'] + default_found = True + print(' - {}: {}{}'.format(det, branch, default_str)) + print(' --> Building and installing detector/ip libraries') + for det in detectors: + if not args.nightly and 'nightly' in detectors[det]: + del detectors[det]['nightly'] + for branch in detectors[det]: + cfg = detectors[det][branch] + ip = cfg['ip'] + version = cfg['version'] if branch != 'nightly' else 'nightly' + print(' - {}-{} and {}-{}'.format( + det, cfg['version'], ip['config'], ip['version'])) + prefix = '{}/{}-{}'.format(args.prefix, det, version) + data_dir = '{}/share/{}'.format(prefix, det) + ## build and install detector and IP code + for (proj, vers) in [(det, cfg['version']), (ip['config'], ip['version'])]: + ## clone/build/install detector libraries + cmd = ['rm -rf /tmp/build /tmp/det', + '&&', + 'git clone --depth 1 -b {version} {repo_grp}/{detector}.git /tmp/det'.format( + version=vers, + repo_grp=DETECTOR_REPO_GROUP, + detector=proj), + '&&', + 'cmake -B /tmp/build -S /tmp/det -DCMAKE_CXX_STANDARD=17', + '-DCMAKE_INSTALL_PREFIX={prefix}'.format(prefix=prefix), + '&&', + 'cmake --build /tmp/build -j$((($(nproc)/4)+1)) -- install'] + print(' '.join(cmd)) + os.system(' '.join(cmd)) + ## write version info to jug_info if available + if os.path.exists('/etc/jug_info'): + cmd = ['cd /tmp/det', + '&&', + 'echo " - {detector}/{branch}: {version}-$(git rev-parse HEAD)"'.format( + detector=proj, + branch=branch, + version=cfg['version']), + '>> /etc/jug_info', + '&&', + 'cd -'] + print(' '.join(cmd)) + os.system(' '.join(cmd)) + ## also copy over IP configuration to the detector + if os.path.exists('/tmp/det/{ip}'.format(ip=ip['config'])): + cmd = 'cp -r /tmp/det/{ip} {data_dir}'.format( + ip=ip['config'], data_dir=data_dir) + print(cmd) + os.system(cmd) + ## cleanup + cmd = 'rm -rf /tmp/det /tmp/build' + print(cmd) + os.system(cmd) + # be resilient against failures + if os.path.exists(prefix): + ## create a shortcut for the prefix if desired + if branch != version: + cmd = 'rm -rf {shortcut} && ln -sf {prefix} {shortcut}'.format( + prefix=prefix, + shortcut='{}/{}-{}'.format(args.prefix, det, branch)) + print(cmd) + os.system(cmd) + ## write an environment file for this detector + with open('{prefix}/setup.sh'.format(prefix=prefix), 'w') as f: + print(DETECTOR_ENV.format( + detector=det, + data_prefix=data_dir, + version=cfg['version'], + ip=ip['config'], + ip_version=ip['version']), + file=f) + print(' --> Symlinking default detector for backward compatibility') + full_prefix='{}/{}-{}'.format(args.prefix, default_detector, default_version) + cmd = ['ln -sf {full_prefix}/share {short_prefix}', + '&&', + 'ln -sf {full_prefix}/lib {short_prefix}', + '&&', + 'ln -sf {full_prefix}/setup.sh {short_prefix}'] + print(' '.join(cmd)) + os.system(' '.join(cmd).format(full_prefix=full_prefix, short_prefix=args.prefix)) + + print('All done!') + + + + + + + + + + + diff --git a/containers/jug/xl.Dockerfile b/containers/jug/xl.Dockerfile index ca49d6520c5639c4364a0f71fae6cdac3897ab60..8f4948f313b9cafac05b1ea7a0c43a982820e329 100644 --- a/containers/jug/xl.Dockerfile +++ b/containers/jug/xl.Dockerfile @@ -20,6 +20,8 @@ ARG AFTERBURNER_VERSION=main ARG JUG_VERSION=1 ADD ${EICWEB}/18/repository/tree?ref=${NPDET_VERSION} /tmp/18.json +ADD ${EICWEB}/373/repository/tree?ref=${EICD_VERSION} /tmp/373.json +ADD ${EICWEB}/492/repository/tree?ref=${AFTERBURNER_VERSION} /tmp/492.json RUN cd /tmp \ && echo " - jug_xl: ${JUG_VERSION}" >> /etc/jug_info \ && echo "INSTALLING NPDET" \ @@ -30,10 +32,8 @@ RUN cd /tmp && pushd NPDet \ && echo " - NPDet: ${NPDET_VERSION}-$(git rev-parse HEAD)">> /etc/jug_info \ && popd \ - && rm -rf build NPDet - -ADD ${EICWEB}/373/repository/tree?ref=${EICD_VERSION} /tmp/373.json -RUN cd /tmp \ + && rm -rf build NPDet \ + && cd /tmp \ && echo "INSTALLING EICD" \ && git clone -b ${EICD_VERSION} --depth 1 \ https://eicweb.phy.anl.gov/EIC/eicd.git \ @@ -42,7 +42,19 @@ RUN cd /tmp && pushd eicd \ && echo " - EICD: ${EICD_VERSION}-$(git rev-parse HEAD)">> /etc/jug_info \ && popd \ - && rm -rf build eicd + && rm -rf build eicd \ + && cd /tmp \ + && echo "INSTALLING AFTERBURNER" \ + && git clone -b ${AFTERBURNER_VERSION} --depth 1 \ + https://eicweb.phy.anl.gov/monte_carlo/afterburner.git \ + && cmake -B build -S afterburner/cpp -DCMAKE_INSTALL_PREFIX=/usr/local \ + -DCMAKE_CXX_STANDARD=17 \ + && cmake --build build -j12 --target all -- install \ + && pushd afterburner \ + && echo " - afterburner: ${AFTERBURNER_VERSION}-$(git rev-parse HEAD)" \ + >> jug_info \ + && popd \ + && rm -rf build afterburner ADD ${EICWEB}/369/repository/tree?ref=${JUGGLER_VERSION} /tmp/369.json RUN cd /tmp \ @@ -58,70 +70,17 @@ RUN cd /tmp && popd \ && rm -rf build juggler -ADD ${EICWEB}/492/repository/tree?ref=${AFTERBURNER_VERSION} /tmp/492.json -RUN cd /tmp \ - && echo "INSTALLING AFTERBURNER" \ - && git clone -b ${AFTERBURNER_VERSION} --depth 1 \ - https://eicweb.phy.anl.gov/monte_carlo/afterburner.git \ - && cmake -B build -S afterburner/cpp -DCMAKE_INSTALL_PREFIX=/usr/local \ - -DCMAKE_CXX_STANDARD=17 \ - && cmake --build build -j12 --target all -- install \ - && pushd afterburner \ - && echo " - afterburner: ${AFTERBURNER_VERSION}-$(git rev-parse HEAD)" \ - >> jug_info \ - && popd \ - && rm -rf build afterburner - ## also install detector/ip geometries into opt -## FIXME: need to add proper compact file install directly to the athena detector -## build -ARG DETECTOR_VERSION="master" -ARG IP6_VERSION="master" -ADD ${EICWEB}/473/repository/tree?ref=${DETECTOR_VERSION} /tmp/473.json -ADD ${EICWEB}/452/repository/tree?ref=${IP6_VERSION} /tmp/452.json +ARG NIGHTLY='' +ADD ${EICWEB}/473/repository/tree?ref=master /tmp/473.json +ADD ${EICWEB}/452/repository/tree?ref=master /tmp/452.json +COPY setup_detectors.py /tmp +COPY detectors.yaml /tmp RUN cd /tmp \ - && DETECTOR_PREFIX=/opt/detector \ - && DETECTOR_DATA=$DETECTOR_PREFIX/share/athena \ - && mkdir -p /opt/detector/share/athena \ - && echo "INSTALLING ATHENA" \ - && git clone -b ${DETECTOR_VERSION} \ - https://eicweb.phy.anl.gov/EIC/detectors/athena.git \ - && cmake -B build -S athena -DCMAKE_CXX_STANDARD=17 \ - -DCMAKE_INSTALL_PREFIX=${DETECTOR_PREFIX} \ - && cmake --build build -j12 -- install \ - && pushd athena \ - && echo " - Athena: ${DETECTOR_VERSION}-$(git rev-parse HEAD)" \ - >> /etc/jug_info \ - && popd \ - && rm -rf build athena \ - && echo "INSTALLING IP6 GEOMETRY" \ - && git clone -b ${IP6_VERSION} \ - https://eicweb.phy.anl.gov/EIC/detectors/ip6.git \ - && cmake -B build -S ip6 -DCMAKE_CXX_STANDARD=17 \ - -DCMAKE_INSTALL_PREFIX=${DETECTOR_PREFIX} \ - && cmake --build build -j12 -- install \ - && cp -r ip6/ip6 \ - ${DETECTOR_DATA} \ - && pushd ip6 \ - && echo " - IP6: ${IP6_VERSION}-$(git rev-parse HEAD)" \ - >> /etc/jug_info \ - && popd \ - && rm -rf build ip6 \ - && echo "ADDING SETUP SCRIPT" \ - && echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/detector/lib' \ - > /opt/detector/setup.sh \ - && echo "export JUGGLER_DETECTOR=athena" \ - >> /opt/detector/setup.sh \ - && echo "export DETECTOR_PATH=/opt/detector/share/athena" \ - >> /opt/detector/setup.sh \ - && echo "export DETECTOR_VERSION=${DETECTOR_VERSION}" \ - >> /opt/detector/setup.sh \ - && echo "export JUGGLER_DETECTOR_VERSION=${DETECTOR_VERSION}" \ - >> /opt/detector/setup.sh \ - && echo "BEAMLINE_CONFIG=ip6" \ - && echo "BEAMLINE_CONFIG_VERSION=${IP6_VERSION}" \ - && echo "export JUGGLER_INSTALL_PREFIX=/usr/local" \ - >> /opt/detector/setup.sh + && [ "z$NIGHTLY" = "z1" ] && NIGHTLY_FLAG="--nightly" || NIGHTLY_FLAG="" \ + && /tmp/setup_detectors.py --prefix /opt/detector --config /tmp/detectors.yaml \ + $NIGHTLY_FLAG \ + && rm /tmp/setup_detectors.py ## Install benchmarks into the container @@ -131,27 +90,24 @@ ARG BENCHMARK_REC_VERSION="master" ARG BENCHMARK_PHY_VERSION="master" ADD ${EICWEB}/458/repository/tree?ref=${BENCHMARK_COM_VERSION} /tmp/485.json +ADD ${EICWEB}/399/repository/tree?ref=${BENCHMARK_DET_VERSION} /tmp/399.json +ADD ${EICWEB}/408/repository/tree?ref=${BENCHMARK_REC_VERSION} /tmp/408.json +ADD ${EICWEB}/400/repository/tree?ref=${BENCHMARK_PHY_VERSION} /tmp/400.json RUN mkdir -p /opt/benchmarks \ && cd /opt/benchmarks \ && git clone -b ${BENCHMARK_COM_VERSION} --depth 1 \ - https://eicweb.phy.anl.gov/EIC/benchmarks/common_bench.git - -ADD ${EICWEB}/399/repository/tree?ref=${BENCHMARK_DET_VERSION} /tmp/399.json -RUN mkdir -p /opt/benchmarks \ + https://eicweb.phy.anl.gov/EIC/benchmarks/common_bench.git \ + && mkdir -p /opt/benchmarks \ && cd /opt/benchmarks \ && git clone -b ${BENCHMARK_DET_VERSION} --depth 1 \ https://eicweb.phy.anl.gov/EIC/benchmarks/detector_benchmarks.git \ - && ln -sf ../common_bench detector_benchmarks/.local - -ADD ${EICWEB}/408/repository/tree?ref=${BENCHMARK_REC_VERSION} /tmp/408.json -RUN mkdir -p /opt/benchmarks \ + && ln -sf ../common_bench detector_benchmarks/.local \ + && mkdir -p /opt/benchmarks \ && cd /opt/benchmarks \ && git clone -b ${BENCHMARK_REC_VERSION} --depth 1 \ https://eicweb.phy.anl.gov/EIC/benchmarks/reconstruction_benchmarks.git \ - && ln -sf ../common_bench reconstruction_benchmarks/.local - -ADD ${EICWEB}/400/repository/tree?ref=${BENCHMARK_PHY_VERSION} /tmp/400.json -RUN mkdir -p /opt/benchmarks \ + && ln -sf ../common_bench reconstruction_benchmarks/.local \ + && mkdir -p /opt/benchmarks \ && cd /opt/benchmarks \ && git clone -b ${BENCHMARK_PHY_VERSION} --depth 1 \ https://eicweb.phy.anl.gov/EIC/benchmarks/physics_benchmarks.git \ @@ -165,25 +121,22 @@ ARG CAMPAIGNS_CONDOR_VERSION="main" ARG CAMPAIGNS_SLURM_VERSION="main" ADD ${EICWEB}/482/repository/tree?ref=${CAMPAIGNS_SINGLE_VERSION} /tmp/482.json +ADD ${EICWEB}/483/repository/tree?ref=${CAMPAIGNS_HEPMC3_VERSION} /tmp/483.json +ADD ${EICWEB}/484/repository/tree?ref=${CAMPAIGNS_CONDOR_VERSION} /tmp/484.json +ADD ${EICWEB}/485/repository/tree?ref=${CAMPAIGNS_SLURM_VERSION} /tmp/485.json RUN mkdir -p /opt/campaigns \ && cd /opt/campaigns \ && git clone -b ${CAMPAIGNS_SINGLE_VERSION} --depth 1 \ - https://eicweb.phy.anl.gov/EIC/campaigns/single.git - -ADD ${EICWEB}/483/repository/tree?ref=${CAMPAIGNS_HEPMC3_VERSION} /tmp/483.json -RUN mkdir -p /opt/campaigns \ + https://eicweb.phy.anl.gov/EIC/campaigns/single.git \ + && mkdir -p /opt/campaigns \ && cd /opt/campaigns \ && git clone -b ${CAMPAIGNS_HEPMC3_VERSION} --depth 1 \ - https://eicweb.phy.anl.gov/EIC/campaigns/hepmc3.git - -ADD ${EICWEB}/484/repository/tree?ref=${CAMPAIGNS_CONDOR_VERSION} /tmp/484.json -RUN mkdir -p /opt/campaigns \ + https://eicweb.phy.anl.gov/EIC/campaigns/hepmc3.git \ + && mkdir -p /opt/campaigns \ && cd /opt/campaigns \ && git clone -b ${CAMPAIGNS_CONDOR_VERSION} --depth 1 \ - https://eicweb.phy.anl.gov/EIC/campaigns/condor.git - -ADD ${EICWEB}/485/repository/tree?ref=${CAMPAIGNS_SLURM_VERSION} /tmp/485.json -RUN mkdir -p /opt/campaigns \ + https://eicweb.phy.anl.gov/EIC/campaigns/condor.git \ + && mkdir -p /opt/campaigns \ && cd /opt/campaigns \ && git clone -b ${CAMPAIGNS_SLURM_VERSION} --depth 1 \ https://eicweb.phy.anl.gov/EIC/campaigns/slurm.git diff --git a/detectors.yaml b/detectors.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9409ff1313319dfe186fcbb41e0166fc36a5f197 --- /dev/null +++ b/detectors.yaml @@ -0,0 +1,18 @@ +detectors: + athena: + acadia: + version: acadia-v2.1 + ip: + config: ip6 + version: v0.5.2 + canyonlands: + default: true + version: canyonlands-v1.1 + ip: + config: ip6 + version: v0.6.0 + nightly: + version: master + ip: + config: ip6 + version: master