Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/ Fix docs build. #435

Merged
merged 4 commits into from
Feb 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/environments.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/environments/smac.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Currently supported through the [PettingZoo Wrapper](pettingzoo).
::: mava.wrappers.smac
1 change: 0 additions & 1 deletion docs/systems.md

This file was deleted.

3 changes: 0 additions & 3 deletions docs/systems/tf/dial.md

This file was deleted.

3 changes: 0 additions & 3 deletions docs/systems/tf/qmix.md

This file was deleted.

3 changes: 3 additions & 0 deletions docs/systems/tf/value_decomposition.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--8<-- "mava/systems/tf/value_decomposition/README.md"

::: mava.systems.tf.value_decomposition
3 changes: 0 additions & 3 deletions docs/systems/tf/vdn.md

This file was deleted.

29 changes: 21 additions & 8 deletions mava/utils/environments/flatland_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,27 @@
)
from mava.wrappers.flatland import FlatlandEnvWrapper

try:

def check_flatland_import() -> bool:
arnupretorius marked this conversation as resolved.
Show resolved Hide resolved
"""Consistent way to check if flatland has been installed.

Returns:
whether flatland exists or not.
"""
try:
from flatland.envs.line_generators import sparse_line_generator

# Delete unused var
del sparse_line_generator
_found_flatland = True

except ModuleNotFoundError:
_found_flatland = False
return _found_flatland


_found_flatland = check_flatland_import()
if _found_flatland:
from flatland.envs.line_generators import sparse_line_generator
from flatland.envs.malfunction_generators import (
MalfunctionParameters,
Expand All @@ -33,13 +53,6 @@
from flatland.envs.rail_env import RailEnv
from flatland.envs.rail_generators import sparse_rail_generator

_found_flatland = True

except ModuleNotFoundError:
_found_flatland = False

if _found_flatland:

def _create_rail_env_with_tree_obs(
n_agents: int = 5,
x_dim: int = 30,
Expand Down
15 changes: 11 additions & 4 deletions mava/wrappers/flatland.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,17 @@
import numpy as np
from acme import specs
from acme.wrappers.gym_wrapper import _convert_to_spec
from flatland.envs.observations import GlobalObsForRailEnv, Node, TreeObsForRailEnv
from flatland.envs.rail_env import RailEnv
from flatland.envs.step_utils.states import TrainState
from flatland.utils.rendertools import AgentRenderVariant, RenderTool

try:
from flatland.envs.observations import GlobalObsForRailEnv, Node, TreeObsForRailEnv
from flatland.envs.rail_env import RailEnv
from flatland.envs.step_utils.states import TrainState
from flatland.utils.rendertools import AgentRenderVariant, RenderTool
except ModuleNotFoundError:
# Without these types - the docs fail.
# TODO(Kale-ab): Remove this hack.
RailEnv = Any
Node = Any
from gym.spaces import Discrete
from gym.spaces.box import Box

Expand Down
4 changes: 1 addition & 3 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ nav:
- mad4pg: systems/tf/mad4pg.md
- mappo: systems/tf/mappo.md
- madqn: systems/tf/madqn.md
- vdn: systems/tf/vdn.md
- qmix: systems/tf/qmix.md
- dial: systems/tf/dial.md
- vdn and qmix: systems/tf/value_decomposition.md
- Environments:
- General: environments/general.md
- Supported Environments:
Expand Down
10 changes: 4 additions & 6 deletions tests/utils/environment_utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@
import pytest

from mava.utils.environments import debugging_utils, pettingzoo_utils
from mava.utils.environments.flatland_utils import check_flatland_import

try:
from mava.utils.environments import flatland_utils
_has_flatland = check_flatland_import()

_has_flatland = True
except (ModuleNotFoundError, ImportError):
_has_flatland = False
pass
if _has_flatland:
from mava.utils.environments import flatland_utils


@pytest.mark.parametrize(
Expand Down
9 changes: 2 additions & 7 deletions tests/wrappers/wrapper_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,11 @@
from _pytest.monkeypatch import MonkeyPatch

from mava import types
from mava.utils.environments.flatland_utils import check_flatland_import
from tests.conftest import EnvSpec, EnvType, Helpers
from tests.enums import EnvSource

try:
import flatland # noqa: F401

_has_flatland = True
except (ModuleNotFoundError, ImportError):
_has_flatland = False
pass
_has_flatland = check_flatland_import()
"""
TestEnvWrapper is a general purpose test class that runs tests for environment wrappers.
This is meant to flexibily test various environments wrappers.
Expand Down