|
a |
|
b/contributing.md |
|
|
1 |
# Contributing to EDS-NLP |
|
|
2 |
|
|
|
3 |
We welcome contributions ! There are many ways to help. For example, you can: |
|
|
4 |
|
|
|
5 |
1. Help us track bugs by filing issues |
|
|
6 |
2. Suggest and help prioritise new functionalities |
|
|
7 |
3. Develop a new pipe ! Fork the project and propose a new functionality through a pull request |
|
|
8 |
4. Help us make the library as straightforward as possible, by simply asking questions on whatever does not seem clear to you. |
|
|
9 |
|
|
|
10 |
## Development installation |
|
|
11 |
|
|
|
12 |
To be able to run the test suite, run the example notebooks and develop your own pipeline component, you should clone the repo and install it locally. |
|
|
13 |
|
|
|
14 |
<div class="termy"> |
|
|
15 |
|
|
|
16 |
```console |
|
|
17 |
# Clone the repository and change directory |
|
|
18 |
$ git clone https://github.com/aphp/edsnlp.git |
|
|
19 |
---> 100% |
|
|
20 |
$ cd edsnlp |
|
|
21 |
|
|
|
22 |
# Optional: create a virtual environment |
|
|
23 |
$ python -m venv venv |
|
|
24 |
$ source venv/bin/activate |
|
|
25 |
|
|
|
26 |
# Install the package with common, dev, setup dependencies in editable mode |
|
|
27 |
$ pip install -e '.[dev,setup]' |
|
|
28 |
# And build resources |
|
|
29 |
$ python scripts/conjugate_verbs.py |
|
|
30 |
``` |
|
|
31 |
|
|
|
32 |
</div> |
|
|
33 |
|
|
|
34 |
To make sure the pipeline will not fail because of formatting errors, we added pre-commit hooks using the `pre-commit` Python library. To use it, simply install it: |
|
|
35 |
|
|
|
36 |
<div class="termy"> |
|
|
37 |
|
|
|
38 |
```console |
|
|
39 |
$ pre-commit install |
|
|
40 |
``` |
|
|
41 |
|
|
|
42 |
</div> |
|
|
43 |
|
|
|
44 |
The pre-commit hooks defined in the [configuration](https://github.com/aphp/edsnlp/blob/master/.pre-commit-config.yaml) will automatically run when you commit your changes, letting you know if something went wrong. |
|
|
45 |
|
|
|
46 |
The hooks only run on staged changes. To force-run it on all files, run: |
|
|
47 |
|
|
|
48 |
<div class="termy"> |
|
|
49 |
|
|
|
50 |
```console |
|
|
51 |
$ pre-commit run --all-files |
|
|
52 |
---> 100% |
|
|
53 |
color:green All good ! |
|
|
54 |
``` |
|
|
55 |
|
|
|
56 |
</div> |
|
|
57 |
|
|
|
58 |
## Proposing a merge request |
|
|
59 |
|
|
|
60 |
At the very least, your changes should : |
|
|
61 |
|
|
|
62 |
- Be well-documented ; |
|
|
63 |
- Pass every tests, and preferably implement its own ; |
|
|
64 |
- Follow the style guide. |
|
|
65 |
|
|
|
66 |
### Testing your code |
|
|
67 |
|
|
|
68 |
We use the Pytest test suite. |
|
|
69 |
|
|
|
70 |
The following command will run the test suite. Writing your own tests is encouraged ! |
|
|
71 |
|
|
|
72 |
```shell |
|
|
73 |
python -m pytest |
|
|
74 |
``` |
|
|
75 |
|
|
|
76 |
!!! warning "Testing Cython code" |
|
|
77 |
|
|
|
78 |
Make sure the package is [installed in editable mode](#development-installation). |
|
|
79 |
Otherwise `Pytest` won't be able to find the Cython modules. |
|
|
80 |
|
|
|
81 |
Should your contribution propose a bug fix, we require the bug be thoroughly tested. |
|
|
82 |
|
|
|
83 |
### Architecture of a pipeline component |
|
|
84 |
|
|
|
85 |
Pipes should follow the same pattern : |
|
|
86 |
|
|
|
87 |
``` |
|
|
88 |
edsnlp/pipes/<pipe> |
|
|
89 |
|-- <pipe>.py # Defines the component logic |
|
|
90 |
|-- patterns.py # Defines matched patterns |
|
|
91 |
|-- factory.py # Declares the component to spaCy |
|
|
92 |
``` |
|
|
93 |
|
|
|
94 |
### Style Guide |
|
|
95 |
|
|
|
96 |
We use [Black](https://github.com/psf/black) to reformat the code. While other formatter only enforce PEP8 compliance, Black also makes the code uniform. In short : |
|
|
97 |
|
|
|
98 |
> Black reformats entire files in place. It is not configurable. |
|
|
99 |
|
|
|
100 |
Moreover, the CI/CD pipeline enforces a number of checks on the "quality" of the code. To wit, non black-formatted code will make the test pipeline fail. We use `pre-commit` to keep our codebase clean. |
|
|
101 |
|
|
|
102 |
Refer to the [development install tutorial](#development-installation) for tips on how to format your files automatically. |
|
|
103 |
Most modern editors propose extensions that will format files on save. |
|
|
104 |
|
|
|
105 |
### Documentation |
|
|
106 |
|
|
|
107 |
Make sure to document your improvements, both within the code with comprehensive docstrings, |
|
|
108 |
as well as in the documentation itself if need be. |
|
|
109 |
|
|
|
110 |
We use `MkDocs` for EDS-NLP's documentation. You can checkout the changes you make with: |
|
|
111 |
|
|
|
112 |
<div class="termy"> |
|
|
113 |
|
|
|
114 |
```console |
|
|
115 |
# Install the requirements |
|
|
116 |
$ pip install -e '.[docs]' |
|
|
117 |
---> 100% |
|
|
118 |
color:green Installation successful |
|
|
119 |
|
|
|
120 |
# Run the documentation |
|
|
121 |
$ mkdocs serve |
|
|
122 |
``` |
|
|
123 |
|
|
|
124 |
</div> |
|
|
125 |
|
|
|
126 |
Go to [`localhost:8000`](http://localhost:8000) to see your changes. MkDocs watches for changes in the documentation folder |
|
|
127 |
and automatically reloads the page. |