Skip to content

Commit 6001537

Browse files
authored
Update: Contributing guide with respect to #1358 (#1389)
* Update: Contributing guide with respect to #1358 * Fix: Add line on manually running pre-commit * Add: Line for `isort` in contributing guide * Fix: uncomment `make examples` in overview
1 parent 4fa8c0e commit 6001537

File tree

1 file changed

+52
-27
lines changed

1 file changed

+52
-27
lines changed

CONTRIBUTING.md

+52-27
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ Following that we'll tell you about how you can test your changes locally and th
8787
Fortunately, you can check out [pyenv](https://github.com/pyenv/pyenv) which lets you switch between Python versions on the fly!
8888
8989
* Now that we have a virtual environment, it's time to install all the dependencies into it.
90+
We've provided a simple `make` command to help do this.
9091
```bash
92+
make install-dev
93+
94+
# Manually
9195
pip install -e .[test,examples,doc]
9296
9397
# If you're using shells other than bash you'll need to use
@@ -101,6 +105,8 @@ Following that we'll tell you about how you can test your changes locally and th
101105
You can check out what these are in the `setup.py` file.
102106
* If you're new to virtual environments, after performing all this, it's a great time to check out what actually exists in the `my-virtual-env` folder.
103107

108+
* You can check out some functionality we have captured in a `Makefile` by running `make help`
109+
104110
* Now it's time to make some changes, whether it be for [documentation](#documentation), a [bug fix](#bug-fixes) or a new [features](#features).
105111
106112
## Making Changes
@@ -234,23 +240,18 @@ Lastly, if the feature really is a game changer or you're very proud of it, cons
234240
235241
* Now we are going to use [sphinx](https://www.sphinx-doc.org/en/master/) to generate all the documentation and make sure there are no issues.
236242
```bash
237-
cd doc
238-
make html
243+
make doc
239244
```
240245
* If you're unfamiliar with sphinx, it's a documentation generator which can read comments and docstrings from within the code and generate html documentation.
241-
* We also use sphinx-gallery which can take python files (such as those in the `examples` folder) and run them, creating html which shows the code and the output it generates.
242-
Unfortunately this can take quite some time but you should only have to run this once.
243-
* If you need to quickly check something, you can run `make html-noexamples` to prevent sphinx from running the examples.
244-
```bash
245-
cd doc
246-
make html-noexamples
247-
```
248-
* Sphinx also has a command `linkcheck` for making sure all the links correctly go to some destination.
246+
* If you've added documentation, we also has a command `linkcheck` for making sure all the links correctly go to some destination.
249247
This helps tests for dead links or accidental typos.
250248
```bash
251-
cd doc
252249
make linkcheck
253250
```
251+
* We also use sphinx-gallery which can take python files (such as those in the `examples` folder) and run them, creating html which shows the code and the output it generates.
252+
```bash
253+
make examples
254+
```
254255
* To view the documentation itself, make sure it is built with the above commands and then open `doc/build/html/index.html` with your favourite browser:
255256
```bash
256257
# Firefox
@@ -261,19 +262,33 @@ Lastly, if the feature really is a game changer or you're very proud of it, cons
261262
```
262263
263264
* Once you've made all your changes and all the tests pass successfully, we need to make sure that the code fits a certain format and that the [typing](https://docs.python.org/3/library/typing.html) is correct.
264-
To do this, we use a tool call `pre-commit` which runs `flake8`, a code checker and `mypy`, a static type checker against the code.
265+
* Formatting and import sorting can helps keep things uniform across all coding styles. We use `black` and `isort` to do this for us. To automatically run these formatters across the code base, just run the following command:
265266
```bash
266-
pip install pre-commit
267-
pre-commit run --all-files
267+
make format
268268
```
269-
* The reason we use a code standard like `flake8` is to make sure that when we review code:
270-
* There are no extra blank spaces and blank lines.
271-
* Lines don't end up too long
272-
* Code from multiple source keeps a similar appearance.
273-
* We perform static type checking with `mypy` as this can remove a majority of bugs, before a test is even run.
274-
It points out programmer errors and is what makes compiled languages so safe.
269+
* To then check for other issues with `mypy`, `flake8` and `pydocstyle`, run
270+
```bash
271+
make check
272+
```
273+
* To do this checking automatically, we use `pre-commit` which if you already installed everything with `make install-dev` then this has been done for you.
274+
This will happen every time you make a commit and warn you of any issues.
275+
Otherwise you can run the following to install pre-commit.
276+
```bash
277+
pre-commit install
278+
```
279+
* To run `pre-commit` manually:
280+
```bash
281+
pre-commit run --al-files
282+
```
283+
* The reason we use tools like `flake8`, `mypy`, `black`, `isort` and `pydocstyle` is to make sure that when we review code:
284+
* There are no extra blank spaces and blank lines. (`flake8`, `black`)
285+
* Lines don't end up too long. (`flake8`, `black`)
286+
* Code from multiple source keeps a similar appearance. (`black`)
287+
* Importing things is consistently ordered. (`isort`)
288+
* Functions are type annotated and correct with static type checking. (`mypy`)
289+
* Function and classes have docstrings. (`pydocstyle`)
275290
If you are new to Python types, or stuck with how something should be 'typed', please feel free to push the pull request in the following steps and we should be able to help you out.
276-
* If interested, the configuration for `pre-commit` can be found in `.pre-commit-config.yaml`
291+
* If interested, the configuration for `pre-commit` can be found in `.pre-commit-config.yaml` with the other tools mainly being configured in `pyproject.toml` and `.flake8`.
277292
278293
279294
## Creating the PR
@@ -341,6 +356,7 @@ Lastly, if the feature really is a game changer or you're very proud of it, cons
341356
342357
# Pull Request Overview
343358
* Create a [fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo) of the [automl/auto-sklearn](https://github.com/automl/auto-sklearn) git repo
359+
* Check out what's available by running `make help`.
344360
* Clone your own fork and create a new branch from the branch to work on
345361
```bash
346362
git clone [email protected]:your-username/auto-sklearn.git
@@ -355,15 +371,24 @@ Lastly, if the feature really is a game changer or you're very proud of it, cons
355371
python -m venv my-virtual-env
356372
source my-virtual-env/bin/activate
357373
358-
pip install -e .[test,docs,examples] # zsh users need quotes ".[test,...]"
374+
make install-dev
375+
# pip install -e ".[test,docs,examples]" # To manually install things
359376
360377
# Edit files...
361378
379+
# Format code
380+
make format
381+
382+
# Check for any issues
383+
make check
384+
385+
# ... fix any issues
386+
362387
# If you changed documentation:
363-
# This will generate all documentation, run examples and check links
364-
cd doc
365-
make html
388+
# This will generate all documentation and check links
389+
make doc
366390
make linkcheck
391+
make examples # mainly needed if you modified some examples
367392
368393
# ... fix any issues
369394
@@ -373,8 +398,8 @@ Lastly, if the feature really is a game changer or you're very proud of it, cons
373398
374399
# ... fix any issues
375400
376-
# Use pre-commit for style and typing checks
377-
pip install pre-commit
401+
# If you want to run pre-commit, the formatting checks we run on github
402+
pre-commit install
378403
pre-commit run --all-files
379404
380405
# ... fix any issues

0 commit comments

Comments
 (0)