From dfd383d605099e4f42ab40bdb483a60024dcb90d Mon Sep 17 00:00:00 2001 From: ksimpson Date: Mon, 20 Jan 2025 10:50:44 -0800 Subject: [PATCH 1/3] isolate changes --- cuda_core/cuda/core/experimental/_memoryview.pyx | 13 +++++++------ cuda_core/docs/source/conf.py | 6 ++---- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/cuda_core/cuda/core/experimental/_memoryview.pyx b/cuda_core/cuda/core/experimental/_memoryview.pyx index 61ff09dff4..feca227821 100644 --- a/cuda_core/cuda/core/experimental/_memoryview.pyx +++ b/cuda_core/cuda/core/experimental/_memoryview.pyx @@ -48,20 +48,20 @@ cdef class StridedMemoryView: ---------- ptr : int Pointer to the tensor buffer (as a Python `int`). - shape: tuple + shape : tuple Shape of the tensor. - strides: tuple + strides : tuple Strides of the tensor (in **counts**, not bytes). dtype: numpy.dtype Data type of the tensor. - device_id: int + device_id : int The device ID for where the tensor is located. It is -1 for CPU tensors (meaning those only accessible from the host). - is_device_accessible: bool + is_device_accessible : bool Whether the tensor data can be accessed on the GPU. readonly: bool Whether the tensor data can be modified in place. - exporting_obj: Any + exporting_obj : Any A reference to the original tensor object that is being viewed. Parameters @@ -334,7 +334,8 @@ cdef StridedMemoryView view_as_cai(obj, stream_ptr, view=None): def args_viewable_as_strided_memory(tuple arg_indices): - """Decorator to create proxy objects to :obj:`StridedMemoryView` for the + """ + Decorator to create proxy objects to :obj:`StridedMemoryView` for the specified positional arguments. This allows array/tensor attributes to be accessed inside the function diff --git a/cuda_core/docs/source/conf.py b/cuda_core/docs/source/conf.py index b122a63113..6c9ab10471 100644 --- a/cuda_core/docs/source/conf.py +++ b/cuda_core/docs/source/conf.py @@ -75,10 +75,6 @@ # "navbar-icon-links", # ], } -if os.environ.get("CI"): - PR_NUMBER = f"{os.environ['PR_NUMBER']}" - PR_TEXT = f'PR {PR_NUMBER}' - html_theme_options["announcement"] = f"Warning: This documentation is only a preview for {PR_TEXT}!" # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, @@ -99,6 +95,8 @@ section_titles = ["Returns"] +autodoc_mock_imports = ["cuda"] + def autodoc_process_docstring(app, what, name, obj, options, lines): if name.startswith("cuda.core.experimental.system"): From 42500888908f383aa693fdd8c3f417edc9caebb7 Mon Sep 17 00:00:00 2001 From: ksimpson Date: Mon, 20 Jan 2025 10:53:13 -0800 Subject: [PATCH 2/3] merge --- cuda_core/docs/source/conf.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cuda_core/docs/source/conf.py b/cuda_core/docs/source/conf.py index 6c9ab10471..4f875f14f7 100644 --- a/cuda_core/docs/source/conf.py +++ b/cuda_core/docs/source/conf.py @@ -75,6 +75,10 @@ # "navbar-icon-links", # ], } +if os.environ.get("CI"): + PR_NUMBER = f"{os.environ['PR_NUMBER']}" + PR_TEXT = f'PR {PR_NUMBER}' + html_theme_options["announcement"] = f"Warning: This documentation is only a preview for {PR_TEXT}!" # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, @@ -92,11 +96,10 @@ napoleon_google_docstring = False napoleon_numpy_docstring = True +autodoc_mock_imports = ["cuda"] section_titles = ["Returns"] -autodoc_mock_imports = ["cuda"] - def autodoc_process_docstring(app, what, name, obj, options, lines): if name.startswith("cuda.core.experimental.system"): From 7f1beb9d5f518bcf6e6e9008d1cc25c5447efcd1 Mon Sep 17 00:00:00 2001 From: ksimpson Date: Thu, 30 Jan 2025 15:07:52 -0800 Subject: [PATCH 3/3] mock the whole system class --- cuda_core/docs/source/conf.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/cuda_core/docs/source/conf.py b/cuda_core/docs/source/conf.py index 4f875f14f7..32a2d1b05d 100644 --- a/cuda_core/docs/source/conf.py +++ b/cuda_core/docs/source/conf.py @@ -10,8 +10,11 @@ # 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 -# import sys # sys.path.insert(0, os.path.abspath('.')) @@ -96,7 +99,24 @@ napoleon_google_docstring = False napoleon_numpy_docstring = True -autodoc_mock_imports = ["cuda"] + +# 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"] section_titles = ["Returns"]