Skip to content

Commit

Permalink
Add shellcheck to pre-commit and fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
gforsyth committed Mar 3, 2025
1 parent c959469 commit afb0bf3
Show file tree
Hide file tree
Showing 15 changed files with 66 additions and 58 deletions.
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,9 @@ repos:
hooks:
- id: rapids-dependency-file-generator
args: ["--clean"]
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck
args: ["--severity=warning"]
files: ^ci/
17 changes: 10 additions & 7 deletions ci/build_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
set -euo pipefail

if [[ "${RAPIDS_CUDA_VERSION}" == "11.8.0" ]]; then
CONDA_CUDA_VERSION="11.8"
DGL_CHANNEL="dglteam/label/th23_cu118"
else
CONDA_CUDA_VERSION="12.1"
DGL_CHANNEL="dglteam/label/th23_cu121"
fi

Expand All @@ -18,9 +16,12 @@ PYTHON_CHANNEL=$(rapids-download-conda-from-s3 python)
rapids-logger "Create test conda environment"
. /opt/conda/etc/profile.d/conda.sh

export RAPIDS_VERSION="$(rapids-version)"
export RAPIDS_VERSION_MAJOR_MINOR="$(rapids-version-major-minor)"
export RAPIDS_VERSION_NUMBER="$RAPIDS_VERSION_MAJOR_MINOR"
RAPIDS_VERSION="$(rapids-version)"
export RAPIDS_VERSION
RAPIDS_VERSION_MAJOR_MINOR="$(rapids-version-major-minor)"
export RAPIDS_VERSION_MAJOR_MINOR
RAPIDS_VERSION_NUMBER="$RAPIDS_VERSION_MAJOR_MINOR"
export RAPIDS_VERSION_NUMBER

rapids-dependency-file-generator \
--output conda \
Expand All @@ -38,12 +39,14 @@ conda activate docs

rapids-print-env

export RAPIDS_DOCS_DIR="$(mktemp -d)"
RAPIDS_DOCS_DIR="$(mktemp -d)"
export RAPIDS_DOCS_DIR

rapids-logger "Build CPP docs"
pushd cpp/doxygen
doxygen Doxyfile
export XML_DIR_LIBCUGRAPH="$(pwd)/xml"
XML_DIR_LIBCUGRAPH="$(pwd)/xml"
export XML_DIR_LIBCUGRAPH
mkdir -p "${RAPIDS_DOCS_DIR}/libcugraph/xml_tar"
tar -czf "${RAPIDS_DOCS_DIR}/libcugraph/xml_tar"/xml.tar.gz -C xml .
popd
Expand Down
3 changes: 2 additions & 1 deletion ci/build_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ rapids-print-env
CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp)

rapids-generate-version > ./VERSION
export RAPIDS_PACKAGE_VERSION=$(head -1 ./VERSION)
RAPIDS_PACKAGE_VERSION=$(head -1 ./VERSION)
export RAPIDS_PACKAGE_VERSION

rapids-logger "Begin py build"

Expand Down
2 changes: 1 addition & 1 deletion ci/build_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package_type=$3
source rapids-configure-sccache
source rapids-date-string

RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})"
RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen "${RAPIDS_CUDA_VERSION}")"

rapids-generate-version > ./VERSION

Expand Down
6 changes: 3 additions & 3 deletions ci/build_wheel_cugraph.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ set -euo pipefail

package_dir="python/cugraph"

RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})"
RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen "${RAPIDS_CUDA_VERSION}")"

# Download the libcugraph and pylibcugraph wheels built in the previous step and make them
# available for pip to find.
LIBCUGRAPH_WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="libcugraph_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 cpp /tmp/libcugraph_dist)
PYLIBCUGRAPH_WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="pylibcugraph_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 python /tmp/pylibcugraph_dist)

