You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
- 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
104
120
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
110
126
rest of the header.
111
127
128
+
---
129
+
130
+
112
131
### Python File Headers
113
132
114
133
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:
130
149
# See the License for the specific language governing permissions and
131
150
# limitations under the License.
132
151
```
152
+
133
153
The copyright year should be updated every calendar year.
134
154
135
155
## Security
136
156
137
157
### Bandit
138
158
139
159
We use [Bandit](https://github.com/PyCQA/bandit) to find common security issues
140
-
in Python code.
160
+
in the Python code.
141
161
142
-
Install: `pip install bandit`
162
+
To install, run:
163
+
```bash
164
+
pip install bandit
165
+
```
143
166
144
-
- Revision: `1.7.0`
167
+
Bandit revision used: `1.7.0`
145
168
146
-
Run before each commit: `bandit -r dpctl -lll`
169
+
Before each commit, run:
170
+
```bash
171
+
bandit -r dpctl -lll
172
+
```
147
173
148
174
## Code Coverage
149
175
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
151
177
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:
155
182
156
183
1. Install dependencies for C/C++ source.
157
184
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`
162
187
environment variable to make sure the correct one is used to generate
163
188
coverage.
164
189
165
190
2. Install dependencies for Python sources.
166
191
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`:
169
194
170
195
```bash
171
196
python -m pip install coverage[toml]
@@ -178,13 +203,13 @@ these steps:
178
203
coverage html
179
204
```
180
205
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
182
207
reason, the coverage script builds the package in`develop` mode of
183
208
`setup.py`.
184
209
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
188
213
`dpctl-c-api-coverage` directory. The Python coverage reports are saved to
189
214
the `htmlcov` directory.
190
215
@@ -201,37 +226,39 @@ these steps:
201
226
> ^
202
227
> 1 error generated.
203
228
> ```
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.
206
231
207
232
## Error Reporting and Logging
208
233
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:
211
236
212
237
```bash
213
238
export DPCTL_VERBOSITY=warning
214
239
```
215
240
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.
217
242
218
243
### Optional use of the Google logging library (glog)
219
244
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).
221
246
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
223
250
224
251
```bash
225
252
conda install glog
226
253
```
227
-
2. Build dpctl with glog support
254
+
2. Build dpctl with the glog support
228
255
229
256
```bash
230
257
python scripts/build_locally.py --oneapi --glog
231
258
```
232
259
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:
235
262
236
263
```python
237
264
from dpctl._diagnostics import syclinterface_diagnostics
@@ -245,10 +272,9 @@ with syclinterface_diagnostics():
- `*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``.
251
278
252
279
> **_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