Skip to content
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

Treat warnings as errors in Python documentation #1316

Merged
merged 17 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ci/build_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ popd

rapids-logger "Build Python docs"
pushd python/docs
sphinx-build -b dirhtml . _html
sphinx-build -b text . _text
make dirhtml
make text
mkdir -p "${RAPIDS_DOCS_DIR}/rmm/"{html,txt}
mv _html/* "${RAPIDS_DOCS_DIR}/rmm/html"
mv _text/* "${RAPIDS_DOCS_DIR}/rmm/txt"
mv _build/dirhtml/* "${RAPIDS_DOCS_DIR}/rmm/html"
mv _build/text/* "${RAPIDS_DOCS_DIR}/rmm/txt"
popd

rapids-upload-docs
10 changes: 10 additions & 0 deletions conda/environments/all_cuda-118_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,28 @@ dependencies:
- cuda-version=11.8
- cudatoolkit
- cython>=3.0.0
- doxygen=1.8.20
- fmt>=9.1.0,<10
- gcovr>=5.0
- graphviz
- identify>=2.5.20
- ipython
- make
- nbsphinx
- ninja
- numba>=0.57
- numpy>=1.21
- numpydoc
- nvcc_linux-64=11.8
- pre-commit
- pytest
- pytest-cov
- python>=3.9,<3.11
- scikit-build>=0.13.1
- spdlog>=1.11.0,<1.12
- sphinx
- sphinx-copybutton
- sphinx-markdown-tables
- sphinx_rtd_theme
- tomli
name: all_cuda-118_arch-x86_64
10 changes: 10 additions & 0 deletions conda/environments/all_cuda-120_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,27 @@ dependencies:
- cuda-python>=12.0,<13.0a0
- cuda-version=12.0
- cython>=3.0.0
- doxygen=1.8.20
- fmt>=9.1.0,<10
- gcovr>=5.0
- graphviz
- identify>=2.5.20
- ipython
- make
- nbsphinx
- ninja
- numba>=0.57
- numpy>=1.21
- numpydoc
- pre-commit
- pytest
- pytest-cov
- python>=3.9,<3.11
- scikit-build>=0.13.1
- spdlog>=1.11.0,<1.12
- sphinx
- sphinx-copybutton
- sphinx-markdown-tables
- sphinx_rtd_theme
- tomli
name: all_cuda-120_arch-x86_64
2 changes: 2 additions & 0 deletions dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ files:
- checks
- cudatoolkit
- develop
- docs
- run
- test_python
test_python:
Expand Down Expand Up @@ -155,6 +156,7 @@ dependencies:
- doxygen=1.8.20
- graphviz
- ipython
- make
- nbsphinx
- numpydoc
- sphinx
Expand Down
2 changes: 1 addition & 1 deletion python/docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXOPTS = -n -v -W --keep-going
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build
Expand Down
2 changes: 2 additions & 0 deletions python/docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Memory Resources

.. automodule:: rmm.mr
:members:
:inherited-members:
:undoc-members:
:show-inheritance:

Expand All @@ -28,6 +29,7 @@ Memory Allocators

.. automodule:: rmm.allocators.numba
:members:
:inherited-members:
:undoc-members:
:show-inheritance:

Expand Down
2 changes: 1 addition & 1 deletion python/docs/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ example, enabling the `ManagedMemoryResource` tells RMM to use
> :warning: The default resource must be set for any device **before**
> allocating any device memory on that device. Setting or changing the
> resource after device allocations have been made can lead to unexpected
> behaviour or crashes. See [Multiple Devices](#multiple-devices)
> behaviour or crashes.

As another example, `PoolMemoryResource` allows you to allocate a
large "pool" of device memory up-front. Subsequent allocations will
Expand Down
12 changes: 10 additions & 2 deletions python/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
# 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,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
html_static_path = []


# -- Options for HTMLHelp output ------------------------------------------
Expand Down Expand Up @@ -179,14 +179,22 @@


# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {"https://docs.python.org/": None}
intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
"numba": ("https://numba.readthedocs.io/en/stable", None),
}

# Config numpydoc
numpydoc_show_inherited_class_members = True
numpydoc_class_members_toctree = False

autoclass_content = "init"

nitpick_ignore = [
("py:class", "size_t"),
("py:class", "void"),
]


def setup(app):
app.add_js_file("copybutton_pydocs.js")
Expand Down
23 changes: 23 additions & 0 deletions python/rmm/_lib/memory_resource.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -217,18 +217,41 @@ cdef extern from "rmm/mr/device/failure_callback_resource_adaptor.hpp" \
cdef class DeviceMemoryResource:

cdef device_memory_resource* get_mr(self):
"""Get the underlying C++ memory resource object."""
return self.c_obj.get()

def allocate(self, size_t nbytes):
"""Allocate ``nbytes`` bytes of memory.

Parameters
----------
nbytes : size_t
The size of the allocation in bytes
"""
return <uintptr_t>self.c_obj.get().allocate(nbytes)

def deallocate(self, uintptr_t ptr, size_t nbytes):
"""Deallocate memory pointed to by ``ptr`` of size ``nbytes``.

Parameters
----------
ptr : uintptr_t
Pointer to be deallocated
nbytes : size_t
Size of the allocation in bytes
"""
self.c_obj.get().deallocate(<void*>(ptr), nbytes)


# See the note about `no_gc_clear` in `device_buffer.pyx`.
@cython.no_gc_clear
cdef class UpstreamResourceAdaptor(DeviceMemoryResource):
"""Parent class for all memory resources that track an upstream.

Upstream resource tracking requires maintaining a reference to the upstream
mr so that it is kept alive and may be accessed by any downstream resource
adaptors.
"""

def __cinit__(self, DeviceMemoryResource upstream_mr, *args, **kwargs):

Expand Down
17 changes: 17 additions & 0 deletions python/rmm/allocators/numba.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import ctypes
import inspect

from cuda.cuda import CUdeviceptr, cuIpcGetMemHandle
from numba import config, cuda
Expand Down Expand Up @@ -112,13 +113,29 @@ def get_ipc_handle(self, memory):
)

def get_memory_info(self):
"""Returns ``(free, total)`` memory in bytes in the context.

This implementation raises `NotImplementedError` because the allocation
will be performed using rmm's currently set default mr, which may be a
pool allocator.
"""
raise NotImplementedError()

@property
def interface_version(self):
return 1


# The parent class docstrings contain references without fully qualified names,
# so we need to replace them here for our Sphinx docs to render properly.
for _, method in inspect.getmembers(RMMNumbaManager, inspect.isfunction):
if method.__doc__ is not None:
method.__doc__ = method.__doc__.replace(
":class:`BaseCUDAMemoryManager`",
":class:`numba.cuda.BaseCUDAMemoryManager`",
)


# Enables the use of RMM for Numba via an environment variable setting,
# NUMBA_CUDA_MEMORY_MANAGER=rmm. See:
# https://numba.readthedocs.io/en/stable/cuda/external-memory.html#environment-variable
Expand Down
2 changes: 2 additions & 0 deletions python/rmm/mr.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
PoolMemoryResource,
StatisticsResourceAdaptor,
TrackingResourceAdaptor,
UpstreamResourceAdaptor,
_flush_logs,
_initialize,
disable_logging,
Expand Down Expand Up @@ -51,6 +52,7 @@
"StatisticsResourceAdaptor",
"TrackingResourceAdaptor",
"FailureCallbackResourceAdaptor",
"UpstreamResourceAdaptor",
"_flush_logs",
"_initialize",
"set_per_device_resource",
Expand Down