diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 000000000..654b6dd58
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,22 @@
+name: build
+on: [pull_request, push]
+
+permissions:
+ contents: read # to fetch code (actions/checkout)
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ python-version: ['3.8', '3.9', '3.10', '3.11']
+ steps:
+ - uses: actions/checkout@v3
+ - run: |
+ docker build -f docker/Dockerfile \
+ --build-arg PYTHON_VERSION=${{ matrix.python-version }} \
+ --tag metaworld-docker .
+ - name: Run tests
+ run: docker run metaworld-docker pytest tests/*
+# - name: Run doctests
+# run: docker run metaworld-docker pytest --doctest-modules metaworld/
diff --git a/.github/workflows/metaworld-ci.yml b/.github/workflows/metaworld-ci.yml
deleted file mode 100644
index 5eca156d0..000000000
--- a/.github/workflows/metaworld-ci.yml
+++ /dev/null
@@ -1,39 +0,0 @@
-# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
-# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
-
-name: MetaWorld CI
-
-on:
- push:
- branches: [ master ]
- pull_request:
- branches: [ master ]
-
-env:
- MJKEY: ${{ secrets.MJKEY }}
-
-jobs:
- test-docker:
-
- runs-on: ubuntu-latest
-
- steps:
- - uses: actions/checkout@v2
- - name: Build the Docker image
- run: |
- docker pull rlworkgroup/metaworld-ci:latest
- docker build \
- --cache-from rlworkgroup/metaworld-ci:latest \
- -f docker/Dockerfile \
- -t "rlworkgroup/metaworld-ci:$GITHUB_RUN_ID" \
- .
-
- - name: Run the Docker image
- run: |
- docker run \
- -t \
- --rm \
- -e "MJKEY=$MJKEY" \
- --memory 7000m \
- --memory-swap 7000m \
- --name metaworld-ci rlworkgroup/metaworld-ci:$GITHUB_RUN_ID pytest -n 0 -v -m 'not large and not skip_on_ci'
diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml
index 26515d79f..9060a3791 100644
--- a/.github/workflows/pre-commit.yml
+++ b/.github/workflows/pre-commit.yml
@@ -1,6 +1,5 @@
# https://pre-commit.com
# This GitHub Action assumes that the repo contains a valid .pre-commit-config.yaml file.
----
name: pre-commit
on:
pull_request:
@@ -8,15 +7,15 @@ on:
branches: [master]
permissions:
- contents: read
+ contents: read # to fetch code (actions/checkout)
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- - uses: actions/setup-python@v3
- - run: pip install pre-commit
- - run: pre-commit --version
- - run: pre-commit install
- - run: pre-commit run --all-files
+ - uses: actions/setup-python@v4
+ - run: python -m pip install pre-commit
+ - run: python -m pre_commit --version
+ - run: python -m pre_commit install
+ - run: python -m pre_commit run --all-files
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 24dc7fc60..87496fce6 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,52 +1,60 @@
----
+# See https://pre-commit.com for more information
+# See https://pre-commit.com/hooks.html for more hooks
repos:
- - repo: https://github.com/python/black
- rev: 23.3.0
+ - repo: https://github.com/pre-commit/pre-commit-hooks
+ rev: v4.4.0
hooks:
- - id: black
+ - id: check-symlinks
+ - id: destroyed-symlinks
+ - id: trailing-whitespace
+ - id: end-of-file-fixer
+ - id: check-yaml
+ - id: check-toml
+ - id: check-ast
+ - id: check-added-large-files
+ - id: check-merge-conflict
+ - id: check-executables-have-shebangs
+ - id: check-shebang-scripts-are-executable
+ - id: detect-private-key
+ - id: debug-statements
- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
hooks:
- id: codespell
- args:
- - --skip=*.css,*.js,*.map,*.scss,*.svg,*.ipynb
- - --ignore-words-list=magent
+ exclude: metaworld/envs/assets_updated/sawyer_xyz/dm_control_pick_place.ipynb
+# args:
+# - --ignore-words-list==
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
args:
- '--per-file-ignores=*/__init__.py:F401'
- - --extend-ignore=E203,W605,F841,E731,E741,F401 # TODO: fix some of these
- - --max-complexity=205
- - --max-line-length=300
+ - --ignore=E203,W503,E741
+ - --max-complexity=30
+ - --max-line-length=456
- --show-source
- --statistics
- - repo: https://github.com/PyCQA/isort
- rev: 5.12.0
- hooks:
- - id: isort
- args: ["--profile", "black"]
- repo: https://github.com/asottile/pyupgrade
- rev: v3.3.1
+ rev: v3.3.2
hooks:
- id: pyupgrade
- args: ["--py37-plus"]
- - repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v4.4.0
+ args: ["--py38-plus"]
+ - repo: https://github.com/PyCQA/isort
+ rev: 5.12.0
hooks:
- - id: mixed-line-ending
- args: ["--fix=lf"]
- - repo: https://github.com/pycqa/pydocstyle
- rev: 6.3.0
+ - id: isort
+ - repo: https://github.com/python/black
+ rev: 23.3.0
hooks:
- - id: pydocstyle
- args:
- - --source
- - --explain
- - --convention=google
- - --count
- # TODO: Remove ignoring rules D101, D102, D103, D105
- - --add-ignore=D100,D107,D101,D102,D103,D105
- exclude: "__init__.py$|^metaworld.tests|^docs"
- additional_dependencies: ["tomli"]
+ - id: black
+# - repo: https://github.com/pycqa/pydocstyle
+# rev: 6.3.0
+# hooks:
+# - id: pydocstyle
+# exclude: ^
+# args:
+# - --source
+# - --explain
+# - --convention=google
+# additional_dependencies: ["tomli"]
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 1c113d79b..751148e75 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -7,12 +7,12 @@ We particularly welcome contributions of additional tasks that thematically fit
### Checklist for adding new tasks
Ensure that your task and pull request:
-* [ ] Can be performed by a real robot arm
+* [ ] Can be performed by a real robot arm
* [ ] Is dissimilar from current tasks
* [ ] Contains meaningful internal variation (e.g. different object positions, etc.)
* [ ] Conforms to the action space, observation space, and reward functions conventions used by metaworld environments
* [ ] Uses existing assets if they exist, and that any new assets added are high-quality
-* [ ] Follows the code qualtiy, style, testing, and documentation guidelines outlined below
+* [ ] Follows the code quality, style, testing, and documentation guidelines outlined below
* [ ] Provides learning curves which show the task can by solved by PPO and SAC, using the implementations linked below
PPO: https://github.com/rlworkgroup/garage/blob/master/src/garage/tf/algos/ppo.py
@@ -35,7 +35,7 @@ These criteria may be satisfied in any order, but in practice your PR is unlikel
## Preparing your repo to make contributions
First, install the Metaworld locally in editable mode, with testing dependencies:
-```
+```
pip install -e .[dev]
```
@@ -68,7 +68,7 @@ These are Meta-World specific rules which are not part of the aforementioned sty
* Add convenience imports in `__init__.py` of a package for shallow first-level repetitive imports, but not for subpackages, even if that subpackage is defined in a single `.py` file.
- For instance, if an import line reads `from
+ For instance, if an import line reads `from
.foo.bar import Bar` then you should add `from metaworld.foo.bar import Bar` to `metaworld/foo/__init__.py` so that users may instead write `from metaworld.foo import Bar`. However, if an import line reads `from metaworld.foo.bar.stuff import Baz`, *do not* add `from metaworld.foo.bar.stuff import Baz` to `metaworld/foo/__init__.py`, because that obscures the `stuff` subpackage.
*Do*
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 70800f13e..000000000
--- a/Makefile
+++ /dev/null
@@ -1,69 +0,0 @@
-SHELL := /bin/bash
-
-.PHONY: help test ci-job build-ci build-headlessrun-ci run-headless
-
-.DEFAULT_GOAL := help
-
-test: ## Run the CI test suite locally
-test: RUN_CMD = pytest -v
-test: run
- @echo "Running test suite..."
-
-check-memory: ## Profile memory usage
-check-memory: RUN_CMD = scripts/profile_memory_usage.py
-check-memory: run
- @echo "Profiling memory usage..."
-
-ci-job:
- pytest -n 0 --cov=metaworld -v -m 'not large and not skip_on_ci'
- coverage xml
- # bash <(curl -s https://codecov.io/bash)
-
-ci-deploy-docker:
- echo "${DOCKER_API_KEY}" | docker login -u "${DOCKER_USERNAME}" \
- --password-stdin
- docker tag "${TAG}" rlworkgroup/metaworld-ci:latest
- docker push rlworkgroup/metaworld-ci
-
-build-ci: TAG ?= rlworkgroup/metaworld-ci:latest
-build-ci: docker/Dockerfile
- TAG=${TAG} \
- docker build \
- --cache-from rlworkgroup/metaworld-ci:latest \
- -f docker/Dockerfile \
- -t ${TAG} \
- ${ADD_ARGS} \
- .
-
-run-ci: TAG ?= rlworkgroup/metaworld-ci
-run-ci:
- docker run \
- -e TRAVIS_BRANCH \
- -e TRAVIS_PULL_REQUEST \
- -e TRAVIS_COMMIT_RANGE \
- -e TRAVIS \
- -e MJKEY \
- --memory 7500m \
- --memory-swap 7500m \
- ${ADD_ARGS} \
- ${TAG} ${RUN_CMD}
-
-run: ## Run the Docker container on a local machine
-run: CONTAINER_NAME ?= metaworld-ci
-run: build-ci
- docker run \
- -it \
- --rm \
- --memory 7500m \
- --memory-swap 7500m \
- --name $(CONTAINER_NAME) \
- ${ADD_ARGS} \
- rlworkgroup/metaworld-ci $(RUN_CMD)
-
-# Help target
-# See https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
-help: ## Display this message
-help:
- @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
- | sort \
- | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
diff --git a/README.md b/README.md
index a9d79f66f..def96912a 100644
--- a/README.md
+++ b/README.md
@@ -40,7 +40,7 @@ cd metaworld
pip install -e .
```
-For users attempting to reproduce results found in the Meta-World paper please use this command:
+For users attempting to reproduce results found in the Meta-World paper please use this command:
```
pip install git+https://github.com/Farama-Foundation/Metaworld.git@04be337a12305e393c0caf0cbf5ec7755c7c8feb
```
@@ -174,7 +174,7 @@ env2.reset()
a1 = env1.action_space.sample() # Sample an action
a2 = env2.action_space.sample()
next_obs1, _, _, _ = env1.step(a1) # Step the environoment with the sampled random action
-next_obs2, _, _, _ = env2.step(a2)
+next_obs2, _, _, _ = env2.step(a2)
assert (next_obs1[-3:] == next_obs2[-3:]).all() # 2 envs initialized with the same seed will have the same goal
assert not (next_obs2[-3:] == np.zeros(3)).all() # The env's are goal observable, meaning the goal is not zero'd out
@@ -184,7 +184,7 @@ env3.reset()
a1 = env1.action_space.sample() # Sample an action
a3 = env3.action_space.sample()
next_obs1, _, _, _ = env1.step(a1) # Step the environoment with the sampled random action
-next_obs3, _, _, _ = env3.step(a3)
+next_obs3, _, _, _ = env3.step(a3)
assert not (next_obs1[-3:] == next_obs3[-3:]).all() # 2 envs initialized with different seeds will have different goals
assert not (next_obs1[-3:] == np.zeros(3)).all() # The env's are goal observable, meaning the goal is not zero'd out
@@ -208,7 +208,7 @@ If you use Meta-World for academic research, please kindly cite our CoRL 2019 pa
```
## Accompanying Baselines
-If you're looking for implementations of the baselines algorithms used in the Metaworld conference publication, please look at our sister directory, [Garage](https://github.com/rlworkgroup/garage).
+If you're looking for implementations of the baselines algorithms used in the Metaworld conference publication, please look at our sister directory, [Garage](https://github.com/rlworkgroup/garage).
Note that these aren't the exact same baselines that were used in the original conference publication, however they are true to the original baselines.
## Become a Contributor
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 70033068d..ab22e9185 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -1,65 +1,32 @@
-ARG PARENT_IMAGE=ubuntu:20.04
-FROM $PARENT_IMAGE
-
-# apt dependencies
-RUN \
- apt-get -y -q update && \
- # Prevents debconf from prompting for user input
- # See https://github.com/phusion/baseimage-docker/issues/58
- DEBIAN_FRONTEND=noninteractive apt-get install -y \
- # Dockerfile deps
- git \
- curl \
- python3 \
- python3-venv \
- python3-dev \
- # mujoco_py
- # See https://github.com/openai/mujoco-py/blob/master/Dockerfile
- libglew-dev \
- libosmesa6-dev \
- patchelf \
- # OpenAI baselines
- libopenmpi-dev \
- # virtualenv
- libbz2-dev \
- libreadline-dev \
- libssl-dev \
- libsqlite3-dev \
- xvfb \
- pulseaudio && \
- apt-get clean && \
- rm -rf /var/lib/apt/lists/* && \
- mkdir -p -m 1777 /tmp/.X11-unix
-
-ARG user=metaworld-user
-ARG uid=999
-RUN groupadd -g $uid $user && \
- useradd -m -r -u $uid -g $user $user && \
- chown -R $user:$user /home/$user
-ENV USER $user
-USER $user
-ENV HOME /home/$user
-WORKDIR $HOME
-
-RUN mkdir -p $HOME/.mujoco && \
- curl -O https://mujoco.org/download/mujoco210-linux-x86_64.tar.gz && \
- tar xf mujoco210-linux-x86_64.tar.gz --directory $HOME/.mujoco
-
-ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:$HOME/.mujoco/mujoco210/bin
-
-RUN python3 -m venv $HOME/venv
-
-# Copy setup.py/config.cfg/pyproject.toml first, so that the Docker cache doesn't expire until
-# dependencies change
-COPY --chown=$USER:$USER setup.py $HOME/code/metaworld/setup.py
-COPY --chown=$USER:$USER pyproject.toml $HOME/code/metaworld/pyproject.toml
-
-WORKDIR $HOME/code/metaworld
-
-# Install metaworld dependencies
-RUN . $HOME/venv/bin/activate && exec pip install -e .[testing]
-
-# Add code stub last
-COPY --chown=$USER:$USER . $HOME/code/metaworld
-
-ENTRYPOINT ["docker/entrypoint-headless.sh"]
+# A Dockerfile that sets up a full Gymnasium install with test dependencies
+ARG PYTHON_VERSION
+FROM python:$PYTHON_VERSION
+
+SHELL ["/bin/bash", "-o", "pipefail", "-c"]
+
+RUN apt-get -y update \
+ && apt-get install --no-install-recommends -y \
+ libglu1-mesa-dev libgl1-mesa-dev libosmesa6-dev \
+ xvfb unzip patchelf ffmpeg cmake swig \
+ && apt-get autoremove -y \
+ && apt-get clean \
+ && rm -rf /var/lib/apt/lists/* \
+ # Download mujoco
+ && mkdir /root/.mujoco \
+ && cd /root/.mujoco \
+ && wget -qO- 'https://github.com/deepmind/mujoco/releases/download/2.1.0/mujoco210-linux-x86_64.tar.gz' | tar -xzvf -
+
+ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/root/.mujoco/mujoco210/bin"
+
+# Build mujoco-py from source. Pypi installs wheel packages and Cython won't recompile old file versions in the Github Actions CI.
+# Thus generating the following error https://github.com/cython/cython/pull/4428
+RUN git clone https://github.com/openai/mujoco-py.git\
+ && cd mujoco-py \
+ && pip install -e .
+
+COPY . /usr/local/metaworld/
+WORKDIR /usr/local/metaworld/
+
+RUN pip install .[testing]
+
+ENTRYPOINT ["/usr/local/metaworld/docker/entrypoint"]
diff --git a/docker/entrypoint b/docker/entrypoint
new file mode 100755
index 000000000..a5fe2c9f0
--- /dev/null
+++ b/docker/entrypoint
@@ -0,0 +1,26 @@
+#!/bin/bash
+# This script is the entrypoint for our Docker image.
+
+set -ex
+
+# Set up display; otherwise rendering will fail
+Xvfb -screen 0 1024x768x24 &
+export DISPLAY=:0
+
+# Wait for the file to come up
+display=0
+file="/tmp/.X11-unix/X$display"
+for i in $(seq 1 10); do
+ if [ -e "$file" ]; then
+ break
+ fi
+
+ echo "Waiting for $file to be created (try $i/10)"
+ sleep "$i"
+done
+if ! [ -e "$file" ]; then
+ echo "Timing out: $file was not created"
+ exit 1
+fi
+
+exec "$@"
diff --git a/docker/entrypoint-headless.sh b/docker/entrypoint-headless.sh
deleted file mode 100755
index b2b6c15bc..000000000
--- a/docker/entrypoint-headless.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/env bash
-# Dockerfile entrypoint
-set -e
-
-# Setup dummy X server display
-# Socket for display :0 may already be in use if the container is connected
-# to the network of the host, and other low-numbered socket could also be in
-# use, that's why we use 100.
-display_num=100
-export DISPLAY=:"${display_num}"
-Xvfb "${DISPLAY}" -screen 0 1024x768x24 &
-pulseaudio -D --exit-idle-time=-1
-
-# Wait for X to come up
-file="/tmp/.X11-unix/X${display_num}"
-for i in $(seq 1 10); do
- if [ -e "$file" ]; then
- break
- fi
- echo "Waiting for X to start (i.e. $file to be created) (attempt $i/10)"
- sleep "$i"
-done
-if ! [ -e "$file" ]; then
- echo "Timed out waiting for X to start: $file was not created"
- exit 1
-fi
-
-. $HOME/venv/bin/activate && exec "$@"
diff --git a/metaworld/envs/assets_v1/classic_mujoco/half_cheetah.xml b/metaworld/envs/assets_v1/classic_mujoco/half_cheetah.xml
index 950cd7a3f..29a6b58d6 100644
--- a/metaworld/envs/assets_v1/classic_mujoco/half_cheetah.xml
+++ b/metaworld/envs/assets_v1/classic_mujoco/half_cheetah.xml
@@ -90,4 +90,4 @@