Skip to content

Commit

Permalink
Merge pull request #89 from johodges/dev
Browse files Browse the repository at this point in the history
Fix verification cases to updated framework
  • Loading branch information
johodges authored Aug 31, 2023
2 parents 2e88029 + 8b24847 commit eef5eb1
Show file tree
Hide file tree
Showing 17 changed files with 947 additions and 90 deletions.
72 changes: 45 additions & 27 deletions .github/workflows/github-actions-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ jobs:
run: sudo apt install qgis qgis-plugin-grass
- name: Check out repository code
uses: actions/checkout@v3
- name: Checkout submodules
run: git submodule update --init --recursive
- run: echo "The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "The workflow is now ready to test your code on the runner."
- name: Configure plugin in qgis
Expand All @@ -86,46 +88,62 @@ jobs:
run: |
Xvfb :$display_port -fp /usr/share/X11/fonts/misc -screen 0 1280x1024x24 &
echo "setting up graphics environment (pausing $PAUSE s)"
- name: Run Verification
run: |
cd verification
source /home/runner/FDS/FDS6/bin/FDS6VARS.sh
bash headless_verify.sh
- name: Download baseline results
run: |
cd /home/runner/work/qgis2fds
git clone https://github.com/firetools/qgis2fds.figures.git
cp qgis2fds.figures/baseline/*/*.png qgis2fds.figures/baseline/
- name: Calculating image differences
#- name: Setup upterm session
# uses: lhotari/action-upterm@v1
- name: Run Verification
run: |
cd verification
mkdir -p tests/test_out
mkdir -p tests/test_diff
mkdir -p tests/test_err
cp tests/*/output/*.png tests/test_out/
bash compare_images.sh
source /home/runner/FDS/FDS6/bin/FDS6VARS.sh
bash run.sh
#- name: Calculating image differences
# run: |
# cd verification
# mkdir -p tests/test_out
# mkdir -p tests/test_diff
# mkdir -p tests/test_err
# cp tests/*/output/*.png tests/test_out/
# bash compare_images.sh
#- name: Setup upterm session
# uses: lhotari/action-upterm@v1
- name: Push results to release
run: |
cp verification/tests/*/output/*.fds verification/tests/test_out/
cp verification/tests/*/output/*.bingeom verification/tests/test_out/
cd verification/tests
tar -cvzf ubuntu.tar.gz test_out
gh release upload verify-${{ github.ref_name }} ubuntu.tar.gz --clobber
find . -name "*.png" -o -name "*.fds" -o -name "*.bingeom" -o -name "*.ini" -o -name "*.ssf" -o -name "*.smv" > tarnames.txt
tar -cvf ../ubuntu.tar.gz -T tarnames.txt
gh release upload verify-${{ github.ref_name }} ../ubuntu.tar.gz --clobber
# gh release delete verify-${{ github.ref_name }} -y --cleanup-tag
# gh release create -n "verify ${{ github.ref_name }} branch" verify-${{ github.ref_name }} ubuntu.tar.gz
# gh release create ${{ github.ref }}-${{ runner.os }} data_out.tar.gz
- name: List files in the repository
shell: bash
- name: Check for errors
run: |
ls ${{ github.workspace }}/verification/tests/*/output/
NUMBER_OF_ERR_FILES=$(ls verification/tests/test_err/ -1 | wc -l)
echo "NUMBER_OF_ERR_FILES=$NUMBER_OF_ERR_FILES" >> "$GITHUB_ENV"
cd verification/logs
cat log.txt
if grep "err" log.txt; then
echo "Errors present in log file"
exit 1
fi
if grep "Err" log.txt; then
echo "Errors present in log file"
exit 1
fi
#- name: List files in the repository
# shell: bash
# run: |
# ls ${{ github.workspace }}/verification/tests/*/output/
# NUMBER_OF_ERR_FILES=$(ls verification/tests/test_err/ -1 | wc -l)
# echo "NUMBER_OF_ERR_FILES=$NUMBER_OF_ERR_FILES" >> "$GITHUB_ENV"
#- name: Setup upterm session
# uses: lhotari/action-upterm@v1
- name: Check coverage tolerance
if: ${{ env.NUMBER_OF_ERR_FILES > 0.0 }}
uses: actions/github-script@v3
with:
script: |
core.setFailed('Rendered images out of tolerance')
#- name: Check coverage tolerance
# if: ${{ env.NUMBER_OF_ERR_FILES > 0.0 }}
# uses: actions/github-script@v3
# with:
# script: |
# core.setFailed('Rendered images out of tolerance')
- run: echo "This job's status is ${{ job.status }}."
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "verification/tests/firemodels_cad"]
path = verification/tests/firemodels_cad
url = https://github.com/firemodels/cad
2 changes: 1 addition & 1 deletion lang/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def get(cls, algo, parameters, context, feedback, project):
value = algo.parameterAsDouble(parameters, cls.name, context)
project.writeEntryDouble("qgis2fds", cls.name, value)
else:
value = None
value = cls.default
project.writeEntry("qgis2fds", cls.name, None)
feedback.setProgressText(f"{cls.label}: {value}")
return value
Expand Down
46 changes: 46 additions & 0 deletions verification/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Configure locations
LOG_FILE="$(pwd)/logs/log.txt"
QGISFIGURES_DIR="$(pwd)/../../qgis2fds.figures"
DIFF_DIR="$(pwd)/diff/"

