Skip to content

Commit

Permalink
Remove hard-coding of RAPIDS version where possible (rapidsai#4217)
Browse files Browse the repository at this point in the history
* Read `VERSION` file in CMake
* Read `cugraph.__version__` in docs build
* Read `VERSION` file in shell scripts
* Use environment variables in Doxyfile
* Remove updates from `ci/update-version.sh`

Issue: rapidsai/build-planning#15

Authors:
  - Kyle Edwards (https://github.com/KyleFromNVIDIA)

Approvers:
  - Don Acosta (https://github.com/acostadon)
  - Chuck Hastings (https://github.com/ChuckHastings)
  - Brad Rees (https://github.com/BradReesWork)
  - Jake Awe (https://github.com/AyodeAwe)
  - https://github.com/jakirkham

URL: rapidsai#4217
  • Loading branch information
KyleFromNVIDIA authored Mar 13, 2024
1 parent fda91fa commit 3086f83
Show file tree
Hide file tree
Showing 18 changed files with 75 additions and 80 deletions.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ARGS=$*
# script, and that this script resides in the repo dir!
REPODIR=$(cd $(dirname $0); pwd)

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

# Valid args to this script (all possible targets and options) - only one per line
VALIDARGS="
Expand Down
4 changes: 3 additions & 1 deletion ci/build_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ rapids-mamba-retry install \
rapids-logger "Install cugraph-dgl"
rapids-mamba-retry install "${PYTHON_CHANNEL}/linux-64/cugraph-dgl-*.tar.bz2"

export RAPIDS_VERSION_NUMBER="24.04"
export RAPIDS_VERSION="$(rapids-version)"
export RAPIDS_VERSION_MAJOR_MINOR="$(rapids-version-major-minor)"
export RAPIDS_VERSION_NUMBER="$RAPIDS_VERSION_MAJOR_MINOR"
export RAPIDS_DOCS_DIR="$(mktemp -d)"

for PROJECT in libcugraphops libwholegraph; do
Expand Down
3 changes: 2 additions & 1 deletion ci/build_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ echo "${version}" > VERSION
rapids-logger "Begin py build"

package_dir="python"
for package_name in pylibcugraph cugraph nx-cugraph cugraph-pyg cugraph-dgl; do
for package_name in pylibcugraph cugraph cugraph-pyg cugraph-dgl; do
underscore_package_name=$(echo "${package_name}" | tr "-" "_")
sed -i "/^__git_commit__/ s/= .*/= \"${git_commit}\"/g" "${package_dir}/${package_name}/${underscore_package_name}/_version.py"
done
sed -i "/^__git_commit__/ s/= .*/= \"${git_commit}\"/g" "${package_dir}/nx-cugraph/_nx_cugraph/_version.py"

# TODO: Remove `--no-test` flags once importing on a CPU
# node works correctly
Expand Down
6 changes: 5 additions & 1 deletion ci/build_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})"
PACKAGE_CUDA_SUFFIX="-${RAPIDS_PY_CUDA_SUFFIX}"

# Patch project metadata files to include the CUDA version suffix and version override.
version_package_name="$underscore_package_name"
if [[ "${version_package_name}" = "nx_cugraph" ]]; then
version_package_name="_nx_cugraph"
fi
pyproject_file="${package_dir}/pyproject.toml"
version_file="${package_dir}/${underscore_package_name}/_version.py"
version_file="${package_dir}/${version_package_name}/_version.py"

sed -i "s/name = \"${package_name}\"/name = \"${package_name}${PACKAGE_CUDA_SUFFIX}\"/g" ${pyproject_file}
echo "${version}" > VERSION
Expand Down
31 changes: 0 additions & 31 deletions ci/release/update-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,33 +39,11 @@ function sed_runner() {
sed -i.bak ''"$1"'' $2 && rm -f ${2}.bak
}

# rapids-cmake version
sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' fetch_rapids.cmake

# CMakeLists update
sed_runner 's/'"CUGRAPH VERSION .* LANGUAGES C CXX CUDA)"'/'"CUGRAPH VERSION ${NEXT_FULL_TAG} LANGUAGES C CXX CUDA)"'/g' cpp/CMakeLists.txt
sed_runner 's|'"branch-.*/RAPIDS.cmake"'|'"branch-${NEXT_SHORT_TAG}/RAPIDS.cmake"'|g' cpp/CMakeLists.txt
sed_runner 's/'"CUGRAPH_ETL VERSION .* LANGUAGES C CXX CUDA)"'/'"CUGRAPH_ETL VERSION ${NEXT_FULL_TAG} LANGUAGES C CXX CUDA)"'/g' cpp/libcugraph_etl/CMakeLists.txt
sed_runner 's|'"branch-.*/RAPIDS.cmake"'|'"branch-${NEXT_SHORT_TAG}/RAPIDS.cmake"'|g' cpp/libcugraph_etl/CMakeLists.txt
sed_runner "s/set(pylibcugraph_version .*)/set(pylibcugraph_version ${NEXT_FULL_TAG})/g" python/pylibcugraph/CMakeLists.txt
sed_runner "s/set(cugraph_version .*)/set(cugraph_version ${NEXT_FULL_TAG})/g" python/cugraph/CMakeLists.txt

# RTD update
sed_runner 's/version = .*/version = '"'${NEXT_SHORT_TAG}'"'/g' docs/cugraph/source/conf.py
sed_runner 's/release = .*/release = '"'${NEXT_FULL_TAG}'"'/g' docs/cugraph/source/conf.py


# build.sh script
sed_runner 's/RAPIDS_VERSION=.*/RAPIDS_VERSION='${NEXT_SHORT_TAG}'/g' build.sh

# Centralized version file update
# NOTE: Any script that runs in CI will need to use gha-tool `rapids-generate-version`
# and echo it to `VERSION` file to get an alpha spec of the current version
echo "${NEXT_FULL_TAG}" > VERSION

# Wheel testing script
sed_runner "s/branch-.*/branch-${NEXT_SHORT_TAG}/g" ci/test_wheel_cugraph.sh

# Need to distutils-normalize the original version
NEXT_SHORT_TAG_PEP440=$(python -c "from setuptools.extern import packaging; print(packaging.version.Version('${NEXT_SHORT_TAG}'))")

Expand Down Expand Up @@ -105,19 +83,11 @@ for DEP in "${DEPENDENCIES[@]}"; do
done
done

# Doxyfile update
sed_runner "s|PROJECT_NUMBER[[:space:]]*=.*|PROJECT_NUMBER=${NEXT_SHORT_TAG}|" cpp/doxygen/Doxyfile

# ucx-py version
sed_runner "/^ucx_py_version:$/ {n;s/.*/ - \"${NEXT_UCX_PY_VERSION}.*\"/}" conda/recipes/cugraph/conda_build_config.yaml
sed_runner "/^ucx_py_version:$/ {n;s/.*/ - \"${NEXT_UCX_PY_VERSION}.*\"/}" conda/recipes/cugraph-service/conda_build_config.yaml
sed_runner "/^ucx_py_version:$/ {n;s/.*/ - \"${NEXT_UCX_PY_VERSION}.*\"/}" conda/recipes/pylibcugraph/conda_build_config.yaml

# nx-cugraph NetworkX entry-point meta-data
sed_runner "s@branch-[0-9][0-9].[0-9][0-9]@branch-${NEXT_SHORT_TAG}@g" python/nx-cugraph/_nx_cugraph/__init__.py
# FIXME: can this use the standard VERSION file and update mechanism?
sed_runner "s/__version__ = .*/__version__ = \"${NEXT_FULL_TAG}\"/g" python/nx-cugraph/_nx_cugraph/__init__.py

# CI files
for FILE in .github/workflows/*.yaml; do
sed_runner "/shared-workflows/ s/@.*/@branch-${NEXT_SHORT_TAG}/g" "${FILE}"
Expand All @@ -126,7 +96,6 @@ for FILE in .github/workflows/*.yaml; do
# Wheel builds install dask-cuda from source, update its branch
sed_runner "s/dask-cuda.git@branch-[0-9][0-9].[0-9][0-9]/dask-cuda.git@branch-${NEXT_SHORT_TAG}/g" "${FILE}"
done
sed_runner "s/RAPIDS_VERSION_NUMBER=\".*/RAPIDS_VERSION_NUMBER=\"${NEXT_SHORT_TAG}\"/g" ci/build_docs.sh

sed_runner "s/branch-.*/branch-${NEXT_SHORT_TAG}/g" python/nx-cugraph/README.md

Expand Down
6 changes: 3 additions & 3 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR)

include(../fetch_rapids.cmake)
include(../rapids_config.cmake)
include(rapids-cmake)
include(rapids-cpm)
include(rapids-cuda)
Expand All @@ -25,7 +25,7 @@ include(rapids-find)

rapids_cuda_init_architectures(CUGRAPH)

project(CUGRAPH VERSION 24.04.00 LANGUAGES C CXX CUDA)
project(CUGRAPH VERSION "${RAPIDS_VERSION}" LANGUAGES C CXX CUDA)

if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA" AND
CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 11.0)
Expand Down Expand Up @@ -590,7 +590,7 @@ find_package(Doxygen 1.8.11)
if(Doxygen_FOUND)
add_custom_command(OUTPUT CUGRAPH_DOXYGEN
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doxygen
COMMAND doxygen Doxyfile
COMMAND ${CMAKE_COMMAND} -E env "RAPIDS_VERSION_MAJOR_MINOR=${RAPIDS_VERSION_MAJOR_MINOR}" doxygen Doxyfile
VERBATIM)

add_custom_target(docs_cugraph DEPENDS CUGRAPH_DOXYGEN)
Expand Down
2 changes: 1 addition & 1 deletion cpp/doxygen/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ PROJECT_NAME = libcugraph
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER=24.04
PROJECT_NUMBER=$(RAPIDS_VERSION_MAJOR_MINOR)

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
4 changes: 2 additions & 2 deletions cpp/libcugraph_etl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#=============================================================================

cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR)
include(../../fetch_rapids.cmake)
include(../../rapids_config.cmake)

include(rapids-cmake)
include(rapids-cpm)
Expand All @@ -25,7 +25,7 @@ include(rapids-find)

rapids_cuda_init_architectures(CUGRAPH_ETL)

project(CUGRAPH_ETL VERSION 24.04.00 LANGUAGES C CXX CUDA)
project(CUGRAPH_ETL VERSION "${RAPIDS_VERSION}" LANGUAGES C CXX CUDA)

if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA" AND
CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 11.0)
Expand Down
9 changes: 7 additions & 2 deletions docs/cugraph/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
import os
import sys

