Skip to content

Commit 0ffb276

Browse files
committed
Fix Windows Jumanji and VizDoom CI
1 parent 00dd55f commit 0ffb276

2 files changed

Lines changed: 53 additions & 4 deletions

File tree

envpool/jumanji/jumanji_official_align_test.py

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@
1515

1616
from __future__ import annotations
1717

18+
import hashlib
1819
import os
20+
import shutil
21+
import sys
22+
import tempfile
1923
import warnings
2024
from dataclasses import fields, is_dataclass, replace
2125
from pathlib import Path
2226
from typing import Any, cast
2327

24-
import numpy as np
25-
from absl.testing import absltest
26-
2728

2829
def _configure_matplotlib() -> None:
2930
"""Configure Matplotlib without importing EnvPool's Jumanji package."""
@@ -39,7 +40,53 @@ def _configure_matplotlib() -> None:
3940
os.environ["MPLCONFIGDIR"] = str(mpl_config)
4041

4142

43+
def _shorten_windows_oracle_site_packages() -> None:
44+
"""Copy oracle wheels to a short path before loading Windows extensions."""
45+
if os.name != "nt":
46+
return
47+
48+
oracle_sites: list[Path] = []
49+
for entry in sys.path:
50+
if "jumanji_oracle_requirements" not in str(entry):
51+
continue
52+
path = Path(entry)
53+
if path.name == "site-packages":
54+
oracle_sites.append(path)
55+
if not oracle_sites:
56+
return
57+
58+
key = hashlib.sha1(
59+
"|".join(str(path) for path in oracle_sites).encode("utf-8")
60+
).hexdigest()[:12]
61+
short_site = Path(tempfile.gettempdir()) / "ej_o" / key / "s"
62+
marker = short_site / ".copied"
63+
if not marker.exists():
64+
short_site.mkdir(parents=True, exist_ok=True)
65+
for site in oracle_sites:
66+
for src in site.iterdir():
67+
if src.name == "__pycache__":
68+
continue
69+
dst = short_site / src.name
70+
if src.is_dir():
71+
shutil.copytree(
72+
src,
73+
dst,
74+
dirs_exist_ok=True,
75+
ignore=shutil.ignore_patterns("__pycache__"),
76+
)
77+
else:
78+
shutil.copy2(src, dst)
79+
marker.write_text("ok")
80+
81+
sys.path[:] = [str(short_site)] + [
82+
entry
83+
for entry in sys.path
84+
if "jumanji_oracle_requirements" not in str(entry)
85+
]
86+
87+
4288
_configure_matplotlib()
89+
_shorten_windows_oracle_site_packages()
4390
warnings.filterwarnings(
4491
"ignore",
4592
message="FigureCanvasAgg is non-interactive.*",
@@ -55,6 +102,8 @@ def _configure_matplotlib() -> None:
55102
import jax # noqa: E402
56103
import jax.numpy as jnp # noqa: E402
57104
import jumanji # noqa: E402
105+
import numpy as np # noqa: E402
106+
from absl.testing import absltest # noqa: E402
58107
from jumanji.environments.routing.sokoban.generator import ( # noqa: E402
59108
SimpleSolveGenerator,
60109
)

envpool/vizdoom/vizdoom_pretrain_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def test_d3(self) -> None:
232232
model_path = self.get_package_path("policy-d3.pth")
233233
self.assertTrue(os.path.exists(model_path))
234234
reward_config = {"KILLCOUNT": [1, 0]}
235-
num_envs = 2
235+
num_envs = 1
236236
baseline_reward, baseline_length = self.eval_c51_subprocess(
237237
"D3_battle",
238238
model_path,

0 commit comments

Comments
 (0)