Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pycbc_test_suite to be able to run from anywhere within the git repo #4774

Merged
merged 4 commits into from
Aug 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions tools/pycbc_test_suite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ echo -e "\\n>> [`date`] Python Major Version:" $PYTHON_VERSION
PYTHON_MINOR_VERSION=`python -c 'import sys; print(sys.version_info.minor)'`
echo -e "\\n>> [`date`] Python Minor Version:" $PYTHON_MINOR_VERSION

# This will work from anywhere within the pycbc directory
PYCBC_BASE_DIR=`git rev-parse --show-toplevel`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are problems if we assume git access in certain circumstances (e.g. it will make it hard to integrate into conda's testing if we want to improve that). Can we get this without that?

I think one can do this because the script can know what directly it exists in, no?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess a clarification is needed. Do you want to be able to move the test script to any folder or to run the test script from a different folder? I guess my suggestion wouldn't solve the former.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think run from any folder - the git problem raised makes sense, so I will look at that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will work now


LOG_FILE=$(mktemp -t pycbc-test-log.XXXXXXXXXX)

RESULT=0

if [ "$PYCBC_TEST_TYPE" = "unittest" ] || [ -z ${PYCBC_TEST_TYPE+x} ]; then
for prog in `find test -name '*.py' -print | egrep -v '(long|lalsim|test_waveform)'`
for prog in `find $PYCBC_BASE_DIR/test -name '*.py' -print | egrep -v '(long|lalsim|test_waveform)'`
do
echo -e ">> [`date`] running unit test for $prog"
prog_short=`echo $prog | rev | cut -d"/" -f1 | rev`
echo -e ">> [`date`] running unit test for $prog_short"
python $prog &> $LOG_FILE
if test $? -ne 0 ; then
RESULT=1
Expand Down Expand Up @@ -61,7 +65,7 @@ fi

if [ "$PYCBC_TEST_TYPE" = "search" ] || [ -z ${PYCBC_TEST_TYPE+x} ]; then
# run pycbc inspiral test
pushd examples/inspiral
pushd $PYCBC_BASE_DIR/examples/inspiral
bash -e run.sh
if test $? -ne 0 ; then
RESULT=1
Expand All @@ -73,7 +77,7 @@ if [ "$PYCBC_TEST_TYPE" = "search" ] || [ -z ${PYCBC_TEST_TYPE+x} ]; then
popd

# run a quick bank placement example
pushd examples/tmpltbank
pushd $PYCBC_BASE_DIR/examples/tmpltbank
bash -e testNonspin2.sh
if test $? -ne 0 ; then
RESULT=1
Expand All @@ -88,7 +92,7 @@ if [ "$PYCBC_TEST_TYPE" = "search" ] || [ -z ${PYCBC_TEST_TYPE+x} ]; then
if ((${PYTHON_MINOR_VERSION} > 7)); then
# ligo.skymap is only supporting python3.8+, and older releases are
# broken by a new release of python-ligo-lw
pushd examples/live
pushd $PYCBC_BASE_DIR/examples/live
bash -e run.sh
if test $? -ne 0 ; then
RESULT=1
Expand All @@ -101,7 +105,7 @@ if [ "$PYCBC_TEST_TYPE" = "search" ] || [ -z ${PYCBC_TEST_TYPE+x} ]; then
fi

# run pycbc_multi_inspiral (PyGRB) test
pushd examples/multi_inspiral
pushd $PYCBC_BASE_DIR/examples/multi_inspiral
bash -e run.sh
if test $? -ne 0 ; then
RESULT=1
Expand All @@ -116,7 +120,7 @@ fi
if [ "$PYCBC_TEST_TYPE" = "inference" ] || [ -z ${PYCBC_TEST_TYPE+x} ]; then
# Run Inference Scripts
## Run inference on 2D-normal analytic likelihood function
pushd examples/inference/analytic-normal2d
pushd $PYCBC_BASE_DIR/examples/inference/analytic-normal2d
bash -e run.sh
if test $? -ne 0 ; then
RESULT=1
Expand All @@ -129,7 +133,7 @@ if [ "$PYCBC_TEST_TYPE" = "inference" ] || [ -z ${PYCBC_TEST_TYPE+x} ]; then

## Run inference on BBH example; this will also run
## a test of create_injections
pushd examples/inference/bbh-injection
pushd $PYCBC_BASE_DIR/examples/inference/bbh-injection
bash -e make_injection.sh
if test $? -ne 0 ; then
RESULT=1
Expand All @@ -150,7 +154,7 @@ if [ "$PYCBC_TEST_TYPE" = "inference" ] || [ -z ${PYCBC_TEST_TYPE+x} ]; then
popd

## Run inference on GW150914 data
pushd examples/inference/gw150914
pushd $PYCBC_BASE_DIR/examples/inference/gw150914
bash -e run_test.sh
if test $? -ne 0 ; then
RESULT=1
Expand All @@ -162,7 +166,7 @@ if [ "$PYCBC_TEST_TYPE" = "inference" ] || [ -z ${PYCBC_TEST_TYPE+x} ]; then
popd

## Run inference using single template model
pushd examples/inference/single
pushd $PYCBC_BASE_DIR/examples/inference/single
bash -e get.sh
bash -e run.sh
if test $? -ne 0 ; then
Expand All @@ -175,7 +179,7 @@ if [ "$PYCBC_TEST_TYPE" = "inference" ] || [ -z ${PYCBC_TEST_TYPE+x} ]; then
popd

## Run inference using relative model
pushd examples/inference/relative
pushd $PYCBC_BASE_DIR/examples/inference/relative
bash -e get.sh
bash -e run.sh
if test $? -ne 0 ; then
Expand All @@ -188,7 +192,7 @@ if [ "$PYCBC_TEST_TYPE" = "inference" ] || [ -z ${PYCBC_TEST_TYPE+x} ]; then
popd

## Run inference using the hierarchical model
pushd examples/inference/hierarchical
pushd $PYCBC_BASE_DIR/examples/inference/hierarchical
bash -e run_test.sh
if test $? -ne 0 ; then
RESULT=1
Expand All @@ -200,7 +204,7 @@ if [ "$PYCBC_TEST_TYPE" = "inference" ] || [ -z ${PYCBC_TEST_TYPE+x} ]; then
popd

## Run inference samplers
pushd examples/inference/samplers
pushd $PYCBC_BASE_DIR/examples/inference/samplers
bash -e run.sh
if test $? -ne 0 ; then
RESULT=1
Expand All @@ -215,7 +219,7 @@ if [ "$PYCBC_TEST_TYPE" = "inference" ] || [ -z ${PYCBC_TEST_TYPE+x} ]; then
if ((${PYTHON_MINOR_VERSION} > 7)); then
# ligo.skymap is only supporting python3.8+, and older releases are
# broken by a new release of python-ligo-lw
pushd examples/make_skymap
pushd $PYCBC_BASE_DIR/examples/make_skymap
bash -e simulated_data.sh
if test $? -ne 0 ; then
RESULT=1
Expand All @@ -231,7 +235,7 @@ fi
if [ "$PYCBC_TEST_TYPE" = "docs" ] || [ -z ${PYCBC_TEST_TYPE+x} ]; then
echo -e "\\n>> [`date`] Building documentation"

python setup.py build_gh_pages
python $PYCBC_BASE_DIR/setup.py build_gh_pages
if test $? -ne 0 ; then
echo -e " FAILED!"
echo -e "---------------------------------------------------------"
Expand Down
Loading