diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1150e846..35d96f5c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,10 +1,10 @@ name: Release PyPI Wheel -# on: [push, pull_request] -on: - push: - branches: - - main +on: [push, pull_request] +# on: +# push: +# branches: +# - main jobs: release: diff --git a/envpool/mujoco/BUILD b/envpool/mujoco/BUILD index e528c5ff..36d38cd4 100644 --- a/envpool/mujoco/BUILD +++ b/envpool/mujoco/BUILD @@ -17,13 +17,6 @@ genrule( cmd = "mkdir -p $(OUTS) && cp -r $(SRCS) $(OUTS)", ) -genrule( - name = "gen_mujoco_so", - srcs = ["@mujoco//:mujoco_so"], - outs = ["libmujoco.so.2.2.1"], - cmd = "cp $< $@", -) - cc_library( name = "mujoco_gym_env", hdrs = [ @@ -109,7 +102,6 @@ py_library( srcs = ["dmc/__init__.py"], data = [ ":gen_mujoco_dmc_xml", - ":gen_mujoco_so", ":mujoco_dmc_envpool.so", ], deps = ["//envpool/python:api"], @@ -120,7 +112,6 @@ py_library( srcs = ["gym/__init__.py"], data = [ ":gen_mujoco_gym_xml", - ":gen_mujoco_so", ":mujoco_gym_envpool.so", ], deps = ["//envpool/python:api"], diff --git a/envpool/mujoco/dmc/mujoco_dmc_suite_align_test.py b/envpool/mujoco/dmc/mujoco_dmc_suite_align_test.py index 9156d5b8..ad24d2f7 100644 --- a/envpool/mujoco/dmc/mujoco_dmc_suite_align_test.py +++ b/envpool/mujoco/dmc/mujoco_dmc_suite_align_test.py @@ -158,7 +158,8 @@ def sample_action(self, action_spec: dm_env.specs.Array) -> np.ndarray: ) def run_align_check( - self, env0: dm_env.Environment, env1: Any, domain: str, task: str + self, env0: dm_env.Environment, env1: Any, domain: str, task: str, + total_step: int ) -> None: logging.info(f"align check for {domain} {task}") obs_spec, action_spec = env0.observation_spec(), env0.action_spec() @@ -171,7 +172,7 @@ def run_align_check( logging.info(f"reset qpos {ts.observation.qpos0[0]}") cnt = 0 done = False - while not done: + while not done and cnt <= total_step: cnt += 1 a = self.sample_action(action_spec) # logging.info(f"{cnt} {a}") @@ -180,19 +181,24 @@ def run_align_check( done = ts0.step_type == dm_env.StepType.LAST o0, o1 = ts0.observation, ts1.observation for k in obs_spec: - np.testing.assert_allclose(o0[k], getattr(o1, k)[0]) + np.testing.assert_allclose(o0[k], getattr(o1, k)[0], atol=1e-5) np.testing.assert_allclose(ts0.step_type, ts1.step_type[0]) - np.testing.assert_allclose(ts0.reward, ts1.reward[0], atol=1e-8) + np.testing.assert_allclose(ts0.reward, ts1.reward[0], atol=1e-5) np.testing.assert_allclose(ts0.discount, ts1.discount[0]) def run_align_check_entry( - self, domain: str, tasks: List[str], spec_cls: Any, envpool_cls: Any + self, + domain: str, + tasks: List[str], + spec_cls: Any, + envpool_cls: Any, + total_step: int = 1000, ) -> None: for task in tasks: env0 = suite.load(domain, task) env1 = envpool_cls(spec_cls(spec_cls.gen_config(task_name=task))) self.run_space_check(env0, env1) - self.run_align_check(env0, env1, domain, task) + self.run_align_check(env0, env1, domain, task, total_step) def test_acrobot(self) -> None: self.run_align_check_entry( @@ -231,13 +237,13 @@ def test_fish(self) -> None: def test_hopper(self) -> None: self.run_align_check_entry( - "hopper", ["hop", "stand"], DmcHopperEnvSpec, DmcHopperDMEnvPool + "hopper", ["hop", "stand"], DmcHopperEnvSpec, DmcHopperDMEnvPool, 400 ) def test_humanoid(self) -> None: self.run_align_check_entry( "humanoid", ["stand", "walk", "run", "run_pure_state"], - DmcHumanoidEnvSpec, DmcHumanoidDMEnvPool + DmcHumanoidEnvSpec, DmcHumanoidDMEnvPool, 100 ) def test_manipulator(self) -> None: @@ -270,7 +276,8 @@ def test_swimmer(self) -> None: def test_walker(self) -> None: self.run_align_check_entry( - "walker", ["run", "stand", "walk"], DmcWalkerEnvSpec, DmcWalkerDMEnvPool + "walker", ["run", "stand", "walk"], DmcWalkerEnvSpec, DmcWalkerDMEnvPool, + 200 ) diff --git a/envpool/mujoco/gym/mujoco_gym_align_test.py b/envpool/mujoco/gym/mujoco_gym_align_test.py index 37478fc2..d3be3c81 100644 --- a/envpool/mujoco/gym/mujoco_gym_align_test.py +++ b/envpool/mujoco/gym/mujoco_gym_align_test.py @@ -124,7 +124,10 @@ def test_half_cheetah(self) -> None: env0 = mjc_mwe.HalfCheetahEnv() env1 = GymHalfCheetahGymEnvPool( GymHalfCheetahEnvSpec( - GymHalfCheetahEnvSpec.gen_config(gym_reset_return_info=True) + GymHalfCheetahEnvSpec.gen_config( + gym_reset_return_info=True, + max_episode_steps=99, + ) ) ) self.run_space_check(env0, env1) @@ -186,6 +189,7 @@ def test_humanoid(self) -> None: terminate_when_unhealthy=False, exclude_current_positions_from_observation=False, gym_reset_return_info=True, + max_episode_steps=999, ) ) ) diff --git a/envpool/workspace0.bzl b/envpool/workspace0.bzl index ea447b96..841adc25 100644 --- a/envpool/workspace0.bzl +++ b/envpool/workspace0.bzl @@ -316,14 +316,74 @@ def workspace(): build_file = "//third_party/vizdoom_extra_maps:vizdoom_extra_maps.BUILD", ) + maybe( + http_archive, + name = "tinyxml2", + sha256 = "cc2f1417c308b1f6acc54f88eb70771a0bf65f76282ce5c40e54cfe52952702c", + strip_prefix = "tinyxml2-9.0.0", + urls = [ + "https://github.com/leethomason/tinyxml2/archive/refs/tags/9.0.0.tar.gz", + "https://ml.cs.tsinghua.edu.cn/~jiayi/envpool/leethomason/tinyxml2/9.0.0.tar.gz", + ], + build_file = "//third_party/tinyxml2:tinyxml2.BUILD", + ) + + maybe( + http_archive, + name = "lodepng", + sha256 = "28a7e91b0476caed45b9b98b42eb765301fa5c9f15146d760c8ded2437ed0dff", + strip_prefix = "lodepng-5601b8272a6850b7c5d693dd0c0e16da50be8d8d", + urls = [ + "https://github.com/lvandeve/lodepng/archive/5601b8272a6850b7c5d693dd0c0e16da50be8d8d.tar.gz", + "https://ml.cs.tsinghua.edu.cn/~jiayi/envpool/lvandeve/lodepng/5601b8272a6850b7c5d693dd0c0e16da50be8d8d.tar.gz", + ], + build_file = "//third_party/lodepng:lodepng.BUILD", + ) + + maybe( + http_archive, + name = "tinyobjloader", + sha256 = "f9061d790905416a8a6c6f3dbfee77c7665636de0a9dc750ce799b513ddba83c", + strip_prefix = "tinyobjloader-2.0.0rc9", + urls = [ + "https://github.com/tinyobjloader/tinyobjloader/archive/refs/tags/v2.0.0rc9.tar.gz", + "https://ml.cs.tsinghua.edu.cn/~jiayi/envpool/tinyobjloader/tinyobjloader/v2.0.0rc9.tar.gz", + ], + build_file = "//third_party/tinyobjloader:tinyobjloader.BUILD", + ) + + maybe( + http_archive, + name = "ccd", + sha256 = "542b6c47f522d581fbf39e51df32c7d1256ac0c626e7c2b41f1040d4b9d50d1e", + strip_prefix = "libccd-2.1", + urls = [ + "https://github.com/danfis/libccd/archive/refs/tags/v2.1.tar.gz", + "https://ml.cs.tsinghua.edu.cn/~jiayi/envpool/danfis/libccd/v2.1.tar.gz", + ], + build_file = "//third_party/ccd:ccd.BUILD", + ) + + maybe( + http_archive, + name = "qhull", + sha256 = "09e5e4c5b2b8a9e617a46876fef5a3d33e70aa1d08a163ff05d37701327c3be7", + strip_prefix = "qhull-8.1-alpha1", + urls = [ + "https://github.com/qhull/qhull/archive/refs/tags/v8.1-alpha1.tar.gz", + "https://ml.cs.tsinghua.edu.cn/~jiayi/envpool/qhull/qhull/v8.1-alpha1.tar.gz", + ], + build_file = "//third_party/qhull:qhull.BUILD", + ) + maybe( http_archive, name = "mujoco", - sha256 = "d1cb3a720546240d894cd315b7fd358a2b96013a1f59b6d718036eca6f6edac2", + sha256 = "e7fa0821c993073b19bd8034df63661e309edcdc2d602101c3f9b28201574ded", strip_prefix = "mujoco-2.2.1", urls = [ - "https://github.com/deepmind/mujoco/releases/download/2.2.1/mujoco-2.2.1-linux-x86_64.tar.gz", - "https://ml.cs.tsinghua.edu.cn/~jiayi/envpool/deepmind/mujoco/mujoco-2.2.1-linux-x86_64.tar.gz", + "https://github.com/deepmind/mujoco/archive/refs/tags/2.2.1.tar.gz", + "https://ml.cs.tsinghua.edu.cn/~jiayi/envpool/deepmind/mujoco/2.2.1.tar.gz", ], build_file = "//third_party/mujoco:mujoco.BUILD", ) diff --git a/third_party/ccd/BUILD b/third_party/ccd/BUILD new file mode 100644 index 00000000..e69de29b diff --git a/third_party/ccd/ccd.BUILD b/third_party/ccd/ccd.BUILD new file mode 100644 index 00000000..6c256dee --- /dev/null +++ b/third_party/ccd/ccd.BUILD @@ -0,0 +1,20 @@ +load("@envpool//third_party:common.bzl", "template_rule") + +package(default_visibility = ["//visibility:public"]) + +template_rule( + name = "ccd_config", + src = "src/ccd/config.h.cmake.in", + out = "src/ccd/config.h", + substitutions = { + "#cmakedefine CCD_SINGLE": "", + "#cmakedefine CCD_DOUBLE": "#define CCD_DOUBLE", + }, +) + +cc_library( + name = "ccd", + srcs = glob(["src/*.h"]) + glob(["src/*.c"]) + [":ccd_config"], + hdrs = glob(["src/ccd/*.h"]), + includes = ["src"], +) diff --git a/third_party/lodepng/BUILD b/third_party/lodepng/BUILD new file mode 100644 index 00000000..e69de29b diff --git a/third_party/lodepng/lodepng.BUILD b/third_party/lodepng/lodepng.BUILD new file mode 100644 index 00000000..2e302bc1 --- /dev/null +++ b/third_party/lodepng/lodepng.BUILD @@ -0,0 +1,7 @@ +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "lodepng", + srcs = ["lodepng.cpp"], + hdrs = ["lodepng.h"], +) diff --git a/third_party/mujoco/mujoco.BUILD b/third_party/mujoco/mujoco.BUILD index e000bcc5..6d12c2eb 100644 --- a/third_party/mujoco/mujoco.BUILD +++ b/third_party/mujoco/mujoco.BUILD @@ -2,17 +2,32 @@ package(default_visibility = ["//visibility:public"]) cc_library( name = "mujoco_lib", - srcs = glob(["lib/*"]), + srcs = glob(["src/**/*.h"]) + glob(["src/**/*.c"]) + glob(["src/**/*.cc"]) + glob(["src/**/*.inc"]), hdrs = glob(["include/mujoco/*.h"]), + copts = [ + "-mavx", + "-Wno-int-in-bool-context", + "-Wno-maybe-uninitialized", + "-Wno-sign-compare", + "-Wno-stringop-overflow", + "-Wno-stringop-truncation", + ], includes = [ "include", "include/mujoco", + "src", + ], + linkopts = [ + "-fuse-ld=gold", + "-Wl,--gc-sections", + ], + linkstatic = 1, + visibility = ["//visibility:public"], + deps = [ + "@ccd", + "@lodepng", + "@qhull", + "@tinyobjloader", + "@tinyxml2", ], - linkopts = ["-Wl,-rpath,'$$ORIGIN'"], - linkstatic = 0, -) - -filegroup( - name = "mujoco_so", - srcs = ["lib/libmujoco.so.2.2.1"], ) diff --git a/third_party/qhull/BUILD b/third_party/qhull/BUILD new file mode 100644 index 00000000..e69de29b diff --git a/third_party/qhull/qhull.BUILD b/third_party/qhull/qhull.BUILD new file mode 100644 index 00000000..2e280db6 --- /dev/null +++ b/third_party/qhull/qhull.BUILD @@ -0,0 +1,8 @@ +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "qhull", + srcs = glob(["src/libqhull_r/*.h"]) + glob(["src/libqhull_r/*.c"]), + hdrs = glob(["src/libqhull_r/*.h"]), + includes = ["src/libqhull_r"], +) diff --git a/third_party/tinyobjloader/BUILD b/third_party/tinyobjloader/BUILD new file mode 100644 index 00000000..e69de29b diff --git a/third_party/tinyobjloader/tinyobjloader.BUILD b/third_party/tinyobjloader/tinyobjloader.BUILD new file mode 100644 index 00000000..ac29279d --- /dev/null +++ b/third_party/tinyobjloader/tinyobjloader.BUILD @@ -0,0 +1,8 @@ +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "tinyobjloader", + srcs = ["tiny_obj_loader.cc"], + hdrs = ["tiny_obj_loader.h"], + includes = ["."], +) diff --git a/third_party/tinyxml2/BUILD b/third_party/tinyxml2/BUILD new file mode 100644 index 00000000..e69de29b diff --git a/third_party/tinyxml2/tinyxml2.BUILD b/third_party/tinyxml2/tinyxml2.BUILD new file mode 100644 index 00000000..298cde85 --- /dev/null +++ b/third_party/tinyxml2/tinyxml2.BUILD @@ -0,0 +1,7 @@ +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "tinyxml2", + srcs = ["tinyxml2.cpp"], + hdrs = ["tinyxml2.h"], +)