from packaging.version import Version

import cugraph

# If extensions (or modules to document with autodoc) are in another
# directory, add these directories to sys.path here. If the directory
# is relative to the documentation root, use os.path.abspath to make it
Expand Down Expand Up @@ -76,10 +80,11 @@
# |version| and |release|, also used in various other places throughout the
# built documents.
#
CUGRAPH_VERSION = Version(cugraph.__version__)
# The short X.Y version.
version = '24.04'
version = f"{CUGRAPH_VERSION.major:02}.{CUGRAPH_VERSION.minor:02}"
# The full version, including alpha/beta/rc tags.
release = '24.04.00'
release = f"{CUGRAPH_VERSION.major:02}.{CUGRAPH_VERSION.minor:02}.{CUGRAPH_VERSION.micro:02}"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
19 changes: 0 additions & 19 deletions fetch_rapids.cmake

This file was deleted.

8 changes: 3 additions & 5 deletions python/cugraph/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@

cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR)

set(cugraph_version 24.04.00)

include(../../fetch_rapids.cmake)
include(../../rapids_config.cmake)

# We always need CUDA for cuML because the raft dependency brings in a
# header-only cuco dependency that enables CUDA unconditionally.
Expand All @@ -25,7 +23,7 @@ rapids_cuda_init_architectures(cugraph-python)

