-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: Event rate CI #40
Open
henry-wallace-phys
wants to merge
65
commits into
develop
Choose a base branch
from
hwallace/feature/event_rate_bot
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 64 commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
99af6f5
Test commit to see if we can find TDR era inputs
d6f6acf
Update event rates yaml
2c2e277
Attempt to mount CVMFS to container
2f65c6b
Shuffles around CVFMs to let the container mount it
d4d3f07
remove T2K command we don't need
8356efa
make -> make install
d5e3fe2
Use EventRates in src not bin
84f3926
Move environment setup
c8592f6
Update baseline error to be 1 rather than -1
8322a0d
Debugging commit as symlink isn't working
945056c
Re-arrange workflow (thanks Prof. Chat GPT)
431eec1
Add ubuntu container as CVMFS runner requires some ubuntu specific in…
c663e61
Second debugging commit, this will build an ubuntu container for use …
858e414
Add more debug info
44578b0
remove debugging info from CI workflow
67518da
more rearranging
4df26c0
Use ubuntu container
a9e2d3d
Properly mount CVMFS (hopefully...)
470f9f3
More playing around with the container
cdf19f5
Docker build->docker run
5933177
More moving of docker options
11349c7
docker build needed directory path
18a49c2
Attempt to neaten workflow to work out why ROOT doesn't mount properly
4f31ada
hyper hack, move everything into the same workflow...
e7e3ea5
Add more instructions to repo, possibly useful to have single script …
012d3d1
Almost there, workflow just needed some more bugs fixed
cec6f2f
Another debug, this will fail to build
4db3ae8
More debugging to work out where the container has put ROOT
ec05737
Another attempt to run this workflow
da3f71e
Workflow now works, removes debugging code
0fe9093
Was overzealous with env paths
ec4e51d
Accidentally broke the yaml...
13df171
Agggh ubuntu
8959254
By default Ubuntu doesnt ues a bash shell, this should fix that
d0135f6
tweaks to dockerfile to (hopefully) use bash
f99011f
Move around shell
ef2b87d
debugging
1961c07
lets try alma9 instead
494af4b
AGHHH
1a718a7
specifies shell
2ada4a7
fix bug in baseline
1bd464e
Remove unecessary root source
d61c906
wrong branch being pulled
3dc1dfc
Event rates now runs BUT uses the wrong oscillator
4b7ed40
Also needed the docker image...
2a7b9cf
Small typo
d91dc81
Attmpt to avoid using CUDA
7d9337e
I'm so dumb, oscillator is set in the configs now
a06d5d9
DEBUG: reduces number of samples briefly
77af813
remove debugging from workflow, set config file back to normal
ab65757
Adds event rates CI and example test result for beam sample
d2c6da1
oops, forgot to actually make it run checks
fd55175
Update the YAML to point to correct folders
c7b00ee
More updates to yaml
78c2f92
Small updates to test code as output format wasnt quite correct
567e9f1
DEBUG: Check files are being linked correctly (sorry for more spam)
c0de0be
Attempt workflow with TDR V1 as V2 files seem to not work with action…
henry-wallace-phys 080220f
More debugging
henry-wallace-phys a81a354
Very dumb bug, didn't remove mkdir from workflow
henry-wallace-phys a9f7da6
Hopefully works, from re-running https://github.com/DUNE/MaCh3_DUNE/a…
e6d0d43
Remove debugging
7881570
Merge branch 'develop' into hwallace/feature/event_rate_bot
henry-wallace-phys f8e990e
Git pointing to wrong branch when CI called on PRs
f1db3cf
Final commit to event rates CI just to make it even more flexible
henry-wallace-phys 6449c06
merge
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
--- | ||
# Check if MaCh3 compiles correctly | ||
|
||
name: Build CI | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: Event Rates Beam | ||
|
||
# To add additional run-time tests add (to matrix) | ||
# - name: <your test> | ||
# test_exe: /test/<your exe> | ||
# test_config: path/to/tconfiguration | ||
# repo_linking_command: ln -sf /path/to/files/ (usually CAFs + splines) | ||
|
||
|
||
on: | ||
pull_request: | ||
branches: [develop] | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- name: Beam Event Rate Validation | ||
test_exe: /test/TestEventRates | ||
test_config: test/test_configs/EventRates_Beam_TEST.yaml | ||
repo_linking_command: | | ||
ln -s \ | ||
/cvmfs/dune.osgstorage.org/pnfs/fnal.gov/usr/dune/persistent/stash/MaCh3/inputs/TDR/v2/DUNE_2021_FD_splines inputs/DUNE_spline_files | ||
ln -s \ | ||
/cvmfs/dune.osgstorage.org/pnfs/fnal.gov/usr/dune/persistent/stash/MaCh3/inputs/TDR/v2/DUNE_2023_FD_CAFs inputs/DUNE_CAF_files | ||
|
||
|
||
|
||
name: Run Test ${{matrix.name}} | ||
|
||
steps: | ||
# Set up CVMFS | ||
- name: Set up CVMFS | ||
uses: cvmfs-contrib/github-action-cvmfs@v4 | ||
|
||
|
||
# Checkout the repository code | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Log in to GitHub Container Registry | ||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
|
||
- name: start docker container with bind mount cvmfs | ||
run: | | ||
docker build . \ | ||
--file doc/MaCh3DockerFiles/Alma9/Dockerfile \ | ||
--tag ghcr.io/dune/mach3:alma9test \ | ||
--build-arg MACH3_DUNE_VERSION=${{ github.head_ref }} \ | ||
--build-arg MACH3_DUNE_BUILD_ARGS="-DCUDAProb3Linear_ENABLED=ON -DMACH3_BUILD_TESTS=ON" | ||
|
||
|
||
# Run event rates | ||
- name: Run Event Rates | ||
uses: addnab/docker-run-action@v3 | ||
with: | ||
image: ghcr.io/dune/mach3:alma9test | ||
shell: bash | ||
options: -v /cvmfs:/cvmfs:shared | ||
run: | | ||
${{matrix.repo_linking_command}} | ||
source ./bin/setup.MaCh3.sh | ||
source ./bin/setup.NuOscillator.sh | ||
source ./bin/setup.MaCh3DUNE.sh | ||
.${{matrix.test_exe}} ${{matrix.test_config}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
add_custom_target(MaCh3DUNETests) | ||
|
||
# Wet up utils lib | ||
set(HEADERS | ||
Comparison.h | ||
) | ||
|
||
add_library( | ||
MaCh3DuneTestUtils SHARED | ||
Comparison.cpp | ||
) | ||
|
||
set_target_properties(MaCh3DuneTestUtils PROPERTIES | ||
PUBLIC_HEADER "${HEADERS}" | ||
EXPORT_NAME MaCh3DuneTestUtils | ||
) | ||
|
||
target_link_libraries(MaCh3DuneTestUtils PUBLIC MaCh3::All MaCh3DUNECompilerOptions) | ||
|
||
target_include_directories(MaCh3DuneTestUtils PUBLIC | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/../> | ||
$<INSTALL_INTERFACE:include>) | ||
|
||
install(TARGETS MaCh3DuneTestUtils | ||
EXPORT mach3dune-targets | ||
LIBRARY DESTINATION lib/ | ||
PUBLIC_HEADER DESTINATION include/MaCh3DuneTestUtils) | ||
|
||
add_library(MACH3DUNE::MaCh3DuneTestUtils ALIAS MaCh3DuneTestUtils) | ||
|
||
|
||
# Now we set up test apps | ||
foreach(app | ||
TestEventRates | ||
) | ||
|
||
add_executable(${app} ${app}.cpp) | ||
target_link_libraries(${app} MaCh3DUNE::All MaCh3DuneTestUtils Minuit) | ||
add_dependencies(MaCh3DUNEApps ${app}) | ||
install(TARGETS ${app} DESTINATION test) | ||
|
||
endforeach(app) | ||
|
||
|
||
# Now copy remaining stuff | ||
install(DIRECTORY test_configs DESTINATION test) | ||
install(DIRECTORY test_results DESTINATION test) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// MaCh3 spline includes | ||
#include "tests/Comparison.h" | ||
|
||
bool CompareTwoFiles(const std::string& File1, const std::string& File2) { | ||
std::ifstream file1(File1); | ||
std::ifstream file2(File2); | ||
|
||
// Check if both files opened successfully | ||
if (!file1.is_open()) { | ||
MACH3LOG_ERROR("Error opening file: {}", File1); | ||
throw MaCh3Exception(__FILE__ , __LINE__ ); | ||
} | ||
if (!file2.is_open()) { | ||
MACH3LOG_ERROR("Error opening file: {}", File2); | ||
throw MaCh3Exception(__FILE__ , __LINE__ ); | ||
} | ||
|
||
std::string line1, line2; | ||
bool sameFiles = true; | ||
int lineNumber = 1; | ||
|
||
// Read and compare line by line | ||
while (std::getline(file1, line1) && std::getline(file2, line2)) { | ||
if (line1 != line2) { | ||
MACH3LOG_WARN("Difference found on line {}:", lineNumber); | ||
MACH3LOG_WARN("File1: {}", line1); | ||
MACH3LOG_WARN("File2: {}", line2); | ||
sameFiles = false; | ||
} | ||
++lineNumber; | ||
} | ||
|
||
// Check if one file has extra lines | ||
while (std::getline(file1, line1)) { | ||
MACH3LOG_WARN("Extra line in {} on line {}: {}", File1, lineNumber, line1); | ||
sameFiles = false; | ||
++lineNumber; | ||
} | ||
while (std::getline(file2, line2)) { | ||
MACH3LOG_WARN("Extra line in {} on line {}: {}", File2, lineNumber, line2); | ||
sameFiles = false; | ||
++lineNumber; | ||
} | ||
|
||
// Close files | ||
file1.close(); | ||
file2.close(); | ||
|
||
return sameFiles; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#pragma once | ||
|
||
#include "manager/manager.h" | ||
|
||
bool CompareTwoFiles(const std::string& File1, const std::string& File2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
#include <iostream> | ||
#include <chrono> | ||
#include <iomanip> | ||
#include <vector> | ||
#include <string> | ||
|
||
#include <TH1D.h> | ||
#include <THStack.h> | ||
#include <TStyle.h> | ||
#include <TCanvas.h> | ||
#include <TRint.h> | ||
#include <TLegend.h> | ||
#include <TColor.h> | ||
#include <TMath.h> | ||
|
||
#include "samplePDFDUNE/MaCh3DUNEFactory.h" | ||
#include "samplePDFDUNE/StructsDUNE.h" | ||
#include "tests/Comparison.h" | ||
|
||
|
||
int main(int argc, char * argv[]) { | ||
MaCh3Utils::MaCh3Usage(argc, argv); | ||
|
||
auto fitMan = std::unique_ptr<manager>(new manager(argv[1])); | ||
|
||
bool skip_checks = false; | ||
|
||
if (CheckNodeExists(fitMan->raw(), "General", "Tests", "SkipChecks") ){ | ||
skip_checks = fitMan->raw()["General"]["Tests"]["SkipChecks"].as<bool>(); | ||
} | ||
|
||
//############################################################################################################################### | ||
//Create samplePDFFD objects | ||
|
||
covarianceXsec* xsec = nullptr; | ||
covarianceOsc* osc = nullptr; | ||
|
||
std::vector<samplePDFFDBase*> DUNEPdfs; | ||
MakeMaCh3DuneInstance(fitMan.get(), DUNEPdfs, xsec, osc); | ||
|
||
|
||
//############################################################################################################################### | ||
//Perform reweight and print total integral | ||
//############################################################################################################################### | ||
//Make oscillation channel breakdown | ||
// Initialise output file | ||
std::ofstream outFile("TestNewSampleOut.txt"); | ||
|
||
|
||
for(auto Sample : DUNEPdfs) { | ||
int nOscChannels = Sample->getNMCSamples(); | ||
for (int iOscChan=0;iOscChan<nOscChannels;iOscChan++) { | ||
std::vector< std::vector<double> > SelectionVec; | ||
|
||
std::vector<double> SelecChannel(3); | ||
SelecChannel[0] = Sample->ReturnKinematicParameterFromString("OscChannel"); | ||
SelecChannel[1] = iOscChan; | ||
SelecChannel[2] = iOscChan+1; | ||
SelectionVec.push_back(SelecChannel); | ||
|
||
TH1* Hist = Sample->get1DVarHist("TrueNeutrinoEnergy",SelectionVec); | ||
outFile<<Sample->GetName()<<" "<<Sample->getFlavourName(iOscChan)<<" "<<Hist->Integral()<<" "; | ||
} | ||
|
||
TH1* Hist = Sample->get1DVarHist("TrueNeutrinoEnergy"); | ||
outFile<<Sample->GetName()<<" "<<Hist->Integral()<<" "; | ||
} | ||
|
||
//############################################################################################################################### | ||
//Make interaction channel breakdown | ||
|
||
for(auto Sample : DUNEPdfs) { | ||
int nModeChannels = kMaCh3_nModes; | ||
for (int iModeChan=0;iModeChan<nModeChannels;iModeChan++) { | ||
std::vector< std::vector<double> > SelectionVec; | ||
|
||
std::vector<double> SelecChannel(3); | ||
SelecChannel[0] = Sample->ReturnKinematicParameterFromString("Mode"); | ||
SelecChannel[1] = iModeChan; | ||
SelecChannel[2] = iModeChan+1; | ||
SelectionVec.push_back(SelecChannel); | ||
|
||
TH1* Hist = Sample->get1DVarHist("TrueNeutrinoEnergy",SelectionVec); | ||
outFile<<Sample->GetName()<<" "<<MaCh3mode_ToDUNEString((MaCh3_Mode)iModeChan)<<" "<<Hist->Integral()<<" "; | ||
} | ||
|
||
TH1* Hist = Sample->get1DVarHist("TrueNeutrinoEnergy"); | ||
outFile<<Sample->GetName()<<" "<<Hist->Integral()<<" "; | ||
} | ||
|
||
// Do you want to gener | ||
if(skip_checks){ | ||
return 0; | ||
} | ||
|
||
std::string results_file = fitMan->raw()["General"]["Tests"]["TestResultsFile"].as<std::string>(); | ||
|
||
|
||
// Okay now we've written we need to compare | ||
bool TheSame = CompareTwoFiles(results_file, "TestNewSampleOut.txt"); | ||
|
||
// Are we right? | ||
if(!TheSame) { | ||
MACH3LOG_CRITICAL("Different event rates detected"); | ||
throw MaCh3Exception(__FILE__ , __LINE__ ); | ||
} else { | ||
MACH3LOG_INFO("Event rates match"); | ||
} | ||
|
||
return 0; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can remove the entire tests directory if you use the github workflow text comparison script that I use in NuOscillator: https://github.com/dbarrow257/NuOscillator/blob/01bee0dfcee824524b81147853faea6be4a77f65/.github/workflows/CIValidations2.yml#L100-L106
Then you don't need the Comparison.{cpp,h} stuff. We should also force event rate CI checks, not allow them to be skipable