# Check if figure repo exists
if ! test -d $QGISFIGURES_DIR; then
echo "***Error $QGISFIGURES_DIR directory not found"
exit 1
fi

# Delete previous log file if it exists
if test -e $LOG_FILE; then
rm $LOG_FILE
fi

# Make output directories if they do not exist
if ! test -d $DIFF_DIR; then
mkdir $DIFF_DIR
fi

cd tests/golden_gate/scripts
bash test_geom.sh
bash test_geom_min.sh
bash test_obst.sh
bash test_obst_min.sh
cd ../../..
cd tests/cern_meyrin/scripts
bash test_geom.sh
bash test_obst.sh
cd ../../..
cd tests/fds_case_studies/scripts
bash test_chimney_tops_2.sh
#find . -name "*.png" -o -name "*.fds" -o -name "*.bingeom" | tar -cf ../output.tar.gz -T -

cd ../../../logs
cat log.txt
if grep "err" log.txt; then
echo "Errors present in log file"
exit 1
fi

if grep "Err" log.txt; then
echo "Errors present in log file"
exit 1
fi
26 changes: 9 additions & 17 deletions verification/scripts/compare_images.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
#!/usr/bin/env bash

#BASE_DIR=$1
#NEW_DIR=$2
#DIFF_DIR=$3
#ERROR_DIR=$4
#TOLERANCE=$5
BASE_DIR=$1
NEW_DIR=$2
DIFF_DIR=$3
CHID=$4
TOLERANCE=$5

BASE_DIR=../../qgis2fds.figures/baseline
NEW_DIR=tests/test_out
DIFF_DIR=tests/test_diff
ERROR_DIR=tests/test_err
TOLERANCE=0.025
METRIC=rmse

file_list=$DIFF_DIR/file_list

