diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6999aa94b6d0ef9b9372bb2d7e891616b964f7d8..daa6d9a2fdbe45d9dbb9f29f921741ab485784d6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -423,8 +423,6 @@ jug_xl:default: --build-arg BASE_IMAGE=${BASE_IMAGE} --build-arg INTERNAL_TAG=${INTERNAL_TAG}-default --build-arg JUG_VERSION=${EXPORT_TAG}-$(git rev-parse HEAD) - --build-arg jobs=${JOBS} - --build-context detectors=. --provenance false containers/jug 2>&1 | tee build.log @@ -503,8 +501,6 @@ jug_xl:nightly: --build-arg INTERNAL_TAG=${INTERNAL_TAG}-nightly --build-arg JUG_VERSION=${EXPORT_TAG}-nightly-$(git rev-parse HEAD)-$(date +%Y-%m-%d_%H-%M-%S) --build-arg NIGHTLY=1 - --build-arg jobs=${JOBS} - --build-context detectors=. --provenance false containers/jug 2>&1 | tee build.log diff --git a/containers/jug/dev.Dockerfile b/containers/jug/dev.Dockerfile index b66e7b4586e89e8f0bae3d5d70fd99ee7ac23f3c..5ec5f4b9aa82050db6e9e424c7d8dda20e49829e 100644 --- a/containers/jug/dev.Dockerfile +++ b/containers/jug/dev.Dockerfile @@ -212,16 +212,16 @@ ccache --show-stats ccache --zero-stats EOF -## Create views at /usr/local and /opt/detectors +## Create views at /usr/local and /opt/detector RUN <<EOF set -e rm -r /usr/local sed -i -e '/view: false/d' ${SPACK_ENV}/spack.yaml cat /opt/spack-environment/view.yaml >> ${SPACK_ENV}/spack.yaml spack -e ${SPACK_ENV} env view regenerate /usr/local -spack -e ${SPACK_ENV} env view regenerate /opt/detectors -if [[ -n $NIGHTLY && -f /opt/detectors/epic ]] ; then - ln -s /opt/detectors/epic-main/setup.sh /opt/detectors/setup.sh +spack -e ${SPACK_ENV} env view regenerate /opt/detector +if [[ -n $NIGHTLY && -f /opt/detector/epic ]] ; then + ln -s /opt/detector/epic-main/setup.sh /opt/detector/setup.sh fi EOF @@ -314,7 +314,7 @@ COPY --from=staging /opt/spack /opt/spack COPY --from=staging /opt/spack-environment /opt/spack-environment COPY --from=staging /opt/software /opt/software COPY --from=staging /usr/._local /usr/._local -COPY --from=staging /opt/._detectors /opt/._detectors +COPY --from=staging /opt/._detector /opt/._detector COPY --from=staging /etc/profile.d /etc/profile.d COPY --from=staging /etc/jug_info /etc/jug_info COPY --from=staging /etc/eic-env.sh /etc/eic-env.sh @@ -328,13 +328,13 @@ SHELL ["docker-shell"] ## ensure /usr/local is the view, not a symlink RUN <<EOF set -ex -rm -rf /usr/local /opt/detectors +rm -rf /usr/local /opt/detector LOCAL_PREFIX_PATH=$(realpath $(ls /usr/._local/ | tail -n1)) mv /usr/._local/${LOCAL_PREFIX_PATH} /usr/local ln -s /usr/local /usr/._local/${LOCAL_PREFIX_PATH} -DETECTORS_PREFIX_PATH=$(realpath $(ls /opt/._detectors/ | tail -n1)) -mv /opt/._detectors/${DETECTORS_PREFIX_PATH} /opt/detectors -ln -s /opt/detectors /opt/._detectors/${DETECTORS_PREFIX_PATH} +DETECTOR_PREFIX_PATH=$(realpath $(ls /opt/._detector/ | tail -n1)) +mv /opt/._detector/${DETECTOR_PREFIX_PATH} /opt/detector +ln -s /opt/detector /opt/._detector/${DETECTOR_PREFIX_PATH} EOF ## set ROOT TFile forward compatibility diff --git a/containers/jug/setup_detectors.py b/containers/jug/setup_detectors.py deleted file mode 100755 index 12737f77192d0ed42982eb2bf29e36905d65a98d..0000000000000000000000000000000000000000 --- a/containers/jug/setup_detectors.py +++ /dev/null @@ -1,205 +0,0 @@ -#!/usr/bin/env python3 - -import os -import sys -import yaml -import argparse -import subprocess -from datetime import datetime - -DETECTOR_REPO_GROUP = 'https://github.com/eic' -DETECTOR_ENV =''' -#!/bin/sh -export DETECTOR={detector} -export DETECTOR_PATH={data_prefix} -export DETECTOR_CONFIG={detector} -export DETECTOR_VERSION={version} - -## Export detector libraries -export LD_LIBRARY_PATH={prefix}/lib${{LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}} - -## modify PS1 for this detector version -export PS1="${{PS1:-}}" -export PS1="{branch}${{PS1_SIGIL}}>${{PS1#*>}}" -unset branch -''' - -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 libraries') - process_list = [] - 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] - version = cfg['version'] if branch != 'nightly' else 'nightly' - prefix = '{}/{}-{}'.format(args.prefix, det, version) - data_dir = '{}/share/{}'.format(prefix, det) - ## build and install - print(' - {}-{}'.format(det, cfg['version'])) - ## cleanup - cmd = [f'rm -rf /tmp/build-{version} /tmp/det-{version}'] - print(' '.join(cmd)) - subprocess.check_call(' '.join(cmd), shell=True) - ## clone - cmd = [ - 'git clone --depth 1 -b {branch} {repo_grp}/{detector}.git /tmp/det-{version}'.format( - branch=cfg['version'], - repo_grp=DETECTOR_REPO_GROUP, - detector=det, - version=version) - ] - print(' '.join(cmd)) - subprocess.check_call(' '.join(cmd), shell=True) - ## patches - if cfg.get('patches'): - for patch in cfg['patches']: - cmd = [f'curl -L {patch} | patch -p1 -d/tmp/det-{version}'] - print(' '.join(cmd)) - subprocess.check_call(' '.join(cmd), shell=True) - ## build - cxxflags = '' - if 'CXXFLAGS' in os.environ: - cxxflags = os.environ['CXXFLAGS'] - if cfg.get('cxxflags'): - cxxflags = cfg['cxxflags'] - cmd = [ - f'cmake -B /tmp/build-{version} -S /tmp/det-{version} -DCMAKE_CXX_STANDARD=17', - f'-DCMAKE_CXX_FLAGS="-Wno-psabi {cxxflags}"', - f'-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache', - f'-DCMAKE_INSTALL_PREFIX={prefix}' - ] - print(' '.join(cmd)) - subprocess.check_call(' '.join(cmd), shell=True) - ## install - cmd = [ - f'cmake --build /tmp/build-{version} -j$(($(($(nproc)/4))+1)) -- install' - ] - print(' '.join(cmd)) - subprocess.check_output(' '.join(cmd), shell=True) - ## write version info to jug_info if available - if os.path.exists('/etc/jug_info'): - cmd = [f'cd /tmp/det-{version}', - '&&', - 'echo " - {detector}/{branch}: {version}-$(git rev-parse HEAD)"'.format( - detector=det, - branch=branch, - version=cfg['version']), - '>> /etc/jug_info', - '&&', - 'cd -'] - print(' '.join(cmd)) - subprocess.check_call(' '.join(cmd), shell=True) - ## cleanup - cmd = f'rm -rf /tmp/det-{version} /tmp/build-{version}' - print(cmd) - subprocess.check_call(cmd, shell=True) - # 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) - subprocess.check_call(cmd, shell=True) - ## write an environment file for this detector - with open('{prefix}/setup.sh'.format(prefix=prefix), 'w') as f: - print(DETECTOR_ENV.format( - prefix=prefix, - detector=det, - data_prefix=data_dir, - version=cfg['version'], - branch=branch), - file=f) - - ## run once inside global prefix to initialize artifacts in /opt/detectors - # os.environ['DETECTOR_PATH'] = args.prefix - # cmd = f'cd {args.prefix} && source {prefix}/setup.sh && ddsim --compactFile {prefix}/share/{det}/{det}.xml --printLevel DEBUG -G -N1' - # print(cmd) - # process_list.append(subprocess.Popen(cmd, shell=True, executable='/bin/bash', stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) - - ## run once inside specific prefix to initialize artifacts in $DETECTOR_PATH - os.environ['DETECTOR_PATH'] = args.prefix - cmd = f'cd {prefix}/share/{det} && source {prefix}/setup.sh && ddsim --compactFile {prefix}/share/{det}/{det}.xml --printLevel DEBUG -G -N1' - print(cmd) - process_list.append(subprocess.Popen(cmd, shell=True, executable='/bin/bash', stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) - - while len(process_list) > 0: - now = datetime.now() - current_time = now.strftime("%H:%M:%S") - print("{} processes running... ({})".format(len(process_list), current_time)) - (out, err) = process_list[-1].communicate() - if process_list[-1].wait() != 0: - print(process_list[-1].args) - if out is not None: - print("stdout:") - print(out.decode()) - if err is not None: - print("stderr:") - print(err.decode()) - sys.exit(1) - process_list.pop() - - if not default_found and not args.nightly: - # Skip symlinking if no defaults present and its not a nightly build - pass - else: - 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)) - subprocess.check_call(' '.join(cmd).format(full_prefix=full_prefix, short_prefix=args.prefix), shell=True) - - print('All done!') diff --git a/containers/jug/xl.Dockerfile b/containers/jug/xl.Dockerfile index b445e63679164dd31c543174d4312e749fd02386..178bcde89905110b79ec3808efd8b0dc07c69686 100644 --- a/containers/jug/xl.Dockerfile +++ b/containers/jug/xl.Dockerfile @@ -10,32 +10,8 @@ ARG INTERNAL_TAG="testing" FROM ${DOCKER_REGISTRY}${BASE_IMAGE}:${INTERNAL_TAG} ARG TARGETPLATFORM -ARG EICWEB="https://eicweb.phy.anl.gov/api/v4/projects" -ARG jobs=1 - ## version will automatically bust cache for nightly, as it includes ## the date ARG JUG_VERSION=1 RUN echo " - jug_xl: ${JUG_VERSION}" >> /etc/jug_info - -## also install detector/ip geometries into opt -ARG NIGHTLY='' -## cache bust when updated repositories -# - just master on eicweb (FIXME too narrow) -ADD ${EICWEB}/473/repository/tree?ref=master /tmp/473.json -ADD ${EICWEB}/452/repository/tree?ref=master /tmp/452.json -# - all branches for ip6 and epic on github -ADD https://api.github.com/repos/eic/ip6 /tmp/ip6.json -ADD https://api.github.com/repos/eic/epic /tmp/epic.json -COPY setup_detectors.py /tmp -COPY --from=detectors detectors.yaml /tmp -RUN --mount=type=cache,target=/ccache/,sharing=locked,id=${TARGETPLATFORM} <<EOF -set -e -cd /tmp -export CCACHE_DIR=/ccache -[ "z$NIGHTLY" = "z1" ] && NIGHTLY_FLAG="--nightly" || NIGHTLY_FLAG="" -/tmp/setup_detectors.py --prefix /opt/detector --config /tmp/detectors.yaml $NIGHTLY_FLAG -ccache --show-stats -rm /tmp/setup_detectors.py -EOF diff --git a/detectors.yaml b/detectors.yaml deleted file mode 100644 index c03a3b5c0a6095dc808d064a06917d9fe4d3d715..0000000000000000000000000000000000000000 --- a/detectors.yaml +++ /dev/null @@ -1,26 +0,0 @@ -# Only retain last 6 months of epic geometry versions -detectors: - epic: - nightly: - default: true - version: main - main: - version: main - 23.10.0: - version: 23.10.0 - 23.11.0: - version: 23.11.0 - 23.12.0: - version: 23.12.0 - 24.02.0: - version: 24.02.0 - 24.02.1: - version: 24.02.1 - 24.03.0: - version: 24.03.0 - 24.03.1: - version: 24.03.1 - 24.04.0: - version: 24.04.0 - 24.05.0: - version: 24.05.0 \ No newline at end of file diff --git a/spack-environment/view.yaml b/spack-environment/view.yaml index d794096d883d7dabf9dff9469520c7d63284b5cb..fb5d3ea5ff0d23d7e5574974ac53878fd67b1ecc 100644 --- a/spack-environment/view.yaml +++ b/spack-environment/view.yaml @@ -4,7 +4,7 @@ exclude: [epic] link_type: symlink detectors: - root: /opt/detectors + root: /opt/detector select: [epic] projections: all: '{name}-{version}'