Skip to content

Commit fc251ab

Browse files
authored
bump to v0.4.3 (#432)
* add makefile * bump version * add isort and yapf * update contributing.md * update PR template * spelling check
1 parent a740496 commit fc251ab

File tree

138 files changed

+5300
-2727
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+5300
-2727
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,7 @@
33
+ [ ] algorithm implementation fix
44
+ [ ] documentation modification
55
+ [ ] new feature
6+
- [ ] I have reformatted the code using `make format` (**required**)
7+
- [ ] I have checked the code using `make commit-checks` (**required**)
68
- [ ] If applicable, I have mentioned the relevant/related issue(s)
7-
8-
Less important but also useful:
9-
10-
- [ ] I have visited the [source website](https://github.com/thu-ml/tianshou)
11-
- [ ] I have searched through the [issue tracker](https://github.com/thu-ml/tianshou/issues) for duplicates
12-
- [ ] I have mentioned version numbers, operating system and environment, where applicable:
13-
```python
14-
import tianshou, torch, numpy, sys
15-
print(tianshou.__version__, torch.__version__, numpy.__version__, sys.version, sys.platform)
16-
```
9+
- [ ] If applicable, I have listed every items in this Pull Request below

.github/workflows/lint_and_docs.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ jobs:
2020
- name: Lint with flake8
2121
run: |
2222
flake8 . --count --show-source --statistics
23+
- name: Code formatter
24+
run: |
25+
yapf -r -d .
26+
isort --check .
2327
- name: Type check
2428
run: |
2529
mypy
2630
- name: Documentation test
2731
run: |
28-
pydocstyle tianshou
29-
doc8 docs --max-line-length 1000
30-
cd docs
31-
make html SPHINXOPTS="-W"
32-
cd ..
32+
make check-docstyle
33+
make spelling

.github/workflows/profile.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on: [push, pull_request]
55
jobs:
66
profile:
77
runs-on: ubuntu-latest
8+
if: "!contains(github.event.head_commit.message, 'ci skip')"
89
steps:
910
- uses: actions/checkout@v2
1011
- name: Set up Python 3.8

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,4 @@ MUJOCO_LOG.TXT
147147
*.swp
148148
*.pkl
149149
*.hdf5
150+
wandb/

Makefile

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
SHELL=/bin/bash
2+
PROJECT_NAME=tianshou
3+
PROJECT_PATH=${PROJECT_NAME}/
4+
LINT_PATHS=${PROJECT_PATH} test/ docs/conf.py examples/ setup.py
5+
6+
check_install = python3 -c "import $(1)" || pip3 install $(1) --upgrade
7+
check_install_extra = python3 -c "import $(1)" || pip3 install $(2) --upgrade
8+
9+
pytest:
10+
$(call check_install, pytest)
11+
$(call check_install, pytest_cov)
12+
$(call check_install, pytest_xdist)
13+
pytest test --cov ${PROJECT_PATH} --durations 0 -v --cov-report term-missing
14+
15+
mypy:
16+
$(call check_install, mypy)
17+
mypy ${PROJECT_NAME}
18+
19+
lint:
20+
$(call check_install, flake8)
21+
$(call check_install_extra, bugbear, flake8_bugbear)
22+
flake8 ${LINT_PATHS} --count --show-source --statistics
23+
24+
format:
25+
# sort imports
26+
$(call check_install, isort)
27+
isort ${LINT_PATHS}
28+
# reformat using yapf
29+
$(call check_install, yapf)
30+
yapf -ir ${LINT_PATHS}
31+
32+
check-codestyle:
33+
$(call check_install, isort)
34+
$(call check_install, yapf)
35+
isort --check ${LINT_PATHS} && yapf -r -d ${LINT_PATHS}
36+
37+
check-docstyle:
38+
$(call check_install, pydocstyle)
39+
$(call check_install, doc8)
40+
$(call check_install, sphinx)
41+
$(call check_install, sphinx_rtd_theme)
42+
pydocstyle ${PROJECT_PATH} && doc8 docs && cd docs && make html SPHINXOPTS="-W"
43+
44+
doc:
45+
$(call check_install, sphinx)
46+
$(call check_install, sphinx_rtd_theme)
47+
cd docs && make html && cd _build/html && python3 -m http.server
48+
49+
spelling:
50+
$(call check_install, sphinx)
51+
$(call check_install, sphinx_rtd_theme)
52+
$(call check_install_extra, sphinxcontrib.spelling, sphinxcontrib.spelling pyenchant)
53+
cd docs && make spelling SPHINXOPTS="-W"
54+
55+
clean:
56+
cd docs && make clean
57+
58+
commit-checks: format lint mypy check-docstyle spelling
59+
60+
.PHONY: clean spelling doc mypy lint format check-codestyle check-docstyle commit-checks

docs/conf.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
# import sys
1515
# sys.path.insert(0, os.path.abspath('.'))
1616

17+
import sphinx_rtd_theme
1718

1819
import tianshou
19-
import sphinx_rtd_theme
2020

2121
# Get the version string
2222
version = tianshou.__version__
@@ -30,7 +30,6 @@
3030
# The full version, including alpha/beta/rc tags
3131
release = version
3232

33-
3433
# -- General configuration ---------------------------------------------------
3534

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

5251
# Add any paths that contain templates here, relative to this directory.
5352
templates_path = ["_templates"]
54-
source_suffix = [".rst", ".md"]
53+
source_suffix = [".rst"]
5554
master_doc = "index"
5655

5756
# List of patterns, relative to source directory, that match files and
5857
# directories to ignore when looking for source files.
5958
# This pattern also affects html_static_path and html_extra_path.
6059
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
6160
autodoc_default_options = {
62-
"special-members": ", ".join(
61+
"special-members":
62+
", ".join(
6363
[
6464
"__len__",
6565
"__call__",

docs/contributing.rst

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,26 @@ in the main directory. This installation is removable by
1818
$ python setup.py develop --uninstall
1919
2020
21-
PEP8 Code Style Check
22-
---------------------
21+
PEP8 Code Style Check and Code Formatter
22+
----------------------------------------
2323

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

2626
.. code-block:: bash
2727
28-
$ flake8 . --count --show-source --statistics
28+
$ make lint
29+
30+
We use isort and yapf to format all codes. To format, in the main directory, run:
31+
32+
.. code-block:: bash
33+
34+
$ make format
35+
36+
To check if formatted correctly, in the main directory, run:
37+
38+
.. code-block:: bash
39+
40+
$ make check-codestyle
2941
3042
3143
Type Check
@@ -35,7 +47,7 @@ We use `mypy <https://github.com/python/mypy/>`_ to check the type annotations.
3547

3648
.. code-block:: bash
3749
38-
$ mypy
50+
$ make mypy
3951
4052
4153
Test Locally
@@ -45,7 +57,7 @@ This command will run automatic tests in the main directory
4557

4658
.. code-block:: bash
4759
48-
$ pytest test --cov tianshou -s --durations 0 -v
60+
$ make pytest
4961
5062
5163
Test by GitHub Actions
@@ -76,13 +88,13 @@ Documentations are written under the ``docs/`` directory as ReStructuredText (``
7688

7789
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.
7890

79-
To compile documentation into webpages, run
91+
To compile documentation into webpage, run
8092

8193
.. code-block:: bash
8294
83-
$ make html
95+
$ make doc
8496
85-
under the ``docs/`` directory. The generated webpages are in ``docs/_build`` and can be viewed with browsers.
97+
The generated webpage is in ``docs/_build`` and can be viewed with browser (http://0.0.0.0:8000/).
8698

8799
Chinese documentation is in https://tianshou.readthedocs.io/zh/latest/.
88100

@@ -92,21 +104,14 @@ Documentation Generation Test
92104

93105
We have the following three documentation tests:
94106

95-
1. pydocstyle: test docstrings under ``tianshou/``. To check, in the main directory, run:
96-
97-
.. code-block:: bash
98-
99-
$ pydocstyle tianshou
100-
101-
2. doc8: test ReStructuredText formats. To check, in the main directory, run:
107+
1. pydocstyle: test all docstring under ``tianshou/``;
102108

103-
.. code-block:: bash
109+
2. doc8: test ReStructuredText format;
104110

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

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

109115
.. code-block:: bash
110116
111-
$ cd docs
112-
$ make html SPHINXOPTS="-W"
117+
$ make check-docstyle

docs/contributor.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ Contributor
44
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>`_).
55

66
* Jiayi Weng (`Trinkle23897 <https://github.com/Trinkle23897>`_)
7-
* Minghao Zhang (`Mehooz <https://github.com/Mehooz>`_)
87
* Alexis Duburcq (`duburcqa <https://github.com/duburcqa>`_)
98
* Kaichao You (`youkaichao <https://github.com/youkaichao>`_)
109
* Huayu Chen (`ChenDRAG <https://github.com/ChenDRAG>`_)

docs/spelling_wordlist.txt

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
tianshou
2+
arXiv
3+
tanh
4+
lr
5+
logits
6+
env
7+
envs
8+
optim
9+
eps
10+
timelimit
11+
TimeLimit
12+
maxsize
13+
timestep
14+
numpy
15+
ndarray
16+
stackoverflow
17+
len
18+
tac
19+
fqf
20+
iqn
21+
qrdqn
22+
rl
23+
quantile
24+
quantiles
25+
dqn
26+
param
27+
async
28+
subprocess
29+
nn
30+
equ
31+
cql
32+
fn
33+
boolean
34+
pre
35+
np
36+
rnn
37+
rew
38+
pre
39+
perceptron
40+
bsz
41+
dataset
42+
mujoco
43+
jit
44+
nstep
45+
preprocess
46+
repo
47+
ReLU
48+
namespace
49+
th
50+
utils
51+
NaN
52+
linesearch
53+
hyperparameters
54+
pseudocode
55+
entropies
56+
nn
57+
config
58+
cpu
59+
rms
60+
debias
61+
indice
62+
regularizer
63+
miniblock
64+
modularize
65+
serializable
66+
softmax
67+
vectorized
68+
optimizers
69+
undiscounted
70+
submodule
71+
subclasses
72+
submodules
73+
tfevent
74+
dirichlet
75+
docstring
76+
webpage
77+
formatter
78+
num
79+
py
80+
pythonic
81+
中文文档位于
82+
conda
83+
miniconda
84+
Amir
85+
Andreas
86+
Antonoglou
87+
Beattie
88+
Bellemare
89+
Charles
90+
Daan
91+
Demis
92+
Dharshan
93+
Fidjeland
94+
Georg
95+
Hassabis
96+
Helen
97+
Ioannis
98+
Kavukcuoglu
99+
King
100+
Koray
101+
Kumaran
102+
Legg
103+
Mnih
104+
Ostrovski
105+
Petersen
106+
Riedmiller
107+
Rusu
108+
Sadik
109+
Shane
110+
Stig
111+
Veness
112+
Volodymyr
113+
Wierstra
114+
Lillicrap
115+
Pritzel
116+
Heess
117+
Erez
118+
Yuval
119+
Tassa
120+
Schulman
121+
Filip
122+
Wolski
123+
Prafulla
124+
Dhariwal
125+
Radford
126+
Oleg
127+
Klimov
128+
Kaichao
129+
Jiayi
130+
Weng
131+
Duburcq
132+
Huayu
133+
Strens
134+
Ornstein
135+
Uhlenbeck

0 commit comments

Comments
 (0)