Skip to content

Commit

Permalink
bump to v0.4.3 (#432)
Browse files Browse the repository at this point in the history
* add makefile
* bump version
* add isort and yapf
* update contributing.md
* update PR template
* spelling check
  • Loading branch information
Trinkle23897 authored Sep 2, 2021
1 parent a740496 commit fc251ab
Show file tree
Hide file tree
Showing 138 changed files with 5,300 additions and 2,727 deletions.
13 changes: 3 additions & 10 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@
+ [ ] algorithm implementation fix
+ [ ] documentation modification
+ [ ] new feature
- [ ] I have reformatted the code using `make format` (**required**)
- [ ] I have checked the code using `make commit-checks` (**required**)
- [ ] If applicable, I have mentioned the relevant/related issue(s)

Less important but also useful:

- [ ] I have visited the [source website](https://github.com/thu-ml/tianshou)
- [ ] I have searched through the [issue tracker](https://github.com/thu-ml/tianshou/issues) for duplicates
- [ ] I have mentioned version numbers, operating system and environment, where applicable:
```python
import tianshou, torch, numpy, sys
print(tianshou.__version__, torch.__version__, numpy.__version__, sys.version, sys.platform)
```
- [ ] If applicable, I have listed every items in this Pull Request below
11 changes: 6 additions & 5 deletions .github/workflows/lint_and_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ jobs:
- name: Lint with flake8
run: |
flake8 . --count --show-source --statistics
- name: Code formatter
run: |
yapf -r -d .
isort --check .
- name: Type check
run: |
mypy
- name: Documentation test
run: |
pydocstyle tianshou
doc8 docs --max-line-length 1000
cd docs
make html SPHINXOPTS="-W"
cd ..
make check-docstyle
make spelling
1 change: 1 addition & 0 deletions .github/workflows/profile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on: [push, pull_request]
jobs:
profile:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'ci skip')"
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,4 @@ MUJOCO_LOG.TXT
*.swp
*.pkl
*.hdf5
wandb/
60 changes: 60 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
SHELL=/bin/bash
PROJECT_NAME=tianshou
PROJECT_PATH=${PROJECT_NAME}/
LINT_PATHS=${PROJECT_PATH} test/ docs/conf.py examples/ setup.py

check_install = python3 -c "import $(1)" || pip3 install $(1) --upgrade
check_install_extra = python3 -c "import $(1)" || pip3 install $(2) --upgrade

pytest:
$(call check_install, pytest)
$(call check_install, pytest_cov)
$(call check_install, pytest_xdist)
pytest test --cov ${PROJECT_PATH} --durations 0 -v --cov-report term-missing

mypy:
$(call check_install, mypy)
mypy ${PROJECT_NAME}

lint:
$(call check_install, flake8)
$(call check_install_extra, bugbear, flake8_bugbear)
flake8 ${LINT_PATHS} --count --show-source --statistics

format:
# sort imports
$(call check_install, isort)
isort ${LINT_PATHS}
# reformat using yapf
$(call check_install, yapf)
yapf -ir ${LINT_PATHS}

check-codestyle:
$(call check_install, isort)
$(call check_install, yapf)
isort --check ${LINT_PATHS} && yapf -r -d ${LINT_PATHS}

check-docstyle:
$(call check_install, pydocstyle)
$(call check_install, doc8)
$(call check_install, sphinx)
$(call check_install, sphinx_rtd_theme)
pydocstyle ${PROJECT_PATH} && doc8 docs && cd docs && make html SPHINXOPTS="-W"

doc:
$(call check_install, sphinx)
$(call check_install, sphinx_rtd_theme)
cd docs && make html && cd _build/html && python3 -m http.server

spelling:
$(call check_install, sphinx)
$(call check_install, sphinx_rtd_theme)
$(call check_install_extra, sphinxcontrib.spelling, sphinxcontrib.spelling pyenchant)
cd docs && make spelling SPHINXOPTS="-W"

clean:
cd docs && make clean

commit-checks: format lint mypy check-docstyle spelling

.PHONY: clean spelling doc mypy lint format check-codestyle check-docstyle commit-checks
8 changes: 4 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
# import sys
# sys.path.insert(0, os.path.abspath('.'))

import sphinx_rtd_theme

import tianshou
import sphinx_rtd_theme

# Get the version string
version = tianshou.__version__
Expand All @@ -30,7 +30,6 @@
# The full version, including alpha/beta/rc tags
release = version


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
Expand All @@ -51,15 +50,16 @@

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
source_suffix = [".rst", ".md"]
source_suffix = [".rst"]
master_doc = "index"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
autodoc_default_options = {
"special-members": ", ".join(
"special-members":
", ".join(
[
"__len__",
"__call__",
Expand Down
47 changes: 26 additions & 21 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,26 @@ in the main directory. This installation is removable by
$ python setup.py develop --uninstall
PEP8 Code Style Check
---------------------
PEP8 Code Style Check and Code Formatter
----------------------------------------

We follow PEP8 python code style. To check, in the main directory, run:
We follow PEP8 python code style with flake8. To check, in the main directory, run:

.. code-block:: bash
$ flake8 . --count --show-source --statistics
$ make lint
We use isort and yapf to format all codes. To format, in the main directory, run:

.. code-block:: bash
$ make format
To check if formatted correctly, in the main directory, run:

.. code-block:: bash
$ make check-codestyle
Type Check
Expand All @@ -35,7 +47,7 @@ We use `mypy <https://github.com/python/mypy/>`_ to check the type annotations.

.. code-block:: bash
$ mypy
$ make mypy
Test Locally
Expand All @@ -45,7 +57,7 @@ This command will run automatic tests in the main directory

.. code-block:: bash
$ pytest test --cov tianshou -s --durations 0 -v
$ make pytest
Test by GitHub Actions
Expand Down Expand Up @@ -76,13 +88,13 @@ Documentations are written under the ``docs/`` directory as ReStructuredText (``

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.

To compile documentation into webpages, run
To compile documentation into webpage, run

.. code-block:: bash
$ make html
$ make doc
under the ``docs/`` directory. The generated webpages are in ``docs/_build`` and can be viewed with browsers.
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/.

Expand All @@ -92,21 +104,14 @@ Documentation Generation Test

We have the following three documentation tests:

1. pydocstyle: test docstrings under ``tianshou/``. To check, in the main directory, run:

.. code-block:: bash
$ pydocstyle tianshou
2. doc8: test ReStructuredText formats. To check, in the main directory, run:
1. pydocstyle: test all docstring under ``tianshou/``;

.. code-block:: bash
2. doc8: test ReStructuredText format;

$ doc8 docs
3. sphinx test: test if there is any error/warning when generating front-end html documentation.

3. sphinx test: test if there is any errors/warnings when generating front-end html documentations. To check, in the main directory, run:
To check, in the main directory, run:

.. code-block:: bash
$ cd docs
$ make html SPHINXOPTS="-W"
$ make check-docstyle
1 change: 0 additions & 1 deletion docs/contributor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Contributor
We always welcome contributions to help make Tianshou better. Below are an incomplete list of our contributors (find more on `this page <https://github.com/thu-ml/tianshou/graphs/contributors>`_).

* Jiayi Weng (`Trinkle23897 <https://github.com/Trinkle23897>`_)
* Minghao Zhang (`Mehooz <https://github.com/Mehooz>`_)
* Alexis Duburcq (`duburcqa <https://github.com/duburcqa>`_)
* Kaichao You (`youkaichao <https://github.com/youkaichao>`_)
* Huayu Chen (`ChenDRAG <https://github.com/ChenDRAG>`_)
135 changes: 135 additions & 0 deletions docs/spelling_wordlist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
tianshou
arXiv
tanh
lr
logits
env
envs
optim
eps
timelimit
TimeLimit
maxsize
timestep
numpy
ndarray
stackoverflow
len
tac
fqf
iqn
qrdqn
rl
quantile
quantiles
dqn
param
async
subprocess
nn
equ
cql
fn
boolean
pre
np
rnn
rew
pre
perceptron
bsz
dataset
mujoco
jit
nstep
preprocess
repo
ReLU
namespace
th
utils
NaN
linesearch
hyperparameters
pseudocode
entropies
nn
config
cpu
rms
debias
indice
regularizer
miniblock
modularize
serializable
softmax
vectorized
optimizers
undiscounted
submodule
subclasses
submodules
tfevent
dirichlet
docstring
webpage
formatter
num
py
pythonic
中文文档位于
conda
miniconda
Amir
Andreas
Antonoglou
Beattie
Bellemare
Charles
Daan
Demis
Dharshan
Fidjeland
Georg
Hassabis
Helen
Ioannis
Kavukcuoglu
King
Koray
Kumaran
Legg
Mnih
Ostrovski
Petersen
Riedmiller
Rusu
Sadik
Shane
Stig
Veness
Volodymyr
Wierstra
Lillicrap
Pritzel
Heess
Erez
Yuval
Tassa
Schulman
Filip
Wolski
Prafulla
Dhariwal
Radford
Oleg
Klimov
Kaichao
Jiayi
Weng
Duburcq
Huayu
Strens
Ornstein
Uhlenbeck
Loading

0 comments on commit fc251ab

Please sign in to comment.