Skip to content

Commit 9e934b2

Browse files
Merge pull request #944 from alexandraepan/infodev-doc-review
Infodev doc review
2 parents d6b7c66 + 3af9993 commit 9e934b2

File tree

20 files changed

+535
-445
lines changed

20 files changed

+535
-445
lines changed

CODE_OF_CONDUCT.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
## Our Pledge
44

55
In the interest of fostering an open and welcoming environment, we as
6-
contributors and maintainers pledge to making participation in our project and
6+
contributors and maintainers pledge to make participation in our project and
77
our community a harassment-free experience for everyone, regardless of age, body
88
size, disability, ethnicity, sex characteristics, gender identity and expression,
99
level of experience, education, socio-economic status, nationality, personal
1010
appearance, race, religion, or sexual identity and orientation.
1111

12-
## Our Standards
12+
# Our Standards
1313

1414
Examples of behavior that contributes to creating a positive environment
1515
include:
@@ -28,7 +28,7 @@ Examples of unacceptable behavior by participants include:
2828
* Public or private harassment
2929
* Publishing others' private information, such as a physical or electronic
3030
address, without explicit permission
31-
* Other conduct which could reasonably be considered inappropriate in a
31+
* Other conduct that could reasonably be considered inappropriate in a
3232
professional setting
3333

3434
## Our Responsibilities

CONTRIBUTING.md

