Skip to content

Commit 18c47ea

Browse files
split development environment from contribution guide
1 parent 722e844 commit 18c47ea

File tree

3 files changed

+14
-131
lines changed

3 files changed

+14
-131
lines changed

CONTRIBUTING.rst

Lines changed: 12 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ Before creating a pull request please ensure the following:
3232
If you are in doubt on where to put your additions to the Kernel Tuner, please
3333
have look at the :ref:`design documentation <design documentation>`, or discuss it in the issue regarding your additions.
3434

35-
.. _development environment:
36-
35+
.. _simple-dev-env:
3736

3837
Simple development setup
3938
------------------------
@@ -44,134 +43,17 @@ For small changes to the code you can setup a quick development environment with
4443
* :bash:`cd kernel_tuner`
4544
* :bash:`pip install -e .`
4645

47-
To run the tests:
46+
To run the tests in your local Python environment:
47+
4848
* :bash:`pip install -r doc/requirements_test.txt`
4949
* :bash:`pytest -v test`
5050

51-
For larger changes, or when you need to change the dependencies of Kernel Tuner, please follow the instructions below to setup the full development environment.
52-
53-
54-
Full development environment
55-
----------------------------
56-
The following steps help you set up a full development environment. **These steps are only needed for core developers of Kernel Tuner who need to test against multiple Python versions
57-
or change dependencies of Kernel Tuner.**
58-
59-
Local setup
60-
^^^^^^^^^^^
61-
Steps with :bash:`sudo` access (e.g. on a local device):
62-
63-
#. Clone the git repository to the desired location: :bash:`git clone https://github.com/KernelTuner/kernel_tuner.git`, and :bash:`cd` to it.
64-
#. Prepare your system for building Python versions.
65-
* On Ubuntu, run :bash:`sudo apt update && sudo apt upgrade`, and :bash:`sudo apt install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl git`.
66-
#. Install `pyenv <https://github.com/pyenv/pyenv#installation>`__:
67-
* On Linux, run :bash:`curl https://pyenv.run | bash` (remember to add the output to :bash:`.bash_profile` and :bash:`.bashrc` as specified).
68-
* On macOS, run :bash:`brew update && brew install pyenv`.
69-
* After installation, restart your shell.
70-
#. Install the required Python versions:
71-
* On some systems, additional packages may be needed to build Python versions. For example on Ubuntu: :bash:`sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev liblzma-dev lzma`.
72-
* Install the Python versions with: :bash:`pyenv install 3.8 3.9 3.10 3.11`. The reason we're installing all these versions as opposed to just one, is so we can test against all supported Python versions.
73-
#. Set the Python versions so they can be found: :bash:`pyenv local 3.8 3.9 3.10 3.11` (replace :bash:`local` with :bash:`global` when not using the virtualenv).
74-
#. Setup a local virtual environment in the folder: :bash:`pyenv virtualenv 3.11 kerneltuner` (or whatever environment name and Python version you prefer).
75-
#. `Install Poetry <https://python-poetry.org/docs/#installing-with-the-official-installer>`__.
76-
* Use :bash:`curl -sSL https://install.python-poetry.org | python3 -` to install Poetry.
77-
* Make sure to add Poetry to :bash:`PATH` as instructed at the end of the installation.
78-
* Add the poetry export plugin with :bash:`poetry self add poetry-plugin-export`.
79-
#. Make sure that non-Python dependencies are installed if applicable, such as CUDA, OpenCL or HIP. This is described in :ref:`Installation <installation>`.
80-
#. Apply changes:
81-
* Re-open the shell for changes to take effect.
82-
* Activate the environment with :bash:`pyenv activate kerneltuner`.
83-
* Make sure :bash:`which python` and :bash:`which pip` point to the expected Python location and version.
84-
* Update Pip with :bash:`pip install --upgrade pip`.
85-
#. Install the project, dependencies and extras: :bash:`poetry install --with test,docs -E cuda -E opencl -E hip`, leaving out :bash:`-E cuda`, :bash:`-E opencl` or :bash:`-E hip` if this does not apply on your system. To go all-out, use :bash:`--all-extras`
86-
* Depending on the environment, it may be necessary or convenient to install extra packages such as :bash:`cupy-cuda11x` / :bash:`cupy-cuda12x`, and :bash:`cuda-python`. These are currently not defined as dependencies for kernel-tuner, but can be part of tests.
87-
* Do not forget to make sure the paths are set correctly. If you're using CUDA, the desired CUDA version should be in :bash:`$PATH`, :bash:`$LD_LIBARY_PATH` and :bash:`$CPATH`.
88-
* Re-open the shell for changes to take effect.
89-
#. Check if the environment is setup correctly by running :bash:`pytest` and :bash:`nox`. All tests should pass, except if one or more extras has been left out in the previous step, then these tests will skip gracefully.
90-
* [Note]: sometimes, changing the NVIDIA driver privileges is required to read program counters and energy measurements. Check if :bash:`cat /proc/driver/nvidia/params | grep RmProfilingAdminOnly` is set to 1. If so, `follow these steps <https://developer.nvidia.com/nvidia-development-tools-solutions-err_nvgpuctrperm-permission-issue-performance-counters>`__
91-
92-
93-
Cluster setup
94-
^^^^^^^^^^^^^
95-
Steps without :bash:`sudo` access (e.g. on a cluster):
96-
97-
#. Clone the git repository to the desired location: :bash:`git clone https://github.com/KernelTuner/kernel_tuner.git`.
98-
#. Install Conda with `Mamba <https://mamba.readthedocs.io/en/latest/mamba-installation.html>`__ (for better performance) or `Miniconda <https://docs.conda.io/projects/conda/en/latest/user-guide/install>`__ (for traditional minimal Conda).
99-
* [Optional] if you are under quotas or are otherwise restricted by disk space, you can instruct Conda to use a different directory for saving environments by adding the following to your :bash:`.condarc` file:
100-
.. code-block:: bash
101-
102-
envs_dirs:
103-
- /path/to/directory
104-
* [Optional] both Mamba and Miniconda can be automatically activated via :bash:`~/.bashrc`. Do not forget to add these (usually provided at the end of the installation).
105-
* Exit the shell and re-enter to make sure Conda is available. :bash:`cd` to the kernel tuner directory.
106-
* [Optional] if you have limited user folder space, the Pip cache can be pointed elsewhere with the environment variable :bash:`PIP_CACHE_DIR`. The cache location can be checked with :bash:`pip cache dir`. On Linux, to point the entire :bash:`~/.cache` default elsewhere, use the :bash:`XDG_CACHE_HOME` environment variable.
107-
* [Optional] update Conda if available before continuing: :bash:`conda update -n base -c conda-forge conda`.
108-
#. Setup a virtual environment: :bash:`conda create --name kerneltuner python=3.11` (or whatever Python version and environment name you prefer).
109-
#. Activate the virtual environment: :bash:`conda activate kerneltuner`.
110-
* [Optional] to use the correct environment by default, execute :bash:`conda config --set auto_activate_base false`, and add `conda activate kerneltuner` to your :bash:`.bash_profile` or :bash:`.bashrc`.
111-
#. Make sure that non-Python dependencies are loaded if applicable, such as CUDA, OpenCL or HIP. On most clusters it is possible to load (or unload) modules (e.g. CUDA, OpenCL / ROCM). For more information, see :ref:`Installation <installation>`.
112-
* Do not forget to make sure the paths are set correctly. If you're using CUDA, the desired CUDA version should be in :bash:`$PATH`, :bash:`$LD_LIBARY_PATH` and :bash:`$CPATH`.
113-
* [Optional] the loading of modules and setting of paths is likely convenient to put in your :bash:`.bash_profile` or :bash:`.bashrc`.
114-
#. `Install Poetry <https://python-poetry.org/docs/#installing-with-the-official-installer>`__.
115-
* Use :bash:`curl -sSL https://install.python-poetry.org | python3 -` to install Poetry.
116-
* Add the poetry export plugin with :bash:`poetry self add poetry-plugin-export`.
117-
#. Install the project, dependencies and extras: :bash:`poetry install --with test,docs -E cuda -E opencl -E hip`, leaving out :bash:`-E cuda`, :bash:`-E opencl` or :bash:`-E hip` if this does not apply on your system. To go all-out, use :bash:`--all-extras`.
118-
* If you run into "keyring" or other seemingly weird issues, this is a known issue with Poetry on some systems. Do: :bash:`pip install keyring`, :bash:`python3 -m keyring --disable`.
119-
* Depending on the environment, it may be necessary or convenient to install extra packages such as :bash:`cupy-cuda11x` / :bash:`cupy-cuda12x`, and :bash:`cuda-python`. These are currently not defined as dependencies for kernel-tuner, but can be part of tests.
120-
* Verify that your development environment has no missing installs or updates with :bash:`poetry install --sync --dry-run --with test`.
121-
#. Check if the environment is setup correctly by running :bash:`pytest`. All tests should pass, except if you're not on a GPU node, or one or more extras has been left out in the previous step, then these tests will skip gracefully.
122-
#. Set Nox to use the correct backend and location:
123-
* Run :bash:`conda -- create-settings-file` to automatically create a settings file.
124-
* In this settings file :bash:`noxsettings.toml`, change the :bash:`venvbackend`:
125-
* If you used Mamba in step 2, to :bash:`mamba`.
126-
* If you used Miniconda or Anaconda in step 2, to :bash:`conda`.
127-
* If you used Venv in step 2, to :bash:`venv`.
128-
* If you used Virtualenv in step 2, this is already the default.
129-
* Be sure to adjust this when changing backends.
130-
* The settings file also has :bash:`envdir`, which allows you to `change the directory Nox caches environments in <https://nox.thea.codes/en/stable/usage.html#opt-envdir>`_, particularly helpful if you have a diskquota on your user directory.
131-
#. [Optional] Run the tests on Nox as described below.
132-
133-
134-
Running tests
135-
-------------
136-
To run the tests you can use :bash:`nox` (to run against all supported Python versions in isolated environments) and :bash:`pytest` (to run against the local Python version, see below) in the top-level directory.
137-
For full coverage, make Nox use the additional tests (such as cupy and cuda-python) with :bash:`nox -- additional-tests`.
138-
139-
The Nox isolated environments can take up to 1 gigabyte in size, so users tight on diskspace can run :bash:`nox` with the :bash:`small-disk` option. This removes the other environment caches before each session is ran (note that this will take longer to run). A better option would be to change the location environments are stored in with :bash:`envdir` in the :bash:`noxsettings.toml` file.
140-
141-
Please note that the command-line options can be combined, e.g. :bash:`nox -- additional-tests skip-hip small-disk`.
142-
If you do not have fully compatible hardware or environment, you can use the following options:
143-
144-
* :bash:`nox -- skip-cuda` to skip tests involving CUDA.
145-
* :bash:`nox -- skip-hip` to skip tests involving HIP.
146-
* :bash:`nox -- skip-opencl` to skip tests involving OpenCL.
147-
* :bash:`nox -- skip-gpu` to skip all tests on the GPU (the same as :bash:`nox -- skip-cuda skip-hip skip-opencl`), especially helpful if you don't have a GPU locally.
148-
149-
Contributions you make to the Kernel Tuner should not break any of the tests even if you cannot run them locally!
150-
151-
Running with :bash:`pytest` will test against your local Python version and PIP packages.
152-
In this case, tests that require PyCuda and/or a CUDA capable GPU will be skipped automatically if these are not installed/present.
153-
The same holds for tests that require PyOpenCL, Cupy, and CUDA.
154-
It is also possible to invoke PyTest from the 'Testing' tab in Visual Studio Code to visualize the testing in your IDE.
155-
156-
The examples can be seen as *integration tests* for the Kernel Tuner.
157-
Note that these will also use the installed package.
158-
159-
Building documentation
160-
----------------------
161-
Documentation is located in the ``doc/`` directory. This is where you can type
162-
``make html`` to generate the html pages in the ``doc/build/html`` directory.
163-
The source files used for building the documentation are located in
164-
``doc/source``.
165-
To locally inspect the documentation before committing you can browse through
166-
the documentation pages generated locally in ``doc/build/html``.
167-
168-
To make sure you have all the dependencies required to build the documentation, at least those in ``--with docs``.
169-
Pandoc is also required, you can install pandoc on Ubuntu using ``sudo apt install pandoc`` and on Mac using ``brew install pandoc``.
170-
For different setups please see `pandoc's install documentation <https://pandoc.org/installing.html>`__.
171-
172-
The documentation pages hosted online are built automatically using GitHub actions.
173-
The documentation pages corresponding to the master branch are hosted in /latest/.
174-
The documentation of the last release is in /stable/. When a new release
175-
is published the documentation for that release will be stored in a directory
176-
created for that release and /stable/ will be updated to point to the last
177-
release. This process is again fully automated using GitHub actions.
51+
To build the documentation locally:
52+
53+
* :bash:`pip install -r doc/requirements.txt`
54+
* :bash:`cd doc`
55+
* :bash:`make html`
56+
57+
These instructions should be enough for most small contributions.
58+
For larger changes, or when you need to change the dependencies of Kernel Tuner, please see the documentation on setting up a full development environment.
59+

doc/source/contents.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ The Kernel Tuner documentation
4545
vocabulary
4646
design
4747
contributing
48-
48+
dev-environment

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ markupsafe = "^2.0.1" # TODO why do we need markupsafe here?
106106
# sphinx-autodoc-typehints = "^1.24.0"
107107

108108
# ATTENTION: if anything is changed here, run `poetry update`
109+
# Please also run `poetry export -f requirements.txt --output doc/requirements_test.txt --with test`
109110
[tool.poetry.group.test]
110111
optional = true
111112
[tool.poetry.group.test.dependencies]

0 commit comments

Comments
 (0)