cat >> ./constraints.txt <<EOF
libcugraph-${RAPIDS_PY_CUDA_SUFFIX} @ file://$(echo ${LIBCUGRAPH_WHEELHOUSE}/libcugraph_*.whl)
pylibcugraph-${RAPIDS_PY_CUDA_SUFFIX} @ file://$(echo ${PYLIBCUGRAPH_WHEELHOUSE}/pylibcugraph_*.whl)
libcugraph-${RAPIDS_PY_CUDA_SUFFIX} @ file://$(echo "${LIBCUGRAPH_WHEELHOUSE}"/libcugraph_*.whl)
pylibcugraph-${RAPIDS_PY_CUDA_SUFFIX} @ file://$(echo "${PYLIBCUGRAPH_WHEELHOUSE}"/pylibcugraph_*.whl)
EOF

# Using env variable PIP_CONSTRAINT is necessary to ensure the constraints
Expand Down
4 changes: 2 additions & 2 deletions ci/build_wheel_pylibcugraph.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ set -euo pipefail

package_dir="python/pylibcugraph"

RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})"
RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen "${RAPIDS_CUDA_VERSION}")"

# Download the libcugraph wheel built in the previous step and make it
# available for pip to find.
LIBCUGRAPH_WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="libcugraph_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 cpp /tmp/libcugraph_dist)

cat >> ./constraints.txt <<EOF
libcugraph-${RAPIDS_PY_CUDA_SUFFIX} @ file://$(echo ${LIBCUGRAPH_WHEELHOUSE}/libcugraph_*.whl)
libcugraph-${RAPIDS_PY_CUDA_SUFFIX} @ file://$(echo "${LIBCUGRAPH_WHEELHOUSE}"/libcugraph_*.whl)
EOF

# Using env variable PIP_CONSTRAINT is necessary to ensure the constraints
Expand Down
12 changes: 4 additions & 8 deletions ci/release/update-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,18 @@ NEXT_FULL_TAG=$1

# Get current version
CURRENT_TAG=$(git tag --merged HEAD | grep -xE '^v.*' | sort --version-sort | tail -n 1 | tr -d 'v')
CURRENT_MAJOR=$(echo $CURRENT_TAG | awk '{split($0, a, "."); print a[1]}')
CURRENT_MINOR=$(echo $CURRENT_TAG | awk '{split($0, a, "."); print a[2]}')
CURRENT_PATCH=$(echo $CURRENT_TAG | awk '{split($0, a, "."); print a[3]}')
CURRENT_SHORT_TAG=${CURRENT_MAJOR}.${CURRENT_MINOR}

#Get <major>.<minor> for next version
NEXT_MAJOR=$(echo $NEXT_FULL_TAG | awk '{split($0, a, "."); print a[1]}')
NEXT_MINOR=$(echo $NEXT_FULL_TAG | awk '{split($0, a, "."); print a[2]}')
NEXT_MAJOR=$(echo "$NEXT_FULL_TAG" | awk '{split($0, a, "."); print a[1]}')
NEXT_MINOR=$(echo "$NEXT_FULL_TAG" | awk '{split($0, a, "."); print a[2]}')
NEXT_SHORT_TAG=${NEXT_MAJOR}.${NEXT_MINOR}
NEXT_UCXX_SHORT_TAG="$(curl -sL https://version.gpuci.io/rapids/${NEXT_SHORT_TAG})"
NEXT_UCXX_SHORT_TAG="$(curl -sL https://version.gpuci.io/rapids/"${NEXT_SHORT_TAG}")"

echo "Preparing release $CURRENT_TAG => $NEXT_FULL_TAG"

# Inplace sed replace; workaround for Linux and Mac
function sed_runner() {
sed -i.bak ''"$1"'' $2 && rm -f ${2}.bak
sed -i.bak ''"$1"'' "$2" && rm -f "${2}".bak
}

# Centralized version file update
Expand Down
32 changes: 16 additions & 16 deletions ci/test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright (c) 2019-2024, NVIDIA CORPORATION.
# Copyright (c) 2019-2025, NVIDIA CORPORATION.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand All @@ -20,8 +20,8 @@ trap "EXITCODE=1" ERR

