Skip to content

Commit cf51186

Browse files
authored
Clean up for PyPI Upload (#187)
* Update setup.py to prepare for PyPI release * Remove stray __init__ file (was breaking pytype amongst other problems) * Seals not benchmark_environments * Rename benchmark_environments to seals * Fix SEALS version * Update configuration guidelines (now horribly out of date) * Clarify contribution guidelines in README and update code coverage to have stricter check for project/main * Add PyPi badge in anticipation of our glourious indexed future * Update Ray to 0.8.x and make dependency optional
1 parent 0173423 commit cf51186

7 files changed

Lines changed: 42 additions & 27 deletions

File tree

.codecov.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ coverage:
33
project:
44
default: false
55
main:
6-
target: 80%
76
paths:
87
- "src/imitation/"
98
- "!src/imitation/envs/examples/"

README.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[![CircleCI](https://circleci.com/gh/HumanCompatibleAI/imitation.svg?style=svg)](https://circleci.com/gh/HumanCompatibleAI/imitation)
22
[![Documentation Status](https://readthedocs.org/projects/imitation/badge/?version=latest)](https://imitation.readthedocs.io/en/latest/?badge=latest)
33
[![codecov](https://codecov.io/gh/HumanCompatibleAI/imitation/branch/master/graph/badge.svg)](https://codecov.io/gh/HumanCompatibleAI/imitation)
4+
[![PyPI version](https://badge.fury.io/py/imitation.svg)](https://badge.fury.io/py/imitation)
5+
46

57
# Imitation Learning Baseline Implementations
68

@@ -30,13 +32,23 @@ View Tensorboard with `tensorboard --logdir output/`.
3032

3133

3234
# Contributing
33-
* Follow the [Google Python Style Guide](http://google.github.io/styleguide/pyguide.html). Examples of Google-style
34-
docstrings can be found [here](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html).
35-
* Add units tests covering any new features, or bugs that are being fixed.
36-
* PEP8 guidelines with line width 80 and 2-space indents are enforced by `ci/lint.sh`,
37-
which is automatically run by Travis CI.
38-
* Static type checking via `pytype` is automatically run in `ci/type_check.sh`.
39-
* Code coverage is automatically enforced by CodeCov.
40-
The exact coverage required by CodeCov depends on the previous
41-
code coverage %. Files in `imitation/{examples,scripts}/` have no
42-
coverage requirements.
35+
36+
Please follow a coding style of:
37+
* PEP8, with line width 88.
38+
* Use the `black` autoformatter.
39+
* Follow the [Google Python Style Guide](http://google.github.io/styleguide/pyguide.html) unless
40+
it conflicts with the above. Examples of Google-style docstrings can be found
41+
[here](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html).
42+
43+
PRs should include unit tests for any new features, and add type annotations where possible.
44+
It is OK to omit annotations when it would make the code significantly more complex.
45+
46+
We use `pytest` for unit testing: run `pytest tests/` to run the test suite.
47+
We use `pytype` for static type analysis.
48+
You should run `ci/code_checks.sh` to run linting and static type checks, and may wish
49+
to configure this as a Git pre-commit hook.
50+
51+
These checks are run on CircleCI and are required to pass before merging.
52+
Additionally, we track test coverage by CodeCov, and mandate that code coverage
53+
should not decrease. This can be overridden by maintainers in exceptional cases.
54+
Files in `imitation/{examples,scripts}/` have no coverage requirements.

ci/build_venv.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ fi
99

1010
virtualenv -p python3.7 ${venv}
1111
source ${venv}/bin/activate
12-
pip install .[cpu,test,docs] gym[mujoco]
12+
pip install .[cpu,docs,parallel,test] gym[mujoco]

ci/code_checks.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,5 @@ if [ "$skipexpensive" != "true" ]; then
2323
popd
2424

2525
echo "Type checking"
26-
# Tell pytype Python path explicitly using -P: otherwise it gets lost
27-
# when the package is installed in editable mode (`pip -e .`). Note CI
28-
# checks still run using full install (`pip .`) which is more robust
29-
# but cumbersome for a Git commit hook.
30-
pytype -P src/:. ${SRC_FILES[@]}
26+
pytype ${SRC_FILES[@]}
3127
fi

setup.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
TF_VERSION = ">=1.15.0,<2.0"
55
TESTS_REQUIRE = [
66
"seals~=0.1.0",
7-
# remove pin once https://github.com/nedbat/coveragepy/issues/881 fixed
87
"black",
8+
# remove pin once https://github.com/nedbat/coveragepy/issues/881 fixed
99
"coverage==4.5.4",
1010
"codecov",
1111
"codespell",
@@ -24,11 +24,21 @@
2424
"sphinx",
2525
"sphinxcontrib-napoleon",
2626
]
27+
PARALLEL_REQUIRE = ["ray[debug,tune]~=0.8.5"]
28+
29+
30+
def get_readme() -> str:
31+
"""Retrieve content from README."""
32+
with open("README.md", "r") as f:
33+
return f.read()
34+
2735

2836
setup(
2937
name="imitation",
3038
version=src.imitation.__version__,
31-
description=("Implementation of modern IRL and imitation learning algorithms."),
39+
description="Implementation of modern IRL and imitation learning algorithms.",
40+
long_description=get_readme(),
41+
long_description_content_type="text/markdown",
3242
author="Center for Human-Compatible AI and Google",
3343
python_requires=">=3.7.0",
3444
packages=find_packages("src"),
@@ -40,15 +50,11 @@
4050
"gym[classic_control]",
4151
"matplotlib",
4252
"numpy>=1.15",
43-
"ray[debug]==0.7.4",
4453
"tqdm",
4554
"scikit-learn>=0.21.2",
46-
# TODO(adam): Change to >=2.10.0 once 2.10.0 released
47-
"stable-baselines @ git+https://github.com/hill-a/stable-baselines.git",
48-
# TODO(shwang): Change to PyPI release once >0.1.55 is released.
49-
# Needs https://github.com/google/jax/pull/1931
50-
"jax @ git+https://github.com/google/jax",
51-
"jaxlib~=0.1.20",
55+
"stable-baselines~=2.10.0",
56+
"jax~=0.1.66",
57+
"jaxlib~=0.1.47",
5258
# sacred==0.7.5 build is broken without pymongo
5359
# sacred>0.7.4 have non-picklable config objects (see GH #109)
5460
"sacred==0.7.4",
@@ -72,6 +78,7 @@
7278
],
7379
"test": TESTS_REQUIRE,
7480
"docs": DOCS_REQUIRE,
81+
"parallel": PARALLEL_REQUIRE,
7582
},
7683
entry_points={
7784
"console_scripts": [

src/__init__.py

Whitespace-only changes.

src/imitation/scripts/parallel.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ def parallel(
4242
Ray directory name.
4343
base_config_updates: `search_space["config_updates"]` is applied to this
4444
dict before it is passed to the inner experiment's `run()`.
45-
resource_per_trial: Argument to `ray.tune.run()`.
45+
resources_per_trial: Argument to `ray.tune.run()`.
46+
init_kwargs: Arguments to pass to `ray.init`.
4647
local_dir: `local_dir` argument to `ray.tune.run()`.
4748
upload_dir: `upload_dir` argument to `ray.tune.run()`.
4849
"""

0 commit comments

Comments
 (0)