diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b344c2..45f4f89 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,6 +50,46 @@ jobs: file: ./coverage.xml flags: unittests + test-ROOT-6_22-Py-3_8: + + runs-on: ubuntu-latest + container: pyhf/pyhf-validation-root-base:root6.22.02-python3.8 + + steps: + - uses: actions/checkout@master + - name: Install utilities + # git init done as the .git directory seems + # to be missing after the checkout + run: | + apt-get -qq -y update + apt-get -qq -y install shellcheck + git init . + - name: Lint with Shellcheck + run: | + shellcheck tests/*.sh + shellcheck scripts/*.sh + - name: Install dependencies + run: | + python -m pip install --upgrade --no-cache-dir pip setuptools wheel + python -m pip install --quiet --no-cache-dir --editable .[complete] + python -m pip list + - name: Test with pytest + run: | + python -m pytest -r sx tests + - name: Generate ROOT workspace from JSON + run: | + bash scripts/JSON_to_workspace.sh \ + sbottom-pallet \ + https://www.hepdata.net/record/resource/1408070?view=true \ + RegionA/BkgOnly.json \ + sbottom_1300_205_60 \ + RegionA/workspace_sbottom_1300_205_60.json + - name: Test workspace comparison + run: | + bash tests/test_suite.sh \ + sbottom-pallet/xml/config/FitConfig_combined_NormalMeasurement_model.root \ + sbottom-pallet/RegionA/workspace_sbottom_1300_205_60.json + docker: runs-on: ubuntu-latest diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e38768b..3a7b5c6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -22,7 +22,7 @@ jobs: password: ${{ secrets.DOCKER_PASSWORD }} repository: pyhf/pyhf-validation dockerfile: docker/Dockerfile - tags: latest,root6.20.00,root6.20.00-python3.7 + tags: latest,root6.22.02,root6.22.02-python3.8 - name: Build and Publish to Registry with Release Tag if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v1 @@ -31,5 +31,5 @@ jobs: password: ${{ secrets.DOCKER_PASSWORD }} repository: pyhf/pyhf-validation dockerfile: docker/Dockerfile - tags: latest,latest-stable,root6.20.00,root6.20.00-python3.7 + tags: latest,latest-stable,root6.22.02,root6.22.02-python3.8 tag_with_ref: true diff --git a/docker/Dockerfile b/docker/Dockerfile index 722d398..d97d4a4 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM pyhf/pyhf-validation-root-base:root6.20.00-python3.7 as base +FROM pyhf/pyhf-validation-root-base:root6.22.02-python3.8 as base FROM base as builder COPY . /code diff --git a/scripts/JSON_to_workspace.sh b/scripts/JSON_to_workspace.sh new file mode 100644 index 0000000..f0b8458 --- /dev/null +++ b/scripts/JSON_to_workspace.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +set -e + +function JSON_to_workspace() { + # 1: the analysis pallet name + # 2: the url of the JSON workspaces + # 3: the background only workspace + # 4: the name of the signal patch + # 5: the patched background + signal workspace + local PALLET_NAME=$1 + local HEPDATA_URL=$2 + local BACKGROUND_ONLY=$3 + local PATCH_NAME=$4 + local JSON_WORKSPACE=$5 + + # Download from HEPData + pyhf contrib download "${HEPDATA_URL}" "${PALLET_NAME}" + + # Create a full signal+background workspace + workspace_dir="${BACKGROUND_ONLY%/*}" + pyhf patchset extract \ + --name "${PATCH_NAME}" \ + --output-file "${PALLET_NAME}/${workspace_dir}/${PATCH_NAME}.json" \ + "${PALLET_NAME}/${workspace_dir}/patchset.json" + jsonpatch \ + "${PALLET_NAME}/${BACKGROUND_ONLY}" \ + "${PALLET_NAME}/${workspace_dir}/${PATCH_NAME}.json" > \ + "${PALLET_NAME}/${JSON_WORKSPACE}" + + # Convert to ROOT + XML + if [[ -d "${PALLET_NAME}/xml" ]]; then + rm -rf "${PALLET_NAME}/xml" + fi + mkdir "${PALLET_NAME}/xml" + pyhf json2xml \ + --output-dir "${PALLET_NAME}/xml" \ + "${PALLET_NAME}/${JSON_WORKSPACE}" + + # Generate ROOT workspace + hist2workspace "${PALLET_NAME}/xml/FitConfig.xml" +} + +function main() { + # 1: the analysis pallet name + # 2: the url of the JSON workspaces + # 3: the background only workspace + # 4: the name of the signal patch + # 5: the patched background + signal workspace + local PALLET_NAME=$1 + local HEPDATA_URL=$2 + local BACKGROUND_ONLY=$3 + local PATCH_NAME=$4 + local JSON_WORKSPACE=$5 + + JSON_to_workspace "${PALLET_NAME}" "${HEPDATA_URL}" "${BACKGROUND_ONLY}" "${PATCH_NAME}" "${JSON_WORKSPACE}" +} + +main "$@" || exit 1 diff --git a/scripts/compare_fitted_nuisance.py b/scripts/compare_fitted_nuisance.py index e59e716..a4c0c83 100644 --- a/scripts/compare_fitted_nuisance.py +++ b/scripts/compare_fitted_nuisance.py @@ -94,7 +94,7 @@ def exhaust_argset(s): pyhf_param = ( param.replace("alpha_", "") .replace("gamma_stat_", "staterror_") - .replace("lumi", "Lumi") + .replace("Lumi", "lumi") .replace("_bin", "") ) diff --git a/scripts/compare_nuisance.py b/scripts/compare_nuisance.py index 06dc43b..7701000 100644 --- a/scripts/compare_nuisance.py +++ b/scripts/compare_nuisance.py @@ -35,8 +35,7 @@ def exhaust_argset(s): pars_root = [ sub.replace("alpha_", "") .replace("gamma_stat_", "staterror_") - .replace("gamma_stat_", "staterror_") - .replace("lumi", "Lumi") + .replace("Lumi", "lumi") .replace("_bin", "") for sub in pars ]