Skip to content

Commit 078f88f

Browse files
committed
validation bash file
1 parent 59c2c16 commit 078f88f

File tree

5 files changed

+89
-18
lines changed

5 files changed

+89
-18
lines changed

.github/workflows/fitting_check.yml

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
- main
1010

1111
jobs:
12-
run-pyroot:
12+
run-cms-open-data-ttbar-analysis:
1313
runs-on: ubuntu-latest
1414

1515
steps:
@@ -31,29 +31,41 @@ jobs:
3131
run: |
3232
source root/bin/thisroot.sh
3333
cd analyses/cms-open-data-ttbar/
34-
python analysis.py --n-max-files-per-sample 1 --remote-data-prefix='root://eospublic.cern.ch//eos/root-eos/AGC' --validation 1
34+
./validate | tee output.txt
3535
36-
- name: Run validation sequences
36+
- name: Compare histograms validation output with expected
37+
id: histograms
3738
run: |
38-
source root/bin/thisroot.sh
3939
cd analyses/cms-open-data-ttbar/
40-
python validate_histograms.py --histos histograms.root --reference reference/histos_1_file_per_process.json > output_histograms.txt
41-
python reference/fitResults/validate_fit_result.py > output.txt
40+
if grep -q "Test failed: Histograms validation output does not match expected result." output.txt; then
41+
echo "Histograms validation failed."
42+
echo "RESULT_HISTOGRAMS=fail" >> $GITHUB_ENV
43+
else
44+
echo "Histograms validation passed."
45+
echo "RESULT_HISTOGRAMS=pass" >> $GITHUB_ENV
46+
fi
4247
43-
- name: Compare fitResults output with expected
48+
- name: Histograms validation
49+
if: env.RESULT_HISTOGRAMS == 'fail'
50+
run: |
51+
echo "Test failed: Histograms validation output does not match expected result."
52+
exit 1
53+
54+
- name: Run validation sequences for fitResults
55+
id: fitresults
4456
run: |
45-
diff analyses/cms-open-data-ttbar/output.txt .github/workflows/validation/fitResuts_1_file_validation_reference.yml
57+
cd analyses/cms-open-data-ttbar/
58+
if grep -q "Test failed: fitResults validation output does not match expected result." output.txt; then
59+
echo "fitResults validation failed."
60+
echo "RESULT_FITRESULTS=fail" >> $GITHUB_ENV
61+
else
62+
echo "fitResults validation passed."
63+
echo "RESULT_FITRESULTS=pass" >> $GITHUB_ENV
64+
fi
4665
4766
- name: FitResults validation
48-
if: failure() # This step will be executed if the diff command finds differences
67+
if: env.RESULT_FITRESULTS == 'fail'
4968
run: |
5069
echo "Test failed: fitResults validation output does not match expected result."
51-
52-
- name: Compare histograms validation output with expected
53-
run: |
54-
diff analyses/cms-open-data-ttbar/output_histograms.txt .github/workflows/validation/histograms_1_file_validation_reference.yml
55-
56-
- name: Histograms validationw
57-
if: failure() # This step will be executed if the diff command finds differences
58-
run: |
59-
echo "Test failed: Histograms validation output does not match expected result."
70+
exit 1
71+
-19.7 KB
Binary file not shown.
Binary file not shown.
-80.6 KB
Binary file not shown.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
3+
# Check if a number of files is provided as an argument, otherwise default to 1
4+
NUM_FILES=${1:-1}
5+
6+
# Check if input is 1, 5, or 10
7+
if [[ "$NUM_FILES" -eq 1 || "$NUM_FILES" -eq 5 || "$NUM_FILES" -eq 10 ]]; then
8+
echo "Valid NUM_FILES: $NUM_FILES"
9+
else
10+
echo "Error: Invalid input. Please use one of existing values: 1, 5, or 10."
11+
exit 1
12+
fi
13+
14+
# Define the remote data prefix and other paths
15+
REMOTE_DATA_PREFIX='root://eospublic.cern.ch//eos/root-eos/AGC'
16+
HISTOS_FILE="histograms.root"
17+
REFERENCE_HISTOS="reference/histos_${NUM_FILES}_file_per_process.json"
18+
FIT_REFERENCE="../../.github/workflows/validation/fitResuts_${NUM_FILES}_file_validation_reference.yml"
19+
HISTOGRAMS_REFERENCE="../../.github/workflows/validation/histograms_${NUM_FILES}_file_validation_reference.yml"
20+
21+
# Function to check the status of the previous command and exit if failed
22+
check_status() {
23+
if [ $? -ne 0 ]; then
24+
echo "Test failed: $1"
25+
exit 1
26+
fi
27+
}
28+
29+
# Step 1: Run Analysis
30+
echo "Running analysis with ${NUM_FILES} file(s)..."
31+
python analysis.py --n-max-files-per-sample ${NUM_FILES} --remote-data-prefix="${REMOTE_DATA_PREFIX}" --validation 1
32+
check_status "Analysis failed"
33+
34+
# Step 2: Run validation sequences
35+
echo "Running validation sequences..."
36+
python validate_histograms.py --histos "${HISTOS_FILE}" --reference "${REFERENCE_HISTOS}" > output_histograms.txt
37+
check_status "Histogram validation failed"
38+
39+
python reference/fitResults/validate_fit_result.py > output_fit_results.txt
40+
check_status "FitResults validation failed"
41+
42+
# Step 3: Compare fitResults output with expected
43+
echo "Comparing fitResults with expected results..."
44+
diff output_fit_results.txt "${FIT_REFERENCE}"
45+
if [ $? -ne 0 ]; then
46+
echo "Test failed: fitResults validation output does not match expected result."
47+
exit 1
48+
fi
49+
50+
# Step 4: Compare histograms validation output with expected
51+
echo "Comparing histograms validation with expected results..."
52+
diff output_histograms.txt "${HISTOGRAMS_REFERENCE}"
53+
if [ $? -ne 0 ]; then
54+
echo "Test failed: Histograms validation output does not match expected result."
55+
exit 1
56+
fi
57+
58+
echo "All tests passed successfully."
59+

0 commit comments

Comments
 (0)