Skip to content

Commit

Permalink
Remove gym from skrl.utils
Browse files Browse the repository at this point in the history
  • Loading branch information
Toni-SM committed Oct 19, 2024
1 parent 934fbaa commit dbc6b34
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 40 deletions.
9 changes: 4 additions & 5 deletions skrl/utils/model_instantiators/jax/categorical.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from typing import Any, Mapping, Optional, Sequence, Tuple, Union

import textwrap
import gym
import gymnasium

import flax.linen as nn # noqa
Expand All @@ -14,8 +13,8 @@
from skrl.utils.spaces.jax import unflatten_tensorized_space # noqa


def categorical_model(observation_space: Optional[Union[int, Tuple[int], gym.Space, gymnasium.Space]] = None,
action_space: Optional[Union[int, Tuple[int], gym.Space, gymnasium.Space]] = None,
def categorical_model(observation_space: Optional[Union[int, Tuple[int], gymnasium.Space]] = None,
action_space: Optional[Union[int, Tuple[int], gymnasium.Space]] = None,
device: Optional[Union[str, jax.Device]] = None,
unnormalized_log_prob: bool = True,
network: Sequence[Mapping[str, Any]] = [],
Expand All @@ -27,10 +26,10 @@ def categorical_model(observation_space: Optional[Union[int, Tuple[int], gym.Spa
:param observation_space: Observation/state space or shape (default: None).
If it is not None, the num_observations property will contain the size of that space
:type observation_space: int, tuple or list of integers, gym.Space, gymnasium.Space or None, optional
:type observation_space: int, tuple or list of integers, gymnasium.Space or None, optional
:param action_space: Action space or shape (default: None).
If it is not None, the num_actions property will contain the size of that space
:type action_space: int, tuple or list of integers, gym.Space, gymnasium.Space or None, optional
:type action_space: int, tuple or list of integers, gymnasium.Space or None, optional
:param device: Device on which a tensor/array is or will be allocated (default: ``None``).
If None, the device will be either ``"cuda"`` if available or ``"cpu"``
:type device: str or jax.Device, optional
Expand Down
9 changes: 4 additions & 5 deletions skrl/utils/model_instantiators/jax/deterministic.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from typing import Any, Mapping, Optional, Sequence, Tuple, Union

import textwrap
import gym
import gymnasium

import flax.linen as nn # noqa
Expand All @@ -14,8 +13,8 @@
from skrl.utils.spaces.jax import unflatten_tensorized_space # noqa


def deterministic_model(observation_space: Optional[Union[int, Tuple[int], gym.Space, gymnasium.Space]] = None,
action_space: Optional[Union[int, Tuple[int], gym.Space, gymnasium.Space]] = None,
def deterministic_model(observation_space: Optional[Union[int, Tuple[int], gymnasium.Space]] = None,
action_space: Optional[Union[int, Tuple[int], gymnasium.Space]] = None,
device: Optional[Union[str, jax.Device]] = None,
clip_actions: bool = False,
network: Sequence[Mapping[str, Any]] = [],
Expand All @@ -27,10 +26,10 @@ def deterministic_model(observation_space: Optional[Union[int, Tuple[int], gym.S
:param observation_space: Observation/state space or shape (default: None).
If it is not None, the num_observations property will contain the size of that space
:type observation_space: int, tuple or list of integers, gym.Space, gymnasium.Space or None, optional
:type observation_space: int, tuple or list of integers, gymnasium.Space or None, optional
:param action_space: Action space or shape (default: None).
If it is not None, the num_actions property will contain the size of that space
:type action_space: int, tuple or list of integers, gym.Space, gymnasium.Space or None, optional
:type action_space: int, tuple or list of integers, gymnasium.Space or None, optional
:param device: Device on which a tensor/array is or will be allocated (default: ``None``).
If None, the device will be either ``"cuda"`` if available or ``"cpu"``
:type device: str or jax.Device, optional
Expand Down
9 changes: 4 additions & 5 deletions skrl/utils/model_instantiators/jax/gaussian.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from typing import Any, Mapping, Optional, Sequence, Tuple, Union

import textwrap
import gym
import gymnasium

import flax.linen as nn # noqa
Expand All @@ -14,8 +13,8 @@
from skrl.utils.spaces.jax import unflatten_tensorized_space # noqa


def gaussian_model(observation_space: Optional[Union[int, Tuple[int], gym.Space, gymnasium.Space]] = None,
action_space: Optional[Union[int, Tuple[int], gym.Space, gymnasium.Space]] = None,
def gaussian_model(observation_space: Optional[Union[int, Tuple[int], gymnasium.Space]] = None,
action_space: Optional[Union[int, Tuple[int], gymnasium.Space]] = None,
device: Optional[Union[str, jax.Device]] = None,
clip_actions: bool = False,
clip_log_std: bool = True,
Expand All @@ -31,10 +30,10 @@ def gaussian_model(observation_space: Optional[Union[int, Tuple[int], gym.Space,
:param observation_space: Observation/state space or shape (default: None).
If it is not None, the num_observations property will contain the size of that space
:type observation_space: int, tuple or list of integers, gym.Space, gymnasium.Space or None, optional
:type observation_space: int, tuple or list of integers, gymnasium.Space or None, optional
:param action_space: Action space or shape (default: None).
If it is not None, the num_actions property will contain the size of that space
:type action_space: int, tuple or list of integers, gym.Space, gymnasium.Space or None, optional
:type action_space: int, tuple or list of integers, gymnasium.Space or None, optional
:param device: Device on which a tensor/array is or will be allocated (default: ``None``).
If None, the device will be either ``"cuda"`` if available or ``"cpu"``
:type device: str or jax.Device, optional
Expand Down
9 changes: 4 additions & 5 deletions skrl/utils/model_instantiators/torch/categorical.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from typing import Any, Mapping, Optional, Sequence, Tuple, Union

import textwrap
import gym
import gymnasium

import torch
Expand All @@ -13,8 +12,8 @@
from skrl.utils.spaces.torch import unflatten_tensorized_space # noqa


def categorical_model(observation_space: Optional[Union[int, Tuple[int], gym.Space, gymnasium.Space]] = None,
action_space: Optional[Union[int, Tuple[int], gym.Space, gymnasium.Space]] = None,
def categorical_model(observation_space: Optional[Union[int, Tuple[int], gymnasium.Space]] = None,
action_space: Optional[Union[int, Tuple[int], gymnasium.Space]] = None,
device: Optional[Union[str, torch.device]] = None,
unnormalized_log_prob: bool = True,
network: Sequence[Mapping[str, Any]] = [],
Expand All @@ -26,10 +25,10 @@ def categorical_model(observation_space: Optional[Union[int, Tuple[int], gym.Spa
:param observation_space: Observation/state space or shape (default: None).
If it is not None, the num_observations property will contain the size of that space
:type observation_space: int, tuple or list of integers, gym.Space, gymnasium.Space or None, optional
:type observation_space: int, tuple or list of integers, gymnasium.Space or None, optional
:param action_space: Action space or shape (default: None).
If it is not None, the num_actions property will contain the size of that space
:type action_space: int, tuple or list of integers, gym.Space, gymnasium.Space or None, optional
:type action_space: int, tuple or list of integers, gymnasium.Space or None, optional
:param device: Device on which a tensor/array is or will be allocated (default: ``None``).
If None, the device will be either ``"cuda"`` if available or ``"cpu"``
:type device: str or torch.device, optional
Expand Down
9 changes: 4 additions & 5 deletions skrl/utils/model_instantiators/torch/deterministic.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from typing import Any, Mapping, Optional, Sequence, Tuple, Union

import textwrap
import gym
import gymnasium

import torch
Expand All @@ -13,8 +12,8 @@
from skrl.utils.spaces.torch import unflatten_tensorized_space # noqa


def deterministic_model(observation_space: Optional[Union[int, Tuple[int], gym.Space, gymnasium.Space]] = None,
action_space: Optional[Union[int, Tuple[int], gym.Space, gymnasium.Space]] = None,
def deterministic_model(observation_space: Optional[Union[int, Tuple[int], gymnasium.Space]] = None,
action_space: Optional[Union[int, Tuple[int], gymnasium.Space]] = None,
device: Optional[Union[str, torch.device]] = None,
clip_actions: bool = False,
network: Sequence[Mapping[str, Any]] = [],
Expand All @@ -26,10 +25,10 @@ def deterministic_model(observation_space: Optional[Union[int, Tuple[int], gym.S
:param observation_space: Observation/state space or shape (default: None).
If it is not None, the num_observations property will contain the size of that space
:type observation_space: int, tuple or list of integers, gym.Space, gymnasium.Space or None, optional
:type observation_space: int, tuple or list of integers, gymnasium.Space or None, optional
:param action_space: Action space or shape (default: None).
If it is not None, the num_actions property will contain the size of that space
:type action_space: int, tuple or list of integers, gym.Space, gymnasium.Space or None, optional
:type action_space: int, tuple or list of integers, gymnasium.Space or None, optional
:param device: Device on which a tensor/array is or will be allocated (default: ``None``).
If None, the device will be either ``"cuda"`` if available or ``"cpu"``
:type device: str or torch.device, optional
Expand Down
9 changes: 4 additions & 5 deletions skrl/utils/model_instantiators/torch/gaussian.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from typing import Any, Mapping, Optional, Sequence, Tuple, Union

import textwrap
import gym
import gymnasium

import torch
Expand All @@ -13,8 +12,8 @@
from skrl.utils.spaces.torch import unflatten_tensorized_space # noqa


def gaussian_model(observation_space: Optional[Union[int, Tuple[int], gym.Space, gymnasium.Space]] = None,
action_space: Optional[Union[int, Tuple[int], gym.Space, gymnasium.Space]] = None,
def gaussian_model(observation_space: Optional[Union[int, Tuple[int], gymnasium.Space]] = None,
action_space: Optional[Union[int, Tuple[int], gymnasium.Space]] = None,
device: Optional[Union[str, torch.device]] = None,
clip_actions: bool = False,
clip_log_std: bool = True,
Expand All @@ -30,10 +29,10 @@ def gaussian_model(observation_space: Optional[Union[int, Tuple[int], gym.Space,
:param observation_space: Observation/state space or shape (default: None).
If it is not None, the num_observations property will contain the size of that space
:type observation_space: int, tuple or list of integers, gym.Space, gymnasium.Space or None, optional
:type observation_space: int, tuple or list of integers, gymnasium.Space or None, optional
:param action_space: Action space or shape (default: None).
If it is not None, the num_actions property will contain the size of that space
:type action_space: int, tuple or list of integers, gym.Space, gymnasium.Space or None, optional
:type action_space: int, tuple or list of integers, gymnasium.Space or None, optional
:param device: Device on which a tensor/array is or will be allocated (default: ``None``).
If None, the device will be either ``"cuda"`` if available or ``"cpu"``
:type device: str or torch.device, optional
Expand Down
9 changes: 4 additions & 5 deletions skrl/utils/model_instantiators/torch/multivariate_gaussian.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from typing import Any, Mapping, Optional, Sequence, Tuple, Union

import textwrap
import gym
import gymnasium

import torch
Expand All @@ -13,8 +12,8 @@
from skrl.utils.spaces.torch import unflatten_tensorized_space # noqa


def multivariate_gaussian_model(observation_space: Optional[Union[int, Tuple[int], gym.Space, gymnasium.Space]] = None,
action_space: Optional[Union[int, Tuple[int], gym.Space, gymnasium.Space]] = None,
def multivariate_gaussian_model(observation_space: Optional[Union[int, Tuple[int], gymnasium.Space]] = None,
action_space: Optional[Union[int, Tuple[int], gymnasium.Space]] = None,
device: Optional[Union[str, torch.device]] = None,
clip_actions: bool = False,
clip_log_std: bool = True,
Expand All @@ -30,10 +29,10 @@ def multivariate_gaussian_model(observation_space: Optional[Union[int, Tuple[int
:param observation_space: Observation/state space or shape (default: None).
If it is not None, the num_observations property will contain the size of that space
:type observation_space: int, tuple or list of integers, gym.Space, gymnasium.Space or None, optional
:type observation_space: int, tuple or list of integers, gymnasium.Space or None, optional
:param action_space: Action space or shape (default: None).
If it is not None, the num_actions property will contain the size of that space
:type action_space: int, tuple or list of integers, gym.Space, gymnasium.Space or None, optional
:type action_space: int, tuple or list of integers, gymnasium.Space or None, optional
:param device: Device on which a tensor/array is or will be allocated (default: ``None``).
If None, the device will be either ``"cuda"`` if available or ``"cpu"``
:type device: str or torch.device, optional
Expand Down
9 changes: 4 additions & 5 deletions skrl/utils/model_instantiators/torch/shared.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from typing import Any, Mapping, Optional, Sequence, Tuple, Union

import textwrap
import gym
import gymnasium

import torch
Expand All @@ -13,8 +12,8 @@
from skrl.utils.spaces.torch import unflatten_tensorized_space # noqa


def shared_model(observation_space: Optional[Union[int, Tuple[int], gym.Space, gymnasium.Space]] = None,
action_space: Optional[Union[int, Tuple[int], gym.Space, gymnasium.Space]] = None,
def shared_model(observation_space: Optional[Union[int, Tuple[int], gymnasium.Space]] = None,
action_space: Optional[Union[int, Tuple[int], gymnasium.Space]] = None,
device: Optional[Union[str, torch.device]] = None,
structure: str = "",
roles: Sequence[str] = [],
Expand All @@ -25,10 +24,10 @@ def shared_model(observation_space: Optional[Union[int, Tuple[int], gym.Space, g
:param observation_space: Observation/state space or shape (default: None).
If it is not None, the num_observations property will contain the size of that space
:type observation_space: int, tuple or list of integers, gym.Space, gymnasium.Space or None, optional
:type observation_space: int, tuple or list of integers, gymnasium.Space or None, optional
:param action_space: Action space or shape (default: None).
If it is not None, the num_actions property will contain the size of that space
:type action_space: int, tuple or list of integers, gym.Space, gymnasium.Space or None, optional
:type action_space: int, tuple or list of integers, gymnasium.Space or None, optional
:param device: Device on which a tensor/array is or will be allocated (default: ``None``).
If None, the device will be either ``"cuda"`` if available or ``"cpu"``
:type device: str or torch.device, optional
Expand Down

0 comments on commit dbc6b34

Please sign in to comment.