2020-06-01 09:37:30 +08:00
Contributing to Tianshou
========================
2020-03-29 10:22:03 +08:00
2020-09-11 07:55:37 +08:00
2020-04-11 19:29:46 +08:00
Install Develop Version
2020-06-02 08:51:14 +08:00
-----------------------
2020-03-29 10:22:03 +08:00
2023-09-05 23:34:23 +02:00
Tianshou is built and managed by `poetry <https://python-poetry.org/> `_ . For example,
to install all relevant requirements in editable mode you can simply call
2020-04-11 19:29:46 +08:00
.. code-block :: bash
2023-09-05 23:34:23 +02:00
$ poetry install --with dev
2020-04-11 19:29:46 +08:00
2020-09-11 07:55:37 +08:00
2023-08-25 23:40:56 +02:00
PEP8 Code Style Check and Formatting
2021-09-03 05:05:04 +08:00
----------------------------------------
2020-04-11 19:29:46 +08:00
2022-10-02 17:57:45 +02:00
Please set up pre-commit by running
.. code-block :: bash
$ pre-commit install
in the main directory. This should make sure that your contribution is properly
formatted before every commit.
2023-08-25 23:40:56 +02:00
The code is inspected and formatted by `black` and `ruff` . They are executed as
2023-09-05 23:34:23 +02:00
pre-commit hooks. In addition, `poe the poet` tasks are configured.
Simply run `poe` to see the available tasks.
E.g, to format and check the linting manually you can run:
2020-04-11 19:29:46 +08:00
.. code-block :: bash
2023-09-05 23:34:23 +02:00
$ poe format
$ poe lint
2020-04-11 19:29:46 +08:00
2020-09-11 07:55:37 +08:00
2020-09-13 19:31:50 +08:00
Type Check
----------
We use `mypy <https://github.com/python/mypy/> `_ to check the type annotations. To check, in the main directory, run:
.. code-block :: bash
2023-09-05 23:34:23 +02:00
$ poe type-check
2020-09-13 19:31:50 +08:00
2020-04-11 19:29:46 +08:00
Test Locally
2020-06-02 08:51:14 +08:00
------------
2020-04-11 19:29:46 +08:00
This command will run automatic tests in the main directory
.. code-block :: bash
2023-09-05 23:34:23 +02:00
$ poe test
2020-04-11 19:29:46 +08:00
2020-09-11 07:55:37 +08:00
2020-04-11 19:29:46 +08:00
Test by GitHub Actions
2020-06-02 08:51:14 +08:00
----------------------
2020-04-11 19:29:46 +08:00
2020-04-13 19:37:27 +08:00
1. Click the `` Actions `` button in your own repo:
2020-04-11 19:29:46 +08:00
2023-12-04 13:49:30 +01:00
.. image :: ../_static/images/action1.jpg
2020-04-11 19:29:46 +08:00
:align: center
2. Click the green button:
2023-12-04 13:49:30 +01:00
.. image :: ../_static/images/action2.jpg
2020-04-11 19:29:46 +08:00
:align: center
3. You will see `` Actions Enabled. `` on the top of html page.
4. When you push a new commit to your own repo (e.g. `` git push `` ), it will automatically run the test in this page:
2023-12-04 13:49:30 +01:00
.. image :: ../_static/images/action3.png
2020-04-11 19:29:46 +08:00
:align: center
2020-09-11 07:55:37 +08:00
2020-04-11 19:29:46 +08:00
Documentation
2020-06-02 08:51:14 +08:00
-------------
2020-04-11 19:29:46 +08:00
Documentations are written under the `` docs/ `` directory as ReStructuredText (`` .rst `` ) files. `` index.rst `` is the main page. A Tutorial on ReStructuredText can be found `here <https://pythonhosted.org/an_example_pypi_project/sphinx.html> `_ .
API References are automatically generated by `Sphinx <http://www.sphinx-doc.org/en/stable/> `_ according to the outlines under `` docs/api/ `` and should be modified when any code changes.
2021-09-03 05:05:04 +08:00
To compile documentation into webpage, run
2020-04-11 19:29:46 +08:00
.. code-block :: bash
2023-09-05 23:34:23 +02:00
$ poe doc-build
2020-04-11 19:29:46 +08:00
2021-09-03 05:05:04 +08:00
The generated webpage is in `` docs/_build `` and can be viewed with browser (http://0.0.0.0:8000/).
2020-06-01 08:30:09 +08:00
2020-09-06 16:20:16 +08:00
Chinese documentation is in https://tianshou.readthedocs.io/zh/latest/.
2020-09-11 07:55:37 +08:00
Documentation Generation Test
-----------------------------
We have the following three documentation tests:
2023-09-05 23:34:23 +02:00
1. pydocstyle (as part of ruff): test all docstring under `` tianshou/ `` ;
2020-09-11 07:55:37 +08:00
2023-09-05 23:34:23 +02:00
2. doc8 (as part of ruff): test ReStructuredText format;
2020-09-11 07:55:37 +08:00
2023-09-05 23:34:23 +02:00
3. sphinx spelling and test: test if there is any error/warning when generating front-end html documentation.
2020-09-11 07:55:37 +08:00
2021-09-03 05:05:04 +08:00
To check, in the main directory, run:
2020-09-11 07:55:37 +08:00
.. code-block :: bash
2023-09-05 23:34:23 +02:00
$ poe lint
$ poe doc-build