-
Notifications
You must be signed in to change notification settings - Fork 60
/
CONTRIBUTING.md
288 lines (206 loc) · 10 KB
/
CONTRIBUTING.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
# Contribute to cuCIM
If you are interested in contributing to cuCIM, your contributions will fall
into three categories:
1. You want to report a bug, feature request, or documentation issue
- File an [issue](https://github.com/rapidsai/cucim/issues/new/choose)
describing what you encountered or what you want to see changed.
- The RAPIDS team will evaluate the issues and triage them, scheduling
them for a release. If you believe the issue needs priority attention
comment on the issue to notify the team.
2. You want to propose a new Feature and implement it
- Post about your intended feature, and we shall discuss the design and
implementation.
- Once we agree that the plan looks good, go ahead and implement it, using
the [code contributions](#code-contributions) guide below.
3. You want to implement a feature or bug-fix for an outstanding issue
- Follow the [code contributions](#code-contributions) guide below.
- If you need more context on a particular issue, please ask and we shall
provide.
## Code contributions
### Your first issue
1. Read the project's [README.md](https://github.com/rapidsai/cucim/blob/main/README.md)
to learn how to setup the development environment
2. Find an issue to work on. The best way is to look for the [good first issue](https://github.com/rapidsai/cucim/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)
or [help wanted](https://github.com/rapidsai/cucim/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) labels
3. Comment on the issue saying you are going to work on it
4. Code! Make sure to update unit tests!
5. When done, [create your pull request](https://github.com/rapidsai/cucim/compare)
6. Verify that CI passes all [status checks](https://help.github.com/articles/about-status-checks/). Fix if needed
7. Wait for other developers to review your code and update code as needed
8. Once reviewed and approved, a RAPIDS developer will merge your pull request
Remember, if you are unsure about anything, don't hesitate to comment on issues
and ask for clarifications!
### Seasoned developers
Once you have gotten your feet wet and are more comfortable with the code, you
can look at the prioritized issues of our next release in our [project boards](https://github.com/rapidsai/cucim/projects).
> **Pro Tip:** Always look at the release board with the highest number for
issues to work on. This is where RAPIDS developers also focus their efforts.
Look at the unassigned issues, and find an issue you are comfortable with
contributing to. Start with _Step 3_ from above, commenting on the issue to let
others know you are working on it. If you have any questions related to the
implementation of the issue, ask them in the issue instead of the PR.
## Setting Up Your Build Environment
The following instructions are for developers and contributors to cuCIM OSS development. These instructions are tested on Linux Ubuntu 16.04 & 18.04. Use these instructions to build cuCIM from the source and contribute to its development. Other operating systems may be compatible, but are not currently tested.
### Code Formatting
#### Python
cuCIM uses [isort](https://readthedocs.org/projects/isort/), and
[flake8](http://flake8.pycqa.org/en/latest/) to ensure a consistent code format
throughout the project. `isort`, and `flake8` can be installed with
`conda` or `pip`:
```bash
conda install isort flake8
```
```bash
pip install isort flake8
```
These tools are used to auto-format the Python code in the repository. Additionally, there is a CI check in place to enforce
that the committed code follows our standards. You can use the tools to
automatically format your python code by running:
```bash
isort --atomic python/**/*.py
```
### Get libcucim Dependencies
Compiler requirements:
* `gcc` version 9.0+
* `nvcc` version 11.0+
* `cmake` version 3.18.0+
CUDA/GPU requirements:
* CUDA 11.0+
* NVIDIA driver 450.36+
* Pascal architecture or better
You can obtain CUDA from [https://developer.nvidia.com/cuda-downloads](https://developer.nvidia.com/cuda-downloads).
# Building and Testing cuCIM from Source
First, please clone cuCIM's repository
```bash
CUCIM_HOME=$(pwd)/cucim
git clone https://github.com/rapidsai/cucim.git $CUCIM_HOME
cd $CUCIM_HOME
```
## Local Development using Conda Environment (for gcc 9.x and nvcc 11.0.x)
Conda can be used to setup an environment which includes all of the necessary dependencies (as shown in `./conda/environments/all_cuda-118_arch-x86_64.yaml`) for building cuCIM.
Otherwise, you may need to install dependencies (such as zlib, xz, yasm) through your OS's package manager (`apt`, `yum`, and so on).
### Creating the Conda Development Environment `cucim`
Note that `./conda/environments/all_cuda-118_arch-x86_64.yaml` is currently set to use specific versions of gcc (gxx_linux-64) and CUDA (cudatoolkit & cudatoolkit-dev).
If you want to change the version of gcc or CUDA toolkit package, please update `./conda/environments/all_cuda-118_arch-x86_64.yaml` before executing the following commands.
```bash
conda env create -n cucim -f ./conda/environments/all_cuda-118_arch-x86_64.yaml
# activate the environment
conda activate cucim
```
### Building `libcucim` and install `cucim` (python bindings):
**Building `libcucim`**
```bash
# `CC` and `CXX` environment variable will be set by default by `gxx_linux-64` package.
# Check if the environments are correctly set.
[ ${CC##$CONDA_PREFIX/bin} = "$CC" ] && >&2 echo "Environment variable CC doesn't start with '$CONDA_PREFIX/bin'"
[ ${CXX##$CONDA_PREFIX/bin} = "$CXX" ] && >&2 echo "Environment variable CXX doesn't start with '$CONDA_PREFIX/bin'"
# set to use nvcc in the conda environment
export CUDACXX=$CONDA_PREFIX/pkgs/cuda-toolkit/bin/nvcc
# build all with `release` binaries (you can change it to `debug` or `rel-debug`)
./run build_local all release $CONDA_PREFIX
```
The build command will create the following files:
- `./install/lib/libcucim*`
- `./python/install/lib/_cucim.cpython-*-x86_64-linux-gnu.so`
- `./cpp/plugins/cucim.kit.cuslide/install/lib/cucim.kit.cuslide@*.so`
- `./cpp/plugins/cucim.kit.cumed/install/lib/cucim.kit.cumed@*.so`
And, it will copy the built library files to `python/cucim/src/cucim/clara/` folder:
- `libcucim.so.*`
- `_cucim.cpython-*-x86_64-linux-gnu.so`
- `cucim.kit.cuslide@*.so`
- `cucim.kit.cumed@*.so`
**Building `cucim`(python bindings)**
```bash
python -m pip install python/cucim
```
For contributors interested in working on the Python code from an in-place
(editable) installation, replace the last line above with
```bash
python -m pip install --editable python/cucim
```
**Cleaning build files**
You can execute the following command whenever C++ code is changed during the development:
```bash
./run build_local all release $CONDA_PREFIX
```
Once it is built, the subsequent build doesn't take much time.
However, if a build option or dependent packages are updated, the build can be failed (due to CMakeCache.txt or existing build files). In that case, you can remove use the following commands to remove CMakeCache.txt or build folder, then build it again.
1) Remove CMakeCache.txt for libcucim, cuslide/cumed plugin, and the python wrapper (pybind11).
```bash
# this command wouldn't remove already downloaded dependency so faster than `clean` subcommand
./run build_local clean_cache
```
2) Remove `build-*` and `install` folder for libcucim, cuslide/cumed plugin, and the python wrapper (pybind11).
```bash
# this command is for clean build
./run build_local clean
```
## Building a Conda package
**Setup**
You can build a conda package on top of `cucim` Conda environment created by instructions above:
```bash
conda activate cucim
```
First, please make sure that you have `conda-build` installed:
```bash
# Install conda-build if `conda build` command is not available.
! conda build --help > /dev/null && conda install -c conda-forge conda-build
```
Export necessary environment variables:
```bash
export CUDA="$(conda list | grep cudatoolkit-dev | egrep -o "[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+")"
export PYTHON_VER="$(python -c "import sys; print('.'.join(map(str, sys.version_info[:2])))")"
echo "CUDA : ${CUDA}"
echo "PYTHON_VER : ${PYTHON_VER}"
```
Then, create `conda-bld` folder:
```bash
CONDA_BLD_DIR=$(pwd)/conda-bld
mkdir -p $CONDA_BLD_DIR
```
**Build**
```bash
conda build -c conda-forge \
--dirty \
--no-remove-work-dir \
--no-build-id \
--croot ${CONDA_BLD_DIR} \
--use-local \
conda/recipes/libcucim \
conda/recipes/cucim
# Conda Package files would be available at `conda-bld/linux-64`
ls conda-bld/linux-64/*cucim*
```
**Install**
```bash
conda install -y -c ${CONDA_BLD_DIR} -c conda-forge \
libcucim \
cucim
```
## Building a package (for distribution. Including a wheel package for pip)
**Build**
You can execute the following command to build a wheel file for pip.
```bash
./run build_package
```
The command would use `./temp` folder as a local build folder and build a distribution package into `dist` folder using [dockcross](https://github.com/dockcross/dockcross)'s manylinux2014 docker image.
`./run build_package` will reuse local `./temp` folder to reduce the build time.
If C++ code or dependent packages are updated so the build is failing somehow, please retry it after deleting the `temp` folder under the repository root.
**Install**
```bash
python -m pip install dist/cucim*.whl
```
## Running Tests
Once cuCIM is installed, you can test the module through `./run test` command.
```bash
# Arguments:
# $1 - subcommand [all|python|c++] (default: all)
# $2 - test_type [all|unit|integration|system|performance] (default: all)
# $3 - test_component [all|clara|skimage] (default: all)
./run test # execute all tests
./run test python # execute all python tests
./run test python unit # execute all python unit tests
./run test python unit skimage # execute all python unit tests in `skimage` module
./run test python unit clara # execute all python unit tests in `clara` module
./run test python performance # execute all python performance tests
```