From dc161d92de42b12380062f9ce73e617d1ccfd256 Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Tue, 4 Feb 2025 00:46:24 -0500 Subject: [PATCH 01/11] switch back to a cpu runner to build docs --- .github/workflows/build-docs.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index d0801870d3..d905cbb642 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -37,9 +37,7 @@ jobs: name: Build docs # The build stage could fail but we want the CI to keep moving. if: ${{ github.repository_owner == 'nvidia' && !cancelled() }} - # WAR: Building the doc currently requires a GPU (NVIDIA/cuda-python#326,327) - runs-on: linux-amd64-gpu-t4-latest-1 - #runs-on: ubuntu-latest + runs-on: ubuntu-latest defaults: run: shell: bash -el {0} From 106781ba2721a47f5aa9bf6dba8eff72da7bcb71 Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Tue, 4 Feb 2025 09:05:52 -0500 Subject: [PATCH 02/11] remove gpu check step --- .github/workflows/build-docs.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index d905cbb642..1a54733870 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -42,10 +42,6 @@ jobs: run: shell: bash -el {0} steps: - # WAR: Building the doc currently requires a GPU (NVIDIA/cuda-python#326,327) - - name: Ensure GPU is working - run: nvidia-smi - - name: Checkout ${{ github.event.repository.name }} uses: actions/checkout@v4 with: From 7014a335c602b2f22c0cab67529550d8c690459e Mon Sep 17 00:00:00 2001 From: ksimpson Date: Tue, 4 Feb 2025 09:34:41 -0800 Subject: [PATCH 03/11] try mocking module instead of object --- cuda_core/docs/source/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cuda_core/docs/source/conf.py b/cuda_core/docs/source/conf.py index 7c42cd7d04..2204ed0916 100644 --- a/cuda_core/docs/source/conf.py +++ b/cuda_core/docs/source/conf.py @@ -121,7 +121,7 @@ def __init__(self, *args, **kwargs): sys.modules["cuda.core.experimental._system.System"] = MagicMock(System=MockSystem) # Add 'cuda.core.experimental.system' to autodoc_mock_imports -autodoc_mock_imports = ["cuda.core.experimental.system"] +autodoc_mock_imports = ["cuda.core.experimental.System"] section_titles = ["Returns"] From 6b36a1db1c268a53f568d270a5e6c3cc3d6a796e Mon Sep 17 00:00:00 2001 From: ksimpson Date: Wed, 5 Feb 2025 16:45:41 -0800 Subject: [PATCH 04/11] try mocking bindings --- cuda_core/docs/build_docs.sh | 4 ++-- cuda_core/docs/source/conf.py | 22 +--------------------- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/cuda_core/docs/build_docs.sh b/cuda_core/docs/build_docs.sh index 2262278c9c..b05e08120e 100755 --- a/cuda_core/docs/build_docs.sh +++ b/cuda_core/docs/build_docs.sh @@ -19,12 +19,12 @@ if [[ -z "${SPHINX_CUDA_CORE_VER}" ]]; then fi # build the docs (in parallel) -SPHINXOPTS="-j 4 -d build/.doctrees" make html +#SPHINXOPTS="-j 5 -d build/.doctrees" make html # for debugging/developing (conf.py), please comment out the above line and # use the line below instead, as we must build in serial to avoid getting # obsecure Sphinx errors -#SPHINXOPTS="-v" make html +SPHINXOPTS="-vvv" make html # to support version dropdown menu cp ./versions.json build/html diff --git a/cuda_core/docs/source/conf.py b/cuda_core/docs/source/conf.py index 2204ed0916..85a1c7c9db 100644 --- a/cuda_core/docs/source/conf.py +++ b/cuda_core/docs/source/conf.py @@ -10,10 +10,6 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. import os -import sys -from unittest.mock import MagicMock - -from cuda.core.experimental._system import System # sys.path.insert(0, os.path.abspath('.')) @@ -105,23 +101,7 @@ napoleon_numpy_docstring = True -# Mock the System class and its methods -class MockSystem: - def __init__(self, *args, **kwargs): - pass - - driver_version = MagicMock() - driver_version.__doc__ = System.driver_version.__doc__ - num_devices = MagicMock() - num_devices.__doc__ = System.num_devices.__doc__ - devices = MagicMock() - devices.__doc__ = System.devices.__doc__ - - -sys.modules["cuda.core.experimental._system.System"] = MagicMock(System=MockSystem) - -# Add 'cuda.core.experimental.system' to autodoc_mock_imports -autodoc_mock_imports = ["cuda.core.experimental.System"] +autodoc_mock_imports = ["cuda.bindings"] section_titles = ["Returns"] From f5c3c3e5b49d6d05e6fa45efe876387a6c553cbf Mon Sep 17 00:00:00 2001 From: ksimpson Date: Fri, 7 Feb 2025 11:01:08 -0800 Subject: [PATCH 05/11] reference the module instead of the object. need to address title names --- cuda_core/docs/source/api.rst | 9 ++++++--- cuda_core/docs/source/conf.py | 10 ++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/cuda_core/docs/source/api.rst b/cuda_core/docs/source/api.rst index 5239174f4e..f6a39ac27d 100644 --- a/cuda_core/docs/source/api.rst +++ b/cuda_core/docs/source/api.rst @@ -42,12 +42,15 @@ CUDA compilation toolchain CUDA system information ----------------------- -.. autodata:: cuda.core.experimental.system.driver_version +.. autodata:: cuda.core.experimental._system.System.driver_version :no-value: -.. autodata:: cuda.core.experimental.system.num_devices + :noindex: +.. autodata:: cuda.core.experimental._system.System.num_devices :no-value: -.. autodata:: cuda.core.experimental.system.devices + :noindex: +.. autodata:: cuda.core.experimental._system.System.devices :no-value: + :noindex: .. module:: cuda.core.experimental.utils diff --git a/cuda_core/docs/source/conf.py b/cuda_core/docs/source/conf.py index 85a1c7c9db..2c5b319be6 100644 --- a/cuda_core/docs/source/conf.py +++ b/cuda_core/docs/source/conf.py @@ -100,14 +100,14 @@ napoleon_google_docstring = False napoleon_numpy_docstring = True - -autodoc_mock_imports = ["cuda.bindings"] - section_titles = ["Returns"] def autodoc_process_docstring(app, what, name, obj, options, lines): - if name.startswith("cuda.core.experimental.system"): + if name.startswith("cuda.core.experimental._system.System"): + new_name = name = name.replace("cuda.core.experimental._system.System", "cuda.core.experimental.system") + lines.insert(0, f".. py:data:: {new_name}") + lines.insert(1, "") # patch the docstring (in lines) *in-place*. Should docstrings include section titles other than "Returns", # this will need to be modified to handle them. attr = name.split(".")[-1] @@ -128,6 +128,8 @@ def autodoc_process_docstring(app, what, name, obj, options, lines): for _ in range(n_pops): lines.pop(0) + print("\n\n\n\n", lines, name, what, obj, options, app, "\n\n\n\n") + def setup(app): app.connect("autodoc-process-docstring", autodoc_process_docstring) From 19dd93d82913dd41d95c88b5592be2bc7f90ead8 Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Wed, 12 Feb 2025 05:10:38 +0000 Subject: [PATCH 06/11] fix pop to make it slightly nicer --- cuda_core/docs/build_docs.sh | 4 ++-- cuda_core/docs/source/conf.py | 28 ++++++++++++---------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/cuda_core/docs/build_docs.sh b/cuda_core/docs/build_docs.sh index b05e08120e..2262278c9c 100755 --- a/cuda_core/docs/build_docs.sh +++ b/cuda_core/docs/build_docs.sh @@ -19,12 +19,12 @@ if [[ -z "${SPHINX_CUDA_CORE_VER}" ]]; then fi # build the docs (in parallel) -#SPHINXOPTS="-j 5 -d build/.doctrees" make html +SPHINXOPTS="-j 4 -d build/.doctrees" make html # for debugging/developing (conf.py), please comment out the above line and # use the line below instead, as we must build in serial to avoid getting # obsecure Sphinx errors -SPHINXOPTS="-vvv" make html +#SPHINXOPTS="-v" make html # to support version dropdown menu cp ./versions.json build/html diff --git a/cuda_core/docs/source/conf.py b/cuda_core/docs/source/conf.py index 2c5b319be6..f1547a4429 100644 --- a/cuda_core/docs/source/conf.py +++ b/cuda_core/docs/source/conf.py @@ -105,30 +105,26 @@ def autodoc_process_docstring(app, what, name, obj, options, lines): if name.startswith("cuda.core.experimental._system.System"): - new_name = name = name.replace("cuda.core.experimental._system.System", "cuda.core.experimental.system") - lines.insert(0, f".. py:data:: {new_name}") - lines.insert(1, "") + name = name.replace("._system.System", ".system") # patch the docstring (in lines) *in-place*. Should docstrings include section titles other than "Returns", # this will need to be modified to handle them. + while lines: + lines.pop() attr = name.split(".")[-1] from cuda.core.experimental._system import System - - lines_new = getattr(System, attr).__doc__.split("\n") - formatted_lines = [] - for line in lines_new: + original_lines = getattr(System, attr).__doc__.split("\n") + new_lines = [] + new_lines.append(f".. py:data:: {name}") + new_lines.append("") + for line in original_lines: title = line.strip() if title in section_titles: - formatted_lines.append(line.replace(title, f".. rubric:: {title}")) + new_lines.append(line.replace(title, f".. rubric:: {title}")) elif line.strip() == "-" * len(title): - formatted_lines.append(" " * len(title)) + new_lines.append(" " * len(title)) else: - formatted_lines.append(line) - n_pops = len(lines) - lines.extend(formatted_lines) - for _ in range(n_pops): - lines.pop(0) - - print("\n\n\n\n", lines, name, what, obj, options, app, "\n\n\n\n") + new_lines.append(line) + lines.extend(new_lines) def setup(app): From 043685780bda1b4c7022c3732a4ffcf694464c21 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 12 Feb 2025 05:12:36 +0000 Subject: [PATCH 07/11] [pre-commit.ci] auto code formatting --- cuda_core/docs/source/conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cuda_core/docs/source/conf.py b/cuda_core/docs/source/conf.py index f1547a4429..9e0972e03d 100644 --- a/cuda_core/docs/source/conf.py +++ b/cuda_core/docs/source/conf.py @@ -112,6 +112,7 @@ def autodoc_process_docstring(app, what, name, obj, options, lines): lines.pop() attr = name.split(".")[-1] from cuda.core.experimental._system import System + original_lines = getattr(System, attr).__doc__.split("\n") new_lines = [] new_lines.append(f".. py:data:: {name}") From 2e121acb4e0a38c71459408cae1313bec5db883f Mon Sep 17 00:00:00 2001 From: ksimpson Date: Wed, 12 Feb 2025 10:49:22 -0800 Subject: [PATCH 08/11] try autoprop --- cuda_core/docs/source/api.rst | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/cuda_core/docs/source/api.rst b/cuda_core/docs/source/api.rst index f6a39ac27d..27f9680a6d 100644 --- a/cuda_core/docs/source/api.rst +++ b/cuda_core/docs/source/api.rst @@ -42,16 +42,10 @@ CUDA compilation toolchain CUDA system information ----------------------- -.. autodata:: cuda.core.experimental._system.System.driver_version - :no-value: - :noindex: -.. autodata:: cuda.core.experimental._system.System.num_devices - :no-value: - :noindex: -.. autodata:: cuda.core.experimental._system.System.devices - :no-value: - :noindex: - +.. autoproperty:: cuda.core.experimental._system.System.driver_version +.. autoproperty:: cuda.core.experimental._system.System.num_devices +.. autoproperty:: cuda.core.experimental._system.System.devices + .. module:: cuda.core.experimental.utils From 406565cc49c52a504ce8301a27509b17573d0030 Mon Sep 17 00:00:00 2001 From: ksimpson Date: Wed, 12 Feb 2025 10:51:40 -0800 Subject: [PATCH 09/11] switch to autoproperty --- cuda_core/docs/source/api.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cuda_core/docs/source/api.rst b/cuda_core/docs/source/api.rst index 27f9680a6d..f5ee30c1af 100644 --- a/cuda_core/docs/source/api.rst +++ b/cuda_core/docs/source/api.rst @@ -45,7 +45,7 @@ CUDA system information .. autoproperty:: cuda.core.experimental._system.System.driver_version .. autoproperty:: cuda.core.experimental._system.System.num_devices .. autoproperty:: cuda.core.experimental._system.System.devices - + .. module:: cuda.core.experimental.utils From 0a24ff7e39d775669979591e6c6e3edb66332c1e Mon Sep 17 00:00:00 2001 From: Keenan Simpson Date: Fri, 14 Feb 2025 09:07:36 -0800 Subject: [PATCH 10/11] Try referencing system as autoproperty Co-authored-by: Leo Fang --- cuda_core/docs/source/api.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cuda_core/docs/source/api.rst b/cuda_core/docs/source/api.rst index f5ee30c1af..4b2ac87684 100644 --- a/cuda_core/docs/source/api.rst +++ b/cuda_core/docs/source/api.rst @@ -42,7 +42,7 @@ CUDA compilation toolchain CUDA system information ----------------------- -.. autoproperty:: cuda.core.experimental._system.System.driver_version +.. autoproperty:: cuda.core.experimental.system.driver_version .. autoproperty:: cuda.core.experimental._system.System.num_devices .. autoproperty:: cuda.core.experimental._system.System.devices From aaecd5f71c453138a05baf974f2385b2bbed0786 Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Fri, 14 Feb 2025 14:27:06 -0500 Subject: [PATCH 11/11] revert --- cuda_core/docs/source/api.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cuda_core/docs/source/api.rst b/cuda_core/docs/source/api.rst index 4b2ac87684..f5ee30c1af 100644 --- a/cuda_core/docs/source/api.rst +++ b/cuda_core/docs/source/api.rst @@ -42,7 +42,7 @@ CUDA compilation toolchain CUDA system information ----------------------- -.. autoproperty:: cuda.core.experimental.system.driver_version +.. autoproperty:: cuda.core.experimental._system.System.driver_version .. autoproperty:: cuda.core.experimental._system.System.num_devices .. autoproperty:: cuda.core.experimental._system.System.devices