From 7a0f446406beafbe3623a87ed34cd3d608fac617 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Thu, 12 Oct 2023 12:34:37 +0200 Subject: [PATCH 01/44] Switching to pyproject.toml; setup.py will remain for backwards compat --- pyproject.toml | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++ setup.py | 3 +++ 2 files changed, 71 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..053c1b8 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,68 @@ +[project] +name = "fancy_gym" +version = "1.0" +description = "Fancy Gym: Unifying interface for various RL benchmarks with support for Black Box approaches." +readme = "README.md" +authors = [ + {name = "Fabian Otto", email = "fabian.otto@uni-tuebingen.de"}, + {name = "Onur Celik", email = "celik@kit.edu"}, + {name = "Dominik Roth", email = "fancy_gym@dominik-roth.eu"}, + {name = "Hongyi Zhou", email = "hongyi.zhou@kit.edu"} +] +license = "MIT" +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: MIT License", + "Natural Language :: English", + "Operating System :: OS Independent", + "Topic :: Scientific/Engineering :: Artificial Intelligence", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11" +] +homepage = "https://github.com/ALRhub/fancy_gym/" +repository = "https://github.com/ALRhub/fancy_gym/" + +[project.urls] +Homepage = "https://github.com/ALRhub/fancy_gym/" + +[build-system] +requires = ["setuptools>=51.0.0", "wheel"] +build-backend = "setuptools.build_meta" + +[project.scripts] +# If you have any entry points (scripts), define them here. + +[project.dependencies] +gymnasium = ">=0.26.0" +mp_pytorch = "<=0.1.3" + +[project.optional-dependencies] +dmc = ["shimmy[dm-control]", "Shimmy==1.0.0"] +metaworld = ["metaworld @ git+https://github.com/Farama-Foundation/Metaworld.git@d155d0051630bb365ea6a824e02c66c068947439#egg=metaworld"] +box2d = ["gymnasium[box2d]>=0.26.0"] +mujoco = ["mujoco==2.3.3", "gymnasium[mujoco]>0.26.0"] +mujoco-legacy = ["mujoco-py>=2.1,<2.2", "cython<3"] +jax = ["jax>=0.4.0", "jaxlib>=0.4.0"] + +testing = [ + "pytest", + # include all the optional dependencies as well + "shimmy[dm-control]", + "Shimmy==1.0.0", + "metaworld @ git+https://github.com/Farama-Foundation/Metaworld.git@d155d0051630bb365ea6a824e02c66c068947439#egg=metaworld", + "gymnasium[box2d]>=0.26.0", + "mujoco==2.3.3", + "gymnasium[mujoco]>0.26.0", + "mujoco-py>=2.1,<2.2", + "cython<3", + "jax>=0.4.0", + "jaxlib>=0.4.0" +] + +[project.python-requires] +python_version = ">=3.7" diff --git a/setup.py b/setup.py index 1daa568..24dda38 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,5 @@ +# We still provide a setup.py for backwards compatability. +# But the pyproject.toml should be prefered. import itertools from pathlib import Path from typing import List @@ -48,6 +50,7 @@ setup( 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', ], extras_require=extras, install_requires=[ From 10038f5d731e85184c0537aa10c7ce3db487be21 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Thu, 12 Oct 2023 12:34:55 +0200 Subject: [PATCH 02/44] We need to use a MANIFEST rto insure inclusion of our *.stl and *.xml files --- MANIFEST.in | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..a19bc97 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,9 @@ +# Include the README +include README.md + +# Include the license file +include LICENSE + +# Include stl and xml files from the fancy_gym/envs/mujoco directory +recursive-include fancy_gym/envs/mujoco *.stl +recursive-include fancy_gym/envs/mujoco *.xml From d10ea23b4c010ab148b973bbd2f3db50af0eff8a Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Thu, 12 Oct 2023 12:41:55 +0200 Subject: [PATCH 03/44] Added Code of Conduct and Contributing guidelines to the MANIFEST --- MANIFEST.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index a19bc97..47ae90a 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,8 +1,10 @@ # Include the README include README.md -# Include the license file +# Include the license, Code of Conduct and Contributing guidelines include LICENSE +include CODE_OF_CONDUCT.md +include CONTRIBUTING.md # Include stl and xml files from the fancy_gym/envs/mujoco directory recursive-include fancy_gym/envs/mujoco *.stl From a5a29176cb0fcad62d7e2267a8e207034b7fe56f Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Thu, 12 Oct 2023 12:46:53 +0200 Subject: [PATCH 04/44] Add 'all' as an optional installation to the toml --- pyproject.toml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 053c1b8..4e844cb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,21 +43,34 @@ mp_pytorch = "<=0.1.3" [project.optional-dependencies] dmc = ["shimmy[dm-control]", "Shimmy==1.0.0"] -metaworld = ["metaworld @ git+https://github.com/Farama-Foundation/Metaworld.git@d155d0051630bb365ea6a824e02c66c068947439#egg=metaworld"] +# PyPi does not allow external dependencies. Metaworld will have to be installed manually until Farama publishes up-to-date version of metaworld on PyPi. +#metaworld = ["metaworld @ git+https://github.com/Farama-Foundation/Metaworld.git@d155d0051630bb365ea6a824e02c66c068947439#egg=metaworld"] box2d = ["gymnasium[box2d]>=0.26.0"] mujoco = ["mujoco==2.3.3", "gymnasium[mujoco]>0.26.0"] mujoco-legacy = ["mujoco-py>=2.1,<2.2", "cython<3"] jax = ["jax>=0.4.0", "jaxlib>=0.4.0"] +all = [ + # include all the optional dependencies + "shimmy[dm-control]", + "Shimmy==1.0.0", + #"metaworld @ git+https://github.com/Farama-Foundation/Metaworld.git@d155d0051630bb365ea6a824e02c66c068947439#egg=metaworld", + "mujoco==2.3.3", + "gymnasium[box2d,mujoco]>=0.26.0", + "mujoco-py>=2.1,<2.2", + "cython<3", + "jax>=0.4.0", + "jaxlib>=0.4.0" +] + testing = [ "pytest", # include all the optional dependencies as well "shimmy[dm-control]", "Shimmy==1.0.0", - "metaworld @ git+https://github.com/Farama-Foundation/Metaworld.git@d155d0051630bb365ea6a824e02c66c068947439#egg=metaworld", - "gymnasium[box2d]>=0.26.0", + #"metaworld @ git+https://github.com/Farama-Foundation/Metaworld.git@d155d0051630bb365ea6a824e02c66c068947439#egg=metaworld", "mujoco==2.3.3", - "gymnasium[mujoco]>0.26.0", + "gymnasium[box2d,mujoco]>=0.26.0", "mujoco-py>=2.1,<2.2", "cython<3", "jax>=0.4.0", From ee573788fc47a79c34a106cb3ad792c7190ef5a9 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Thu, 12 Oct 2023 12:55:32 +0200 Subject: [PATCH 05/44] Fix: pyproject.toml license needs to point to file --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 4e844cb..5c96ba1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ authors = [ {name = "Dominik Roth", email = "fancy_gym@dominik-roth.eu"}, {name = "Hongyi Zhou", email = "hongyi.zhou@kit.edu"} ] -license = "MIT" +license = { file = "LICENSE" } classifiers = [ "Development Status :: 4 - Beta", "Intended Audience :: Science/Research", From b6c67b1adc67bfe0e0b1814d66200228f967daca Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Thu, 12 Oct 2023 13:04:16 +0200 Subject: [PATCH 06/44] The pyproject.toml now actually works --- pyproject.toml | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5c96ba1..8a49117 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,8 +24,8 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11" ] -homepage = "https://github.com/ALRhub/fancy_gym/" -repository = "https://github.com/ALRhub/fancy_gym/" + +requires-python = ">=3.7" [project.urls] Homepage = "https://github.com/ALRhub/fancy_gym/" @@ -34,12 +34,10 @@ Homepage = "https://github.com/ALRhub/fancy_gym/" requires = ["setuptools>=51.0.0", "wheel"] build-backend = "setuptools.build_meta" -[project.scripts] -# If you have any entry points (scripts), define them here. - -[project.dependencies] -gymnasium = ">=0.26.0" -mp_pytorch = "<=0.1.3" +project.dependencies = [ + "gymnasium>=0.26.0", + "mp_pytorch<=0.1.3" +] [project.optional-dependencies] dmc = ["shimmy[dm-control]", "Shimmy==1.0.0"] @@ -76,6 +74,3 @@ testing = [ "jax>=0.4.0", "jaxlib>=0.4.0" ] - -[project.python-requires] -python_version = ">=3.7" From ce779bc6fb788955c4670068938010f4a1ff66a6 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Thu, 12 Oct 2023 14:55:00 +0200 Subject: [PATCH 07/44] Make mujoco (modern version) a required dependency --- pyproject.toml | 17 +++++++++-------- setup.py | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 8a49117..2d2c8c2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,26 +25,27 @@ classifiers = [ "Programming Language :: Python :: 3.11" ] +dependencies = [ + "mp_pytorch<=0.1.3", + "mujoco==2.3.3", + "gymnasium[mujoco]>0.26.0" +] + requires-python = ">=3.7" [project.urls] -Homepage = "https://github.com/ALRhub/fancy_gym/" +"Homepage" = "https://github.com/ALRhub/fancy_gym/" +"Bug Tracker" = "https://github.com/ALRhub/fancy_gym/issues" [build-system] -requires = ["setuptools>=51.0.0", "wheel"] +requires = ["setuptools>=61.0.0", "wheel"] build-backend = "setuptools.build_meta" -project.dependencies = [ - "gymnasium>=0.26.0", - "mp_pytorch<=0.1.3" -] - [project.optional-dependencies] dmc = ["shimmy[dm-control]", "Shimmy==1.0.0"] # PyPi does not allow external dependencies. Metaworld will have to be installed manually until Farama publishes up-to-date version of metaworld on PyPi. #metaworld = ["metaworld @ git+https://github.com/Farama-Foundation/Metaworld.git@d155d0051630bb365ea6a824e02c66c068947439#egg=metaworld"] box2d = ["gymnasium[box2d]>=0.26.0"] -mujoco = ["mujoco==2.3.3", "gymnasium[mujoco]>0.26.0"] mujoco-legacy = ["mujoco-py>=2.1,<2.2", "cython<3"] jax = ["jax>=0.4.0", "jaxlib>=0.4.0"] diff --git a/setup.py b/setup.py index 24dda38..cf2397f 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,6 @@ extras = { 'dmc': ['shimmy[dm-control]', 'Shimmy==1.0.0'], 'metaworld': ['metaworld @ git+https://github.com/Farama-Foundation/Metaworld.git@d155d0051630bb365ea6a824e02c66c068947439#egg=metaworld'], 'box2d': ['gymnasium[box2d]>=0.26.0'], - 'mujoco': ['mujoco==2.3.3', 'gymnasium[mujoco]>0.26.0'], 'mujoco-legacy': ['mujoco-py >=2.1,<2.2', 'cython<3'], 'jax': ["jax >=0.4.0", "jaxlib >=0.4.0"], } @@ -54,8 +53,9 @@ setup( ], extras_require=extras, install_requires=[ - 'gymnasium>=0.26.0', 'mp_pytorch<=0.1.3' + 'mujoco==2.3.3', + 'gymnasium[mujoco]>0.26.0'] ], packages=[package for package in find_packages( ) if package.startswith("fancy_gym")], From 6528c5d5b9bfe311282c87ca02b8dbd22be2c14e Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Thu, 12 Oct 2023 14:55:15 +0200 Subject: [PATCH 08/44] Update README (Test-PyPI and dependency changes) --- README.md | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c457932..bedb5c3 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@

