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

Spinup Gym to Gymnasium Migration with Package version updates #439

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
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
Binary file added dist/spinup-0.2.0-py3-none-any.whl
Binary file not shown.
Binary file added dist/spinup-0.2.0-py3.12.egg
Binary file not shown.
6 changes: 5 additions & 1 deletion docs/user/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ Installing Spinning Up
cd spinningup
pip install -e .

.. admonition:: You Should Know
.. admonition::
*Note* I had to use `pip wheel --no-deps -w dist .` to move past this step. A reference was deprecated and I believe the omittion of
re-downloading of dependencies helped. I will need to look into this more, getting it up and running was the priority.

You Should Know

Spinning Up defaults to installing everything in Gym **except** the MuJoCo environments. In case you run into any trouble with the Gym installation, check out the `Gym`_ github page for help. If you want the MuJoCo environments, see the optional installation section below.

Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
'gym[atari,box2d,classic_control]~=0.15.3',
'ipython',
'joblib',
'matplotlib==3.1.1',
'matplotlib==3.10.0',
'mpi4py',
'numpy',
'pandas',
'pytest',
'psutil',
'scipy',
'seaborn==0.8.1',
'tensorflow>=1.8.0,<2.0',
'torch==1.3.1',
'seaborn==0.13.2',
'tensorflow==2.18.0',
'torch==2.6.0',
'tqdm'
],
description="Teaching tools for introducing people to deep RL.",
Expand Down
2 changes: 1 addition & 1 deletion spinup/algos/pytorch/ddpg/ddpg.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np
import torch
from torch.optim import Adam
import gym
import gymnasium
import time
import spinup.algos.pytorch.ddpg.core as core
from spinup.utils.logx import EpochLogger
Expand Down
2 changes: 1 addition & 1 deletion spinup/algos/pytorch/ppo/core.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
import scipy.signal
from gym.spaces import Box, Discrete
from gymnasium.spaces import Box, Discrete

import torch
import torch.nn as nn
Expand Down
2 changes: 1 addition & 1 deletion spinup/algos/pytorch/ppo/ppo.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
import torch
from torch.optim import Adam
import gym
import gymnasium
import time
import spinup.algos.pytorch.ppo.core as core
from spinup.utils.logx import EpochLogger
Expand Down
2 changes: 1 addition & 1 deletion spinup/algos/pytorch/sac/sac.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np
import torch
from torch.optim import Adam
import gym
import gymnasium
import time
import spinup.algos.pytorch.sac.core as core
from spinup.utils.logx import EpochLogger
Expand Down
2 changes: 1 addition & 1 deletion spinup/algos/pytorch/td3/td3.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np
import torch
from torch.optim import Adam
import gym
import gymnasium
import time
import spinup.algos.pytorch.td3.core as core
from spinup.utils.logx import EpochLogger
Expand Down
2 changes: 1 addition & 1 deletion spinup/algos/pytorch/vpg/core.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
import scipy.signal
from gym.spaces import Box, Discrete
from gymnasium.spaces import Box, Discrete

import torch
import torch.nn as nn
Expand Down
2 changes: 1 addition & 1 deletion spinup/algos/pytorch/vpg/vpg.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
import torch
from torch.optim import Adam
import gym
import gymnasium
import time
import spinup.algos.pytorch.vpg.core as core
from spinup.utils.logx import EpochLogger
Expand Down
2 changes: 1 addition & 1 deletion spinup/algos/tf1/ddpg/ddpg.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
import tensorflow as tf
import gym
import gymnasium
import time
from spinup.algos.tf1.ddpg import core
from spinup.algos.tf1.ddpg.core import get_vars
Expand Down
2 changes: 1 addition & 1 deletion spinup/algos/tf1/ppo/core.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
import tensorflow as tf
import scipy.signal
from gym.spaces import Box, Discrete
from gymnasium.spaces import Box, Discrete

EPS = 1e-8

Expand Down
2 changes: 1 addition & 1 deletion spinup/algos/tf1/ppo/ppo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
import tensorflow as tf
import gym
import gymnasium as gym
import time
import spinup.algos.tf1.ppo.core as core
from spinup.utils.logx import EpochLogger
Expand Down
2 changes: 1 addition & 1 deletion spinup/algos/tf1/sac/sac.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
import tensorflow as tf
import gym
import gymnasium
import time
from spinup.algos.tf1.sac import core
from spinup.algos.tf1.sac.core import get_vars
Expand Down
2 changes: 1 addition & 1 deletion spinup/algos/tf1/td3/td3.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
import tensorflow as tf
import gym
import gymnasium
import time
from spinup.algos.tf1.td3 import core
from spinup.algos.tf1.td3.core import get_vars
Expand Down
2 changes: 1 addition & 1 deletion spinup/algos/tf1/trpo/core.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
import tensorflow as tf
import scipy.signal
from gym.spaces import Box, Discrete
from gymnasium.spaces import Box, Discrete

EPS = 1e-8

Expand Down
2 changes: 1 addition & 1 deletion spinup/algos/tf1/trpo/trpo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
import tensorflow as tf
import gym
import gymnasium
import time
import spinup.algos.tf1.trpo.core as core
from spinup.utils.logx import EpochLogger
Expand Down
2 changes: 1 addition & 1 deletion spinup/algos/tf1/vpg/core.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
import tensorflow as tf
import scipy.signal
from gym.spaces import Box, Discrete
from gymnasium.spaces import Box, Discrete

EPS = 1e-8

Expand Down
2 changes: 1 addition & 1 deletion spinup/algos/tf1/vpg/vpg.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
import tensorflow as tf
import gym
import gymnasium
import time
import spinup.algos.tf1.vpg.core as core
from spinup.utils.logx import EpochLogger
Expand Down
6 changes: 3 additions & 3 deletions spinup/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from spinup.utils.run_utils import ExperimentGrid
from spinup.utils.serialization_utils import convert_json
import argparse
import gym
import gymnasium as gym
import json
import os, subprocess, sys
import os.path as osp
Expand Down Expand Up @@ -153,7 +153,7 @@ def process(arg):

# Special handling for environment: make sure that env_name is a real,
# registered gym environment.
valid_envs = [e.id for e in list(gym.envs.registry.all())]
valid_envs = [id for e in list(gym.envs.registry.keys())]
assert 'env_name' in arg_dict, \
friendly_err("You did not give a value for --env_name! Add one and try again.")
for env_name in arg_dict['env_name']:
Expand Down Expand Up @@ -245,4 +245,4 @@ def process(arg):
# Assume that the user plans to execute an algorithm. Run custom
# parsing on the arguments and build a grid search to execute.
args = sys.argv[2:]
parse_and_execute_grid_search(cmd, args)
parse_and_execute_grid_search(cmd, args)
2 changes: 1 addition & 1 deletion spinup/utils/mpi_tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def sync_all_params():
return sync_params(tf.global_variables())


class MpiAdamOptimizer(tf.train.AdamOptimizer):
class MpiAdamOptimizer(tf.compat.v1.train.AdamOptimizer):
"""
Adam optimizer that averages gradients across MPI processes.

Expand Down