Skip to content

Add shellcheck to pre-commit and fix warnings #4954

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

Merged
merged 10 commits into from
Apr 15, 2025
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,8 @@ 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"]
6 changes: 3 additions & 3 deletions benchmarks/cugraph/standalone/run_all_nightly_benches.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright (c) 2021-2022, NVIDIA CORPORATION.
# Copyright (c) 2021-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 @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

THIS_SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}) && pwd)
THIS_SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)

#WEIGHTED_ALGOS="--algo=bfs --algo=sssp"
#UNWEIGHTED_ALGOS="--algo=wcc"
Expand All @@ -34,7 +34,7 @@ for scale in $SCALE_VALUES; do
echo ""
echo ">>>>>>>>>>>>>>>>> EDGEFACTOR: $edgefactor"
#env CUDA_VISIBLE_DEVICES="$gpus" python "$THIS_SCRIPT_DIR"/main.py $WEIGHTED_ALGOS --scale=$scale --symmetric-graph
env CUDA_VISIBLE_DEVICES="$gpus" python "$THIS_SCRIPT_DIR"/main.py $UNWEIGHTED_ALGOS --unweighted --symmetric-graph --scale=$scale --edgefactor=$edgefactor
env CUDA_VISIBLE_DEVICES="$gpus" python "$THIS_SCRIPT_DIR"/main.py "$UNWEIGHTED_ALGOS" --unweighted --symmetric-graph --scale="$scale" --edgefactor="$edgefactor"
done
done
mv out.csv random_scale_"$scale".csv
Expand Down
12 changes: 6 additions & 6 deletions benchmarks/shared/build_cugraph_ucx/build-ucx.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#!/bin/bash
# Copyright (c) 2023-2024, NVIDIA CORPORATION.
# Copyright (c) 2023-2025, NVIDIA CORPORATION.
# SPDX-License-Identifier: Apache-2.0
set -ex

UCX_VERSION_TAG=${1:-"v1.14.x"}
CUDA_HOME=${2:-"/usr/local/cuda"}
# Send any remaining arguments to configure
CONFIGURE_ARGS=${@:2}
CONFIGURE_ARGS=("${@:2}")
git clone https://github.com/openucx/ucx.git
cd ucx
git checkout ${UCX_VERSION_TAG}
git checkout "${UCX_VERSION_TAG}"
./autogen.sh
mkdir build-linux && cd build-linux
../contrib/configure-release --prefix=${CONDA_PREFIX} --with-sysroot --enable-cma \
../contrib/configure-release --prefix="${CONDA_PREFIX}" --with-sysroot --enable-cma \
--enable-mt --enable-numa --with-gnu-ld --with-rdmacm --with-verbs \
--with-cuda=${CUDA_HOME} \
${CONFIGURE_ARGS}
--with-cuda="${CUDA_HOME}" \
"${CONFIGURE_ARGS[@]}"
make -j install
171 changes: 79 additions & 92 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ ARGS=$*

# NOTE: ensure all dir changes are relative to the location of this
# script, and that this script resides in the repo dir!
REPODIR=$(cd $(dirname $0); pwd)

RAPIDS_VERSION="$(sed -E -e 's/^([0-9]{2})\.([0-9]{2})\.([0-9]{2}).*$/\1.\2/' VERSION)"
REPODIR=$(cd "$(dirname "$0")"; pwd)

# Valid args to this script (all possible targets and options) - only one per line
VALIDARGS="
Expand Down Expand Up @@ -88,40 +86,40 @@ BUILD_DIRS="${LIBCUGRAPH_BUILD_DIR}

# Set defaults for vars modified by flags to this script
VERBOSE_FLAG=""
CMAKE_VERBOSE_OPTION=""
CMAKE_VERBOSE_OPTION=()
BUILD_TYPE=Release
INSTALL_TARGET="--target install"
INSTALL_TARGET=(--target install)
BUILD_CPP_TESTS=ON
BUILD_CPP_MG_TESTS=OFF
BUILD_CPP_MTMG_TESTS=OFF
BUILD_ALL_GPU_ARCH=0
CMAKE_GENERATOR_OPTION="-G Ninja"
PYTHON_ARGS_FOR_INSTALL="-m pip install --no-build-isolation --no-deps --config-settings rapidsai.disable-cuda=true"
CMAKE_GENERATOR_OPTION=(-G Ninja)
PYTHON_ARGS_FOR_INSTALL=(-m pip install --no-build-isolation --no-deps --config-settings rapidsai.disable-cuda=true)