+ | :exclamation: Fancy Gym has recently received a major refactor, which also updated many of the used dependencies to current versions. The update has brought some breaking changes. If you want to access the old version, check out the [legacy branch](https://github.com/ALRhub/fancy_gym/tree/legacy). Find out more about what changed [here](https://github.com/ALRhub/fancy_gym/pull/75). | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -33,6 +34,32 @@ While the overarching objective of MP environments remains the learning of an op ## Installation +### Installation via pip (recommended) + +While the publication of `fancy_gym` on PyPI is still pending, you can install it from Test-PyPI. +```bash +pip install --index-url https://test.pypi.org/simple/ fancy_gym +``` + +We have a few optional dependencies. If you also want to install those use + +```bash +# to install all optional dependencies +pip install --index-url https://test.pypi.org/simple/ 'fancy_gym[all]' + +# or choose only those you want +pip install --index-url https://test.pypi.org/simple/ 'fancy_gym[dmc,box2d,mujoco-legacy,jax,testing]' +``` + +Pip can not automatically install up-to-date versions of metaworld, since they are not avaible on PyPI yet. +Install metaworld via + +```bash +pip install metaworld@git+https://github.com/Farama-Foundation/Metaworld.git@d155d0051630bb365ea6a824e02c66c068947439#egg=metaworld +``` + +### Installation from master + 1. Clone the repository ```bash @@ -54,8 +81,16 @@ pip install -e . We have a few optional dependencies. If you also want to install those use ```bash -pip install -e '.[all]' # to install all optional dependencies -pip install -e '.[dmc,metaworld,box2d,mujoco,mujoco-legacy,jax,testing]' # or choose only those you want +# to install all optional dependencies +pip install -e '.[all]' + +# or choose only those you want +pip install -e '.[dmc,box2d,mujoco-legacy,jax,testing]' +``` + +Metaworld has to be installed manually with +```bash +pip install metaworld@git+https://github.com/Farama-Foundation/Metaworld.git@d155d0051630bb365ea6a824e02c66c068947439#egg=metaworld ``` ## How to use Fancy Gym From 95a6b9cf2c26cca90ea72b5d069febc655c8e0cb Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Thu, 12 Oct 2023 14:56:02 +0200 Subject: [PATCH 09/44] README: Minor cosmetic changes --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bedb5c3..a359fa5 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,10 @@ -

+



- Fancy Gym + Fancy Gym

-

- + | :exclamation: Fancy Gym has recently received a major refactor, which also updated many of the used dependencies to current versions. The update has brought some breaking changes. If you want to access the old version, check out the [legacy branch](https://github.com/ALRhub/fancy_gym/tree/legacy). Find out more about what changed [here](https://github.com/ALRhub/fancy_gym/pull/75). | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | From 894982f77f6c40df4d0fcb2fd46d8eaf321c92d6 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Thu, 12 Oct 2023 15:30:11 +0200 Subject: [PATCH 10/44] Fix typos in setup.py --- setup.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index cf2397f..65d64a3 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,6 @@ from setuptools import setup, find_packages # Environment-specific dependencies for dmc and metaworld extras = { 'dmc': ['shimmy[dm-control]', 'Shimmy==1.0.0'], - 'metaworld': ['metaworld @ git+https://github.com/Farama-Foundation/Metaworld.git@d155d0051630bb365ea6a824e02c66c068947439#egg=metaworld'], 'box2d': ['gymnasium[box2d]>=0.26.0'], 'mujoco-legacy': ['mujoco-py >=2.1,<2.2', 'cython<3'], 'jax': ["jax >=0.4.0", "jaxlib >=0.4.0"], @@ -53,9 +52,9 @@ setup( ], extras_require=extras, install_requires=[ - 'mp_pytorch<=0.1.3' + 'mp_pytorch<=0.1.3', 'mujoco==2.3.3', - 'gymnasium[mujoco]>0.26.0'] + 'gymnasium[mujoco]>0.26.0' ], packages=[package for package in find_packages( ) if package.startswith("fancy_gym")], From a5b10e11a363a71f651f9a69328fcdab509eb4f8 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Thu, 12 Oct 2023 15:34:10 +0200 Subject: [PATCH 11/44] Allow gymnasium==0.26.0 --- pyproject.toml | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2d2c8c2..4ad9197 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,7 +28,7 @@ classifiers = [ dependencies = [ "mp_pytorch<=0.1.3", "mujoco==2.3.3", - "gymnasium[mujoco]>0.26.0" + "gymnasium[mujoco]>=0.26.0" ] requires-python = ">=3.7" diff --git a/setup.py b/setup.py index 65d64a3..f11769c 100644 --- a/setup.py +++ b/setup.py @@ -54,7 +54,7 @@ setup( install_requires=[ 'mp_pytorch<=0.1.3', 'mujoco==2.3.3', - 'gymnasium[mujoco]>0.26.0' + 'gymnasium[mujoco]>=0.26.0' ], packages=[package for package in find_packages( ) if package.startswith("fancy_gym")], From 0c932807960f66a50c65e650843e535739e08220 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Thu, 12 Oct 2023 15:34:36 +0200 Subject: [PATCH 12/44] Improve handling of missing Metaworld --- fancy_gym/meta/__init__.py | 102 +++++++++++++++------------- fancy_gym/meta/metaworld_adapter.py | 6 +- 2 files changed, 56 insertions(+), 52 deletions(-) diff --git a/fancy_gym/meta/__init__.py b/fancy_gym/meta/__init__.py index 78ec73c..73c0a1f 100644 --- a/fancy_gym/meta/__init__.py +++ b/fancy_gym/meta/__init__.py @@ -7,56 +7,64 @@ from ..envs.registry import register from . import goal_object_change_mp_wrapper, goal_change_mp_wrapper, goal_endeffector_change_mp_wrapper, \ object_change_mp_wrapper -from . import metaworld_adapter +try: + import metaworld +except ModuleNotFoundError: + print('[FANCY GYM] Metaworld not avaible.') +else: + # Will only get executed, if import succeeds -metaworld_adapter.register_all_ML1() + from . import metaworld_adapter -ALL_METAWORLD_MOVEMENT_PRIMITIVE_ENVIRONMENTS = {"DMP": [], "ProMP": [], "ProDMP": []} + metaworld_adapter.register_all_ML1() -# MetaWorld -_goal_change_envs = ["assembly-v2", "pick-out-of-hole-v2", "plate-slide-v2", "plate-slide-back-v2", - "plate-slide-side-v2", "plate-slide-back-side-v2"] -for _task in _goal_change_envs: - register( - id=f'metaworld/{_task}', - register_step_based=False, - mp_wrapper=goal_change_mp_wrapper.MPWrapper, - add_mp_types=['ProMP', 'ProDMP'], - ) + ALL_METAWORLD_MOVEMENT_PRIMITIVE_ENVIRONMENTS = {"DMP": [], "ProMP": [], "ProDMP": []} -_object_change_envs = ["bin-picking-v2", "hammer-v2", "sweep-into-v2"] -for _task in _object_change_envs: - register( - id=f'metaworld/{_task}', - register_step_based=False, - mp_wrapper=object_change_mp_wrapper.MPWrapper, - add_mp_types=['ProMP', 'ProDMP'], - ) + # MetaWorld + _goal_change_envs = ["assembly-v2", "pick-out-of-hole-v2", "plate-slide-v2", "plate-slide-back-v2", + "plate-slide-side-v2", "plate-slide-back-side-v2"] + for _task in _goal_change_envs: + register( + id=f'metaworld/{_task}', + register_step_based=False, + mp_wrapper=goal_change_mp_wrapper.MPWrapper, + add_mp_types=['ProMP', 'ProDMP'], + ) -_goal_and_object_change_envs = ["box-close-v2", "button-press-v2", "button-press-wall-v2", "button-press-topdown-v2", - "button-press-topdown-wall-v2", "coffee-button-v2", "coffee-pull-v2", - "coffee-push-v2", "dial-turn-v2", "disassemble-v2", "door-close-v2", - "door-lock-v2", "door-open-v2", "door-unlock-v2", "hand-insert-v2", - "drawer-close-v2", "drawer-open-v2", "faucet-open-v2", "faucet-close-v2", - "handle-press-side-v2", "handle-press-v2", "handle-pull-side-v2", - "handle-pull-v2", "lever-pull-v2", "peg-insert-side-v2", "pick-place-wall-v2", - "reach-v2", "push-back-v2", "push-v2", "pick-place-v2", "peg-unplug-side-v2", - "soccer-v2", "stick-push-v2", "stick-pull-v2", "push-wall-v2", "reach-wall-v2", - "shelf-place-v2", "sweep-v2", "window-open-v2", "window-close-v2" - ] -for _task in _goal_and_object_change_envs: - register( - id=f'metaworld/{_task}', - register_step_based=False, - mp_wrapper=goal_object_change_mp_wrapper.MPWrapper, - add_mp_types=['ProMP', 'ProDMP'], - ) + _object_change_envs = ["bin-picking-v2", "hammer-v2", "sweep-into-v2"] + for _task in _object_change_envs: + register( + id=f'metaworld/{_task}', + register_step_based=False, + mp_wrapper=object_change_mp_wrapper.MPWrapper, + add_mp_types=['ProMP', 'ProDMP'], + ) -_goal_and_endeffector_change_envs = ["basketball-v2"] -for _task in _goal_and_endeffector_change_envs: - register( - id=f'metaworld/{_task}', - register_step_based=False, - mp_wrapper=goal_endeffector_change_mp_wrapper.MPWrapper, - add_mp_types=['ProMP', 'ProDMP'], - ) + _goal_and_object_change_envs = ["box-close-v2", "button-press-v2", "button-press-wall-v2", "button-press-topdown-v2", + "button-press-topdown-wall-v2", "coffee-button-v2", "coffee-pull-v2", + "coffee-push-v2", "dial-turn-v2", "disassemble-v2", "door-close-v2", + "door-lock-v2", "door-open-v2", "door-unlock-v2", "hand-insert-v2", + "drawer-close-v2", "drawer-open-v2", "faucet-open-v2", "faucet-close-v2", + "handle-press-side-v2", "handle-press-v2", "handle-pull-side-v2", + "handle-pull-v2", "lever-pull-v2", "peg-insert-side-v2", "pick-place-wall-v2", + "reach-v2", "push-back-v2", "push-v2", "pick-place-v2", "peg-unplug-side-v2", + "soccer-v2", "stick-push-v2", "stick-pull-v2", "push-wall-v2", "reach-wall-v2", + "shelf-place-v2", "sweep-v2", "window-open-v2", "window-close-v2" + ] + for _task in _goal_and_object_change_envs: + register( + id=f'metaworld/{_task}', + register_step_based=False, + mp_wrapper=goal_object_change_mp_wrapper.MPWrapper, + add_mp_types=['ProMP', 'ProDMP'], + ) + + _goal_and_endeffector_change_envs = ["basketball-v2"] + for _task in _goal_and_endeffector_change_envs: + register( + id=f'metaworld/{_task}', + register_step_based=False, + mp_wrapper=goal_endeffector_change_mp_wrapper.MPWrapper, + add_mp_types=['ProMP', 'ProDMP'], + ) +` \ No newline at end of file diff --git a/fancy_gym/meta/metaworld_adapter.py b/fancy_gym/meta/metaworld_adapter.py index 21dfed7..7853378 100644 --- a/fancy_gym/meta/metaworld_adapter.py +++ b/fancy_gym/meta/metaworld_adapter.py @@ -11,11 +11,7 @@ import numpy as np from fancy_gym.utils.env_compatibility import EnvCompatibility -try: - import metaworld -except Exception: - print('[FANCY GYM] Metaworld not avaible') - +import metaworld class FixMetaworldHasIncorrectObsSpaceWrapper(gym.Wrapper, gym.utils.RecordConstructorArgs): def __init__(self, env: gym.Env): From 3f0c7b73028ab7429b91db49a36098d0997eff4f Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Thu, 12 Oct 2023 15:37:39 +0200 Subject: [PATCH 13/44] Removing setup.py (built pipeline prefered it over pyproject.toml causing issues) setup.py remains avaible on the legacy branch. --- setup.py | 69 -------------------------------------------------------- 1 file changed, 69 deletions(-) delete mode 100644 setup.py diff --git a/setup.py b/setup.py deleted file mode 100644 index f11769c..0000000 --- a/setup.py +++ /dev/null @@ -1,69 +0,0 @@ -# We still provide a setup.py for backwards compatability. -# But the pyproject.toml should be prefered. -import itertools -from pathlib import Path -from typing import List - -from setuptools import setup, find_packages - -# Environment-specific dependencies for dmc and metaworld -extras = { - 'dmc': ['shimmy[dm-control]', 'Shimmy==1.0.0'], - 'box2d': ['gymnasium[box2d]>=0.26.0'], - 'mujoco-legacy': ['mujoco-py >=2.1,<2.2', 'cython<3'], - 'jax': ["jax >=0.4.0", "jaxlib >=0.4.0"], -} - -# All dependencies -all_groups = set(extras.keys()) -extras["all"] = list(set(itertools.chain.from_iterable( - map(lambda group: extras[group], all_groups)))) - -extras['testing'] = extras["all"] + ['pytest'] - - -def find_package_data(extensions_to_include: List[str]) -> List[str]: - envs_dir = Path("fancy_gym/envs/mujoco") - package_data_paths = [] - for extension in extensions_to_include: - package_data_paths.extend([str(path)[10:] - for path in envs_dir.rglob(extension)]) - - return package_data_paths - - -setup( - author='Fabian Otto, Onur Celik, Dominik Roth, Hongyi Zhou', - name='fancy_gym', - version='1.0', - classifiers=[ - 'Development Status :: 4 - Beta', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: MIT License', - 'Natural Language :: English', - 'Operating System :: OS Independent', - 'Topic :: Scientific/Engineering :: Artificial Intelligence', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - ], - extras_require=extras, - install_requires=[ - 'mp_pytorch<=0.1.3', - 'mujoco==2.3.3', - 'gymnasium[mujoco]>=0.26.0' - ], - packages=[package for package in find_packages( - ) if package.startswith("fancy_gym")], - package_data={ - "fancy_gym": find_package_data(extensions_to_include=["*.stl", "*.xml"]) - }, - python_requires=">=3.7", - url='https://github.com/ALRhub/fancy_gym/', - license='MIT license', - author_email='', - description='Fancy Gym: Unifying interface for various RL benchmarks with support for Black Box approaches.' -) From 9565f7972f61069251dc965d8510bd3cac6eac75 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Thu, 12 Oct 2023 15:48:19 +0200 Subject: [PATCH 14/44] removed typo --- fancy_gym/meta/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fancy_gym/meta/__init__.py b/fancy_gym/meta/__init__.py index 73c0a1f..6e95719 100644 --- a/fancy_gym/meta/__init__.py +++ b/fancy_gym/meta/__init__.py @@ -66,5 +66,4 @@ else: register_step_based=False, mp_wrapper=goal_endeffector_change_mp_wrapper.MPWrapper, add_mp_types=['ProMP', 'ProDMP'], - ) -` \ No newline at end of file + ) \ No newline at end of file From b0b58675b2f9af7699a0c7d469b507e066548534 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Thu, 12 Oct 2023 15:53:41 +0200 Subject: [PATCH 15/44] Don't try to export metaworld envs, if metaworld is not installed --- fancy_gym/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fancy_gym/__init__.py b/fancy_gym/__init__.py index c3adaad..4c55a73 100644 --- a/fancy_gym/__init__.py +++ b/fancy_gym/__init__.py @@ -6,7 +6,10 @@ from .envs.registry import ALL_MOVEMENT_PRIMITIVE_ENVIRONMENTS, MOVEMENT_PRIMITI ALL_DMC_MOVEMENT_PRIMITIVE_ENVIRONMENTS = MOVEMENT_PRIMITIVE_ENVIRONMENTS_FOR_NS['dm_control'] ALL_FANCY_MOVEMENT_PRIMITIVE_ENVIRONMENTS = MOVEMENT_PRIMITIVE_ENVIRONMENTS_FOR_NS['fancy'] -ALL_METAWORLD_MOVEMENT_PRIMITIVE_ENVIRONMENTS = MOVEMENT_PRIMITIVE_ENVIRONMENTS_FOR_NS['metaworld'] +if 'metaworld' in MOVEMENT_PRIMITIVE_ENVIRONMENTS_FOR_NS: + ALL_METAWORLD_MOVEMENT_PRIMITIVE_ENVIRONMENTS = MOVEMENT_PRIMITIVE_ENVIRONMENTS_FOR_NS['metaworld'] +else: + ALL_METAWORLD_MOVEMENT_PRIMITIVE_ENVIRONMENTS = 'Metaworld is not installed.' ALL_GYM_MOVEMENT_PRIMITIVE_ENVIRONMENTS = MOVEMENT_PRIMITIVE_ENVIRONMENTS_FOR_NS['gym'] From 9538c999a01d36e6f96987d19a5f9ccbd25b9923 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Thu, 12 Oct 2023 16:46:45 +0200 Subject: [PATCH 16/44] Make sure the icon is always loaded from GitHub So it is also visible on PyPI --- MANIFEST.in | 3 +++ README.md | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index 47ae90a..b1b03cf 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -9,3 +9,6 @@ include CONTRIBUTING.md # Include stl and xml files from the fancy_gym/envs/mujoco directory recursive-include fancy_gym/envs/mujoco *.stl recursive-include fancy_gym/envs/mujoco *.xml + +# Also shipping the most important part of fancy gym +include icon.svg diff --git a/README.md b/README.md index a359fa5..8fee031 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

- +

Fancy Gym

From a50d1788b15a79fbd26a25e3e19315dee6c6b653 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Thu, 12 Oct 2023 16:54:45 +0200 Subject: [PATCH 17/44] PyPI does not support GitHub-Flavored Markdown. Using HTML-Code for emojis now... --- README.md | 4 ++-- pyproject.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8fee031..4c4b274 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@

-| :exclamation: Fancy Gym has recently received a major refactor, which also updated many of the used dependencies to current versions. The update has brought some breaking changes. If you want to access the old version, check out the [legacy branch](https://github.com/ALRhub/fancy_gym/tree/legacy). Find out more about what changed [here](https://github.com/ALRhub/fancy_gym/pull/75). | +| ❗ Fancy Gym has recently received a major refactor, which also updated many of the used dependencies to current versions. The update has brought some breaking changes. If you want to access the old version, check out the [legacy branch](https://github.com/ALRhub/fancy_gym/tree/legacy). Find out more about what changed [here](https://github.com/ALRhub/fancy_gym/pull/75). | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | Built upon the foundation of [Gymnasium](https://gymnasium.farama.org/) (a maintained fork of OpenAI’s renowned Gym library) `fancy_gym` offers a comprehensive collection of reinforcement learning environments. @@ -100,7 +100,7 @@ We will only show the basics here and prepared [multiple examples](fancy_gym/exa Regular step based environments added by Fancy Gym are added into the `fancy/` namespace. -| :exclamation: Legacy versions of Fancy Gym used `fancy_gym.make(...)`. This is no longer supported and will raise an Exception on new versions. | +| ❗ Legacy versions of Fancy Gym used `fancy_gym.make(...)`. This is no longer supported and will raise an Exception on new versions. | | ----------------------------------------------------------------------------------------------------------------------------------------------- | ```python diff --git a/pyproject.toml b/pyproject.toml index 4ad9197..1de8265 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "fancy_gym" -version = "1.0" +version = "1.0.2" description = "Fancy Gym: Unifying interface for various RL benchmarks with support for Black Box approaches." readme = "README.md" authors = [ From 4107704d9aead2d9dc5ad4b5d031a769e49fb4f5 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Thu, 12 Oct 2023 17:01:51 +0200 Subject: [PATCH 18/44] Fix install instructions (look in both Test-PyPI & PyPI) --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4c4b274..bb7e895 100644 --- a/README.md +++ b/README.md @@ -37,17 +37,17 @@ While the overarching objective of MP environments remains the learning of an op While the publication of `fancy_gym` on PyPI is still pending, you can install it from Test-PyPI. ```bash -pip install --index-url https://test.pypi.org/simple/ fancy_gym +pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple fancy_gym ``` We have a few optional dependencies. If you also want to install those use ```bash # to install all optional dependencies -pip install --index-url https://test.pypi.org/simple/ 'fancy_gym[all]' +pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple 'fancy_gym[all]' # or choose only those you want -pip install --index-url https://test.pypi.org/simple/ 'fancy_gym[dmc,box2d,mujoco-legacy,jax,testing]' +pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple 'fancy_gym[dmc,box2d,mujoco-legacy,jax,testing]' ``` Pip can not automatically install up-to-date versions of metaworld, since they are not avaible on PyPI yet. From 6fea48f6c1df524c8a3a45f14070103c2d913989 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Thu, 12 Oct 2023 17:04:03 +0200 Subject: [PATCH 19/44] Increment version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 1de8265..a5ecb16 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "fancy_gym" -version = "1.0.2" +version = "1.0.3" description = "Fancy Gym: Unifying interface for various RL benchmarks with support for Black Box approaches." readme = "README.md" authors = [ From ebb0e0067597d7f117f9d830838da3737e50171d Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Thu, 12 Oct 2023 17:11:19 +0200 Subject: [PATCH 20/44] Minor changes to pyproject.toml --- pyproject.toml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a5ecb16..bae10fa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "fancy_gym" -version = "1.0.3" +version = "1.0.4" description = "Fancy Gym: Unifying interface for various RL benchmarks with support for Black Box approaches." readme = "README.md" authors = [ @@ -9,7 +9,7 @@ authors = [ {name = "Dominik Roth", email = "fancy_gym@dominik-roth.eu"}, {name = "Hongyi Zhou", email = "hongyi.zhou@kit.edu"} ] -license = { file = "LICENSE" } +license = { text = "MIT License" } classifiers = [ "Development Status :: 4 - Beta", "Intended Audience :: Science/Research", @@ -35,7 +35,9 @@ requires-python = ">=3.7" [project.urls] "Homepage" = "https://github.com/ALRhub/fancy_gym/" +#"Documentation" = "https://github.com/ALRhub/fancy_gym/" "Bug Tracker" = "https://github.com/ALRhub/fancy_gym/issues" +#"Repository" = "https://github.com/ALRhub/fancy_gym/" [build-system] requires = ["setuptools>=61.0.0", "wheel"] From 4051a13324344defacfc0891084b2919358c982b Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Thu, 12 Oct 2023 17:47:34 +0200 Subject: [PATCH 21/44] README: GitHub ignores custom font-size; reverting to using h1 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bb7e895..74f0ccf 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -
+




- Fancy Gym + Fancy Gym

-

+ | ❗ Fancy Gym has recently received a major refactor, which also updated many of the used dependencies to current versions. The update has brought some breaking changes. If you want to access the old version, check out the [legacy branch](https://github.com/ALRhub/fancy_gym/tree/legacy). Find out more about what changed [here](https://github.com/ALRhub/fancy_gym/pull/75). | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | From a7031ce3b999188dde72b64dc8e196849abdcdb0 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Thu, 12 Oct 2023 17:58:11 +0200 Subject: [PATCH 22/44] Version dump --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index bae10fa..89075d4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "fancy_gym" -version = "1.0.4" +version = "1.0.5" description = "Fancy Gym: Unifying interface for various RL benchmarks with support for Black Box approaches." readme = "README.md" authors = [ From 0b240b9eb4b99d1458286610c6a52111b3135083 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Sat, 14 Oct 2023 12:24:04 +0200 Subject: [PATCH 23/44] Define Github Action for test-PyPI publication --- .github/workflows/publish-to-test-pypi.yml | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/publish-to-test-pypi.yml diff --git a/.github/workflows/publish-to-test-pypi.yml b/.github/workflows/publish-to-test-pypi.yml new file mode 100644 index 0000000..53393b4 --- /dev/null +++ b/.github/workflows/publish-to-test-pypi.yml @@ -0,0 +1,38 @@ +name: Publish Python package to TestPyPI + +on: + push: + tags: + - '*' + +jobs: + publish: + name: Publish to TestPyPI + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') # Only run on tagged commits + + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + + - name: Install pypa/build/setuptools/twine + run: >- + python3 -m + pip install + build setuptools twine + --user + + - name: Build a binary wheel and a source tarball + run: python3 -m build + + - name: Publish to TestPyPI + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} + run: twine upload --repository-url https://test.pypi.org/legacy/ dist/* + From 5e63a7288251700db575ffb7d8aa48d742cc00c6 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Sat, 14 Oct 2023 12:36:35 +0200 Subject: [PATCH 24/44] Version bump (to test Github Action) --- .github/workflows/publish-to-test-pypi.yml | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-to-test-pypi.yml b/.github/workflows/publish-to-test-pypi.yml index 53393b4..b348845 100644 --- a/.github/workflows/publish-to-test-pypi.yml +++ b/.github/workflows/publish-to-test-pypi.yml @@ -33,6 +33,6 @@ jobs: - name: Publish to TestPyPI env: TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} + TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }} run: twine upload --repository-url https://test.pypi.org/legacy/ dist/* diff --git a/pyproject.toml b/pyproject.toml index 89075d4..8db9546 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "fancy_gym" -version = "1.0.5" +version = "1.0.6" description = "Fancy Gym: Unifying interface for various RL benchmarks with support for Black Box approaches." readme = "README.md" authors = [ From b183c002ef36a65bc9199115f7db6f4acc8a3070 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Mon, 23 Oct 2023 14:14:11 +0200 Subject: [PATCH 25/44] Provide setup.py as fallback (again) --- setup.py | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 setup.py diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..f11769c --- /dev/null +++ b/setup.py @@ -0,0 +1,69 @@ +# We still provide a setup.py for backwards compatability. +# But the pyproject.toml should be prefered. +import itertools +from pathlib import Path +from typing import List + +from setuptools import setup, find_packages + +# Environment-specific dependencies for dmc and metaworld +extras = { + 'dmc': ['shimmy[dm-control]', 'Shimmy==1.0.0'], + 'box2d': ['gymnasium[box2d]>=0.26.0'], + 'mujoco-legacy': ['mujoco-py >=2.1,<2.2', 'cython<3'], + 'jax': ["jax >=0.4.0", "jaxlib >=0.4.0"], +} + +# All dependencies +all_groups = set(extras.keys()) +extras["all"] = list(set(itertools.chain.from_iterable( + map(lambda group: extras[group], all_groups)))) + +extras['testing'] = extras["all"] + ['pytest'] + + +def find_package_data(extensions_to_include: List[str]) -> List[str]: + envs_dir = Path("fancy_gym/envs/mujoco") + package_data_paths = [] + for extension in extensions_to_include: + package_data_paths.extend([str(path)[10:] + for path in envs_dir.rglob(extension)]) + + return package_data_paths + + +setup( + author='Fabian Otto, Onur Celik, Dominik Roth, Hongyi Zhou', + name='fancy_gym', + version='1.0', + classifiers=[ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Science/Research', + 'License :: OSI Approved :: MIT License', + 'Natural Language :: English', + 'Operating System :: OS Independent', + 'Topic :: Scientific/Engineering :: Artificial Intelligence', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + ], + extras_require=extras, + install_requires=[ + 'mp_pytorch<=0.1.3', + 'mujoco==2.3.3', + 'gymnasium[mujoco]>=0.26.0' + ], + packages=[package for package in find_packages( + ) if package.startswith("fancy_gym")], + package_data={ + "fancy_gym": find_package_data(extensions_to_include=["*.stl", "*.xml"]) + }, + python_requires=">=3.7", + url='https://github.com/ALRhub/fancy_gym/', + license='MIT license', + author_email='', + description='Fancy Gym: Unifying interface for various RL benchmarks with support for Black Box approaches.' +) From b277ed6477a0c35a46161d82b343af6e82a512db Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Mon, 23 Oct 2023 14:24:50 +0200 Subject: [PATCH 26/44] Adding forward looking statements to README (Install instructions based on PyPI package) --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 74f0ccf..950bd8c 100644 --- a/README.md +++ b/README.md @@ -33,21 +33,23 @@ While the overarching objective of MP environments remains the learning of an op ## Installation +We recommend installing `fancy_gym` into a virtual environments like [venv](https://docs.python.org/3/library/venv.html). 3rd party alternatives to venv like [Poetry](https://python-poetry.org/) or [Conda](https://docs.conda.io/en/latest/) can also be used. + ### Installation via pip (recommended) -While the publication of `fancy_gym` on PyPI is still pending, you can install it from Test-PyPI. +Install `fancy_gym` via ```bash -pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple fancy_gym +pip install fancy_gym ``` We have a few optional dependencies. If you also want to install those use ```bash # to install all optional dependencies -pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple 'fancy_gym[all]' +pip install 'fancy_gym[all]' # or choose only those you want -pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple 'fancy_gym[dmc,box2d,mujoco-legacy,jax,testing]' +pip install 'fancy_gym[dmc,box2d,mujoco-legacy,jax,testing]' ``` Pip can not automatically install up-to-date versions of metaworld, since they are not avaible on PyPI yet. From d138c3c1f1e1791652242256cc95342bd912dfcc Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Mon, 23 Oct 2023 14:28:26 +0200 Subject: [PATCH 27/44] README: Minor improvements --- README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/README.md b/README.md index 950bd8c..46c536b 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ While the overarching objective of MP environments remains the learning of an op We recommend installing `fancy_gym` into a virtual environments like [venv](https://docs.python.org/3/library/venv.html). 3rd party alternatives to venv like [Poetry](https://python-poetry.org/) or [Conda](https://docs.conda.io/en/latest/) can also be used. -### Installation via pip (recommended) +### Installation from PyPI (recommended) Install `fancy_gym` via ```bash @@ -62,25 +62,21 @@ pip install metaworld@git+https://github.com/Farama-Foundation/Metaworld.git@d15 ### Installation from master 1. Clone the repository - ```bash git clone git@github.com:ALRhub/fancy_gym.git ``` 2. Go to the folder - ```bash cd fancy_gym ``` 3. Install with - ```bash pip install -e . ``` We have a few optional dependencies. If you also want to install those use - ```bash # to install all optional dependencies pip install -e '.[all]' From af636164a83b5c1f1356502124025dadc25b6224 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Mon, 23 Oct 2023 14:34:43 +0200 Subject: [PATCH 28/44] Version bump and update setup.py --- pyproject.toml | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 8db9546..7c58d24 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "fancy_gym" -version = "1.0.6" +version = "1.0.7" description = "Fancy Gym: Unifying interface for various RL benchmarks with support for Black Box approaches." readme = "README.md" authors = [ diff --git a/setup.py b/setup.py index f11769c..09ea286 100644 --- a/setup.py +++ b/setup.py @@ -35,7 +35,7 @@ def find_package_data(extensions_to_include: List[str]) -> List[str]: setup( author='Fabian Otto, Onur Celik, Dominik Roth, Hongyi Zhou', name='fancy_gym', - version='1.0', + version='1.0.7', classifiers=[ 'Development Status :: 4 - Beta', 'Intended Audience :: Science/Research', From 049e45cb0907f8b841ada5d16c0401378a524742 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Mon, 23 Oct 2023 14:51:21 +0200 Subject: [PATCH 29/44] Print warning when setup.py is still used. --- setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.py b/setup.py index 09ea286..d55fefc 100644 --- a/setup.py +++ b/setup.py @@ -6,6 +6,8 @@ from typing import List from setuptools import setup, find_packages +print('[!] You are currently installing/building fancy_gym via setup.py. This is only provided for backwards-compatability. Please use the pyproject.toml instead.') + # Environment-specific dependencies for dmc and metaworld extras = { 'dmc': ['shimmy[dm-control]', 'Shimmy==1.0.0'], From be250bee5e1bc167b71c105e9dfd6a98334e7e86 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Sun, 29 Oct 2023 14:11:25 +0100 Subject: [PATCH 30/44] Add action to publish to real PyPI --- .github/workflows/publish-to-pypi.yml | 38 +++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/publish-to-pypi.yml diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml new file mode 100644 index 0000000..d56e142 --- /dev/null +++ b/.github/workflows/publish-to-pypi.yml @@ -0,0 +1,38 @@ +name: Publish Python package to PyPI + +on: + push: + tags: + - '*' + +jobs: + publish: + name: Publish to PyPI + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') # Only run on tagged commits + + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + + - name: Install pypa/build/setuptools/twine + run: >- + python3 -m + pip install + build setuptools twine + --user + + - name: Build a binary wheel and a source tarball + run: python3 -m build + + - name: Publish to PyPI + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} + run: twine upload dist/* + From 11a46889d9cdccd4c21524e89d141b2a118f1315 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Sun, 29 Oct 2023 14:11:47 +0100 Subject: [PATCH 31/44] Decrement version (we will start with 01.0 on PyPI) --- pyproject.toml | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 7c58d24..c1be41e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "fancy_gym" -version = "1.0.7" +version = "0.1.0" description = "Fancy Gym: Unifying interface for various RL benchmarks with support for Black Box approaches." readme = "README.md" authors = [ diff --git a/setup.py b/setup.py index d55fefc..62b950c 100644 --- a/setup.py +++ b/setup.py @@ -37,7 +37,7 @@ def find_package_data(extensions_to_include: List[str]) -> List[str]: setup( author='Fabian Otto, Onur Celik, Dominik Roth, Hongyi Zhou', name='fancy_gym', - version='1.0.7', + version='0.1.0', classifiers=[ 'Development Status :: 4 - Beta', 'Intended Audience :: Science/Research', From 707ec0880836ead69915e4973d70a5c0abce358f Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Sun, 29 Oct 2023 14:21:08 +0100 Subject: [PATCH 32/44] Disable push to reakl PyPI for initial test --- .github/workflows/publish-to-pypi.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index d56e142..09665f3 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -1,9 +1,11 @@ name: Publish Python package to PyPI on: - push: - tags: - - '*' + # Action currently disabled to only push to TestPyPI for now + + #push: + # tags: + # - '*' jobs: publish: From 3c7df908100c7763167a524f69b476bbf8fb8086 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Sun, 29 Oct 2023 14:37:30 +0100 Subject: [PATCH 33/44] Ensure we only react to push onto master; disable via if clause --- .github/workflows/publish-to-pypi.yml | 12 ++++++------ .github/workflows/publish-to-test-pypi.yml | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 09665f3..fb75642 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -1,17 +1,17 @@ name: Publish Python package to PyPI on: - # Action currently disabled to only push to TestPyPI for now - - #push: - # tags: - # - '*' + push: + branches: + - master + tags: + - '*' jobs: publish: name: Publish to PyPI runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') # Only run on tagged commits + if: false && startsWith(github.ref, 'refs/tags/') # Only run on tagged commits steps: - name: Check out code diff --git a/.github/workflows/publish-to-test-pypi.yml b/.github/workflows/publish-to-test-pypi.yml index b348845..2afd464 100644 --- a/.github/workflows/publish-to-test-pypi.yml +++ b/.github/workflows/publish-to-test-pypi.yml @@ -1,6 +1,8 @@ name: Publish Python package to TestPyPI on: + branches: + - master push: tags: - '*' From 4a9ea368b8ca835d9c38cdb3ef8487c50f23476b Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Sun, 29 Oct 2023 14:39:02 +0100 Subject: [PATCH 34/44] fix typo in publish-to-test-pypi.yml --- .github/workflows/publish-to-test-pypi.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-to-test-pypi.yml b/.github/workflows/publish-to-test-pypi.yml index 2afd464..8cc98fb 100644 --- a/.github/workflows/publish-to-test-pypi.yml +++ b/.github/workflows/publish-to-test-pypi.yml @@ -1,9 +1,9 @@ name: Publish Python package to TestPyPI on: - branches: - - master push: + branches: + - master tags: - '*' From f02461380050d03fece877128e849a0369eced71 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Sun, 29 Oct 2023 16:02:10 +0100 Subject: [PATCH 35/44] Prevent fallback to setup.py when building package --- .github/workflows/publish-to-pypi.yml | 3 +++ .github/workflows/publish-to-test-pypi.yml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index fb75642..3747e30 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -29,6 +29,9 @@ jobs: build setuptools twine --user + - name: Prevent fallback onto setup.py + run: rm setup.py + - name: Build a binary wheel and a source tarball run: python3 -m build diff --git a/.github/workflows/publish-to-test-pypi.yml b/.github/workflows/publish-to-test-pypi.yml index 8cc98fb..8b8d003 100644 --- a/.github/workflows/publish-to-test-pypi.yml +++ b/.github/workflows/publish-to-test-pypi.yml @@ -29,6 +29,9 @@ jobs: build setuptools twine --user + - name: Prevent fallback onto setup.py + run: rm setup.py + - name: Build a binary wheel and a source tarball run: python3 -m build From bbd964ed80edea8e56b39fe253320b89248ecdf0 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Sun, 29 Oct 2023 16:50:02 +0100 Subject: [PATCH 36/44] Use full URLs for links in README (wont work on PyPI otherwise) --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 46c536b..1cedaba 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ pip install metaworld@git+https://github.com/Farama-Foundation/Metaworld.git@d15 ## How to use Fancy Gym -We will only show the basics here and prepared [multiple examples](fancy_gym/examples/) for a more detailed look. +We will only show the basics here and prepared [multiple examples](https://github.com/ALRhub/fancy_gym/tree/master/fancy_gym/examples/) for a more detailed look. ### Step-Based Environments @@ -197,7 +197,7 @@ print(fancy_gym.MOVEMENT_PRIMITIVE_ENVIRONMENTS_FOR_NS['']) ### How to create a new MP task In case a required task is not supported yet in the MP framework, it can be created relatively easy. For the task at -hand, the following [interface](fancy_gym/black_box/raw_interface_wrapper.py) needs to be implemented. +hand, the following [interface](https://github.com/ALRhub/fancy_gym/tree/master/fancy_gym/black_box/raw_interface_wrapper.py) needs to be implemented. ```python from abc import abstractmethod @@ -283,7 +283,7 @@ class RawInterfaceWrapper(gym.Wrapper): If you created a new task wrapper, feel free to open a PR, so we can integrate it for others to use as well. Without the integration the task can still be used. A rough outline can be shown here, for more details we recommend having a look -at the [examples](fancy_gym/examples/). +at the [examples](https://github.com/ALRhub/fancy_gym/tree/master/fancy_gym/examples/). If the step-based is already registered with gym, you can simply do the following: From e32f836a3c1dd945668d23ac8b789220922b047b Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Sun, 29 Oct 2023 17:02:12 +0100 Subject: [PATCH 37/44] Version increment --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c1be41e..2bdef52 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "fancy_gym" -version = "0.1.0" +version = "0.1.2" description = "Fancy Gym: Unifying interface for various RL benchmarks with support for Black Box approaches." readme = "README.md" authors = [ From da5592124ef9278d823ec7e8f55fa8f5c45bb773 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Sun, 29 Oct 2023 17:14:58 +0100 Subject: [PATCH 38/44] Fix issue with trigger --- .github/workflows/publish-to-pypi.yml | 2 -- .github/workflows/publish-to-test-pypi.yml | 2 -- 2 files changed, 4 deletions(-) diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 3747e30..f9ac5bf 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -2,8 +2,6 @@ name: Publish Python package to PyPI on: push: - branches: - - master tags: - '*' diff --git a/.github/workflows/publish-to-test-pypi.yml b/.github/workflows/publish-to-test-pypi.yml index 8b8d003..df88021 100644 --- a/.github/workflows/publish-to-test-pypi.yml +++ b/.github/workflows/publish-to-test-pypi.yml @@ -2,8 +2,6 @@ name: Publish Python package to TestPyPI on: push: - branches: - - master tags: - '*' From 9d1d925179d84efb404ff51364f9084f90b9b44c Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Sun, 29 Oct 2023 17:21:13 +0100 Subject: [PATCH 39/44] Require tagged commits to be on master for package to be published --- .github/workflows/publish-to-pypi.yml | 14 ++++++++++++++ .github/workflows/publish-to-test-pypi.yml | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index f9ac5bf..7d15b3d 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -14,6 +14,20 @@ jobs: steps: - name: Check out code uses: actions/checkout@v4 + with: + fetch-depth: 0 # This fetches all history for all branches and tags + + - name: Verify tag is on master branch + run: | + TAG_SHA=$(git rev-parse ${{ github.ref }}) + MASTER_SHA=$(git rev-parse refs/heads/master) + + if [ "$TAG_SHA" == "$MASTER_SHA" ]; then + echo "Tag is on the master branch. Proceeding with the workflow." + else + echo "Tag is not on the master branch. Cancelling the workflow." + exit 1 + fi - name: Set up Python uses: actions/setup-python@v4 diff --git a/.github/workflows/publish-to-test-pypi.yml b/.github/workflows/publish-to-test-pypi.yml index df88021..54d8dfa 100644 --- a/.github/workflows/publish-to-test-pypi.yml +++ b/.github/workflows/publish-to-test-pypi.yml @@ -14,6 +14,20 @@ jobs: steps: - name: Check out code uses: actions/checkout@v4 + with: + fetch-depth: 0 # This fetches all history for all branches and tags + + - name: Verify tag is on master branch + run: | + TAG_SHA=$(git rev-parse ${{ github.ref }}) + MASTER_SHA=$(git rev-parse refs/heads/master) + + if [ "$TAG_SHA" == "$MASTER_SHA" ]; then + echo "Tag is on the master branch. Proceeding with the workflow." + else + echo "Tag is not on the master branch. Cancelling the workflow." + exit 1 + fi - name: Set up Python uses: actions/setup-python@v4 From 06e6c64e49e9488d0105304eea14145f847b27d9 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Sun, 29 Oct 2023 17:23:44 +0100 Subject: [PATCH 40/44] Version increment --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2bdef52..7ae44f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "fancy_gym" -version = "0.1.2" +version = "0.1.3" description = "Fancy Gym: Unifying interface for various RL benchmarks with support for Black Box approaches." readme = "README.md" authors = [ From 0d3336b8d9eb67387fd705e72c84b2960217af41 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Sun, 29 Oct 2023 17:28:45 +0100 Subject: [PATCH 41/44] Made check for wether tagged commit is on master more robust --- .github/workflows/publish-to-pypi.yml | 9 +++------ .github/workflows/publish-to-test-pypi.yml | 9 +++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 7d15b3d..8eebbee 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -19,15 +19,12 @@ jobs: - name: Verify tag is on master branch run: | - TAG_SHA=$(git rev-parse ${{ github.ref }}) - MASTER_SHA=$(git rev-parse refs/heads/master) - - if [ "$TAG_SHA" == "$MASTER_SHA" ]; then - echo "Tag is on the master branch. Proceeding with the workflow." - else + TAG_IS_ON_MASTER=$(git branch -r --contains ${{ github.ref }} | grep 'origin/master') + if [ -z "$TAG_IS_ON_MASTER" ]; then echo "Tag is not on the master branch. Cancelling the workflow." exit 1 fi + echo "Tag is on the master branch. Proceeding with the workflow." - name: Set up Python uses: actions/setup-python@v4 diff --git a/.github/workflows/publish-to-test-pypi.yml b/.github/workflows/publish-to-test-pypi.yml index 54d8dfa..64c1888 100644 --- a/.github/workflows/publish-to-test-pypi.yml +++ b/.github/workflows/publish-to-test-pypi.yml @@ -19,15 +19,12 @@ jobs: - name: Verify tag is on master branch run: | - TAG_SHA=$(git rev-parse ${{ github.ref }}) - MASTER_SHA=$(git rev-parse refs/heads/master) - - if [ "$TAG_SHA" == "$MASTER_SHA" ]; then - echo "Tag is on the master branch. Proceeding with the workflow." - else + TAG_IS_ON_MASTER=$(git branch -r --contains ${{ github.ref }} | grep 'origin/master') + if [ -z "$TAG_IS_ON_MASTER" ]; then echo "Tag is not on the master branch. Cancelling the workflow." exit 1 fi + echo "Tag is on the master branch. Proceeding with the workflow." - name: Set up Python uses: actions/setup-python@v4 From fae7c887ce50dad8df77d551c686fee422e6842e Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Sun, 29 Oct 2023 17:29:22 +0100 Subject: [PATCH 42/44] Version Increment --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7ae44f0..acefa88 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "fancy_gym" -version = "0.1.3" +version = "0.1.4" description = "Fancy Gym: Unifying interface for various RL benchmarks with support for Black Box approaches." readme = "README.md" authors = [ From 74bede4ba3ff55a3c4d38cf2492521cb141fd81d Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Sun, 29 Oct 2023 17:38:38 +0100 Subject: [PATCH 43/44] fixed typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1cedaba..1c76595 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ While the overarching objective of MP environments remains the learning of an op ## Installation -We recommend installing `fancy_gym` into a virtual environments like [venv](https://docs.python.org/3/library/venv.html). 3rd party alternatives to venv like [Poetry](https://python-poetry.org/) or [Conda](https://docs.conda.io/en/latest/) can also be used. +We recommend installing `fancy_gym` into a virtual environment as provided by [venv](https://docs.python.org/3/library/venv.html). 3rd party alternatives to venv like [Poetry](https://python-poetry.org/) or [Conda](https://docs.conda.io/en/latest/) can also be used. ### Installation from PyPI (recommended) From beaf5df2fcd7d957ed1f5c678ab6dcaa0a2215ce Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Thu, 23 Nov 2023 21:14:11 +0100 Subject: [PATCH 44/44] Bring to parity with dev-branch --- test/test_all_gym_builtin_envs.py | 4 +++- test/test_black_box.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/test_all_gym_builtin_envs.py b/test/test_all_gym_builtin_envs.py index f2eeac6..9264b98 100644 --- a/test/test_all_gym_builtin_envs.py +++ b/test/test_all_gym_builtin_envs.py @@ -12,7 +12,9 @@ GYM_IDS = [spec.id for spec in gym.envs.registry.values() if not isinstance(spec.entry_point, Callable) and "fancy_gym" not in spec.entry_point and 'make_bb_env_helper' not in spec.entry_point and 'jax' not in spec.id.lower() - and 'jax' not in spec.id.lower() + and 'shimmy' not in spec.id.lower() + and 'ale_py' not in spec.id.lower() + and 'tabular' not in spec.id.lower() and not re.match(r'GymV2.Environment', spec.id) ] GYM_MP_IDS = fancy_gym.ALL_DMC_MOVEMENT_PRIMITIVE_ENVIRONMENTS['all'] diff --git a/test/test_black_box.py b/test/test_black_box.py index c1a760a..fc4f0bf 100644 --- a/test/test_black_box.py +++ b/test/test_black_box.py @@ -103,7 +103,7 @@ def test_verbosity(mp_type: str, env_wrap: Tuple[str, Type[RawInterfaceWrapper]] env_step = make(env_id) env_step.reset() - _obs, _reward, _terminated, _truncated, info = env.step(env.action_space.sample()) + _obs, _reward, _terminated, _truncated, info = env_step.step(env_step.action_space.sample()) info_keys_step = info.keys() assert all(e in info_keys for e in info_keys_step)