From 034c453de83dcf93e8f7e44ebcf103279d09ecd5 Mon Sep 17 00:00:00 2001 From: Heiko Carrasco Date: Mon, 9 Oct 2023 19:21:25 -0400 Subject: [PATCH 1/9] Ignore local changes/symlinked pre-commit --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index adf9265e48f..ee1aa7a5c17 100644 --- a/.gitignore +++ b/.gitignore @@ -93,3 +93,6 @@ MUJOCO_LOG.* ### sbi-logs Pyrado/sbi-logs/ Pyrado/tests/sbi-logs/ + +### pre-commit local/symlink +.pre-commit-config.yaml From 386d9f7d896c48cc2222810fff36da327aafe0ed Mon Sep 17 00:00:00 2001 From: Heiko Carrasco Date: Sat, 14 Oct 2023 23:57:11 -0400 Subject: [PATCH 2/9] Install torch-based deps with dependencies --- setup_deps.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup_deps.py b/setup_deps.py index 6fe7b8333ba..5a27a6f40c8 100644 --- a/setup_deps.py +++ b/setup_deps.py @@ -564,9 +564,9 @@ def setup_pytorch_based(): # Set up GPyTorch without touching the PyTorch installation (requires scikit-learn which requires threadpoolctl) sp.check_call([sys.executable, "-m", "pip", "install", "-U", "--no-deps", "threadpoolctl"]) sp.check_call([sys.executable, "-m", "pip", "install", "-U", "--no-deps", "scikit-learn"]) - sp.check_call([sys.executable, "-m", "pip", "install", "-U", "--no-deps", "gpytorch"]) + sp.check_call([sys.executable, "-m", "pip", "install", "-U", "gpytorch"]) # Set up BoTorch without touching the PyTorch installation (requires gpytorch) - sp.check_call([sys.executable, "-m", "pip", "install", "-U", "--no-deps", "botorch"]) + sp.check_call([sys.executable, "-m", "pip", "install", "-U", "botorch"]) # Set up Pyro without touching the PyTorch installation (requires opt-einsum) sp.check_call([sys.executable, "-m", "pip", "install", "-U", "--no-deps", "opt-einsum"]) sp.check_call([sys.executable, "-m", "pip", "install", "-U", "--no-deps", "pyro-api"]) From 81b36c7bdaadd134fe1855490f12f96868fbc562 Mon Sep 17 00:00:00 2001 From: Heiko Carrasco Date: Sat, 14 Oct 2023 23:57:51 -0400 Subject: [PATCH 3/9] Add mujoco as a python dependency --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 6b0c4970b34..48a4668e21d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -28,3 +28,4 @@ sphinx_rtd_theme tabulate tensorboard tqdm +mujoco \ No newline at end of file From bcedd706a28bdd7b1b835fb3dc2a8a04f6386f6a Mon Sep 17 00:00:00 2001 From: Heiko Carrasco Date: Sat, 14 Oct 2023 23:58:27 -0400 Subject: [PATCH 4/9] Remove mujoco-py installation from install script --- setup_deps.py | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/setup_deps.py b/setup_deps.py index 5a27a6f40c8..0f0ca2b505e 100644 --- a/setup_deps.py +++ b/setup_deps.py @@ -40,7 +40,6 @@ import zipfile from urllib.request import urlretrieve -import yaml # Get the project's root directory @@ -138,11 +137,6 @@ ] # using --headless: conda install -c conda-forge bullet freetype libglu freeglut mesalib lapack -required_packages_mujocopy = [ - "libglew-dev", - "libosmesa6-dev", -] - env_vars = { # Global cmake prefix path "CMAKE_PREFIX_PATH": ":".join(cmake_prefix_path) @@ -292,7 +286,7 @@ def downloadAndExtract(url, destdir, archiveContentPath=None): # Taken from https://stackoverflow.com/a/43094365 def members(ml): subfolder = osp.normpath(archiveContentPath) - l = len(subfolder) + len(subfolder) for member in ml: # Skip directories in zip isdir = getattr(member, "is_dir", None) @@ -386,7 +380,7 @@ def setup_dep_libraries(): quiet = [] if not CI else ["-qq"] sp.check_call(["sudo", "apt-get"] + quiet + ["update", "-y"]) # Install dependencies - sp.check_call(["sudo", "apt-get"] + quiet + ["install", "-y"] + required_packages + required_packages_mujocopy) + sp.check_call(["sudo", "apt-get"] + quiet + ["install", "-y"] + required_packages) def setup_wm5(): @@ -553,10 +547,6 @@ def setup_render_pipeline(): sp.check_call([sys.executable, "setup.py"], cwd=osp.join(project_dir, "thirdParty", "RenderPipeline")) -def setup_mujoco_py(): - # Set up mujoco-py (doing it via pip caused problems on some machines) - sp.check_call([sys.executable, "setup.py", "install"], cwd=osp.join(project_dir, "thirdParty", "mujoco-py")) - def setup_pytorch_based(): # Locally build PyTorch>=1.7.0 requires dataclasses (does not harm when using pytorch from pip) @@ -675,13 +665,12 @@ def setup_wo_rcs_wo_pytorch(): print("\nStarting Option Red Velvet Setup\n") # Rcs will still be downloaded since it is a submodule setup_wam() # ignoring the meshes used in RcsPySim - setup_mujoco_py() if not CI: setup_pyrado() if not args.headless: setup_render_pipeline() setup_pytorch_based() - print("\nWAM meshes, mujoco-py, Pyrado (with GPyTorch, BoTorch, and Pyro using the --no-deps flag) are set up!\n") + print("\nWAM meshes, Pyrado (with GPyTorch, BoTorch, and Pyro using the --no-deps flag) are set up!\n") def setup_wo_rcs_w_pytorch(): @@ -689,14 +678,13 @@ def setup_wo_rcs_w_pytorch(): # Rcs will still be downloaded since it is a submodule setup_pytorch() setup_wam() # ignoring the meshes used in RcsPySim - setup_mujoco_py() if not CI: setup_pyrado() if not args.headless: setup_render_pipeline() setup_pytorch_based() print( - "\nPyTorch, WAM meshes, mujoco-py, Pyrado (with GPyTorch, BoTorch, and Pyro using the --no-deps flag) are " + "\nPyTorch, WAM meshes, Pyrado (with GPyTorch, BoTorch, and Pyro using the --no-deps flag) are " "set up!\n" ) @@ -712,14 +700,13 @@ def setup_w_rcs_wo_pytorch(): if not CI: setup_rcspysim() setup_meshes() - setup_mujoco_py() if not CI: setup_pyrado() if not args.headless: setup_render_pipeline() setup_pytorch_based() print( - "\nWM5, Rcs, RcsPySim, iiwa & Schunk & WAM meshes, mujoco-py, and Pyrado (with GPyTorch, BoTorch, and Pyro " + "\nWM5, Rcs, RcsPySim, iiwa & Schunk & WAM meshes and Pyrado (with GPyTorch, BoTorch, and Pyro " "using the --no-deps flag) are set up!\n" ) @@ -734,14 +721,13 @@ def setup_w_rcs_w_pytorch(): if not CI: setup_rcspysim() setup_meshes() - setup_mujoco_py() if not CI: setup_pyrado() if not args.headless: setup_render_pipeline() setup_pytorch_based() print( - "\nWM5, Rcs, PyTorch, RcsPySim, iiwa & Schunk & WAM meshes, mujoco-py, Pyrado (with GPyTorch, BoTorch, and " + "\nWM5, Rcs, PyTorch, RcsPySim, iiwa & Schunk & WAM meshes, Pyrado (with GPyTorch, BoTorch, and " "Pyro using the --no-deps flag) are set up!\n" ) From 00cd6d069151d2679a1e1e1a1994619ecee1e581 Mon Sep 17 00:00:00 2001 From: Heiko Carrasco Date: Sun, 22 Oct 2023 16:02:08 -0400 Subject: [PATCH 5/9] Switch to new mujoco package --- Pyrado/pyrado/environments/mujoco/__init__.py | 29 +--------- Pyrado/pyrado/environments/mujoco/base.py | 54 ++++++------------- .../pyrado/environments/mujoco/openai_ant.py | 13 +++-- .../mujoco/openai_half_cheetah.py | 11 ++-- .../environments/mujoco/openai_hopper.py | 9 ++-- .../environments/mujoco/openai_humanoid.py | 39 +++++++------- .../environments/mujoco/quanser_qube.py | 21 +++----- setup_deps.py | 7 +-- 8 files changed, 63 insertions(+), 120 deletions(-) diff --git a/Pyrado/pyrado/environments/mujoco/__init__.py b/Pyrado/pyrado/environments/mujoco/__init__.py index 1a9b6925814..94590e58b4d 100644 --- a/Pyrado/pyrado/environments/mujoco/__init__.py +++ b/Pyrado/pyrado/environments/mujoco/__init__.py @@ -26,35 +26,8 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -import os import pyrado -from pyrado.utils.input_output import print_cbt -try: - import mujoco_py -except (ImportError, Exception): - # The ImportError is raised if mujoco-py is simply not installed - # The Exception catches the case that you have everything installed properly but your IDE does not set the - # LD_LIBRARY_PATH correctly (happens for PyCharm & CLion). To check this, try to run your script from the terminal. - ld_library_path = os.environ.get("LD_LIBRARY_PATH") - ld_preload = os.environ.get("LD_PRELOAD") - print_cbt( - "You are trying to use are MuJoCo-based environment, but the required mujoco_py module can not be imported.\n" - "Try adding\n" - "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/$USER/.mujoco/mujoco200/bin\n" - "export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libGLEW.so\n" - "to your shell's rc-file.\n" - "The current values of the environment variables are:\n" - f"LD_LIBRARY_PATH={ld_library_path}\n" - f"LD_PRELOAD={ld_preload}" - "If you are using PyCharm or CLion, also add the environment variables above to your run configurations. " - "Note that the IDE will not resolve $USER for some reason, so enter the user name directly, " - "or run it from your terminal.\n\n" - "Here comes the mujoco-py error message:\n\n", - "r", - ) - pyrado.mujoco_loaded = False -else: - pyrado.mujoco_loaded = True +pyrado.mujoco_loaded = True diff --git a/Pyrado/pyrado/environments/mujoco/base.py b/Pyrado/pyrado/environments/mujoco/base.py index 6f19c2b9a3b..19e3b27df6e 100644 --- a/Pyrado/pyrado/environments/mujoco/base.py +++ b/Pyrado/pyrado/environments/mujoco/base.py @@ -31,10 +31,10 @@ from math import floor from typing import Optional -import mujoco_py +import mujoco +import mujoco.viewer import numpy as np from init_args_serializer import Serializable -from mujoco_py.generated.const import RND_FOG import pyrado from pyrado.environments.sim_base import SimEnv @@ -87,7 +87,7 @@ def __init__( xml_model_temp = file_raw.read() xml_model_temp = self._adapt_model_file(xml_model_temp, self.domain_param) # Create a dummy model to extract the solver's time step size - model_tmp = mujoco_py.load_model_from_xml(xml_model_temp) + model_tmp = mujoco.MjModel.from_xml_path(xml_model_temp) frame_skip = dt / model_tmp.opt.timestep if frame_skip.is_integer(): self.frame_skip = int(frame_skip) @@ -112,8 +112,8 @@ def __init__( super().__init__(dt=self.model.opt.timestep * self.frame_skip, max_steps=max_steps) # Memorize the initial states of the model from the xml (for fixed init space or later reset) - self.init_qpos = self.sim.data.qpos.copy() - self.init_qvel = self.sim.data.qvel.copy() + self.init_qpos = self.data.qpos.copy() + self.init_qvel = self.data.qvel.copy() # Initialize space (to be overwritten in constructor of subclasses) self._init_space = None @@ -177,13 +177,7 @@ def domain_param(self, domain_param: dict): # Update MuJoCo model self._create_mujoco_model() - if self.viewer is not None: - # If the viewer already exists and we reset the domain parameters, we must also recreate the viewer since - # it references to the simulation object which get's reconstructed during _create_mujoco_model() - import glfw - - glfw.destroy_window(self.viewer.window) - self.viewer = None + self.viewer = None # Update task self._task = self._create_task(self.task_args) @@ -202,7 +196,7 @@ def _adapt_model_file(self, xml_model: str, domain_param: dict) -> str: :return: adapted model file where the placeholders are filled with numerical values """ # The mesh dir is not resolved when later passed as a string, thus we do it manually - xml_model = xml_model.replace(f"[ASSETS_DIR]", pyrado.MUJOCO_ASSETS_DIR) + xml_model = xml_model.replace("[ASSETS_DIR]", pyrado.MUJOCO_ASSETS_DIR) # Replace all occurrences of the domain parameter placeholder with its value for key, value in domain_param.items(): @@ -230,14 +224,14 @@ def _create_mujoco_model(self): xml_model = self._adapt_model_file(xml_model, self.domain_param) # Create MuJoCo model from parsed XML file - self.model = mujoco_py.load_model_from_xml(xml_model) - self.sim = mujoco_py.MjSim(self.model, nsubsteps=self.frame_skip) + self.model = mujoco.MjModel.from_xml_string(xml_model) + self.data = mujoco.MjData(self.model) def configure_viewer(self): """Configure the camera when the viewer is initialized. You need to set `self.camera_config` before.""" # Render a fog around the scene by default if self.camera_config.pop("render_fog", True): - self.viewer.scn.flags[RND_FOG] = 1 + self.viewer.scn.flags[mujoco.mjtRndFlag.mjRND_FOG] = 1 # Parse all other options for key, value in self.camera_config.items(): @@ -274,8 +268,8 @@ def reset(self, init_state: np.ndarray = None, domain_param: dict = None) -> np. self._task.reset(env_spec=self.spec, init_state=init_state.copy()) # Reset MuJoCo simulation model (only reset the joint configuration) - self.sim.reset() - old_state = self.sim.get_state() + mujoco.mj_resetData(self.model, self.data) + old_state = self.data nq = self.model.nq nv = self.model.nv if not init_state[:nq].shape == old_state.qpos.shape: # check joint positions dimension @@ -283,16 +277,9 @@ def reset(self, init_state: np.ndarray = None, domain_param: dict = None) -> np. # Exclude everything that is appended to the state (at the end), e.g. the ball position for WAMBallInCupSim if not init_state[nq : nq + nv].shape == old_state.qvel.shape: # check joint velocities dimension raise pyrado.ShapeErr(given=init_state[nq : nq + nv], expected_match=old_state.qvel) - new_state = mujoco_py.MjSimState( - # Exclude everything that is appended to the state (at the end), e.g. the ball position for WAMBallInCupSim - old_state.time, - init_state[:nq], - init_state[nq : nq + nv], - old_state.act, - old_state.udd_state, - ) - self.sim.set_state(new_state) - self.sim.forward() + self.data.qpos[:] = np.copy(init_state[:nq]) + self.data.qvel[:] = np.copy(init_state[nq : nq + nv]) + mujoco.mj_forward(self.model, self.data) # Return an observation return self.observe(self.state) @@ -342,14 +329,7 @@ def render(self, mode: RenderMode = RenderMode(), render_step: int = 1): if mode.video: if self.viewer is None: # Create viewer if not existent (see 'human' mode of OpenAI Gym's MujocoEnv) - self.viewer = mujoco_py.MjViewer(self.sim) - - # Adjust window size and position to custom values - import glfw - - glfw.make_context_current(self.viewer.window) - glfw.set_window_size(self.viewer.window, 1280, 720) - glfw.set_window_pos(self.viewer.window, 50, 50) + self.viewer = mujoco.viewer.launch_passive(self.model, self.data) self.configure_viewer() - self.viewer.render() + self.viewer.sync() diff --git a/Pyrado/pyrado/environments/mujoco/openai_ant.py b/Pyrado/pyrado/environments/mujoco/openai_ant.py index d78dbc2d765..862948ecc42 100644 --- a/Pyrado/pyrado/environments/mujoco/openai_ant.py +++ b/Pyrado/pyrado/environments/mujoco/openai_ant.py @@ -29,6 +29,7 @@ import os.path as osp from typing import Optional +import mujoco import numpy as np from init_args_serializer import Serializable @@ -98,9 +99,7 @@ def __init__( @property def state_space(self) -> Space: - state_shape = np.concatenate( - [self.sim.data.qpos.flat, self.sim.data.qvel.flat, self.sim.data.cfrc_ext.flat] - ).shape + state_shape = np.concatenate([self.data.qpos.flat, self.data.qvel.flat, self.data.cfrc_ext.flat]).shape return BoxSpace(-pyrado.inf, pyrado.inf, shape=state_shape) @property @@ -148,11 +147,11 @@ def contact_forces(self): return contact_forces def _mujoco_step(self, act: np.ndarray) -> dict: - self.sim.data.ctrl[:] = act - self.sim.step() + self.data.ctrl[:] = act + mujoco.mj_step(self.model, self.data) - pos = self.sim.data.qpos.flat.copy() - vel = self.sim.data.qvel.flat.copy() + pos = self.data.qpos.flat.copy() + vel = self.data.qvel.flat.copy() cfrc_ext = self.contact_forces.flat.copy() self.state = np.concatenate([pos, vel, cfrc_ext]) diff --git a/Pyrado/pyrado/environments/mujoco/openai_half_cheetah.py b/Pyrado/pyrado/environments/mujoco/openai_half_cheetah.py index f72288a1068..dafceef2a33 100644 --- a/Pyrado/pyrado/environments/mujoco/openai_half_cheetah.py +++ b/Pyrado/pyrado/environments/mujoco/openai_half_cheetah.py @@ -31,6 +31,7 @@ import numpy as np from init_args_serializer import Serializable +import mujoco import pyrado from pyrado.environments.mujoco.base import MujocoSimEnv @@ -91,7 +92,7 @@ def __init__( @property def state_space(self) -> Space: - state_shape = np.concatenate([self.sim.data.qpos, self.sim.data.qvel]).shape + state_shape = np.concatenate([self.data.qpos, self.data.qvel]).shape return BoxSpace(-pyrado.inf, pyrado.inf, shape=state_shape) @property @@ -123,11 +124,11 @@ def _create_task(self, task_args: dict) -> Task: return GoallessTask(self.spec, ForwardVelocityRewFcn(self._dt, idx_fwd=0, **task_args)) def _mujoco_step(self, act: np.ndarray) -> dict: - self.sim.data.ctrl[:] = act - self.sim.step() + self.data.ctrl[:] = act + mujoco.mj_step(self.model, self.data) - pos = self.sim.data.qpos.copy() - vel = self.sim.data.qvel.copy() + pos = self.data.qpos.copy() + vel = self.data.qvel.copy() self.state = np.concatenate([pos, vel]) return dict() diff --git a/Pyrado/pyrado/environments/mujoco/openai_hopper.py b/Pyrado/pyrado/environments/mujoco/openai_hopper.py index 57be4b61624..c1dd9e0b859 100644 --- a/Pyrado/pyrado/environments/mujoco/openai_hopper.py +++ b/Pyrado/pyrado/environments/mujoco/openai_hopper.py @@ -29,6 +29,7 @@ import os.path as osp from typing import Optional +import mujoco import numpy as np from init_args_serializer import Serializable @@ -141,11 +142,11 @@ def _create_task(self, task_args: dict) -> Task: return GoallessTask(self.spec, rew_fcn) def _mujoco_step(self, act: np.ndarray) -> dict: - self.sim.data.ctrl[:] = act - self.sim.step() + self.data.ctrl[:] = act + mujoco.mj_step(self.model, self.data) - pos = self.sim.data.qpos.copy() - vel = self.sim.data.qvel.copy() + pos = self.data.qpos.copy() + vel = self.data.qvel.copy() self.state = np.concatenate([pos, vel]) return dict() diff --git a/Pyrado/pyrado/environments/mujoco/openai_humanoid.py b/Pyrado/pyrado/environments/mujoco/openai_humanoid.py index 4de37cdc86f..7b56f64c1b5 100644 --- a/Pyrado/pyrado/environments/mujoco/openai_humanoid.py +++ b/Pyrado/pyrado/environments/mujoco/openai_humanoid.py @@ -29,6 +29,7 @@ import os.path as osp from typing import Optional +import mujoco import numpy as np from init_args_serializer import Serializable @@ -84,10 +85,10 @@ def __init__( rest_shape = np.concatenate( [ - self.sim.data.cinert.flat, - self.sim.data.cvel.flat, - self.sim.data.qfrc_actuator.flat, - self.sim.data.cfrc_ext.flat, + self.data.cinert.flat, + self.data.cvel.flat, + self.data.qfrc_actuator.flat, + self.data.cfrc_ext.flat, ] ).shape min_init_rest = -np.ones(rest_shape) @@ -102,12 +103,12 @@ def __init__( def state_space(self) -> Space: state_shape = np.concatenate( [ - self.sim.data.qpos.flat, - self.sim.data.qvel.flat, - self.sim.data.cinert.flat, - self.sim.data.cvel.flat, - self.sim.data.qfrc_actuator.flat, - self.sim.data.cfrc_ext.flat, + self.data.qpos.flat, + self.data.qvel.flat, + self.data.cinert.flat, + self.data.cvel.flat, + self.data.qfrc_actuator.flat, + self.data.cfrc_ext.flat, ] ).shape return BoxSpace(-pyrado.inf, pyrado.inf, shape=state_shape) @@ -162,15 +163,15 @@ def _create_task(self, task_args: dict) -> Task: return GoallessTask(self.spec, ForwardVelocityRewFcnHumanoid(self._dt, **task_args)) def _mujoco_step(self, act: np.ndarray) -> dict: - self.sim.data.ctrl[:] = act - self.sim.step() - - position = self.sim.data.qpos.flat.copy() - velocity = self.sim.data.qvel.flat.copy() - com_inertia = self.sim.data.cinert.flat.copy() - com_velocity = self.sim.data.cvel.flat.copy() - actuator_forces = self.sim.data.qfrc_actuator.flat.copy() - external_contact_forces = self.sim.data.cfrc_ext.flat.copy() + self.data.ctrl[:] = act + mujoco.mj_step(self.model, self.data) + + position = self.data.qpos.flat.copy() + velocity = self.data.qvel.flat.copy() + com_inertia = self.data.cinert.flat.copy() + com_velocity = self.data.cvel.flat.copy() + actuator_forces = self.data.qfrc_actuator.flat.copy() + external_contact_forces = self.data.cfrc_ext.flat.copy() self.state = np.concatenate( [ diff --git a/Pyrado/pyrado/environments/mujoco/quanser_qube.py b/Pyrado/pyrado/environments/mujoco/quanser_qube.py index a609f763555..20e136fb33e 100644 --- a/Pyrado/pyrado/environments/mujoco/quanser_qube.py +++ b/Pyrado/pyrado/environments/mujoco/quanser_qube.py @@ -30,9 +30,8 @@ from abc import abstractmethod from typing import Optional -import mujoco_py +import mujoco import numpy as np -import torch as to from init_args_serializer import Serializable import pyrado @@ -122,19 +121,13 @@ def _mujoco_step(self, act: np.ndarray) -> dict: ) # act is a scalar array, causing warning on later np.array construction # Apply the torques to the robot - self.sim.data.ctrl[:] = torque + self.data.ctrl[:] = torque # Call MuJoCo - try: - self.sim.step() - mjsim_crashed = False - except mujoco_py.builder.MujocoException: - # When MuJoCo recognized instabilities in the simulation, it simply kills it. - # Instead, we want the episode to end with a failure. - mjsim_crashed = True - - qpos = self.sim.data.qpos.copy() - qvel = self.sim.data.qvel.copy() + mujoco.mj_step(self.model, self.data) + + qpos = self.data.qpos.copy() + qvel = self.data.qvel.copy() self.state = np.concatenate([qpos, qvel]) # If state is out of bounds (this is normally checked by the task, but does not work because of the mask) @@ -143,7 +136,7 @@ def _mujoco_step(self, act: np.ndarray) -> dict: return dict( qpos=qpos, qvel=qvel, - failed=mjsim_crashed or state_oob, + failed=state_oob, ) def observe(self, state: np.ndarray) -> np.ndarray: diff --git a/setup_deps.py b/setup_deps.py index 0f0ca2b505e..344ae2ddc0e 100644 --- a/setup_deps.py +++ b/setup_deps.py @@ -41,7 +41,6 @@ from urllib.request import urlretrieve - # Get the project's root directory project_dir = osp.dirname(osp.abspath(__file__)) @@ -547,7 +546,6 @@ def setup_render_pipeline(): sp.check_call([sys.executable, "setup.py"], cwd=osp.join(project_dir, "thirdParty", "RenderPipeline")) - def setup_pytorch_based(): # Locally build PyTorch>=1.7.0 requires dataclasses (does not harm when using pytorch from pip) sp.check_call([sys.executable, "-m", "pip", "install", "-U", "--no-deps", "dataclasses"]) @@ -683,10 +681,7 @@ def setup_wo_rcs_w_pytorch(): if not args.headless: setup_render_pipeline() setup_pytorch_based() - print( - "\nPyTorch, WAM meshes, Pyrado (with GPyTorch, BoTorch, and Pyro using the --no-deps flag) are " - "set up!\n" - ) + print("\nPyTorch, WAM meshes, Pyrado (with GPyTorch, BoTorch, and Pyro using the --no-deps flag) are " "set up!\n") def setup_w_rcs_wo_pytorch(): From 9b48aa8001927d0a4b81b9565df77d3cf5b9cff2 Mon Sep 17 00:00:00 2001 From: Heiko Carrasco Date: Sun, 22 Oct 2023 16:07:43 -0400 Subject: [PATCH 6/9] Remove mujoco submodule --- .gitmodules | 3 --- thirdParty/mujoco-py | 1 - 2 files changed, 4 deletions(-) delete mode 160000 thirdParty/mujoco-py diff --git a/.gitmodules b/.gitmodules index 5b7a8e3399a..fb5900aea92 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,9 +10,6 @@ [submodule "thirdParty/catch2"] path = thirdParty/catch2 url = https://github.com/catchorg/Catch2.git -[submodule "thirdParty/mujoco-py"] - path = thirdParty/mujoco-py - url = https://github.com/openai/mujoco-py.git [submodule "thirdParty/RenderPipeline"] path = thirdParty/RenderPipeline url = https://github.com/famura/RenderPipeline.git diff --git a/thirdParty/mujoco-py b/thirdParty/mujoco-py deleted file mode 160000 index d73ce6e91d0..00000000000 --- a/thirdParty/mujoco-py +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d73ce6e91d096b74da2a2fcb0a4164e10db5f641 From 4fcfaa706edea263db56565129cf6ead9710d100 Mon Sep 17 00:00:00 2001 From: Heiko Carrasco Date: Sun, 22 Oct 2023 16:26:33 -0400 Subject: [PATCH 7/9] Update pre-commit hooks to latest version --- .github/.pre-commit-config.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/.pre-commit-config.yaml b/.github/.pre-commit-config.yaml index 87d2bc0b8cd..c8fea89bcd7 100644 --- a/.github/.pre-commit-config.yaml +++ b/.github/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pycqa/isort - rev: 5.8.0 + rev: 5.12.0 hooks: - id: isort name: isort (python) @@ -11,7 +11,6 @@ repos: name: isort (pyi) types: [pyi] - repo: https://github.com/psf/black - rev: 20.8b1 + rev: 23.10.0 hooks: - id: black - language_version: python3.7 From f5022d4d32188d5cf8835af3826d378212f5e993 Mon Sep 17 00:00:00 2001 From: Heiko Carrasco Date: Sun, 22 Oct 2023 16:27:16 -0400 Subject: [PATCH 8/9] Apply isort to half_cheetah --- Pyrado/pyrado/environments/mujoco/openai_half_cheetah.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pyrado/pyrado/environments/mujoco/openai_half_cheetah.py b/Pyrado/pyrado/environments/mujoco/openai_half_cheetah.py index dafceef2a33..088698c8fc1 100644 --- a/Pyrado/pyrado/environments/mujoco/openai_half_cheetah.py +++ b/Pyrado/pyrado/environments/mujoco/openai_half_cheetah.py @@ -29,9 +29,9 @@ import os.path as osp from typing import Optional +import mujoco import numpy as np from init_args_serializer import Serializable -import mujoco import pyrado from pyrado.environments.mujoco.base import MujocoSimEnv From 08ef8c8074f03a91a1c2e7b13050eaae3d7c9da9 Mon Sep 17 00:00:00 2001 From: Heiko Carrasco Date: Thu, 26 Oct 2023 23:53:57 -0400 Subject: [PATCH 9/9] Remove unnecessary subfolder length call --- setup_deps.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup_deps.py b/setup_deps.py index 344ae2ddc0e..56076d4fc18 100644 --- a/setup_deps.py +++ b/setup_deps.py @@ -285,7 +285,6 @@ def downloadAndExtract(url, destdir, archiveContentPath=None): # Taken from https://stackoverflow.com/a/43094365 def members(ml): subfolder = osp.normpath(archiveContentPath) - len(subfolder) for member in ml: # Skip directories in zip isdir = getattr(member, "is_dir", None)