# Set defaults for vars that may not have been defined externally
# FIXME: if PREFIX is not set, check CONDA_PREFIX, but there is no fallback
# from there!
INSTALL_PREFIX=${PREFIX:=${CONDA_PREFIX}}
PARALLEL_LEVEL=${PARALLEL_LEVEL:=`nproc`}
PARALLEL_LEVEL=${PARALLEL_LEVEL:=$(nproc)}
BUILD_ABI=${BUILD_ABI:=ON}

function hasArg {
(( ${NUMARGS} != 0 )) && (echo " ${ARGS} " | grep -q " $1 ")
(( NUMARGS != 0 )) && (echo " ${ARGS} " | grep -q " $1 ")
}

function buildDefault {
(( ${NUMARGS} == 0 )) || !(echo " ${ARGS} " | grep -q " [^-][a-zA-Z0-9\_\-]\+ ")
(( NUMARGS == 0 )) || ! (echo " ${ARGS} " | grep -q " [^-][a-zA-Z0-9\_\-]\+ ")
}

function cleanPythonDir {
pushd $1 > /dev/null
rm -rf dist dask-worker-space cugraph/raft *.egg-info
find . -type d -name __pycache__ -print | xargs rm -rf
find . -type d -name build -print | xargs rm -rf
find . -type d -name dist -print | xargs rm -rf
pushd "$1" > /dev/null
rm -rf dist dask-worker-space cugraph/raft ./*.egg-info
find . -type d -name __pycache__ -print0 | xargs -0 rm -rf
find . -type d -name build -print0 | xargs -0 rm -rf
find . -type d -name dist -print0 | xargs -0 rm -rf
find . -type f -name "*.cpp" -delete
find . -type f -name "*.cpython*.so" -delete
find . -type d -name _external_repositories -print | xargs rm -rf
find . -type d -name _external_repositories -print0 | xargs -0 rm -rf
popd > /dev/null
}

Expand All @@ -131,7 +129,7 @@ if hasArg -h || hasArg --help; then
fi

# Check for valid usage
if (( ${NUMARGS} != 0 )); then
if (( NUMARGS != 0 )); then
for a in ${ARGS}; do
if ! (echo "${VALIDARGS}" | grep -q "^[[:blank:]]*${a}$"); then
echo "Invalid option: ${a}"
Expand All @@ -143,13 +141,13 @@ fi
# Process flags
if hasArg -v; then
VERBOSE_FLAG="-v"
CMAKE_VERBOSE_OPTION="--log-level=VERBOSE"
CMAKE_VERBOSE_OPTION=(--log-level=VERBOSE)
fi
if hasArg -g; then
BUILD_TYPE=Debug
fi
if hasArg -n; then
INSTALL_TARGET=""
INSTALL_TARGET=()
fi
if hasArg --allgpuarch; then
BUILD_ALL_GPU_ARCH=1
Expand All @@ -164,33 +162,33 @@ if hasArg cpp-mgtests || hasArg all; then
BUILD_CPP_MG_TESTS=ON
fi
if hasArg --cmake_default_generator; then
CMAKE_GENERATOR_OPTION=""
CMAKE_GENERATOR_OPTION=()
fi
if hasArg --pydevelop; then
PYTHON_ARGS_FOR_INSTALL="${PYTHON_ARGS_FOR_INSTALL} -e"
PYTHON_ARGS_FOR_INSTALL+=(-e)
fi

SKBUILD_EXTRA_CMAKE_ARGS="${EXTRA_CMAKE_ARGS}"

# Replace spaces with semicolons in SKBUILD_EXTRA_CMAKE_ARGS
SKBUILD_EXTRA_CMAKE_ARGS=$(echo ${SKBUILD_EXTRA_CMAKE_ARGS} | sed 's/ /;/g')
SKBUILD_EXTRA_CMAKE_ARGS=${SKBUILD_EXTRA_CMAKE_ARGS// /;}

# If clean or uninstall targets given, run them prior to any other steps
if hasArg uninstall; then
if [[ "$INSTALL_PREFIX" != "" ]]; then
rm -rf ${INSTALL_PREFIX}/include/cugraph
rm -f ${INSTALL_PREFIX}/lib/libcugraph.so
rm -rf ${INSTALL_PREFIX}/include/cugraph_c
rm -f ${INSTALL_PREFIX}/lib/libcugraph_c.so
rm -rf ${INSTALL_PREFIX}/include/cugraph_etl
rm -f ${INSTALL_PREFIX}/lib/libcugraph_etl.so
rm -rf ${INSTALL_PREFIX}/lib/cmake/cugraph
rm -rf ${INSTALL_PREFIX}/lib/cmake/cugraph_etl
rm -rf "${INSTALL_PREFIX}/include/cugraph"
rm -f "${INSTALL_PREFIX}/lib/libcugraph.so"
rm -rf "${INSTALL_PREFIX}/include/cugraph_c"
rm -f "${INSTALL_PREFIX}/lib/libcugraph_c.so"
rm -rf "${INSTALL_PREFIX}/include/cugraph_etl"
rm -f "${INSTALL_PREFIX}/lib/libcugraph_etl.so"
rm -rf "${INSTALL_PREFIX}/lib/cmake/cugraph"
rm -rf "${INSTALL_PREFIX}/lib/cmake/cugraph_etl"
fi
# This may be redundant given the above, but can also be used in case
# there are other installed files outside of the locations above.
if [ -e ${LIBCUGRAPH_BUILD_DIR}/install_manifest.txt ]; then
xargs rm -f < ${LIBCUGRAPH_BUILD_DIR}/install_manifest.txt > /dev/null 2>&1
if [ -e "${LIBCUGRAPH_BUILD_DIR}/install_manifest.txt" ]; then
xargs rm -f < "${LIBCUGRAPH_BUILD_DIR}/install_manifest.txt" > /dev/null 2>&1
fi
# uninstall cugraph and pylibcugraph installed from a prior install
# FIXME: if multiple versions of these packages are installed, this only
Expand All @@ -204,17 +202,17 @@ if hasArg clean; then
set +e
# remove artifacts generated inplace
if [[ -d ${REPODIR}/python ]]; then
cleanPythonDir ${REPODIR}/python
cleanPythonDir "${REPODIR}/python"
fi

# If the dirs to clean are mounted dirs in a container, the contents should
# be removed but the mounted dirs will remain. The find removes all
# contents but leaves the dirs, the rmdir attempts to remove the dirs but
# can fail safely.
for bd in ${BUILD_DIRS}; do
if [ -d ${bd} ]; then
find ${bd} -mindepth 1 -delete
rmdir ${bd} || true
if [ -d "${bd}" ]; then
find "${bd}" -mindepth 1 -delete
rmdir "${bd}" || true
fi
done
# Go back to failing on first error for all other operations
Expand All @@ -225,128 +223,117 @@ fi
# Configure, build, and install libcugraph
if buildDefault || hasArg libcugraph || hasArg all; then
if hasArg --clean; then
if [ -d ${LIBCUGRAPH_BUILD_DIR} ]; then
find ${LIBCUGRAPH_BUILD_DIR} -mindepth 1 -delete
rmdir ${LIBCUGRAPH_BUILD_DIR} || true
if [ -d "${LIBCUGRAPH_BUILD_DIR}" ]; then
find "${LIBCUGRAPH_BUILD_DIR}" -mindepth 1 -delete
rmdir "${LIBCUGRAPH_BUILD_DIR}" || true
fi
else
if (( ${BUILD_ALL_GPU_ARCH} == 0 )); then
if (( BUILD_ALL_GPU_ARCH == 0 )); then
CUGRAPH_CMAKE_CUDA_ARCHITECTURES="NATIVE"
echo "Building for the architecture of the GPU in the system..."
else
CUGRAPH_CMAKE_CUDA_ARCHITECTURES="RAPIDS"
echo "Building for *ALL* supported GPU architectures..."
fi
mkdir -p ${LIBCUGRAPH_BUILD_DIR}
cd ${LIBCUGRAPH_BUILD_DIR}
mkdir -p "${LIBCUGRAPH_BUILD_DIR}"
cd "${LIBCUGRAPH_BUILD_DIR}"
cmake -B "${LIBCUGRAPH_BUILD_DIR}" -S "${REPODIR}/cpp" \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
-DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" \
-DCMAKE_CUDA_ARCHITECTURES=${CUGRAPH_CMAKE_CUDA_ARCHITECTURES} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DBUILD_TESTS=${BUILD_CPP_TESTS} \
-DBUILD_CUGRAPH_MG_TESTS=${BUILD_CPP_MG_TESTS} \
-DBUILD_CUGRAPH_MTMG_TESTS=${BUILD_CPP_MTMG_TESTS} \
${CMAKE_GENERATOR_OPTION} \
${CMAKE_VERBOSE_OPTION}
cmake --build "${LIBCUGRAPH_BUILD_DIR}" -j${PARALLEL_LEVEL} ${INSTALL_TARGET} ${VERBOSE_FLAG}
-DBUILD_CUGRAPH_MTMG_TESTS=${BUILD_CPP_MTMG_TESTS} \
"${CMAKE_GENERATOR_OPTION[@]}" \
"${CMAKE_VERBOSE_OPTION[@]}"

cmake --build "${LIBCUGRAPH_BUILD_DIR}" "-j${PARALLEL_LEVEL}" "${INSTALL_TARGET[@]}" "${VERBOSE_FLAG}"
fi
fi

# Configure, build, and install libcugraph_etl
if buildDefault || hasArg libcugraph_etl || hasArg all; then
if hasArg --clean; then
if [ -d ${LIBCUGRAPH_ETL_BUILD_DIR} ]; then
find ${LIBCUGRAPH_ETL_BUILD_DIR} -mindepth 1 -delete
rmdir ${LIBCUGRAPH_ETL_BUILD_DIR} || true
if [ -d "${LIBCUGRAPH_ETL_BUILD_DIR}" ]; then
find "${LIBCUGRAPH_ETL_BUILD_DIR}" -mindepth 1 -delete
rmdir "${LIBCUGRAPH_ETL_BUILD_DIR}" || true
fi
else
if (( ${BUILD_ALL_GPU_ARCH} == 0 )); then
if (( BUILD_ALL_GPU_ARCH == 0 )); then
CUGRAPH_CMAKE_CUDA_ARCHITECTURES="NATIVE"
echo "Building for the architecture of the GPU in the system..."
else
CUGRAPH_CMAKE_CUDA_ARCHITECTURES="RAPIDS"
echo "Building for *ALL* supported GPU architectures..."
fi
mkdir -p ${LIBCUGRAPH_ETL_BUILD_DIR}
cd ${LIBCUGRAPH_ETL_BUILD_DIR}
cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
-DCMAKE_CUDA_ARCHITECTURES=${CUGRAPH_CMAKE_CUDA_ARCHITECTURES} \
-DDISABLE_DEPRECATION_WARNING=${BUILD_DISABLE_DEPRECATION_WARNING} \
mkdir -p "${LIBCUGRAPH_ETL_BUILD_DIR}"
cd "${LIBCUGRAPH_ETL_BUILD_DIR}"
cmake -DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" \
-DCMAKE_CUDA_ARCHITECTURES="${CUGRAPH_CMAKE_CUDA_ARCHITECTURES}" \
-DDISABLE_DEPRECATION_WARNING="${BUILD_DISABLE_DEPRECATION_WARNING}" \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DBUILD_TESTS=${BUILD_CPP_TESTS} \
-DBUILD_CUGRAPH_MG_TESTS=${BUILD_CPP_MG_TESTS} \
-DBUILD_CUGRAPH_MTMG_TESTS=${BUILD_CPP_MTMG_TESTS} \
-DCMAKE_PREFIX_PATH=${LIBCUGRAPH_BUILD_DIR} \
${CMAKE_GENERATOR_OPTION} \
${CMAKE_VERBOSE_OPTION} \
${REPODIR}/cpp/libcugraph_etl
cmake --build "${LIBCUGRAPH_ETL_BUILD_DIR}" -j${PARALLEL_LEVEL} ${INSTALL_TARGET} ${VERBOSE_FLAG}
-DCMAKE_PREFIX_PATH="${LIBCUGRAPH_BUILD_DIR}" \
"${CMAKE_GENERATOR_OPTION[@]}" \
"${CMAKE_VERBOSE_OPTION[@]}" \
"${REPODIR}/cpp/libcugraph_etl"
cmake --build "${LIBCUGRAPH_ETL_BUILD_DIR}" "-j${PARALLEL_LEVEL}" "${INSTALL_TARGET[@]}" "${VERBOSE_FLAG}"
fi
fi

# Build, and install pylibcugraph
if buildDefault || hasArg pylibcugraph || hasArg all; then
if hasArg --clean; then
cleanPythonDir ${REPODIR}/python/pylibcugraph
cleanPythonDir "${REPODIR}/python/pylibcugraph"
else
SKBUILD_CMAKE_ARGS="${SKBUILD_EXTRA_CMAKE_ARGS}" \
python ${PYTHON_ARGS_FOR_INSTALL} ${REPODIR}/python/pylibcugraph
python "${PYTHON_ARGS_FOR_INSTALL[@]}" "${REPODIR}/python/pylibcugraph"
fi
fi

# Build and install the cugraph Python package
if buildDefault || hasArg cugraph || hasArg all; then
if hasArg --clean; then
cleanPythonDir ${REPODIR}/python/cugraph
cleanPythonDir "${REPODIR}/python/cugraph"
else
SKBUILD_CMAKE_ARGS="${SKBUILD_EXTRA_CMAKE_ARGS}" \
python ${PYTHON_ARGS_FOR_INSTALL} ${REPODIR}/python/cugraph
python "${PYTHON_ARGS_FOR_INSTALL[@]}" "${REPODIR}/python/cugraph"
fi
fi

# Install the cugraph-service-client and cugraph-service-server Python packages
if hasArg cugraph-service || hasArg all; then
if hasArg --clean; then
cleanPythonDir ${REPODIR}/python/cugraph-service
cleanPythonDir "${REPODIR}/python/cugraph-service"
else
python ${PYTHON_ARGS_FOR_INSTALL} ${REPODIR}/python/cugraph-service/client
python ${PYTHON_ARGS_FOR_INSTALL} ${REPODIR}/python/cugraph-service/server
python "${PYTHON_ARGS_FOR_INSTALL[@]}" "${REPODIR}/python/cugraph-service/client"
python "${PYTHON_ARGS_FOR_INSTALL[@]}" "${REPODIR}/python/cugraph-service/server"
fi
fi

# Build the docs
if hasArg docs || hasArg all; then
if [ ! -d ${LIBCUGRAPH_BUILD_DIR} ]; then
mkdir -p ${LIBCUGRAPH_BUILD_DIR}
cd ${LIBCUGRAPH_BUILD_DIR}
if [ ! -d "${LIBCUGRAPH_BUILD_DIR}" ]; then
mkdir -p "${LIBCUGRAPH_BUILD_DIR}"
cd "${LIBCUGRAPH_BUILD_DIR}"
cmake -B "${LIBCUGRAPH_BUILD_DIR}" -S "${REPODIR}/cpp" \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
${CMAKE_GENERATOR_OPTION} \
${CMAKE_VERBOSE_OPTION}
-DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" \
-DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \
"${CMAKE_GENERATOR_OPTION[@]}" \
"${CMAKE_VERBOSE_OPTION[@]}"
fi

# for PROJECT in libwholegraph; do
# XML_DIR="${REPODIR}/docs/cugraph/${PROJECT}"
# rm -rf "${XML_DIR}"
# mkdir -p "${XML_DIR}"
# export XML_DIR_${PROJECT^^}="$XML_DIR"

# echo "downloading xml for ${PROJECT} into ${XML_DIR}. Environment variable XML_DIR_${PROJECT^^} is set to ${XML_DIR}"
# curl -O "https://d1664dvumjb44w.cloudfront.net/${PROJECT}/xml_tar/${RAPIDS_VERSION}/xml.tar.gz"
# tar -xzf xml.tar.gz -C "${XML_DIR}"
# rm "./xml.tar.gz"
# done

cd ${LIBCUGRAPH_BUILD_DIR}
cmake --build "${LIBCUGRAPH_BUILD_DIR}" -j${PARALLEL_LEVEL} --target docs_cugraph ${VERBOSE_FLAG}
cd "${LIBCUGRAPH_BUILD_DIR}"
cmake --build "${LIBCUGRAPH_BUILD_DIR}" "-j${PARALLEL_LEVEL}" --target docs_cugraph ${VERBOSE_FLAG}

echo "making libcugraph doc dir"
rm -rf ${REPODIR}/docs/cugraph/libcugraph
mkdir -p ${REPODIR}/docs/cugraph/libcugraph
rm -rf "${REPODIR}/docs/cugraph/libcugraph"
mkdir -p "${REPODIR}/docs/cugraph/libcugraph"

export XML_DIR_LIBCUGRAPH="${REPODIR}/cpp/doxygen/xml"

cd ${REPODIR}/docs/cugraph
cd "${REPODIR}/docs/cugraph"
make html
fi
Loading