project(
cugraph-python
VERSION ${cugraph_version}
VERSION "${RAPIDS_VERSION}"
LANGUAGES CXX CUDA
)

Expand All @@ -43,7 +41,7 @@ endif()

# If the user requested it, we attempt to find CUGRAPH.
if(FIND_CUGRAPH_CPP)
find_package(cugraph ${cugraph_version} REQUIRED)
find_package(cugraph "${RAPIDS_VERSION}" REQUIRED)
else()
set(cugraph_FOUND OFF)
endif()
Expand Down
File renamed without changes.
11 changes: 7 additions & 4 deletions python/nx-cugraph/_nx_cugraph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,18 @@
$ python _nx_cugraph/__init__.py
"""

from packaging.version import Version

from _nx_cugraph._version import __version__

_nx_cugraph_version = Version(__version__)

# Entries between BEGIN and END are automatically generated
_info = {
"backend_name": "cugraph",
"project": "nx-cugraph",
"package": "nx_cugraph",
"url": "https://github.com/rapidsai/cugraph/tree/branch-24.04/python/nx-cugraph",
"url": f"https://github.com/rapidsai/cugraph/tree/branch-{_nx_cugraph_version.major:02}.{_nx_cugraph_version.minor:02}/python/nx-cugraph",
"short_summary": "GPU-accelerated backend.",
# "description": "TODO",
"functions": {
Expand Down Expand Up @@ -252,9 +258,6 @@ def get_info():
return d


# FIXME: can this use the standard VERSION file and update mechanism?
__version__ = "24.04.00"

if __name__ == "__main__":
from pathlib import Path

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
# to update version info (including commit hashes) without modifying
# source files.
__version__ = (
importlib.resources.files("nx_cugraph").joinpath("VERSION").read_text().strip()
importlib.resources.files("_nx_cugraph").joinpath("VERSION").read_text().strip()
)
__git_commit__ = ""
4 changes: 2 additions & 2 deletions python/nx-cugraph/nx_cugraph/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023, NVIDIA CORPORATION.
# Copyright (c) 2023-2024, 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 @@ -29,4 +29,4 @@
from . import algorithms
from .algorithms import *

from nx_cugraph._version import __git_commit__, __version__
from _nx_cugraph._version import __git_commit__, __version__
2 changes: 1 addition & 1 deletion python/nx-cugraph/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ cugraph = "_nx_cugraph:get_info"
license-files = ["LICENSE"]

[tool.setuptools.dynamic]
version = {file = "nx_cugraph/VERSION"}
version = {file = "_nx_cugraph/VERSION"}

[tool.setuptools.packages.find]
include = [
Expand Down
8 changes: 3 additions & 5 deletions python/pylibcugraph/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@

cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR)

set(pylibcugraph_version 24.04.00)

include(../../fetch_rapids.cmake)
include(../../rapids_config.cmake)

# We always need CUDA for cuML because the raft dependency brings in a
# header-only cuco dependency that enables CUDA unconditionally.
Expand All @@ -25,7 +23,7 @@ rapids_cuda_init_architectures(pylibcugraph-python)

project(
pylibcugraph-python
VERSION ${pylibcugraph_version}
VERSION "${RAPIDS_VERSION}"
LANGUAGES CXX CUDA
)

Expand All @@ -43,7 +41,7 @@ endif()

# If the user requested it we attempt to find CUGRAPH.
if(FIND_CUGRAPH_CPP)
find_package(cugraph ${pylibcugraph_version} REQUIRED)
find_package(cugraph "${RAPIDS_VERSION}" REQUIRED)
else()
set(cugraph_FOUND OFF)
endif()
Expand Down
34 changes: 34 additions & 0 deletions rapids_config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# =============================================================================
# Copyright (c) 2018-2024, 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied. See the License for the specific language governing permissions and limitations under
# the License.
# =============================================================================
file(READ "${CMAKE_CURRENT_LIST_DIR}/VERSION" _rapids_version)
if(_rapids_version MATCHES [[^([0-9][0-9])\.([0-9][0-9])\.([0-9][0-9])]])
set(RAPIDS_VERSION_MAJOR "${CMAKE_MATCH_1}")
set(RAPIDS_VERSION_MINOR "${CMAKE_MATCH_2}")
set(RAPIDS_VERSION_PATCH "${CMAKE_MATCH_3}")
set(RAPIDS_VERSION_MAJOR_MINOR "${RAPIDS_VERSION_MAJOR}.${RAPIDS_VERSION_MINOR}")
set(RAPIDS_VERSION "${RAPIDS_VERSION_MAJOR}.${RAPIDS_VERSION_MINOR}.${RAPIDS_VERSION_PATCH}")
else()
string(REPLACE "\n" "\n " _rapids_version_formatted " ${_rapids_version}")
message(
FATAL_ERROR
"Could not determine RAPIDS version. Contents of VERSION file:\n${_rapids_version_formatted}")
endif()

if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/CUGRAPH_RAPIDS-${RAPIDS_VERSION_MAJOR_MINOR}.cmake")
file(
DOWNLOAD
"https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-${RAPIDS_VERSION_MAJOR_MINOR}/RAPIDS.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/CUGRAPH_RAPIDS-${RAPIDS_VERSION_MAJOR_MINOR}.cmake")
endif()
include("${CMAKE_CURRENT_BINARY_DIR}/CUGRAPH_RAPIDS-${RAPIDS_VERSION_MAJOR_MINOR}.cmake")

0 comments on commit 3086f83

Please sign in to comment.