Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
Add environment-agnostic scripts for running ctests and pytests (#128)
Browse files Browse the repository at this point in the history
This PR adds environment-agnostic `run_{ctests,pytests}.sh` scripts, and updates `test_{cpp,python}.sh` to call them.

The `test_{cpp,python}.sh` scripts assume they're running in our CI environment, and they do more than just run the tests.

This PR allows devs and downstream consumers to only run the tests, and skip the unrelated logic in `test_{cpp,python}.sh`.

Authors:
  - Paul Taylor (https://github.com/trxcllnt)
  - Ray Douglass (https://github.com/raydouglass)

Approvers:
  - Jake Awe (https://github.com/AyodeAwe)
  - Bradley Dice (https://github.com/bdice)

URL: #128
  • Loading branch information
trxcllnt authored Mar 4, 2024
1 parent aafd5be commit 0668299
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 32 deletions.
9 changes: 9 additions & 0 deletions ci/run_ctests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# Copyright (c) 2024, NVIDIA CORPORATION.

set -euo pipefail

# Support customizing the ctests' install location
cd "${INSTALL_PREFIX:-${CONDA_PREFIX:-/usr}}/bin/gtests/libwholegraph/"

find . -type f -executable -print0 | xargs -0 -r -t -n1 -P1 sh -c 'exec "$0"';
9 changes: 9 additions & 0 deletions ci/run_pytests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# Copyright (c) 2024, NVIDIA CORPORATION.

set -euo pipefail

# Support invoking run_pytests.sh outside the script directory
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../python/pylibwholegraph/pylibwholegraph/

pytest --cache-clear --forked --import-mode=append "$@" tests
28 changes: 8 additions & 20 deletions ci/test_cpp.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/bin/bash
# Copyright (c) 2022-2023, NVIDIA CORPORATION.
# Copyright (c) 2022-2024, NVIDIA CORPORATION.

set -euo pipefail

# Support invoking test_cpp.sh outside the script directory
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../

. /opt/conda/etc/profile.d/conda.sh

rapids-logger "Generate C++ testing dependencies"
Expand Down Expand Up @@ -32,25 +35,10 @@ rapids-mamba-retry install \

rapids-logger "Check GPU usage"
nvidia-smi
EXITCODE=0
trap "EXITCODE=1" ERR
set +e

# Run libwholegraph tests from libwholegraph-tests package
rapids-logger "Run tests"
INSTALLED_TEST_PATH=${CONDA_PREFIX}/bin/gtests/libwholegraph

for file in "${INSTALLED_TEST_PATH}"/*; do
if [[ -x "$file" ]]; then
rapids-logger "Running: $file"
"$file"
exit_code=$?

if [[ $exit_code -ne 0 ]]; then
echo "Test $file returned a non-zero exit code: $exit_code"
exit $exit_code
fi
fi
done

exit 0
./ci/run_ctests.sh && EXITCODE=$? || EXITCODE=$?

rapids-logger "Test script exiting with value: $EXITCODE"
exit ${EXITCODE}
14 changes: 5 additions & 9 deletions ci/test_python.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/bin/bash
# Copyright (c) 2022-2023, NVIDIA CORPORATION.
# Copyright (c) 2022-2024, NVIDIA CORPORATION.

set -euo pipefail

# Support invoking test_cpp.sh outside the script directory
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../

. /opt/conda/etc/profile.d/conda.sh

ARCH=$(arch)
Expand Down Expand Up @@ -50,16 +53,9 @@ rapids-mamba-retry install \

rapids-logger "Check GPU usage"
nvidia-smi
trap "EXITCODE=1" ERR
set +e

rapids-logger "pytest pylibwholegraph"
PYLIBWHOLEGRAPH_INSTALL_PATH=`python -c 'import os; import pylibwholegraph; print(os.path.dirname(pylibwholegraph.__file__))'`
PYTEST_PATH=${PYLIBWHOLEGRAPH_INSTALL_PATH}/tests
pytest \
--cache-clear \
--forked \
${PYTEST_PATH}
./ci/run_pytests.sh && EXITCODE=$? || EXITCODE=$?

echo "test_python is exiting with value: ${EXITCODE}"
exit ${EXITCODE}
6 changes: 3 additions & 3 deletions ci/test_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ rapids-logger "Installing PyTorch"
rapids-retry python -m pip install --pre torch --index-url ${INDEX_URL}
rapids-retry python -m pip install pytest pytest-forked numpy
rapids-logger "pytest pylibwholegraph"
PYLIBWHOLEGRAPH_INSTALL_PATH=`python -c 'import os; import pylibwholegraph; print(os.path.dirname(pylibwholegraph.__file__))'`
PYTEST_PATH=${PYLIBWHOLEGRAPH_INSTALL_PATH}/tests
cd python/pylibwholegraph/pylibwholegraph/tests
python -m pytest \
--cache-clear \
--forked \
${PYTEST_PATH}
--import-mode=append \
.
Empty file.
Empty file.
Empty file.
Empty file.

0 comments on commit 0668299

Please sign in to comment.