NUMARGS=$#
ARGS=$*
THISDIR=$(cd $(dirname $0);pwd)
CUGRAPH_ROOT=$(cd ${THISDIR}/..;pwd)
THISDIR=$(cd "$(dirname "$0")";pwd)
CUGRAPH_ROOT=$(cd "${THISDIR}"/..;pwd)
GTEST_ARGS="--gtest_output=xml:${CUGRAPH_ROOT}/test-results/"
DOWNLOAD_MODE=""
EXITCODE=0
Expand All @@ -30,7 +30,7 @@ export RAPIDS_DATASET_ROOT_DIR=${RAPIDS_DATASET_ROOT_DIR:-${CUGRAPH_ROOT}/datase

# FIXME: consider using getopts for option parsing
function hasArg {
(( ${NUMARGS} != 0 )) && (echo " ${ARGS} " | grep -q " $1 ")
(( NUMARGS != 0 )) && (echo " ${ARGS} " | grep -q " $1 ")
}

# Add options unique to running a "quick" subset of tests here:
Expand All @@ -50,12 +50,12 @@ if hasArg "--skip-download"; then
echo "Using datasets in ${RAPIDS_DATASET_ROOT_DIR}"
else
echo "Download datasets..."
cd ${RAPIDS_DATASET_ROOT_DIR}
cd "${RAPIDS_DATASET_ROOT_DIR}"
bash ./get_test_data.sh ${DOWNLOAD_MODE}
fi

if [[ -z "$PROJECT_FLASH" || "$PROJECT_FLASH" == "0" ]]; then
cd ${CUGRAPH_ROOT}/cpp/build
cd "${CUGRAPH_ROOT}"/cpp/build
fi

# Do not abort the script on error from this point on. This allows all tests to
Expand All @@ -66,16 +66,16 @@ set +e
if hasArg "--run-cpp-tests"; then
echo "C++ gtests for cuGraph (single-GPU only)..."
for gt in "${CONDA_PREFIX}/bin/gtests/libcugraph/"*_TEST; do
test_name=$(basename $gt)
test_name=$(basename "$gt")
echo "Running gtest $test_name"
${gt} ${GTEST_FILTER} ${GTEST_ARGS}
${gt} "${GTEST_FILTER}" "${GTEST_ARGS}"
echo "Ran gtest $test_name : return code was: $?, test script exit code is now: $EXITCODE"
done
# FIXME: the C API tests do not generate XML, so CI systems will not show
# them in the GUI. Failing C API tests will still fail CI though, and the
# output will appear in logs.
for ct in "${CONDA_PREFIX}/bin/gtests/libcugraph_c/"CAPI_*_TEST; do
test_name=$(basename $ct)
test_name=$(basename "$ct")
echo "Running C API test $test_name"
${ct}
echo "Ran C API test $test_name : return code was: $?, test script exit code is now: $EXITCODE"
Expand All @@ -84,24 +84,24 @@ fi

if hasArg "--run-python-tests"; then
echo "Python pytest for pylibcugraph..."
cd ${CUGRAPH_ROOT}/python/pylibcugraph/pylibcugraph
pytest -sv --cache-clear --junitxml=${CUGRAPH_ROOT}/junit-pylibcugraph-pytests.xml --cov-config=.coveragerc --cov=pylibcugraph --cov-report=xml:${WORKSPACE}/python/pylibcugraph/pylibcugraph-coverage.xml --cov-report term --ignore=raft --benchmark-disable
cd "${CUGRAPH_ROOT}"/python/pylibcugraph/pylibcugraph
pytest -sv --cache-clear --junitxml="${CUGRAPH_ROOT}"/junit-pylibcugraph-pytests.xml --cov-config=.coveragerc --cov=pylibcugraph --cov-report=xml:"{WORKSPACE}"/python/pylibcugraph/pylibcugraph-coverage.xml --cov-report term --ignore=raft --benchmark-disable
echo "Ran Python pytest for pylibcugraph : return code was: $?, test script exit code is now: $EXITCODE"

echo "Python pytest for cuGraph (single-GPU only)..."
conda list
cd ${CUGRAPH_ROOT}/python/cugraph/cugraph
pytest -sv -m sg --cache-clear --junitxml=${CUGRAPH_ROOT}/junit-cugraph-pytests.xml --cov-config=.coveragerc --cov=cugraph --cov-report=xml:${WORKSPACE}/python/cugraph/cugraph-coverage.xml --cov-report term --ignore=raft --benchmark-disable
cd "${CUGRAPH_ROOT}"/python/cugraph/cugraph
pytest -sv -m sg --cache-clear --junitxml="${CUGRAPH_ROOT}"/junit-cugraph-pytests.xml --cov-config=.coveragerc --cov=cugraph --cov-report=xml:"{WORKSPACE}"/python/cugraph/cugraph-coverage.xml --cov-report term --ignore=raft --benchmark-disable
echo "Ran Python pytest for cugraph : return code was: $?, test script exit code is now: $EXITCODE"

echo "Python benchmarks for cuGraph (running as tests)..."
cd ${CUGRAPH_ROOT}/benchmarks/cugraph
cd "${CUGRAPH_ROOT}"/benchmarks/cugraph
pytest -sv -m sg -m "managedmem_on and poolallocator_on and tiny" --benchmark-disable
echo "Ran Python benchmarks for cuGraph (running as tests) : return code was: $?, test script exit code is now: $EXITCODE"

echo "Python pytest for cugraph-service (single-GPU only)..."
cd ${CUGRAPH_ROOT}/python/cugraph-service
pytest -sv --cache-clear --junitxml=${CUGRAPH_ROOT}/junit-cugraph-service-pytests.xml --benchmark-disable -k "not mg" ./tests
cd "${CUGRAPH_ROOT}"/python/cugraph-service
pytest -sv --cache-clear --junitxml="${CUGRAPH_ROOT}"/junit-cugraph-service-pytests.xml --benchmark-disable -k "not mg" ./tests
echo "Ran Python pytest for cugraph-service : return code was: $?, test script exit code is now: $EXITCODE"
fi

Expand Down
5 changes: 3 additions & 2 deletions ci/test_cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ rapids-logger "Check GPU usage"
nvidia-smi

# RAPIDS_DATASET_ROOT_DIR is used by test scripts
export RAPIDS_DATASET_ROOT_DIR="$(realpath datasets)"
RAPIDS_DATASET_ROOT_DIR="$(realpath datasets)"
export RAPIDS_DATASET_ROOT_DIR
pushd "${RAPIDS_DATASET_ROOT_DIR}"
./get_test_data.sh --cpp_ci_subset
popd
Expand All @@ -49,4 +50,4 @@ rapids-logger "Run gtests"
./ci/run_ctests.sh -j10 && EXITCODE=$? || EXITCODE=$?;

rapids-logger "Test script exiting with value: $EXITCODE"
exit ${EXITCODE}
exit "${EXITCODE}"
3 changes: 2 additions & 1 deletion ci/test_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ nvidia-smi
export LD_PRELOAD="${CONDA_PREFIX}/lib/libgomp.so.1"

# RAPIDS_DATASET_ROOT_DIR is used by test scripts
export RAPIDS_DATASET_ROOT_DIR="$(realpath datasets)"
RAPIDS_DATASET_ROOT_DIR="$(realpath datasets)"
export RAPIDS_DATASET_ROOT_DIR
pushd "${RAPIDS_DATASET_ROOT_DIR}"
./get_test_data.sh --benchmark
popd
Expand Down
8 changes: 4 additions & 4 deletions ci/test_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ set -eoxu pipefail

package_name=$1

python_package_name=$(echo ${package_name}|sed 's/-/_/g')
python_package_name=${package_name//-/_}

# Run smoke tests for aarch64 pull requests
arch=$(uname -m)
if [[ "${arch}" == "aarch64" && ${RAPIDS_BUILD_TYPE} == "pull-request" ]]; then
python ./ci/wheel_smoke_test_${package_name}.py
python ./ci/wheel_smoke_test_"{package_name}".py
else
# Test runs that include tests that use dask require
# --import-mode=append. See test_python.sh for details.
# FIXME: Adding PY_IGNORE_IMPORTMISMATCH=1 to workaround conftest.py import
# mismatch error seen by nx-cugraph after using pytest 8 and
# --import-mode=append.
RAPIDS_DATASET_ROOT_DIR=`pwd`/datasets \
RAPIDS_DATASET_ROOT_DIR=$(pwd)/datasets \
PY_IGNORE_IMPORTMISMATCH=1 \
DASK_WORKER_DEVICES="0" \
DASK_DISTRIBUTED__SCHEDULER__WORKER_TTL="1000s" \
Expand All @@ -28,5 +28,5 @@ else
--import-mode=append \
--benchmark-disable \
-k "not test_property_graph_mg and not test_bulk_sampler_io" \
./python/${package_name}/${python_package_name}/tests
./python/"${package_name}"/"${python_package_name}"/tests
fi
2 changes: 1 addition & 1 deletion ci/test_wheel_cugraph.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -eoxu pipefail

# Download the packages built in the previous step
mkdir -p ./dist
RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})"
RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen "${RAPIDS_CUDA_VERSION}")"
RAPIDS_PY_WHEEL_NAME="cugraph_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 python ./dist
RAPIDS_PY_WHEEL_NAME="libcugraph_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 cpp ./local-libcugraph-dep
RAPIDS_PY_WHEEL_NAME="pylibcugraph_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 python ./local-pylibcugraph-dep
Expand Down
2 changes: 1 addition & 1 deletion ci/test_wheel_pylibcugraph.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -eoxu pipefail

