Skip to content

Commit

Permalink
Skip Mujoco tests if OpenGL is not available (#480)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristofKaufmann authored May 16, 2023
1 parent 1554830 commit 553150a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
3 changes: 2 additions & 1 deletion bin/all-py.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/root/.mujoco/mujoco210/bin"
COPY . /usr/local/gymnasium/
WORKDIR /usr/local/gymnasium/

RUN pip install .[all,testing] --no-cache-dir
# Test with PyTorch CPU build, since CUDA is not available in CI anyway
RUN pip install .[all,testing] --no-cache-dir --extra-index-url https://download.pytorch.org/whl/cpu

ENTRYPOINT ["/usr/local/gymnasium/bin/docker_entrypoint"]
22 changes: 14 additions & 8 deletions tests/envs/test_rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,19 @@ def test_render_modes(spec):
if mode != "human":
new_env = spec.make(render_mode=mode)

new_env.reset()
rendered = new_env.render()
check_rendered(rendered, mode)
try:
new_env.reset()
rendered = new_env.render()
check_rendered(rendered, mode)

new_env.step(new_env.action_space.sample())
rendered = new_env.render()
check_rendered(rendered, mode)

new_env.close()
new_env.step(new_env.action_space.sample())
rendered = new_env.render()
check_rendered(rendered, mode)
except Exception as e:
if "gladLoadGL error" in str(e):
pytest.skip("OpenGL not available")
else:
raise
finally:
new_env.close()
env.close()
1 change: 1 addition & 0 deletions tests/envs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def try_make_env(env_spec: EnvSpec) -> Optional[gym.Env]:
return env_spec.make(disable_env_checker=True).unwrapped
except (
ImportError,
AttributeError,
gym.error.DependencyNotInstalled,
gym.error.MissingArgument,
) as e:
Expand Down

0 comments on commit 553150a

Please sign in to comment.