Lines changed: 104 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,47 @@
1-
# Contributing
2-
3-
We welcome your contributions. To contribute, please
4-
- create an [issue](https://github.com/IntelPython/dpctl/issues/new),
5-
- participate in [discussions](https://github.com/IntelPython/dpctl/discussions), or
6-
- open a [pull request](https://github.com/IntelPython/dpctl/compare) from changes committed to your own fork
7-
of `dpctl`.
8-
9-
**N.B.**: Please make sure to tick the checkmark "[x] Allow edits from maintainers" to allow proper functioning
10-
of automation bots, see "[Working with forks](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork)" GitHub document for more details.
11-
1+
# Contributing <!-- omit in toc -->
2+
3+
We welcome your contributions!
4+
5+
To contribute, do one of the following:
6+
- create an [issue](https://github.com/IntelPython/dpctl/issues/new)
7+
- participate in [discussions](https://github.com/IntelPython/dpctl/discussions)
8+
- open a [pull request](https://github.com/IntelPython/dpctl/compare) from changes committed to your fork
9+
of `dpctl`
10+
11+
> **NOTE:** Make sure to check the box ``"[x] Allow edits from maintainers"`` to allow the proper functioning
12+
> of automation bots. See [Working with forks](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork) for more details.
13+
14+
# Table of Contents <!-- omit in toc -->
15+
- [Mechanical Source Issues](#mechanical-source-issues)
16+
- [Source Code Formatting](#source-code-formatting)
17+
- [C/C++ Code Style](#cc-code-style)
18+
- [Python Code Style](#python-code-style)
19+
- [Setting Up a Pre-commit](#setting-up-a-pre-commit)
20+
- [C/C++ File Headers](#cc-file-headers)
21+
- [Python File Headers](#python-file-headers)
22+
- [Security](#security)
23+
- [Bandit](#bandit)
24+
- [Code Coverage](#code-coverage)
25+
- [Error Reporting and Logging](#error-reporting-and-logging)
26+
- [Optional use of the Google logging library (glog)](#optional-use-of-the-google-logging-library-glog)
1227

1328

1429
# Mechanical Source Issues
1530

1631
## Source Code Formatting
1732

18-
### C/C++ code style
33+
### C/C++ Code Style
1934

20-
We use [clang-format](https://clang.llvm.org/docs/ClangFormat.html) code formatter.
35+
We use [clang-format](https://clang.llvm.org/docs/ClangFormat.html) for C++ code formatting.
2136

22-
Install: `conda install clang-tools`
37+
To install, run:
38+
```bash
39+
conda install clang-tools
40+
```
2341

24-
- Revision: `10.0.1`
25-
- See the default configuration used by dpctl in `.clang-format`.
42+
See the default configuration used by dpctl in `.clang-format`.
2643

27-
Run before each commit:
44+
Before each commit, run:
2845

2946
```bash
3047
clang-format -style=file -i \
@@ -36,40 +53,38 @@ clang-format -style=file -i \
3653
libsyclinterface/helper/source/*.cpp
3754
```
3855

39-
> **_NOTE:_** A much simpler option is to use `pre-commit` and the
40-
> `clang-format` hook that we provide.
56+
> **NOTE:** It is recommended to use `pre-commit` that invokes `clang-format` among other linters as configured.
4157
42-
### Python code style
58+
### Python Code Style
4359

4460
We use the following Python code style tools:
4561
- [black](https://black.readthedocs.io/en/stable/) code formatter.
46-
- Revision: `22.3.0`.
4762
- [flake8](https://flake8.pycqa.org/en/latest/) linter.
48-
- Revision `4.0.1`.
4963
- [isort](https://pycqa.github.io/isort/) import sorter.
50-
- Revision `5.10.1`.
5164

52-
- Refer `pyproject.toml` and `.flake8` config files for current configurations.
65+
> **NOTE:** Refer:
66+
> * `pyproject.toml` and `.flake8` config files for current configurations
67+
> * `.pre-commit-config.yaml` file for the versions of the tools
5368
54-
Please run these three tools before each commit. Although, you may choose to
55-
do so manually, but it is much easier and preferable to automate these checks.
56-
Refer your IDE docs to set them up in your IDE, or you can set up `pre-commit`
57-
to add git hooks.
69+
Run these three tools before each commit.
5870

59-
### Setting up pre-commit
71+
> **TIP:** Refer your IDE docs to automate these checks or set up `pre-commit` to add git hooks.
6072
61-
A `.pre-commit-config.yaml` is included to run various check before you
62-
commit your code. Here are the steps to setup `pre-commit` in your workflow:
73+
### Setting Up a Pre-commit
6374

64-
- Install `pre-commit`: `pip install pre-commit`
65-
- Install the git hook scripts: `pre-commit install`
75+
A `.pre-commit-config.yaml` is included to run various checks before you
76+
commit your code.
77+
78+
To setup `pre-commit` in your workflow, install:
79+
80+
- `pre-commit`: `pip install pre-commit`
81+
- the git hook scripts: `pre-commit install`
6682

67-
That should be it!
6883

6984
### C/C++ File Headers
7085

71-
Every C API source file should have a header on it that describes the basic
72-
purpose of the file. The standard header looks like this:
86+
Every C API source file should have a header that describes the file’s basic purpose.
87+
The standard header looks like this:
7388

7489
```
7590
//===----- dpctl_sycl_event_interface.h - C API for sycl::event -*-C++-*- ===//
@@ -97,18 +112,22 @@ purpose of the file. The standard header looks like this:
97112
///
98113
//===----------------------------------------------------------------------===//
99114
```
100-
Few things to note about this format:
101-
- The `-*- C++ -*-` string on the first line is needed to tell Emacs that
102-
the file is a C++ file. The string is only needed for `*.h` headers and
103-
should be omitted for `*.cpp` files. Without the string Emacs assumes that
115+
---
116+
> **NOTE:**
117+
>- The `-*- C++ -*-` string on the first line tells Emacs* that
118+
it is a C++ file. The string is only needed for `*.h` headers and
119+
should be omitted for `*.cpp` files. Without the string, Emacs assumes the
104120
file is a C header.
105-
- The copyright year should be updated every calendar year.
106-
- Each comment line should be a max of 80 chars.
107-
- A Doxygen `\file` tag describing the contents of the file must be provided.
108-
Also note that the `\file` tag is inside a Doxygen comment block (
109-
defined by `///` comment marker instead of the `//` comment marker used in the
121+
>- The copyright year must be updated every calendar year.
122+
>- Each comment line should be a max of 80 chars.
123+
>- A Doxygen `\file` tag describing the contents of the file must be provided.
124+
Note that the `\file` tag is inside a Doxygen comment block. It is
125+
defined by the `///` comment marker instead of the `//` comment marker used in the
110126
rest of the header.
111127

128+
---
129+
130+
112131
### Python File Headers
113132

114133
Every Python and Cython file should only include the following license header:
@@ -130,42 +149,48 @@ Every Python and Cython file should only include the following license header:
130149
# See the License for the specific language governing permissions and
131150
# limitations under the License.
132151
```
152+
133153
The copyright year should be updated every calendar year.
134154

135155
## Security
136156

137157
### Bandit
138158

139159
We use [Bandit](https://github.com/PyCQA/bandit) to find common security issues
140-
in Python code.
160+
in the Python code.
141161

142-
Install: `pip install bandit`
162+
To install, run:
163+
```bash
164+
pip install bandit
165+
```
143166

144-
- Revision: `1.7.0`
167+
Bandit revision used: `1.7.0`
145168

146-
Run before each commit: `bandit -r dpctl -lll`
169+
Before each commit, run:
170+
```bash
171+
bandit -r dpctl -lll
172+
```
147173

148174
## Code Coverage
149175

150-
Code coverage for both C and Python sources in dpctl is generated for each
176+
Code coverage, for both C and Python sources in dpctl, is generated for each
151177
pull request (PR). A PR cannot be merged if it leads to a drop in the code
152-
coverage by more than five percentage points. *Ergo, do not forget to write
153-
unit tests for your changes.* To check the code coverage for your code, follow
154-
these steps:
178+
coverage by more than five percentage points. Therefore, write
179+
unit tests for your changes.
180+
181+
To check the code coverage for your code, follow these steps:
155182

156183
1. Install dependencies for C/C++ source.
157184

158-
For C/C++ source we require `lcov`, `llvm-cov`, and `llvm-profdata`. Note
159-
that `llvm-cov` and `llvm-profdata` should be version 11.0 or higher. If you
160-
have multiple `llvm-cov` tools installed, most likely because you have
161-
multiple llvm installations, you should set the `LLVM_TOOLS_HOME`
185+
For C/C++ source, `lcov`, `llvm-cov` (>=11.0), and `llvm-profdata` (>=11.0) are required. If you
186+
have multiple `llvm-cov` tools installed, set the `LLVM_TOOLS_HOME`
162187
environment variable to make sure the correct one is used to generate
163188
coverage.
164189

165190
2. Install dependencies for Python sources.
166191

167-
To generate the coverage data for dpctl's Python sources, you only need to
168-
install `coverage`.
192+
To generate the coverage data for dpctl Python sources,
193+
install `coverage`:
169194

170195
```bash
171196
python -m pip install coverage[toml]
@@ -178,13 +203,13 @@ these steps:
178203
coverage html
179204
```
180205

181-
Note that code coverage builds the C sources with debug symbols. For this
206+
The code coverage builds the C sources with debug symbols. For this
182207
reason, the coverage script builds the package in `develop` mode of
183208
`setup.py`.
184209

185-
The coverage results for the C and Python sources will be printed to the
186-
terminal during the build (C API) and during the pytest execution (Python).
187-
The detailed coverage reports for the C API is saved to the
210+
The coverage results for the C and Python sources are printed to the
211+
terminal during the build (`libsyclinterface`) and pytest execution (Python).
212+
The detailed coverage reports for the `libsyclinterface` library are saved to the
188213
`dpctl-c-api-coverage` directory. The Python coverage reports are saved to
189214
the `htmlcov` directory.
190215

@@ -201,37 +226,39 @@ these steps:
201226
> ^
202227
> 1 error generated.
203228
> ```
204-
> The error is related to the `tcl` package. You should uninstall the `tcl`
205-
> package to resolve the error.
229+
> The error is related to the `tcl` package. Uninstall the `tcl`
230+
> package to resolve it.
206231

207232
## Error Reporting and Logging
208233

209-
The SyclInterface library responds to `DPCTL_VERBOSITY` environment variable that controls the severity level of errors printed to console.
210-
One can specify one of the following severity levels (in increasing order of severity): `warning` and `error`.
234+
The `libsyclinterface` library responds to the `DPCTL_VERBOSITY` environment variable that controls the severity level of errors printed to the console.
235+
Specify one of the following severity levels (in increasing order of severity): `warning` and `error` by running:
211236

212237
```bash
213238
export DPCTL_VERBOSITY=warning
214239
```
215240

216-
Messages of a given severity are shown not only in the console for that severity, but also for the higher severity. For example, the severity level `warning` will output severity errors for `error` and `warning` to the console.
241+
Messages of a given severity are shown not only in the console for that severity but also for the higher severity. For example, the severity level `warning` outputs severity errors for `error` and `warning` to the console.
217242

218243
### Optional use of the Google logging library (glog)
219244

220-
Dpctl's error handler for libsyclinterface can be optionally configured to use [glog](https://github.com/google/glog). To use glog, follow the following steps:
245+
The dpctl error handler for libsyclinterface can be optionally configured to use [glog](https://github.com/google/glog).
221246

222-
1. Install glog package of the latest version (0.5.0)
247+
To use glog, complete the following steps:
248+
249+
1. Install glog package of the latest version
223250

224251
```bash
225252
conda install glog
226253
```
227-
2. Build dpctl with glog support
254+
2. Build dpctl with the glog support
228255

229256
```bash
230257
python scripts/build_locally.py --oneapi --glog
231258
```
232259

233-
3. Use `dpctl._diagnostics.syclinterface_diagnostics(verbosity="warning", log_dir=None)` context manager to switch library diagnostics on for a block of Python code.
234-
Use `DPCTLService_InitLogger` and `DPCTLService_ShutdownLogger` library C functions during library development to initialize the Google's logging library and de-initialize accordingly
260+
3. Use the `dpctl._diagnostics.syclinterface_diagnostics(verbosity="warning", log_dir=None)` context manager to switch library diagnostics on for a block of a Python code.
261+
Use `DPCTLService_InitLogger` and `DPCTLService_ShutdownLogger` library C functions during library development to initialize Google's logging library and de-initialize accordingly:
235262
236263
```python
237264
from dpctl._diagnostics import syclinterface_diagnostics
@@ -245,10 +272,9 @@ with syclinterface_diagnostics():
245272
DPCTLService_InitLogger(const char *app_name, const char *log_dir);
246273
DPCTLService_ShutdownLogger();
247274
```
248-
249-
- `*app_name` - name of the executable file (prefix for logs of various levels).
250-
- `*log_dir` - directory path for writing log files. Specifying `NULL` results in logging to ``std::cerr``.
275+
Where:
276+
- `*app_name` - the name of the executable file (prefix for logs of various levels).
277+
- `*log_dir` - a directory path for writing log files. Specifying `NULL` results in logging to ``std::cerr``.
251278
252279
> **_NOTE:_**
253-
>
254-
> If `InitGoogleLogging` is not called before first use of glog, the library will self-initialize to `logtostderr` mode and log files will not be generated.
280+
> If `InitGoogleLogging` is not called before the first use of the glog, the library self-initializes to the `logtostderr` mode, and log files are not generated.

0 commit comments

Comments
 (0)