Contributing to Tianshou¶
Install Develop Version¶
To install Tianshou in an “editable” mode, run
$ pip install -e ".[dev]"
in the main directory. This installation is removable by
$ python setup.py develop --uninstall
PEP8 Code Style Check and Code Formatter¶
We follow PEP8 python code style with flake8. To check, in the main directory, run:
$ make lint
We use isort and yapf to format all codes. To format, in the main directory, run:
$ make format
To check if formatted correctly, in the main directory, run:
$ make check-codestyle
We use mypy to check the type annotations. To check, in the main directory, run:
$ make mypy
This command will run automatic tests in the main directory
$ make pytest
Test by GitHub Actions¶
Actionsbutton in your own repo:
Click the green button:
You will see
Actions Enabled.on the top of html page.
When you push a new commit to your own repo (e.g.
git push), it will automatically run the test in this page:
Documentations are written under the
docs/ directory as ReStructuredText (
index.rst is the main page. A Tutorial on ReStructuredText can be found here.
API References are automatically generated by Sphinx according to the outlines under
docs/api/ and should be modified when any code changes.
To compile documentation into webpage, run
$ make doc
The generated webpage is in
docs/_build and can be viewed with browser (http://0.0.0.0:8000/).
Chinese documentation is in https://tianshou.readthedocs.io/zh/latest/.
Documentation Generation Test¶
We have the following three documentation tests:
pydocstyle: test all docstring under
doc8: test ReStructuredText format;
sphinx test: test if there is any error/warning when generating front-end html documentation.
To check, in the main directory, run:
$ make check-docstyle