Skip to content

Commit 2376648

Browse files
committed
Fix flexible lint toolchain drift
1 parent fd43867 commit 2376648

49 files changed

Lines changed: 443 additions & 62 deletions

Some content is hidden

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

BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
load("@pip_requirements//:requirements.bzl", "requirement")
2+
load("@rules_python//python:defs.bzl", "py_binary")
23

34
filegroup(
45
name = "clang_tidy_config",

Makefile

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,22 @@ addlicense-install: go-install
5353
doc-install:
5454
$(call check_install, pydocstyle)
5555
$(call check_install_extra, doc8, "doc8<1")
56+
$(call check_install, setuptools)
57+
$(call check_install, pbr)
5658
$(call check_install, sphinx)
5759
$(call check_install, sphinx_rtd_theme)
5860
$(call check_install_extra, sphinxcontrib.spelling, sphinxcontrib.spelling pyenchant)
5961

62+
spelling-system-install:
63+
python3 -c "import ctypes.util, sys; sys.exit(0 if ctypes.util.find_library('enchant-2') or ctypes.util.find_library('enchant') else 1)" || \
64+
([ "$$(uname -s)" = "Linux" ] && \
65+
if command -v sudo >/dev/null 2>&1; then \
66+
sudo apt-get update && sudo apt-get install -y libenchant-2-dev; \
67+
else \
68+
apt-get update && apt-get install -y libenchant-2-dev; \
69+
fi && \
70+
python3 -c "import ctypes.util, sys; sys.exit(0 if ctypes.util.find_library('enchant-2') or ctypes.util.find_library('enchant') else 1)")
71+
6072
auditwheel-install:
6173
$(call check_install_extra, auditwheel, auditwheel typed-ast patchelf)
6274

@@ -119,15 +131,15 @@ bazel-clean: bazel-install
119131
# documentation
120132

121133
addlicense: addlicense-install
122-
addlicense -c $(COPYRIGHT) -l apache -y 2023 -check $(PROJECT_FOLDER)
134+
addlicense -c $(COPYRIGHT) -l apache -y 2026 -check $(PROJECT_FOLDER)
123135

124136
docstyle: doc-install
125137
pydocstyle $(PROJECT_NAME) && doc8 docs && cd docs && make html SPHINXOPTS="-W"
126138

127139
doc: doc-install
128140
cd docs && make html && cd _build/html && python3 -m http.server
129141

130-
spelling: doc-install
142+
spelling: doc-install spelling-system-install
131143
cd docs && make spelling SPHINXOPTS="-W"
132144

133145
doc-clean:
@@ -144,7 +156,7 @@ format: py-format-install clang-format-install buildifier-install addlicense-ins
144156
yapf -ir $(PYTHON_FILES)
145157
clang-format -style=file -i $(CPP_FILES)
146158
buildifier -r -lint=fix $(BAZEL_FILES)
147-
addlicense -c $(COPYRIGHT) -l apache -y 2023 $(PROJECT_FOLDER)
159+
addlicense -c $(COPYRIGHT) -l apache -y 2026 $(PROJECT_FOLDER)
148160

149161
# Build docker images
150162

docs/conf.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
import os
1818

19-
import sphinx_rtd_theme
20-
2119

2220
def get_version() -> str:
2321
# https://packaging.python.org/guides/single-sourcing-package-version/
@@ -63,7 +61,6 @@ def get_version() -> str:
6361
# a list of builtin themes.
6462
#
6563
html_theme = "sphinx_rtd_theme"
66-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
6764

6865
# Add any paths that contain custom static files (such as style sheets) here,
6966
# relative to this directory. They are copied after the builtin static files,

docs/spelling_wordlist.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ bazel
1313
bazelisk
1414
buildifier
1515
addlicense
16+
isort
17+
yapf
1618
envpool
1719
th
1820
rew

envpool/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
load("@pip_requirements//:requirements.bzl", "requirement")
16+
load("@rules_python//python:defs.bzl", "py_library", "py_test")
1617

1718
package(default_visibility = ["//visibility:public"])
1819

envpool/atari/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
load("@pip_requirements//:requirements.bzl", "requirement")
1616
load("@pybind11_bazel//:build_defs.bzl", "pybind_extension")
17+
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
18+
load("@rules_python//python:defs.bzl", "py_library", "py_test")
1719

1820
package(default_visibility = ["//visibility:public"])
1921

envpool/atari/atari_network.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,17 @@ def __init__(
4545
nn.Flatten(),
4646
)
4747
with torch.no_grad():
48-
self.output_dim = np.prod(self.net(torch.zeros(1, c, h, w)).shape[1:])
48+
self.output_dim = int(
49+
np.prod(self.net(torch.zeros(1, c, h, w)).shape[1:])
50+
)
4951
if not features_only:
5052
self.net = nn.Sequential(
5153
self.net,
5254
nn.Linear(self.output_dim, 512),
5355
nn.ReLU(inplace=True),
54-
nn.Linear(512, np.prod(action_shape)),
56+
nn.Linear(512, int(np.prod(action_shape))),
5557
)
56-
self.output_dim = np.prod(action_shape)
58+
self.output_dim = int(np.prod(action_shape))
5759

5860
@no_type_check
5961
def forward(
@@ -80,7 +82,7 @@ def __init__(
8082
device: Union[str, int, torch.device] = "cpu",
8183
) -> None:
8284
"""Constructor of C51."""
83-
self.action_num = np.prod(action_shape)
85+
self.action_num = int(np.prod(action_shape))
8486
super().__init__(c, h, w, [self.action_num * num_atoms], device)
8587
self.num_atoms = num_atoms
8688

@@ -111,7 +113,7 @@ def __init__(
111113
device: Union[str, int, torch.device] = "cpu",
112114
) -> None:
113115
"""Constructor of QRDQN."""
114-
self.action_num = np.prod(action_shape)
116+
self.action_num = int(np.prod(action_shape))
115117
super().__init__(c, h, w, [self.action_num * num_quantiles], device)
116118
self.num_quantiles = num_quantiles
117119

envpool/box2d/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
load("@pip_requirements//:requirements.bzl", "requirement")
1616
load("@pybind11_bazel//:build_defs.bzl", "pybind_extension")
17+
load("@rules_cc//cc:defs.bzl", "cc_library")
18+
load("@rules_python//python:defs.bzl", "py_library", "py_test")
1719

1820
package(default_visibility = ["//visibility:public"])
1921

envpool/box2d/box2d_correctness_test.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ def test_car_racing_space(self) -> None:
6060
self.run_space_check(env0, env1)
6161

6262
@staticmethod
63-
def heuristic_lunar_lander_policy(
64-
s: np.ndarray, continuous: bool
65-
) -> np.ndarray:
63+
def heuristic_lunar_lander_policy(s: np.ndarray, continuous: bool) -> Any:
6664
angle_targ = np.clip(s[0] * 0.5 + s[2] * 1.0, -0.4, 0.4)
6765
hover_targ = 0.55 * np.abs(s[0])
6866
angle_todo = (angle_targ - s[4]) * 0.5 - s[5] * 1.0
@@ -73,17 +71,15 @@ def heuristic_lunar_lander_policy(
7371
hover_todo = -(s[3]) * 0.5
7472

7573
if continuous:
76-
a = np.array([hover_todo * 20 - 1, -angle_todo * 20])
77-
a = np.clip(a, -1, 1)
78-
else:
79-
a = 0
80-
if hover_todo > np.abs(angle_todo) and hover_todo > 0.05:
81-
a = 2
82-
elif angle_todo < -0.05:
83-
a = 3
84-
elif angle_todo > 0.05:
85-
a = 1
86-
return a
74+
action = np.array([hover_todo * 20 - 1, -angle_todo * 20])
75+
return np.clip(action, -1, 1)
76+
if hover_todo > np.abs(angle_todo) and hover_todo > 0.05:
77+
return 2
78+
if angle_todo < -0.05:
79+
return 3
80+
if angle_todo > 0.05:
81+
return 1
82+
return 0
8783

8884
def solve_lunar_lander(self, num_envs: int, continuous: bool) -> None:
8985
if continuous:

envpool/classic_control/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
load("@pip_requirements//:requirements.bzl", "requirement")
1616
load("@pybind11_bazel//:build_defs.bzl", "pybind_extension")
17+
load("@rules_cc//cc:defs.bzl", "cc_library")
18+
load("@rules_python//python:defs.bzl", "py_library", "py_test")
1719

1820
package(default_visibility = ["//visibility:public"])
1921

0 commit comments

Comments
 (0)