diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6a3e731462bdebaf88852cc63f0a0b4a644dfe71..dffd4618684018308d9eea5872cda1ef817d7496 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,9 @@ image: ${BENCHMARKS_REGISTRY}/${BENCHMARKS_CONTAINER}:${BENCHMARKS_TAG} +variables: + DETECTOR: "epic" + DETECTOR_VERSION: "main" + workflow: rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' @@ -43,26 +47,28 @@ common:variables: echo " CI_PIPELINE_SOURCE = ${CI_PIPELINE_SOURCE}" echo " COMMON_BENCH_VERSION = ${COMMON_BENCH_VERSION}" if [[ "${CI_PIPELINE_SOURCE}" == "push" || "x${CI_PIPELINE_SOURCE}" == "xmerge_request_event" || "$CI_COMMIT_BRANCH" == "master" ]]; then - export COMMON_BENCH_VERSION="${CI_COMMIT_REF_NAME}" - echo "COMMON_BENCH_VERSION = ${CI_COMMIT_REF_NAME}" + export COMMON_BENCH_VERSION=${CI_COMMIT_REF_NAME} echo "COMMON_BENCH_VERSION=${CI_COMMIT_REF_NAME}" >> .env + echo "DETECTOR=${DETECTOR}" >> .env + echo "DETECTOR_VERSION=${DETECTOR_VERSION}" >> .env + echo "COMMON_BENCH_VERSION=${CI_COMMIT_REF_NAME}" fi echo "COMMON_BENCH_VERSION = ${COMMON_BENCH_VERSION}" common:setup: stage: config + needs: ["common:variables"] rules: - if: '$CI_SERVER_HOST == "eicweb.phy.anl.gov"' - needs: ["common:variables"] script: - - git clone -b "${COMMON_BENCH_VERSION}" "${CI_REPOSITORY_URL}" setup + - git clone -b ${CI_COMMIT_REF_NAME} https://eicweb.phy.anl.gov/EIC/benchmarks/common_bench.git setup - source setup/bin/env.sh && ./setup/bin/install_common.sh common:detector: stage: initialize + needs: ["common:setup"] rules: - if: '$CI_SERVER_HOST == "eicweb.phy.anl.gov"' - needs: ["common:setup"] script: - source .local/bin/env.sh && build_detector.sh - bin/mkdir_local_data_link sim_output @@ -81,6 +87,9 @@ detector_benchmarks: strategy: depend parallel: matrix: + - DETECTOR: 'DII' + DETECTOR_VERSION: 'main' + BEAMLINE: 'ip8' - DETECTOR: 'epic' DETECTOR_CONFIG: 'epic_arches' DETECTOR_VERSION: 'main' diff --git a/README.md b/README.md index 06346181c17abac15d58aec2de392374e78e8d39..d0559aab218e95f4c790da5708ad276d899a4279 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,13 @@ ## Overview -Code common to: - - [`detector_benchmarks`](https://eicweb.phy.anl.gov/eic/benchmarks/detector_benchmarks/) - - [`reconstruction_benchmarks`](https://eicweb.phy.anl.gov/eic/benchmarks/reconstruction_benchmarks/) - - [`physics_benchmarks`](https://eicweb.phy.anl.gov/eic/benchmarks/physics_benchmarks/) +This repository aims to provide: +1. A common benchmark reporting library used in: + - [`detector_benchmarks`](https://eicweb.phy.anl.gov/eic/benchmarks/detector_benchmarks/) + - [`reconstruction_benchmarks`](https://eicweb.phy.anl.gov/eic/benchmarks/reconstruction_benchmarks/) + - [`physics_benchmarks`](https://eicweb.phy.anl.gov/eic/benchmarks/physics_benchmarks/) +2. A set of tools to manage CI builds and data workflows in other project repos (such as those above). ## Usage @@ -71,4 +73,38 @@ test1.fail(10) common_bench::write_test({test1, test2}, "test.json"); ~~~~~~~~~~~~~ +## CI builds and data workflow tools + +### Environment Variables + +Here we aim to document a coherent set of environment varialbes to pass between CI jobs **and between pipelines**. +The idea is to write as much generic code as possible, so this can be used by any detector currently being implemented or yet to be defined. + +#### The Important Ones + +| Variable | Meaning and use | Examples | Notes | +| :--- | :--- | :--- | :--- | +| `DETECTOR` | Name of detector and repository | `athena` or `epic` | | +| `DETECTOR_VERSION` | Branch or tagged version to use | A PR branch name automatically generated from issue | Default typically `main` or `master` | +| `BEAMLINE` | Optional, name of beamline/interaction region to build first | `ip6` or `ip8` | Not used if undefined | +| `BEAMLINE_VERSION` | Branch or tagged version to use | Same as | Default typically `main` or `master` | + +#### Build Strategy + +First, let's start with the underlying assumptions: + - A "finished" container image will include a completely furnished detector (or detectors) -- from here, the goals is to run all the benchmarks. + - Development necessitates rebuilding some of the packaged software. Here we need to avoid unintentionally using the container packaged version we want to supplant. + - This problem persists across CI jobs, triggered pipelines, and working locally. + +In the case + + +#### Data Flow: Artifacts Vs dedicated storage + + + + +### For benchmarks + + diff --git a/bin/build_detector.sh b/bin/build_detector.sh index 4b7b6a199e1d4ecc73002708c499c0b254a24eaa..827ea2873f731a47e7574a619fb1b2e263bc605d 100755 --- a/bin/build_detector.sh +++ b/bin/build_detector.sh @@ -20,6 +20,7 @@ if [ -n "${LOCAL_PREFIX}" ] ; then else source ${LOCAL_PREFIX}/bin/env.sh fi +./${LOCAL_PREFIX}/bin/print_env.sh ## ============================================================================= @@ -33,20 +34,24 @@ if [ -d "${DETECTOR}" ]; then echo "cleaning up ${DETECTOR}" mv "${DETECTOR}" "$(mktemp)-${DETECTOR}" fi + echo "Fetching ${DETECTOR}" + +#if [ "${DETECTOR}" == "epic" ] ; then if [ -n "${DETECTOR_DEPLOY_TOKEN_USERNAME:-}" -a -n "${DETECTOR_DEPLOY_TOKEN_PASSWORD:-}" ]; then DEPLOY_TOKEN="${DETECTOR_DEPLOY_TOKEN_USERNAME}:${DETECTOR_DEPLOY_TOKEN_PASSWORD}@" echo "Deploy token for ${DETECTOR_DEPLOY_TOKEN_USERNAME} is masked in the next line." else DEPLOY_TOKEN="" fi + echo "git clone -b ${DETECTOR_VERSION} --depth 1 ${DETECTOR_REPOSITORYURL:-https://eicweb.phy.anl.gov/EIC/detectors/${DETECTOR}.git} ${DETECTOR}" git clone -b ${DETECTOR_VERSION} --depth 1 ${DETECTOR_REPOSITORYURL:-https://${DEPLOY_TOKEN}eicweb.phy.anl.gov/EIC/detectors/${DETECTOR}.git} ${DETECTOR} if [ -f "${DETECTOR}/requirements.txt" ] ; then python -m pip install -r ${DETECTOR}/requirements.txt fi -rm -rf "${DETECTOR}/.git" +rm -rf "${DETECTOR}/.git" popd if [ "${BEAMLINE}" ]; then @@ -57,7 +62,9 @@ if [ "${BEAMLINE}" ]; then echo "cleaning up ${BEAMLINE}" mv "${BEAMLINE}" "$(mktemp)-${BEAMLINE}" fi + echo "Fetching ${BEAMLINE}" + if [ -n "${BEAMLINE_DEPLOY_TOKEN_USERNAME:-}" -a -n "${BEAMLINE_DEPLOY_TOKEN_PASSWORD:-}" ]; then DEPLOY_TOKEN="${BEAMLINE_DEPLOY_TOKEN_USERNAME}:${BEAMLINE_DEPLOY_TOKEN_PASSWORD}@" echo "Deploy token for ${BEAMLINE_DEPLOY_TOKEN_USERNAME} is masked in the next line." @@ -68,14 +75,15 @@ if [ "${BEAMLINE}" ]; then git clone -b ${BEAMLINE_VERSION} --depth 1 ${BEAMLINE_REPOSITORYURL:-https://${DEPLOY_TOKEN}eicweb.phy.anl.gov/EIC/detectors/${BEAMLINE}.git} ${BEAMLINE} [[ "$?" == "0" ]] || exit 1 rm -rf "${BEAMLINE}/.git" - - ln -s -f ${DETECTOR_PREFIX}/${BEAMLINE}/${BEAMLINE} ${DETECTOR_PATH}/${BEAMLINE} - [[ "$?" == "0" ]] || exit 1 popd + #echo "ln -s -f ${BEAMLINE} ${DETECTOR}/${BEAMLINE} " + #ln -s -f ${BEAMLINE} ${DETECTOR}/${BEAMLINE} + #[[ "$?" == "0" ]] || exit 1 + mkdir -p ${DETECTOR_PREFIX}/${BEAMLINE}_build pushd ${DETECTOR_PREFIX}/${BEAMLINE}_build - cmake ${DETECTOR_PREFIX}/${BEAMLINE} -DCMAKE_INSTALL_PREFIX=${LOCAL_PREFIX} -DCMAKE_CXX_STANDARD=17 && make -j$(($(nproc)/4+1)) install || exit 1 + cmake ${DETECTOR_PREFIX}/${BEAMLINE} -DCMAKE_INSTALL_PREFIX=${LOCAL_PREFIX} -DCMAKE_CXX_STANDARD=17 -DCENTRAL_DETECTOR=${DETECTOR} && make -j$(($(nproc)/4+1)) install || exit 1 popd rm -rf ${DETECTOR_PREFIX}/${BEAMLINE}_build @@ -88,7 +96,7 @@ echo "Building and installing the ${DETECTOR} package" mkdir -p ${DETECTOR_PREFIX}/${DETECTOR}_build pushd ${DETECTOR_PREFIX}/${DETECTOR}_build -cmake ${DETECTOR_PATH} -DCMAKE_INSTALL_PREFIX=${LOCAL_PREFIX} -DCMAKE_CXX_STANDARD=17 && make -j$(($(nproc)/4+1)) install || exit 1 +cmake ${DETECTOR_PREFIX}/${DETECTOR} -DCMAKE_INSTALL_PREFIX=${LOCAL_PREFIX} -DCMAKE_CXX_STANDARD=17 && make -j$(($(nproc)/4+1)) install || exit 1 popd rm -rf ${DETECTOR_PREFIX}/${DETECTOR}_build diff --git a/bin/env.sh b/bin/env.sh index 4d3eea1e4b2cc191c37cec837e8fd304f063fa2c..1763a48d9d77872a8b7089aa44ff1cd50b8b7326 100755 --- a/bin/env.sh +++ b/bin/env.sh @@ -33,20 +33,29 @@ echo "Setting up the Physics Benchmarks environment" ## number of events to be analyzed during the benchmark ## Detector package to be used during the benchmark process -if [ ! -n "${DETECTOR}" ] ; then - export DETECTOR="epic" -fi +## If you didn't define DETECTOR already, you have bigger problesm -if [ ! -n "${DETECTOR_CONFIG}" ] ; then - export DETECTOR_CONFIG="${DETECTOR}_full" +if [ ! -n "${DETECTOR}" ] ; then + echo "ERROR: No DETECTOR defined!" + echo " There is no assumed default detector." + echo " Set the environment variable DETECTOR accordingly." + #export DETECTOR="epic" fi +# Optional variable, define it or don't use it +#if [ ! -n "${DETECTOR_CONFIG}" ] ; then +# export DETECTOR_CONFIG="${DETECTOR}_full" +#fi + +# main is the new master if [ ! -n "${DETECTOR_VERSION}" ] ; then export DETECTOR_VERSION="main" fi if [ ! -n "${DETECTOR_REPOSITORYURL}" ] ; then export DETECTOR_REPOSITORYURL="https://eicweb.phy.anl.gov/EIC/detectors/${DETECTOR}.git" + + # This if statement should be removed -- just define the variable upstream. if [ "${DETECTOR}" == "epic" ] ; then export DETECTOR_REPOSITORYURL="https://github.com/eic/${DETECTOR}.git" fi diff --git a/bin/print_env.sh b/bin/print_env.sh index d47bc111118007388da0cd6b80b1cea2ac763dad..5bd38926eb638b6ded9bddc3b02ecd376c59ed2c 100755 --- a/bin/print_env.sh +++ b/bin/print_env.sh @@ -1,19 +1,24 @@ #!/bin/bash -echo "JUGGLER_TAG: ${JUGGLER_TAG}" echo "DETECTOR: ${DETECTOR}" -echo "DETECTOR_CONFIG: ${DETECTOR_CONFIG}" echo "DETECTOR_VERSION: ${DETECTOR_VERSION}" +echo "DETECTOR_CONFIG: ${DETECTOR_CONFIG}" +echo "DETECTOR_PATH : ${DETECTOR_PATH}" +echo "DETECTOR_PREFIX: ${DETECTOR_PREFIX}" +echo " " echo "BEAMLINE: ${BEAMLINE}" echo "BEAMLINE_CONFIG: ${BEAMLINE_CONFIG}" echo "BEAMLINE_VERSION: ${BEAMLINE_VERSION}" -echo "DETECTOR_PREFIX: ${DETECTOR_PREFIX}" -echo "DETECTOR_PATH: ${DETECTOR_PATH}" +echo " " echo "BENCHMARK_N_EVENTS: ${BENCHMARK_N_EVENTS}" echo "BENCHMARK_N_THREADS: ${BENCHMARK_N_THREADS}" echo "BENCHMARK_RNG_SEED: ${BENCHMARK_RNG_SEED}" +echo " " +echo "JUGGLER_TAG: ${JUGGLER_TAG}" echo "JUGGLER_N_EVENTS: ${JUGGLER_N_EVENTS}" echo "JUGGLER_N_THREADS: ${JUGGLER_N_THREADS}" echo "JUGGLER_RNG_SEED: ${JUGGLER_RNG_SEED}" +echo " " echo "LOCAL_PREFIX: ${LOCAL_PREFIX}" echo "LOCAL_DATA_PATH: ${LOCAL_DATA_PATH}" +echo " "