Skip to content

Commit d00ea39

Browse files
committed
[envpool] Fix JAX upgrade typing issues
1 parent 39cdba0 commit d00ea39

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

envpool/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
# Gym 0.26 still references np.bool8, which NumPy 2 removed.
3030
if not hasattr(np, "bool8"):
31-
np.bool8 = np.bool_ # type: ignore[attr-defined]
31+
setattr(np, "bool8", np.bool_)
3232

3333
__version__ = "0.9.0"
3434
__all__ = [

envpool/python/xla_template.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
_core = cast(Any, core)
2828
_xla = cast(Any, xla)
29+
_xla_client = cast(Any, xla_client)
2930

3031

3132
def _shape_with_layout(
@@ -66,12 +67,12 @@ def _make_xla_function(
6667
in_specs = _normalize_specs(in_specs)
6768
out_specs = _normalize_specs(out_specs)
6869
cpu_capsule, gpu_capsule = capsules
69-
xla_client.register_custom_call_target(
70+
_xla_client.register_custom_call_target(
7071
f"{type(obj).__name__}_{id(obj)}_{name}_cpu".encode(),
7172
cpu_capsule,
7273
platform="cpu"
7374
)
74-
xla_client.register_custom_call_target(
75+
_xla_client.register_custom_call_target(
7576
f"{type(obj).__name__}_{id(obj)}_{name}_gpu".encode(),
7677
gpu_capsule,
7778
platform="gpu",
@@ -91,7 +92,7 @@ def translation(c: Any, *args: Any, platform: str = "cpu") -> Any:
9192
output_shape = output_shape_with_layout[0]
9293
else:
9394
output_shape = xla_client.Shape.tuple_shape(output_shape_with_layout)
94-
return xla_client.ops.CustomCallWithLayout(
95+
return _xla_client.ops.CustomCallWithLayout(
9596
c,
9697
f"{type(obj).__name__}_{id(obj)}_{name}_{platform}".encode(),
9798
operands=args,

envpool/registration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
# Gym 0.26 still references np.bool8, which NumPy 2 removed.
2727
if not hasattr(np, "bool8"):
28-
np.bool8 = np.bool_ # type: ignore[attr-defined]
28+
setattr(np, "bool8", np.bool_)
2929

3030

3131
class EnvRegistry:

0 commit comments

Comments
 (0)