Skip to content

Commit a55db7a

Browse files
committed
validation bash file
1 parent 59c2c16 commit a55db7a

File tree

5 files changed

+87
-16
lines changed

5 files changed

+87
-16
lines changed

.github/workflows/fitting_check.yml

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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
35-
36-
- name: Run validation sequences
34+
./validate | tee output.txt
35+
36+
- name: Run validation sequences for fitResults
37+
id: fitresults
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
42-
43-
- name: Compare fitResults output with expected
44-
run: |
45-
diff analyses/cms-open-data-ttbar/output.txt .github/workflows/validation/fitResuts_1_file_validation_reference.yml
40+
if grep -q "Test failed: fitResults validation output does not match expected result." output.txt; then
41+
echo "fitResults validation failed."
42+
echo "RESULT_FITRESULTS=fail" >> $GITHUB_ENV
43+
else
44+
echo "fitResults validation passed."
45+
echo "RESULT_FITRESULTS=pass" >> $GITHUB_ENV
46+
fi
4647
4748
- name: FitResults validation
48-
if: failure() # This step will be executed if the diff command finds differences
49+
if: env.RESULT_FITRESULTS == 'fail'
50+
continue-on-error: true
4951
run: |
5052
echo "Test failed: fitResults validation output does not match expected result."
51-
53+
exit 1
54+
5255
- name: Compare histograms validation output with expected
56+
id: histograms
5357
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+
cd analyses/cms-open-data-ttbar/
59+
if grep -q "Test failed: Histograms validation output does not match expected result." output.txt; then
60+
echo "Histograms validation failed."
61+
echo "RESULT_HISTOGRAMS=fail" >> $GITHUB_ENV
62+
else
63+
echo "Histograms validation passed."
64+
echo "RESULT_HISTOGRAMS=pass" >> $GITHUB_ENV
65+
fi
66+
67+
- name: Histograms validation
68+
if: env.RESULT_HISTOGRAMS == 'fail'
5869
run: |
5970
echo "Test failed: Histograms validation output does not match expected result."
71+
exit 1
-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)