for f in $NEW_DIR/*.png; do
for f in $NEW_DIR/$CHID*.png; do
base=`basename $f`
echo "checking $base..."
blur_base=blur_$base
Expand Down Expand Up @@ -55,22 +50,19 @@ for f in $NEW_DIR/*.png; do
if [[ "$diff" != "0" ]] && [[ ! $diff == *"e"* ]]; then
iftest=`echo "${diff} > ${TOLERANCE}" | bc`
if [ 1 -eq $iftest ]; then
echo "***$FYI: The image $base has changed. $METRIC error=$diff > $TOLERANCE"
echo "***$FYI: The image $base has changed. $METRIC =$diff > $TOLERANCE"
touch $diff_file_changed
IMAGE_ERRORS=$((IMAGE_ERRORS + 1))
# cp $base $ERROR_SUBDIR/.
cp $f $ERROR_DIR/.
else
echo "PASSED: The image $base has not changed. $METRIC error=$diff <= $TOLERANCE"
echo "PASSED: The image $base has not changed. $METRIC =$diff <= $TOLERANCE"
fi
fi
if [[ "$diff" != "0" ]]; then
DIFFS=$((DIFFS + 1))
fi
fi
if [[ ! -e $from_file ]]; then
echo "***$FYI: The base image $from_file does not exist."
echo "***: The base image $from_file does not exist."
echo " Copy $to_file to the fig repo"
cp $f $ERROR_DIR/.
fi
done
104 changes: 104 additions & 0 deletions verification/tests/cern_meyrin/scripts/test_geom.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/usr/bin/env bash

# Get case name
ABSOLUTE_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")"
IFS='/'
read -a strarr <<< $ABSOLUTE_PATH
CASEDIRNAME=${strarr[-3]}
IFS=""

# Get CHID
cd ../QGIS
CHID=$(basename "$0" ".sh")

# Configure parameters
BASE_DIR="$(pwd)/../../../../../qgis2fds.figures/tests/$CASEDIRNAME/FDS/"
NEW_DIR="$(pwd)/../FDS/"
DIFF_DIR="$(pwd)/../../../diff/"
LOG_FILE="$(pwd)/../../../logs/log.txt"
TOLERANCE=0.025

# Make output directories if they do not exist
if ! test -d $DIFF_DIR; then
mkdir $DIFF_DIR
fi

# Clean
rm -f $NEW_DIR/$CHID* # does not rm .gitignore

# Run QGIS

qgis_process run 'NIST FDS:Export FDS case' \
--project_path="$CASEDIRNAME.qgs" \
--distance_units=meters \
--area_units=m2 \
--ellipsoid=EPSG:7019 \
--chid="$CHID" \
--fds_path='../FDS' \
--extent_layer='layers/Extent.gpkg' \
--pixel_size=1 \
--dem_layer='layers/dem_layer.tif' \
--tex_pixel_size=0.5 \
--nmesh=4 \
--cell_size=0.5 \
--t_begin=0 \
--t_end=0 \
--text_filepath='' \
--export_obst=false

# Run FDS

cd ../FDS

cat << EOF > "$CHID.ini"
VIEWPOINT5
0 -4 3
0.500000 -1.533945 0.092708 1.000000 2
0.000000 0.000000 90.000000 0
0.500000 0.452000 0.092708
-33.000000 32.000000
1.000000 0.000000 0.000000 0.000000
0.000000 1.000000 0.000000 0.000000
0.000000 0.000000 1.000000 0.000000
0.000000 0.000000 0.000000 1.000000
0 0 0 0 0 0 0
-62.159824 -56.685352 429.114441 63.090176 56.540646 463.304108
iso
EOF

cat << EOF > "$CHID.ssf"
SETVIEWPOINT
ZMAX
RENDERDOUBLEONCE
SETVIEWPOINT
ZMIN
RENDERDOUBLEONCE
SETVIEWPOINT
YMAX
RENDERDOUBLEONCE
SETVIEWPOINT
YMIN
RENDERDOUBLEONCE
SETVIEWPOINT
XMAX
RENDERDOUBLEONCE
SETVIEWPOINT
XMIN
RENDERDOUBLEONCE
SETVIEWPOINT
iso
RENDERDOUBLEONCE
EOF

fds "$CHID.fds"
smokeview -runscript "$CHID"

# Compare images with baseline FIXME
bash ../../../scripts/compare_images.sh $BASE_DIR $NEW_DIR $DIFF_DIR $CHID 0.025 2>&1 | tee -a $LOG_FILE

Loading

0 comments on commit eef5eb1

Please sign in to comment.