Updated the run_test.sh script

pull/103/head
kaguillera 2020-09-24 17:19:52 -04:00
parent 303d1472ed
commit f4206abc4b
4 changed files with 155 additions and 42 deletions

View File

@ -69,7 +69,7 @@ jobs:
- "$RENV_PATHS_ROOT" - "$RENV_PATHS_ROOT"
- "$TRAVIS_BUILD_DIR/renv/library" - "$TRAVIS_BUILD_DIR/renv/library"
script: script:
- bash tests/scripts/run_tests.sh - bash tests/scripts/run_tests.sh all test
- stage: deploy - stage: deploy
name: Python 3.7 on Xenial Linux Docker name: Python 3.7 on Xenial Linux Docker
os: linux os: linux

View File

@ -3,55 +3,168 @@
echo Setting up for testing... echo Setting up for testing...
# Uncomment the section below if neccessary to remove old files when testing locally clean_old_data() {
# echo deleting old data...
# rm -rf data/raw/* echo deleting old data...
# rm -rf data/processed/* rm -rf data/processed/*
# rm -rf data/interim/* rm -rf data/interim/*
# rm -rf data/external/test*
# echo Backing up preprocessing...
# cp rules/preprocessing.smk bak
}
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() {
echo Running tests on periodic data produced...
python -m unittest discover tests/scripts/ -v
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
}
run_frequency_test() {
# echo Backing up Testing script...
# cp tests/scripts/test_sensor_features.py test_bak
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
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... echo Copying files...
cp -r tests/data/raw/* data/raw cp -r tests/data/raw/* data/raw
cp tests/data/external/* data/external cp tests/data/external/* data/external
# Uncomment the section below to backup snakemake file when testing locally
# echo Backing up preprocessing...
# cp rules/preprocessing.smk bak
echo Disabling downloading of dataset... echo Disabling downloading of dataset...
sed -e '27,39 s/^/#/' -e 's/rules.download_dataset.output/"data\/raw\/\{pid\}\/\{sensor\}_raw\.csv"/' rules/preprocessing.smk > tmp sed -e '27,39 s/^/#/' -e 's/rules.download_dataset.output/"data\/raw\/\{pid\}\/\{sensor\}_raw\.csv"/' rules/preprocessing.smk > tmp
cp tmp rules/preprocessing.smk mv tmp rules/preprocessing.smk
echo Running RAPIDS Pipeline periodic segment on testdata... echo $#
snakemake --profile tests/settings/periodic/
echo Moving produced data from previous pipeline run ... if [ $# -eq 1 ]
# rm -rf data/raw/* then
mkdir data/processed/features/periodic if [ $1 == '-l' ] || [ $1 == 'test' ]
mv data/processed/features/test* data/processed/features/periodic/ then
rm -rf data/interim/* display_usage
# rm -rf data/external/test* elif [ $1 == 'all' ]
then
echo Running RAPIDS Pipeline frequnecy segment on testdata... run_periodic_pipeline
snakemake --profile tests/settings/frequency/ run_frequency_pipeline
elif [ $1 == 'periodic' ]
echo Moving produced data from previous pipeline run... then
mkdir data/processed/features/frequency run_periodic_pipeline
mv data/processed/features/test* data/processed/features/frequency/ elif [ $1 == 'frequency' ]
then
echo Running tests on periodic data produced... run_frequency_pipeline
python -m unittest discover tests/scripts/ -v else
display_usage
echo Backing up Testing script... fi
cp tests/scripts/test_sensor_features.py test_bak elif [ $# -gt 1 ]
then
echo Re-writing the config file being loaded for testing if [ $1 == '-l' ]
sed -e 's/tests\/settings\/periodic\/testing_config\.yaml/tests\/settings\/frequency\/testing_config\.yaml/' tests/scripts/test_sensor_features.py > test_tmp then
cp test_tmp tests/scripts/test_sensor_features.py clean_old_data
if [ $2 == 'all' ]
echo Running tests on frequency data produced... then
python -m unittest discover tests/scripts/ -v run_periodic_pipeline
run_frequency_pipeline
if [ $# -gt 2 ] && [ $3 == 'test' ]
then
run_periodic_test
run_frequency_test
else
display_usage
fi
elif [ $2 == 'periodic' ]
then
run_periodic_pipeline
if [ $# -gt 2 ] && [ $3 == 'test' ]
then
run_periodic_test
else
display_usage
fi
elif [ $2 == 'frequency' ]
then
run_frequency_pipeline
if [ $# -gt 2 ] && [ $3 == 'test' ]
then
run_frequency_test
else
display_usage
fi
else
display_usage
fi
elif [ $1 == 'all' ]
then
run_periodic_pipeline
run_frequency_pipeline
if [ $2 == 'test' ]
then
run_periodic_test
run_frequency_test
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
mv bak rules/preprocessing.smk
# Uncomment to return snakemake back to the original version when testing locally # Uncomment to return snakemake back to the original version when testing locally
# echo Cleaning up... # echo Cleaning up...
# mv bak rules/preprocessing.smk # mv bak rules/preprocessing.smk

View File

@ -2,4 +2,4 @@ directory: ./
configfile: ./tests/settings/frequency/testing_config.yaml configfile: ./tests/settings/frequency/testing_config.yaml
snakefile: ./tests/Snakefile snakefile: ./tests/Snakefile
cores: 1 cores: 1
forcerun: [join_features_from_providers] forcerun: [compute_day_segments, join_features_from_providers]

View File

@ -2,4 +2,4 @@ directory: ./
configfile: ./tests/settings/periodic/testing_config.yaml configfile: ./tests/settings/periodic/testing_config.yaml
snakefile: ./tests/Snakefile snakefile: ./tests/Snakefile
cores: 1 cores: 1
forcerun: [join_features_from_providers] forcerun: [compute_day_segments, join_features_from_providers]