From 2e47f98eb715040a31bbc3a8329f212d22f8ee5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ja=C5=82owiecki?= Date: Sat, 18 Feb 2023 14:00:46 +0100 Subject: [PATCH 01/23] Initialize docs --- docs/Makefile | 20 ++++++++++++++++++++ docs/conf.py | 27 +++++++++++++++++++++++++++ docs/index.rst | 20 ++++++++++++++++++++ docs/make.bat | 35 +++++++++++++++++++++++++++++++++++ pyproject.toml | 11 +++++++++++ 5 files changed, 113 insertions(+) create mode 100644 docs/Makefile create mode 100644 docs/conf.py create mode 100644 docs/index.rst create mode 100644 docs/make.bat diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..d4bb2cb --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..b22baac --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,27 @@ +# Configuration file for the Sphinx documentation builder. +# +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +project = 'setuptools-cuda' +copyright = '2023, Konrad Jałowiecki' +author = 'Konrad Jałowiecki' + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +extensions = [] + +templates_path = ['_templates'] +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] + + + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_theme = 'alabaster' +html_static_path = ['_static'] diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..c0e8e49 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,20 @@ +.. setuptools-cuda documentation master file, created by + sphinx-quickstart on Sat Feb 18 13:59:31 2023. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to setuptools-cuda's documentation! +=========================================== + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..32bb245 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=. +set BUILDDIR=_build + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "" goto help + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/pyproject.toml b/pyproject.toml index 8044448..7afd13b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,6 +11,17 @@ classifiers = [ "Operating System :: POSIX :: Linux" ] +[project.optional-dependencies] +dev = ["flake8>=4.0.1", "black>=21.12b0", "isort>=5.10.1", "mypy>=0.961"] +docs = [ + "sphinx~=5.3.0", + "pydata-sphinx-theme~=0.11.0", + "sphinx_math_dollar~=1.2.1", + "myst-parser~=0.18.1", + "iplantuml~=0.1.1", + "sphinx-design~=0.3.0" +] + [project.entry-points."distutils.setup_keywords"] cuda_extensions = "setuptools_cuda.setuptools_ext:cuda_extensions" From c10c797015556d7146a0e764a70edc9a66f4d7bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ja=C5=82owiecki?= Date: Sat, 18 Feb 2023 14:05:00 +0100 Subject: [PATCH 02/23] Separate source and build directories --- docs/Makefile | 4 ++-- docs/make.bat | 4 ++-- docs/{ => source}/conf.py | 2 +- docs/{ => source}/index.rst | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) rename docs/{ => source}/conf.py (94%) rename docs/{ => source}/index.rst (89%) diff --git a/docs/Makefile b/docs/Makefile index d4bb2cb..d0c3cbf 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -5,8 +5,8 @@ # from the environment for the first two. SPHINXOPTS ?= SPHINXBUILD ?= sphinx-build -SOURCEDIR = . -BUILDDIR = _build +SOURCEDIR = source +BUILDDIR = build # Put it first so that "make" without argument is like "make help". help: diff --git a/docs/make.bat b/docs/make.bat index 32bb245..747ffb7 100644 --- a/docs/make.bat +++ b/docs/make.bat @@ -7,8 +7,8 @@ REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) -set SOURCEDIR=. -set BUILDDIR=_build +set SOURCEDIR=source +set BUILDDIR=build %SPHINXBUILD% >NUL 2>NUL if errorlevel 9009 ( diff --git a/docs/conf.py b/docs/source/conf.py similarity index 94% rename from docs/conf.py rename to docs/source/conf.py index b22baac..45ce54c 100644 --- a/docs/conf.py +++ b/docs/source/conf.py @@ -16,7 +16,7 @@ extensions = [] templates_path = ['_templates'] -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] +exclude_patterns = [] diff --git a/docs/index.rst b/docs/source/index.rst similarity index 89% rename from docs/index.rst rename to docs/source/index.rst index c0e8e49..72f5aba 100644 --- a/docs/index.rst +++ b/docs/source/index.rst @@ -1,5 +1,5 @@ .. setuptools-cuda documentation master file, created by - sphinx-quickstart on Sat Feb 18 13:59:31 2023. + sphinx-quickstart on Sat Feb 18 14:04:40 2023. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. From 97be98c5ba0e2b651c9e226af678f74a58f26b49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ja=C5=82owiecki?= Date: Sun, 19 Feb 2023 22:30:22 +0100 Subject: [PATCH 03/23] Add stubs for all the sections. --- docs/source/conf.py | 6 ++-- docs/source/creating_extensions.md | 1 + docs/source/examples/example01_saxpy.md | 2 ++ docs/source/examples/example02_thrust.md | 1 + docs/source/examples/index.md | 37 ++++++++++++++++++++++++ docs/source/index.md | 29 +++++++++++++++++++ docs/source/index.rst | 20 ------------- docs/source/quickstart.md | 1 + 8 files changed, 75 insertions(+), 22 deletions(-) create mode 100644 docs/source/creating_extensions.md create mode 100644 docs/source/examples/example01_saxpy.md create mode 100644 docs/source/examples/example02_thrust.md create mode 100644 docs/source/examples/index.md create mode 100644 docs/source/index.md delete mode 100644 docs/source/index.rst create mode 100644 docs/source/quickstart.md diff --git a/docs/source/conf.py b/docs/source/conf.py index 45ce54c..f0bd21c 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -13,7 +13,7 @@ # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration -extensions = [] +extensions = ["myst_parser"] templates_path = ['_templates'] exclude_patterns = [] @@ -23,5 +23,7 @@ # -- Options for HTML output ------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output -html_theme = 'alabaster' +html_theme = 'pydata_sphinx_theme' html_static_path = ['_static'] + +myst_enable_extensions = ["colon_fence"] \ No newline at end of file diff --git a/docs/source/creating_extensions.md b/docs/source/creating_extensions.md new file mode 100644 index 0000000..fb8db1f --- /dev/null +++ b/docs/source/creating_extensions.md @@ -0,0 +1 @@ +# Creating extensions \ No newline at end of file diff --git a/docs/source/examples/example01_saxpy.md b/docs/source/examples/example01_saxpy.md new file mode 100644 index 0000000..027eff7 --- /dev/null +++ b/docs/source/examples/example01_saxpy.md @@ -0,0 +1,2 @@ +(sec:example01)= +# Example 01: CUDA Saxpy diff --git a/docs/source/examples/example02_thrust.md b/docs/source/examples/example02_thrust.md new file mode 100644 index 0000000..1d3cede --- /dev/null +++ b/docs/source/examples/example02_thrust.md @@ -0,0 +1 @@ +# Example 02: Using thrust library diff --git a/docs/source/examples/index.md b/docs/source/examples/index.md new file mode 100644 index 0000000..2800049 --- /dev/null +++ b/docs/source/examples/index.md @@ -0,0 +1,37 @@ +# Examples + +Since a code snippet is more than a thousand words, we believe that the best +way to learn `setuptools-cuda` is to look at the examples. If you are +feeling adventurous, you can go and view them directly on our GitHub. +However, we recommend reading at least the description of example 01 below, +as it will introduce you to all the concepts needed for writing your own +extensions. + +## Prerequisites + +Both examples require you to have the following: + +- Working Python >= 3.9 installation +- Ability to install Python packages. We strongly recommend you create a + fresh virtual environment for the purpose of experimenting with + `setuptools-cuda`. +- Working installation of CUDA toolkit. +- (optionally but recommended) Working installation of NVidia driver and + CUDA runtime (otherwise you will be able to build but not run the examples). + +The `setuptools-cuda` uses a `CUDAHOME` environmental variable, which you +should set to the path of your CUDA installation. If you don't do this, +`setuptools-cuda` will try to auto-detect it, but it will probably fail and +you will have a bad time trying to figure out why things aren't working. + +## Currently available examples + +### [Example 01: CUDA Saxpy](sec:example01) + +This example shows how the basic saxpy implementation works with +`setuptools-cuda`. + +### [Example 02: Integration with Thrust library](sec:example02) + +The second example demonstrates how `setuptools-cuda` can be integrated with +thrust. \ No newline at end of file diff --git a/docs/source/index.md b/docs/source/index.md new file mode 100644 index 0000000..8c6949c --- /dev/null +++ b/docs/source/index.md @@ -0,0 +1,29 @@ +--- +html_theme.sidebar_secondary.remove: true +--- +# setuptools-cuda + +The `setuptools-cuda` is a [setuptools](https://setuptools.pypa.io/en/latest/) +plugin for building CUDA enabled Python extension modules. + + +The `setuptools-cuda` is intended for creators of extension modules +who would like to include, along their C/C++ code, a CUDA code. If you are +instead looking for more high-level ways of using CUDA from Python, you +should instead take a look at other packages. + +## Getting started + +We recommend you start by reading the overview in our quickstart guide and then +take a look at the examples (which we thoroughly discuss here). After +that, you can either experiment on your own, on read more-in depth extension +creator guide.. + +:::{toctree} +:maxdepth: 2 + + +quickstart.md +examples/index.md +creating_extensions.md +::: \ No newline at end of file diff --git a/docs/source/index.rst b/docs/source/index.rst deleted file mode 100644 index 72f5aba..0000000 --- a/docs/source/index.rst +++ /dev/null @@ -1,20 +0,0 @@ -.. setuptools-cuda documentation master file, created by - sphinx-quickstart on Sat Feb 18 14:04:40 2023. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - -Welcome to setuptools-cuda's documentation! -=========================================== - -.. toctree:: - :maxdepth: 2 - :caption: Contents: - - - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` diff --git a/docs/source/quickstart.md b/docs/source/quickstart.md new file mode 100644 index 0000000..179f6b7 --- /dev/null +++ b/docs/source/quickstart.md @@ -0,0 +1 @@ +# Quickstart \ No newline at end of file From 989e0395969285c638f8fe2ec7913d0eed1b93e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ja=C5=82owiecki?= Date: Sun, 19 Feb 2023 22:42:36 +0100 Subject: [PATCH 04/23] Remove quickstart chapter --- docs/source/index.md | 10 +++------- docs/source/quickstart.md | 1 - 2 files changed, 3 insertions(+), 8 deletions(-) delete mode 100644 docs/source/quickstart.md diff --git a/docs/source/index.md b/docs/source/index.md index 8c6949c..030668c 100644 --- a/docs/source/index.md +++ b/docs/source/index.md @@ -14,16 +14,12 @@ should instead take a look at other packages. ## Getting started -We recommend you start by reading the overview in our quickstart guide and then -take a look at the examples (which we thoroughly discuss here). After -that, you can either experiment on your own, on read more-in depth extension -creator guide.. +We recommend you start by taking a look at the examples. After +that, you can either experiment on your own, on read the detailed manual. :::{toctree} :maxdepth: 2 - -quickstart.md examples/index.md creating_extensions.md -::: \ No newline at end of file +::: diff --git a/docs/source/quickstart.md b/docs/source/quickstart.md deleted file mode 100644 index 179f6b7..0000000 --- a/docs/source/quickstart.md +++ /dev/null @@ -1 +0,0 @@ -# Quickstart \ No newline at end of file From af3a535ba79fe61bd81659047e2c733680a8ce03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ja=C5=82owiecki?= Date: Sun, 19 Feb 2023 22:43:42 +0100 Subject: [PATCH 05/23] Rename creating_extensions.md and update titles accodringly --- docs/source/creating_extensions.md | 1 - docs/source/index.md | 2 +- docs/source/manual.md | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 docs/source/creating_extensions.md create mode 100644 docs/source/manual.md diff --git a/docs/source/creating_extensions.md b/docs/source/creating_extensions.md deleted file mode 100644 index fb8db1f..0000000 --- a/docs/source/creating_extensions.md +++ /dev/null @@ -1 +0,0 @@ -# Creating extensions \ No newline at end of file diff --git a/docs/source/index.md b/docs/source/index.md index 030668c..7f1a051 100644 --- a/docs/source/index.md +++ b/docs/source/index.md @@ -21,5 +21,5 @@ that, you can either experiment on your own, on read the detailed manual. :maxdepth: 2 examples/index.md -creating_extensions.md +manual.md ::: diff --git a/docs/source/manual.md b/docs/source/manual.md new file mode 100644 index 0000000..3902113 --- /dev/null +++ b/docs/source/manual.md @@ -0,0 +1 @@ +# Manual From bed642cd17359dea15ae907b34432b10b22b2b37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ja=C5=82owiecki?= Date: Sun, 19 Feb 2023 22:48:00 +0100 Subject: [PATCH 06/23] Add missing section label in example02 --- docs/source/examples/example02_thrust.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/examples/example02_thrust.md b/docs/source/examples/example02_thrust.md index 1d3cede..20cc6f8 100644 --- a/docs/source/examples/example02_thrust.md +++ b/docs/source/examples/example02_thrust.md @@ -1 +1,2 @@ +(sec:example02)= # Example 02: Using thrust library From a003fa3918faf4fd35d51a734db81cfa0b9f2444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ja=C5=82owiecki?= Date: Sun, 19 Feb 2023 22:48:19 +0100 Subject: [PATCH 07/23] Include example files in toctree --- docs/source/examples/index.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/source/examples/index.md b/docs/source/examples/index.md index 2800049..573b0ed 100644 --- a/docs/source/examples/index.md +++ b/docs/source/examples/index.md @@ -34,4 +34,11 @@ This example shows how the basic saxpy implementation works with ### [Example 02: Integration with Thrust library](sec:example02) The second example demonstrates how `setuptools-cuda` can be integrated with -thrust. \ No newline at end of file +thrust. + +:::{toctree} +:hidden: + +example01_saxpy.md +example02_thrust.md +::: From da363090fa01bbe48dd28d973a21e8fefc04bf62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ja=C5=82owiecki?= Date: Mon, 20 Feb 2023 01:31:25 +0100 Subject: [PATCH 08/23] Add description of the examples --- docs/source/examples/example01_saxpy.md | 235 +++++++++++++++++++++++ docs/source/examples/example02_thrust.md | 97 +++++++++- 2 files changed, 331 insertions(+), 1 deletion(-) diff --git a/docs/source/examples/example01_saxpy.md b/docs/source/examples/example01_saxpy.md index 027eff7..f3cdce4 100644 --- a/docs/source/examples/example01_saxpy.md +++ b/docs/source/examples/example01_saxpy.md @@ -1,2 +1,237 @@ (sec:example01)= # Example 01: CUDA Saxpy + +## Overview + +In this example we will discuss a simple project implementing the saxpy function run on +CUDA enabled device. If you need a quick recap, saxpy is a function accepting a floating point +number $a$ and two vectors $X, Y$ of the same length. It then performs the following operation: + +$$ +\require{mathtools} +Y \coloneqq aX + Y, +$$ +(i.e. $Y$ is updated in-place). We will be writing our own kernel for saxpy, but to keep things +simple we will not try to compute optimal size of the execution grid. Hence, our implementation +will also accept parameters designating the number of threads in a thread block and the number +of thread blocks. We want our function to work on numpy arrays, which means that we will have to +handle copying data to and from the host. Having all that in mind, the function that we want to +create in this extension has the following signature (we intentionally skip type hints, because, +as you will soon see, we will use Cython for its definition): + + +```python +def saxpy(a, x, y, num_threads, num_blocks): + ... +``` + +The full code for this example can be found +[here](https://github.com/euro-hpc-pl/setuptools_cuda/tree/master/examples/01_basic), +and below is a detailed explanation of each file that the example comprises. + +## File structure + +The file directory tree for our example looks as follows: + +```text +├── pyproject.toml +├── saxpycu +│   ├── saxpy_impl.cu +│   ├── saxpy_impl.h +│   └── saxpy.pyx +├── setup.py +└── test + └── test_saxpy.py +``` + +Briefly, the files play the following role: + +- `saxpycu` directory contains source code of the extension: + - `saxpy_impl.cu` contain the kernel code for saxpy, as well as a wrapper that allows running + it for host arrays. + - `saxpy_impl.h` is a header file containing declaration of the wrapper. This is the file that + we'll include from the Cython source file. + - `saxpy.pyx` is a Cython file containing the actual definition of the function that we will + call from Python. +- `pyproject.toml` defines metadata for the package that we want to bu ild, but most importantly + it defines **build dependencies**. This is where you declare your dependency on `setuptools-cuda`. +- `setup.py` is where you define the extension modules (it's currently not possible to do it in + `pyproject.toml`) +- `test/text_saxpy.py` is a file containing tests to gives us a reasonable confidence that what + we created actually works. + +## Source of the extension + +:::{note} +We are intentionally leaving our the error checking to not clutter the example code. However, in +your production code you should *always* care about error checking. For instance, it might be +wise to check if memory allocation on the device succeeded, or that the kernel was successfully +launched. +::: + +We will start by describing the actual content of the extension - the implementation of `saxpy`. +The `saxpycu/saxpy_impl.cu` contains both a kernel and a wrapper that allow for running it from +the host: + +:::{literalinclude} ../../../examples/01_basic/saxpycu/saxpy_impl.cu +::: + +First, we have the definition of the `_saxpy` kernel. As you can see, the kernel is templated, +and can work on arrays of arbitrary (numerical) type. If you are familiar with CUDA programming, +you shouldn't have any problems working out what the kernel does. + +Next we have `saxpy_wrapper` function, which serves as a "launcher" of the `_saxpy` kernel. +Importantly, using CUDA terminology, this is a host function. We would like to call it from our +Cython code. + +:::{note} +When writing wrappers such as `saxpy_wrapper`, make sure you always free the resources. +Sometimes, you might get away with forgetting e.g. some call to `cudaFree`, but probably it will +resurface later as a hard to track, low-level bug. If you are curious how it may look like, +comment out one of `cudaFree` calls in `saxpy_wrapper`, rebuild the extension and launch the tests. +::: + +Lastly, we have explicit template instantiations of the `saxpy_wrapper` for two values of +parameter `T`, i.e. this code: + +```cpp +template void saxpy_wrapper(float, float*, float*, int, int, int); +template void saxpy_wrapper(double, double*, double*, int, int, int); +``` + +Explicit instantiations tell the compiler to compile those variants of `saxpy_wrapper` even if +they are not called anywhere in the code. **This is a very important detail**, and we'll explain +its importance shortly. + +## Header file + +The header file is short, and contains the declaration of `saxpy_wrapper`. We will use +it in our Cython (.pyx) file to declare `saxpy_wrapper` as external function. + +:::{literalinclude} ../../../examples/01_basic/saxpycu/saxpy_impl.h +::: + +## Cython file + +In this example, Cython serves as a glue between C++ and Python. Of course, you don't have to +use it in your projects, but for many use cases it simplifies things by a lot, compared to e.g. +using NumPy's C API. Our Cython file looks as follows: + +:::{literalinclude} ../../../examples/01_basic/saxpycu/saxpy.pyx +::: + +We start by declaring that we are using C++. The default language is C, which won't let us +compile our templates. Next, we define fused type `real`. In pure Python we would call `real`a +*union* of `float` and `double`. If a function contains arguments of type real, Cython will +prepare bot a version for both single and double precision floating-point numbers. + +Next, we declare usage of the external function `saxpy_wrapper` defined in `saxpy_impl.h`. +Compare this declaration: +```cython +cdef extern from "saxpy_impl.h": + void saxpy_wrapper[T](T a, T * x, T * y, int n, int numThreads, int numBlocks); +``` +with the definition we have in `saxpy_impl.h`: +```cpp +template +void saxpy_wrapper(T a, T* x, T* y, int n, int numThreads, int numBlocks); +``` +As you can see, the Cython version is just a simple rewrite of the C++ function into cythonic +language. + +Finally, we reach the main goal of this example, and define `saxpy` function. Aside from being +Python function, it contains several differences as compared to the `saxpy_wrapper`: + +- We use our fused type `real` instead of an abstract template argument `T`. We hence restrict + possible values of `T` with which `saxpy_wrapper` can be called to `float` and `double`. + Notice however, that we do this only to exemplify how the fused types work, in principle + nothing prevents you from using saxpy with e.g. values of type `int`. + + Also, here is where the explicit instantiation of `saxpy_wrapper` comes into play. By using + `real` type, we make sure that the only variants of `saxpy_wrapper` that will be called by our + extension are ones with `T=float` and `T=double`. By explicitly instantiating those variants, + we make sure they are compiled and will be available at runtime. Without the explicit + instantiation, the compilation would go smoothly, but at runtime we wil get low-level errors + telling us about the undefined symbols. +- Instead of using pointers, we use `real[::1]` syntax. Basically it means that we can accept a + continuous memory view, like e.g. a numpy array. To obtain the underlying pointer, we simply + extract address of the zero-th element (e.g. `&x[0]`). + + :::{note} + Because we use `real[::1]` syntax as the type for our arrays, the `saxpy` function won't work for + numpy views. If we would like to allow views as well, we would have to do some additional work + which we will not discuss here. + ::: +- The `saxpy` function does not accept the explicit `n` argument designating the length of `x` + and `y`. This is simply because it's not needed, as we can just extract len of the `x` or `y` + array. + +## pyproject.toml + +The `pyproject.toml` of our package is simple and looks as follows: + +:::{literalinclude} ../../../examples/01_basic/pyproject.toml +::: + +In the `[build-system]` section we define the build-time requirements. We have +`setuptoools-cuda` and `setuptools` for obvious reasons. Next we have wheel, which will allow us +installing and building the package by simply running `pip install`. Lastly, we have `cython` as +we will also use it for building our project. + +IN the `[project]` section, we define the name of our package and its version, but also +dependencies that will be installed when running `pip install`. We include `numpy`, because we +will test our functions on arrays and also `pytest` for easily running our tests. + +:::{note} +Typically, requirements needed for tests are placed in separate "extra" dependencies. However, +we decided to put them directly in `dependencies` to make the example simpler. +::: + +## setup.py + +The `setup.py` is where we define our extension. It looks as follows; + +:::{literalinclude} ../../../examples/01_basic/setup.py +::: + +Let's break it down. As usually, we import the `setup` function from `setuptools`. We also +import the `cythonize` function, because our extension contains `Cython` modules. Finally, we +import `CudaExtension` from `setuptools_cuda`, which we will use to define our extension. + +The extension is defined by creating and instance of `CudaExtension` class. It accepts the same +arguments as regular extensions, in this example we used only the mandatory ones which is `name` +and `sources`. Contrary to regular extensions, however, `CudaExtensions` need to be passed to +`cuda_extensions` keyword of the `setup` function. Before doing so, we let the Cython do its +magic and pass the extensions through Cythonize. + +## Installing the package + +Now that we know everything about our package, it is time to install it (and the extension it +provides). Before you do this, we highly recommend that you define the `CUDAHOME` environmental +variable. It should point to your CUDA installation location. For instance, you can do it by +running the following command **in the same shell session** that you are going to use for +installing the package (of course, adjust the actual path to your particular setup): +```shell +export CUDAHOME=/opt/nvidia/hpc_sdk/Linux_x86_64/23.1/cuda +``` +Refer to our [manual](sec:manual) for more thorough explanation of `CUDAHOME` variable. + + +To install the package, simply run the following command from the `examples/01_basic` directory. +```shell +pip install . +``` +If everything worked fine, the installation should proceed without errors. + +## Running the tests + +To run the tests, you should have working installation of Nvidia drivers and CUDA runtime. If +this is the case, the tests can be run by simply launching the `pytest` command from the +`examples/01_basic` directory. If you haven't modified the example yourself, the tests should +pass without any errors. + +If you are curious, the tests are simple and comprise a single test, run for multiple +pseudo-randomly generated cases. + +:::{literalinclude} ../../../examples/01_basic/test/test_saxpy.py +::: diff --git a/docs/source/examples/example02_thrust.md b/docs/source/examples/example02_thrust.md index 20cc6f8..badac4a 100644 --- a/docs/source/examples/example02_thrust.md +++ b/docs/source/examples/example02_thrust.md @@ -1,2 +1,97 @@ (sec:example02)= -# Example 02: Using thrust library +# Example 02: Using Thrust library + +## Overview + +This example demonstrates how `setuptools_cuda` can be used in conjunction with Thrust library. +We highly recommend that you first read the [saxpy example](sec:example01) description first, as +here we will only focus on the important differences. + +In this example, we will create a simple `sort` function that will sort a numpy array using +`thrust::sort` on a CUDA enabled device. Internally, we will have to handle the transfer of data +from numpy to the device, and then in the opposite way. Our signature will therefore look as +follows + +```python +def sort(data): + ... +``` +As previously, we will use Cython to make our life easier. + +## Directory structure + +```text +├── pyproject.toml +├── setup.py +├── test +│   └── test_thrustcu.py +└── thrustcu + ├── thrustcu_impl.cu + ├── thrustcu_impl.h + └── thrustcu.pyx + +``` +The directory structure in this example is pretty similar to the one in the first example, and +hence we will not discuss the role of each individual file and instead we'll focus on the +relevant contents. + +## Main file of the extension + +Compared to the previous example, this time we do not implement our own kernel. Instead, we rely +on thrust to perform the heavy lifting. The source code for the main file of the extension looks +as follows: + +:::{literalinclude} ../../../examples/02_thrust/thrustcu/thrustcu_impl.cu +:language: c++ +::: + +We start by including several thrust files: + +- `thrust/copy.h` for copying data between host and device. +- `thrust/device_vector.h` for definition of a device vector, which is a structure similar to a + `vector` in standard C++ library. +- `thrust/sort.h` for the actual implementation of parallel sorting. + +As previously, we use templating to allow usage of several data types in our function. As to the +`_sort` function itself, it performs the following operations: + +- Creates a `device_vector` `data_vec`. By passing it a range of pointers, we initialize the + device data to the contents of the original array. +- Sorts the created `device_vector`. +- Copies the data from the device vector back to the host array passed as the argument. + +Similarly to the first example, we explicitly instantiate `_sort` template with several +different data types. The fact that we used more data types then previously will be explored +later on. + +We also create a header file for the `_sort` function, which contains its declaration. + +## Cython file + +Our Cython file shares many similarities to the one from the first example. What's different is +that we use numpy types in the `humber` fused type: + +:::{literalinclude} ../../../examples/02_thrust/thrustcu/thrustcu.pyx +:language: cython +::: + +Note that here we use `cimport` (it's not a typo, there's **c** there). The `cimport` +instruction is used for importing stuff from another Cython module. If we used `import numpy` +instead, all of those dtypes would be simply treated as Python objects and wouldn't work in a +`fused` type declaration. + +## Installing and running the tests + +We once again remind you that before installing the package using `setuptools_cuda` you should +define a `CUDAHOME` environmental variable pointing to your CUDA installation location. + +Similarly to the first example, the package can be installed by running +```shell +pip install . +``` +from the examples/02_thrust directory, and the tests can be launched by running: + +```shell +pytest +``` +from the same directory. From 0f13074347936a43500ee876d0f07d80afa59fc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ja=C5=82owiecki?= Date: Mon, 20 Feb 2023 01:31:49 +0100 Subject: [PATCH 09/23] Add work in progress banner --- docs/source/manual.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/source/manual.md b/docs/source/manual.md index 3902113..5dcfb93 100644 --- a/docs/source/manual.md +++ b/docs/source/manual.md @@ -1 +1,5 @@ # Manual + +:::{warning} +This section is still a work in progress. +::: From 6712442caf0ee4b1de6ae64c53b429a1083768a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ja=C5=82owiecki?= Date: Mon, 20 Feb 2023 01:40:36 +0100 Subject: [PATCH 10/23] Remove implicit cythonization + remove mypy from pre-commit hook --- .pre-commit-config.yaml | 12 ------------ examples/01_basic/setup.py | 15 +++++++++------ examples/02_thrust/setup.py | 17 ++++++++++------- setuptools_cuda/setuptools_ext.py | 6 ++---- 4 files changed, 21 insertions(+), 29 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 325bb65..6116675 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,15 +21,3 @@ repos: rev: 6.0.0 hooks: - id: flake8 - - - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.0.0 - hooks: - - id: mypy - args: [ - --namespace-packages, - --explicit-package-bases, - --ignore-missing-imports, - --install-types, - --non-interactive - ] diff --git a/examples/01_basic/setup.py b/examples/01_basic/setup.py index 6ce94dc..6f3db62 100644 --- a/examples/01_basic/setup.py +++ b/examples/01_basic/setup.py @@ -1,13 +1,16 @@ """Setup module for the `example` package.""" +from Cython.Build import cythonize from setuptools import setup from setuptools_cuda import CudaExtension setup( - cuda_extensions=[ - CudaExtension( - name="saxpycu", - sources=["saxpycu/saxpy.pyx", "saxpycu/saxpy_impl.cu"], - ), - ], + cuda_extensions=cythonize( + [ + CudaExtension( + name="saxpycu", + sources=["saxpycu/saxpy.pyx", "saxpycu/saxpy_impl.cu"], + ), + ] + ), ) diff --git a/examples/02_thrust/setup.py b/examples/02_thrust/setup.py index 29e541f..4b90ee2 100644 --- a/examples/02_thrust/setup.py +++ b/examples/02_thrust/setup.py @@ -1,15 +1,18 @@ """Setup module for the `example` package.""" import numpy as np +from Cython.Build import cythonize from setuptools import setup from setuptools_cuda import CudaExtension setup( - cuda_extensions=[ - CudaExtension( - name="thrust", - sources=["thrustcu/thrustcu.pyx", "thrustcu/thrustcu_impl.cu"], - include_dirs=[np.get_include()], - ), - ], + cuda_extensions=cythonize( + [ + CudaExtension( + name="thrust", + sources=["thrustcu/thrustcu.pyx", "thrustcu/thrustcu_impl.cu"], + include_dirs=[np.get_include()], + ), + ] + ), ) diff --git a/setuptools_cuda/setuptools_ext.py b/setuptools_cuda/setuptools_ext.py index c3c0a21..ca5b0e1 100644 --- a/setuptools_cuda/setuptools_ext.py +++ b/setuptools_cuda/setuptools_ext.py @@ -2,7 +2,6 @@ from distutils.command.build_ext import build_ext from typing import List, Literal, Type, cast -from Cython.Build import cythonize from setuptools.dist import Distribution from .compiler_customization import customize_compiler_for_nvcc @@ -35,11 +34,10 @@ def build_extensions(self): build_ext.build_extensions(self) dist.cmdclass["build_ext"] = BuildCudaExtension - cythonized_cuda_extensions = cythonize(dist.cuda_extensions) dist.ext_modules = ( - cythonized_cuda_extensions + dist.cuda_extensions if dist.ext_modules is None - else dist.ext_modules + cythonized_cuda_extensions + else dist.ext_modules + dist.cuda_extensions ) print(dist.ext_modules) From 7dc56ad286ff20585ef01faf960c938608f1a152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ja=C5=82owiecki?= Date: Mon, 20 Feb 2023 01:41:03 +0100 Subject: [PATCH 11/23] Remove explicit path in saxpy.pyx --- examples/01_basic/saxpycu/saxpy.pyx | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/01_basic/saxpycu/saxpy.pyx b/examples/01_basic/saxpycu/saxpy.pyx index 707726a..49d5693 100644 --- a/examples/01_basic/saxpycu/saxpy.pyx +++ b/examples/01_basic/saxpycu/saxpy.pyx @@ -1,5 +1,4 @@ # distutils: language=c++ -# distutils: library_dirs=/home/dexter/Projects/setuptools-cuda/examples/saxpycu/saxpycu/ ctypedef fused real: double float From ad48a1f17069def7e1489366b5279ef10cc745df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ja=C5=82owiecki?= Date: Mon, 20 Feb 2023 01:41:15 +0100 Subject: [PATCH 12/23] Apply black --- docs/source/conf.py | 15 +++++++-------- examples/01_basic/test/test_saxpy.py | 3 +-- examples/02_thrust/test/test_thrustcu.py | 10 ++-------- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index f0bd21c..aef0204 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -6,24 +6,23 @@ # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information -project = 'setuptools-cuda' -copyright = '2023, Konrad Jałowiecki' -author = 'Konrad Jałowiecki' +project = "setuptools-cuda" +copyright = "2023, Konrad Jałowiecki" +author = "Konrad Jałowiecki" # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration extensions = ["myst_parser"] -templates_path = ['_templates'] +templates_path = ["_templates"] exclude_patterns = [] - # -- Options for HTML output ------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output -html_theme = 'pydata_sphinx_theme' -html_static_path = ['_static'] +html_theme = "pydata_sphinx_theme" +html_static_path = ["_static"] -myst_enable_extensions = ["colon_fence"] \ No newline at end of file +myst_enable_extensions = ["colon_fence", "dollarmath"] diff --git a/examples/01_basic/test/test_saxpy.py b/examples/01_basic/test/test_saxpy.py index 15dee3b..6fc7142 100644 --- a/examples/01_basic/test/test_saxpy.py +++ b/examples/01_basic/test/test_saxpy.py @@ -11,8 +11,7 @@ def generate_test_cases(): rng = np.random.default_rng(1234) return [ - (rng.random(), rng.random(VECTOR_SIZE), rng.random(VECTOR_SIZE)) - for _ in range(NUM_TESTS) + (rng.random(), rng.random(VECTOR_SIZE), rng.random(VECTOR_SIZE)) for _ in range(NUM_TESTS) ] diff --git a/examples/02_thrust/test/test_thrustcu.py b/examples/02_thrust/test/test_thrustcu.py index f357b48..8b22fe1 100644 --- a/examples/02_thrust/test/test_thrustcu.py +++ b/examples/02_thrust/test/test_thrustcu.py @@ -21,15 +21,9 @@ def generate_test_cases(): rng = np.random.default_rng(1234) return [ + *[rng.random(VECTOR_SIZE, dtype=dtype) for _ in range(NUM_TESTS) for dtype in FLOAT_DTYPES], *[ - rng.random(VECTOR_SIZE, dtype=dtype) - for _ in range(NUM_TESTS) - for dtype in FLOAT_DTYPES - ], - *[ - rng.integers( - np.iinfo(dtype).min, np.iinfo(dtype).max, VECTOR_SIZE, dtype=dtype - ) + rng.integers(np.iinfo(dtype).min, np.iinfo(dtype).max, VECTOR_SIZE, dtype=dtype) for _ in range(NUM_TESTS) for dtype in INTEGER_DTYPES ], From 05e03afdbf23a36ee25af952261378bcdabe7057 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ja=C5=82owiecki?= Date: Mon, 20 Feb 2023 01:44:46 +0100 Subject: [PATCH 13/23] Make version dynamic --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 7afd13b..6e91f63 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,11 +1,11 @@ [build-system] -requires = ["setuptools>=62.4", "wheel", "cython"] +requires = ["setuptools>=62.4", "setuptools_scm[toml]>=3.4", "wheel", "cython"] [project] name = "setuptools-cuda" description = "Setuptools plugin for compiling CUDA-enable extension modules" readme = "README.md" -version = "0.0.3" +dynamic = ["version"] classifiers = [ "Operating System :: POSIX :: Linux" From 141268b8111b697c27e1f75e9080c4310826760f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ja=C5=82owiecki?= Date: Mon, 20 Feb 2023 01:48:00 +0100 Subject: [PATCH 14/23] Add build_and_publish workflow --- .github/workflows/build_and_publish.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/build_and_publish.yml diff --git a/.github/workflows/build_and_publish.yml b/.github/workflows/build_and_publish.yml new file mode 100644 index 0000000..ab49c2e --- /dev/null +++ b/.github/workflows/build_and_publish.yml @@ -0,0 +1,23 @@ +name: Build package + +on: + release: + types: [published] + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.9 + - name: Install pypa/build + run: python -m pip install build --user + - name: Build binary wheel and source tarball + run: python -m build --sdist --wheel --outdir dist/ + - name: Publish distribution to PyPI + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.PYPI_TOKEN }} From c4ea9b93b8eccd45df0ea261652041711dfef5be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ja=C5=82owiecki?= Date: Mon, 20 Feb 2023 01:49:00 +0100 Subject: [PATCH 15/23] Add rtd yaml --- .readthedocs.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .readthedocs.yaml diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000..9515c3f --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,9 @@ +version: 2 + +python: + version: "3.8" + install: + - method: pip + path: . + extra_requirements: + - docs From 0abc7a90660eed1ac472f0033e9cf46e4c0d734b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ja=C5=82owiecki?= Date: Mon, 20 Feb 2023 01:50:31 +0100 Subject: [PATCH 16/23] Add quality checks workflow --- .github/workflows/quality_checks.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/quality_checks.yml diff --git a/.github/workflows/quality_checks.yml b/.github/workflows/quality_checks.yml new file mode 100644 index 0000000..5049293 --- /dev/null +++ b/.github/workflows/quality_checks.yml @@ -0,0 +1,20 @@ +name: Run tests and other quality checks + +on: [pull_request] + +jobs: + run_quality_cheks: + runs-on: ubuntu-latest + steps: + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.9 + - uses: actions/checkout@v2 + - name: Install dependencies and the package + run: | + python -m pip install --upgrade pip + pip install .[test] + pip install pre-commit + pre-commit install + pre-commit run -a From 136de78143cd3b891de7039115331941c5dc2546 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ja=C5=82owiecki?= Date: Mon, 20 Feb 2023 01:50:51 +0100 Subject: [PATCH 17/23] Change trigger of build-and-test-examples.yml to `pull_request` --- .github/workflows/build-and-test-examples.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test-examples.yml b/.github/workflows/build-and-test-examples.yml index 8e08fdf..d993a47 100644 --- a/.github/workflows/build-and-test-examples.yml +++ b/.github/workflows/build-and-test-examples.yml @@ -1,5 +1,5 @@ name: Testing examples -on: [push] +on: [pull_request] jobs: run_tests: runs-on: [self-hosted,gpu] From 1901581c8e3ffc52a120fbd7ff67b5a91cdb0418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ja=C5=82owiecki?= Date: Mon, 20 Feb 2023 01:53:15 +0100 Subject: [PATCH 18/23] Uniformize workflow names --- ...{build-and-test-examples.yml => build_and_test_examples.yml} | 0 README.md | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{build-and-test-examples.yml => build_and_test_examples.yml} (100%) diff --git a/.github/workflows/build-and-test-examples.yml b/.github/workflows/build_and_test_examples.yml similarity index 100% rename from .github/workflows/build-and-test-examples.yml rename to .github/workflows/build_and_test_examples.yml diff --git a/README.md b/README.md index d090cf3..3d86b86 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Setuptools plugin for CUDA extensions [![PyPI version](https://badge.fury.io/py/setuptools-cuda.svg)](https://badge.fury.io/py/setuptools-cuda) -[![github actions](https://github.com/euro-hpc-pl/setuptools_cuda/actions/workflows/build-and-test-examples.yml/badge.svg)](https://github.com/euro-hpc-pl/setuptools_cuda/actions/workflows/build-and-test-examples.yml) +[![github actions](https://github. com/euro-hpc-pl/setuptools_cuda/actions/workflows/build_and_test_examples.yml/badge.svg)](https://github.com/euro-hpc-pl/setuptools_cuda/actions/workflows/build_and_test_examples.yml) The `setuptools-cuda` is a `setuptools` plugin for building CUDA enabled Python extension modules. From 4e818f4887662aac0986680a28c55f8230476efb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ja=C5=82owiecki?= Date: Mon, 20 Feb 2023 02:00:00 +0100 Subject: [PATCH 19/23] Update quality_checks with new versions of steps --- .github/workflows/quality_checks.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/quality_checks.yml b/.github/workflows/quality_checks.yml index 5049293..be3684a 100644 --- a/.github/workflows/quality_checks.yml +++ b/.github/workflows/quality_checks.yml @@ -7,10 +7,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: python-version: 3.9 - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Install dependencies and the package run: | python -m pip install --upgrade pip From 27527e3b315acfd20db5dcb398f9e04dff310944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ja=C5=82owiecki?= Date: Mon, 20 Feb 2023 02:01:04 +0100 Subject: [PATCH 20/23] Bump Python version --- .github/workflows/quality_checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/quality_checks.yml b/.github/workflows/quality_checks.yml index be3684a..6840c59 100644 --- a/.github/workflows/quality_checks.yml +++ b/.github/workflows/quality_checks.yml @@ -9,7 +9,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v3 with: - python-version: 3.9 + python-version: 3.11 - uses: actions/checkout@v3 - name: Install dependencies and the package run: | From b7d24c3a9d2d9b76b8c3d0eb6fe8527cc70a7009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ja=C5=82owiecki?= Date: Mon, 20 Feb 2023 02:04:33 +0100 Subject: [PATCH 21/23] Further bump setup-python action --- .github/workflows/quality_checks.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/quality_checks.yml b/.github/workflows/quality_checks.yml index 6840c59..122b853 100644 --- a/.github/workflows/quality_checks.yml +++ b/.github/workflows/quality_checks.yml @@ -3,11 +3,11 @@ name: Run tests and other quality checks on: [pull_request] jobs: - run_quality_cheks: + run_quality_checks: runs-on: ubuntu-latest steps: - name: Set up Python - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: python-version: 3.11 - uses: actions/checkout@v3 From f4947ed34da2386ad343080ac4926b47f9a76fb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ja=C5=82owiecki?= Date: Mon, 20 Feb 2023 02:06:30 +0100 Subject: [PATCH 22/23] Explicitly invoke Python in workflow --- .github/workflows/quality_checks.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/quality_checks.yml b/.github/workflows/quality_checks.yml index 122b853..017bb12 100644 --- a/.github/workflows/quality_checks.yml +++ b/.github/workflows/quality_checks.yml @@ -13,8 +13,8 @@ jobs: - uses: actions/checkout@v3 - name: Install dependencies and the package run: | - python -m pip install --upgrade pip - pip install .[test] - pip install pre-commit + python3.11 -m pip install --upgrade pip + python3.11 -m pip install .[test] + python3.11 -m pip install pre-commit pre-commit install pre-commit run -a From 42e4862feb0902beac07eab73dc75324010023b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ja=C5=82owiecki?= Date: Mon, 20 Feb 2023 02:10:48 +0100 Subject: [PATCH 23/23] Update language version in black repo --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6116675..14f16d4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: hooks: - id: black args: ["--check"] - language_version: python3.9 + language_version: python3.11 - repo: https://github.com/pycqa/flake8 rev: 6.0.0