# Download the packages built in the previous step
mkdir -p ./dist
RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})"
RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen "${RAPIDS_CUDA_VERSION}")"
RAPIDS_PY_WHEEL_NAME="libcugraph_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 cpp ./local-libcugraph-dep
RAPIDS_PY_WHEEL_NAME="pylibcugraph_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 python ./dist

Expand Down
18 changes: 9 additions & 9 deletions ci/utils/nbtest.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright (c) 2019-2021, NVIDIA CORPORATION.
# Copyright (c) 2019-2025, NVIDIA CORPORATION.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand Down Expand Up @@ -48,22 +48,22 @@ get_ipython().run_cell_magic=my_run_cell_magic
NO_COLORS=--colors=NoColor
EXITCODE=0
NBTMPDIR=${WORKSPACE}/tmp
mkdir -p ${NBTMPDIR}
mkdir -p "${NBTMPDIR}"

for nb in $*; do
NBFILENAME=$1
for nb in "$@"; do
NBFILENAME=$nb
NBNAME=${NBFILENAME%.*}
NBNAME=${NBNAME##*/}
NBTESTSCRIPT=${NBTMPDIR}/${NBNAME}-test.py
shift

echo --------------------------------------------------------------------------------
echo STARTING: ${NBNAME}
echo STARTING: "${NBNAME}"
echo --------------------------------------------------------------------------------
jupyter nbconvert --to script ${NBFILENAME} --output ${NBTMPDIR}/${NBNAME}-test
echo "${MAGIC_OVERRIDE_CODE}" > ${NBTMPDIR}/tmpfile
cat ${NBTESTSCRIPT} >> ${NBTMPDIR}/tmpfile
mv ${NBTMPDIR}/tmpfile ${NBTESTSCRIPT}
jupyter nbconvert --to script "${NBFILENAME}" --output "${NBTMPDIR}"/"${NBNAME}"-test
echo "${MAGIC_OVERRIDE_CODE}" > "${NBTMPDIR}"/tmpfile
cat "${NBTESTSCRIPT}" >> "${NBTMPDIR}"/tmpfile
mv "${NBTMPDIR}"/tmpfile "${NBTESTSCRIPT}"

echo "Running \"ipython ${NO_COLORS} ${NBTESTSCRIPT}\" on $(date)"
echo
Expand Down
4 changes: 2 additions & 2 deletions ci/validate_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ rapids-logger "validate packages with 'pydistcheck'"

pydistcheck \
--inspect \
"$(echo ${wheel_dir_relative_path}/*.whl)"
"$(echo "${wheel_dir_relative_path}"/*.whl)"

rapids-logger "validate packages with 'twine'"

twine check \
--strict \
"$(echo ${wheel_dir_relative_path}/*.whl)"
"$(echo "${wheel_dir_relative_path}"/*.whl)"

0 comments on commit afb0bf3

Please sign in to comment.