rapids/tests/scripts/run_tests.sh

152 lines
3.9 KiB
Bash
Raw Normal View History

2020-06-05 18:46:36 +02:00
#!/bin/bash
# Commmands necessary to setup and run the tests for RAPIDS
echo Setting up for testing...
2020-09-24 23:19:52 +02:00
clean_old_data() {
2020-06-25 22:32:45 +02:00
2020-09-24 23:19:52 +02:00
echo deleting old data...
rm -rf data/processed/*
rm -rf data/interim/*
2020-09-24 23:50:37 +02:00
echo Backing up preprocessing...
cp rules/preprocessing.smk bak
2020-09-24 23:19:52 +02:00
}
2020-06-25 22:32:45 +02:00
2020-09-24 23:19:52 +02:00
run_periodic_pipeline() {
echo Running RAPIDS Pipeline periodic segment on testdata...
snakemake --profile tests/settings/periodic/
echo Moving produced data from previous pipeline run ...
mkdir data/processed/features/periodic
mv data/processed/features/test* data/processed/features/periodic/
rm -rf data/interim/*
}
run_frequency_pipeline() {
echo Running RAPIDS Pipeline frequency segment on testdata...
snakemake --profile tests/settings/frequency/
echo Moving produced data from previous pipeline run...
mkdir data/processed/features/frequency
mv data/processed/features/test* data/processed/features/frequency/
}
run_periodic_test() {
2020-09-24 23:19:52 +02:00
echo Re-writing the config file being loaded for testing
sed -e 's/tests\/settings\/[a-z]*\/testing_config\.yaml/tests\/settings\/periodic\/testing_config\.yaml/' tests/scripts/test_sensor_features.py > test_tmp
mv test_tmp tests/scripts/test_sensor_features.py
echo Running tests on periodic data produced...
python -m unittest discover tests/scripts/ -v
2020-09-24 23:19:52 +02:00
}
2020-09-24 23:19:52 +02:00
run_frequency_test() {
2020-09-24 23:19:52 +02:00
echo Re-writing the config file being loaded for testing
sed -e 's/tests\/settings\/[a-z]*\/testing_config\.yaml/tests\/settings\/frequency\/testing_config\.yaml/' tests/scripts/test_sensor_features.py > test_tmp
mv test_tmp tests/scripts/test_sensor_features.py
2020-06-25 22:32:45 +02:00
2020-09-24 23:19:52 +02:00
echo Running tests on frequency data produced...
python -m unittest discover tests/scripts/ -v
}
display_usage() {
echo "Usage: run_test.sh [-l] all | periodic | frequency [test]"
}
echo Copying files...
cp -r tests/data/raw/* data/raw
cp -r tests/data/external/* data/external
2020-09-24 23:19:52 +02:00
echo Disabling downloading of dataset...
sed -e '26,51 s/^/#/' -e 's/rules.download_dataset.output/"data\/raw\/\{pid\}\/\{sensor\}_raw\.csv"/' rules/preprocessing.smk > tmp
2020-09-24 23:19:52 +02:00
mv tmp rules/preprocessing.smk
2020-09-24 23:19:52 +02:00
if [ $# -eq 1 ]
then
if [ $1 == '-l' ] || [ $1 == 'test' ]
then
display_usage
elif [ $1 == 'all' ]
then
2020-10-09 17:51:36 +02:00
run_periodic_pipeline && run_frequency_pipeline
2020-09-24 23:19:52 +02:00
elif [ $1 == 'periodic' ]
then
run_periodic_pipeline
elif [ $1 == 'frequency' ]
then
run_frequency_pipeline
else
display_usage
fi
elif [ $# -gt 1 ]
then
if [ $1 == '-l' ]
then
clean_old_data
if [ $2 == 'all' ]
then
2020-10-09 17:51:36 +02:00
run_periodic_pipeline && run_frequency_pipeline
2020-09-24 23:19:52 +02:00
if [ $# -gt 2 ] && [ $3 == 'test' ]
then
run_periodic_test
run_frequency_test
fi
elif [ $2 == 'periodic' ]
then
run_periodic_pipeline
if [ $# -gt 2 ] && [ $3 == 'test' ]
then
run_periodic_test
fi
elif [ $2 == 'frequency' ]
then
run_frequency_pipeline
if [ $# -gt 2 ] && [ $3 == 'test' ]
then
run_frequency_test
fi
else
display_usage
fi
2020-09-24 23:50:37 +02:00
mv bak rules/preprocessing.smk
2020-09-24 23:19:52 +02:00
elif [ $1 == 'all' ]
then
run_periodic_pipeline
run_frequency_pipeline
if [ $2 == 'test' ]
then
2020-10-09 17:51:36 +02:00
run_periodic_test && run_frequency_test
2020-09-24 23:19:52 +02:00
else
display_usage
fi
elif [ $1 == 'periodic' ]
then
run_periodic_pipeline
if [ $2 == 'test' ]
then
run_periodic_test
else
display_usage
fi
elif [ $1 == 'frequency' ]
then
run_frequency_pipeline
if [ $2 == 'test' ]
then
run_frequency_test
else
display_usage
fi
else
display_usage
fi
else
display_usage
fi