From 9205e9f6363ff5c7e7839633cae6ee4d37fee242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=92=B2=E6=BA=90?= <48008469+puyuan1996@users.noreply.github.com> Date: Sat, 23 Nov 2024 00:50:32 +0800 Subject: [PATCH] polish(pu): polish requirements (#298) * polish(pu): polish requirements * polish(pu): polish requirements * polish(pu): polish readme --- README.md | 52 ++++++++++++------- README.zh.md | 2 +- requirements.txt | 4 -- zoo/bsuite/envs/bsuite_lightzero_env.py | 12 +++-- zoo/bsuite/envs/check_bsuite_config.py | 8 ++- zoo/memory/envs/pycolab_tvt/common.py | 11 ++-- zoo/memory/envs/pycolab_tvt/human_player.py | 6 ++- zoo/memory/envs/pycolab_tvt/key_to_door.py | 9 ++-- zoo/memory/envs/pycolab_tvt/objects.py | 7 ++- zoo/memory/envs/pycolab_tvt/visual_match.py | 7 ++- .../sum_to_three/envs/sum_to_three_env.py | 8 +-- .../envs/test_sum_to_three_env.py | 9 ++-- 12 files changed, 84 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index 7a7d1f14f..c595d3c3d 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ [![GitHub license](https://img.shields.io/github/license/opendilab/LightZero)](https://github.com/opendilab/LightZero/blob/master/LICENSE) [![discord badge](https://dcbadge.vercel.app/api/server/dkZS2JF56X?style=flat)](https://discord.gg/dkZS2JF56X) -Updated on 2024.08.18 LightZero-v0.1.0 +Updated on 2024.11.23 LightZero-v0.1.0 English | [简体中文(Simplified Chinese)](https://github.com/opendilab/LightZero/blob/main/README.zh.md) | [Documentation](https://opendilab.github.io/LightZero) | [LightZero Paper](https://arxiv.org/abs/2310.08348) | [🔥UniZero Paper](https://arxiv.org/abs/2406.10667) | [🔥ReZero Paper](https://arxiv.org/abs/2404.16364) @@ -58,25 +58,37 @@ For further details, please refer to [Features](#features), [Framework Structure ### Outline -- [Overview](#overview) - - [Outline](#outline) - - [Features](#features) - - [Framework Structure](#framework-structure) - - [Integrated Algorithms](#integrated-algorithms) -- [Installation](#installation) -- [Quick Start](#quick-start) -- [Documentation](#documentation) -- [Benchmark](#benchmark) -- [Awesome-MCTS Notes](#awesome-mcts-notes) - - [Paper Notes](#paper-notes) - - [Algo. Overview](#algo-overview) -- [Awesome-MCTS Papers](#awesome-mcts-papers) - - [Key Papers](#key-papers) - - [Other Papers](#other-papers) -- [Feedback and Contribution](#feedback-and-contribution) -- [Citation](#citation) -- [Acknowledgments](#acknowledgments) -- [License](#license) +- [LightZero](#lightzero) + - [🔍 Background](#-background) + - [🎨 Overview](#-overview) + - [Outline](#outline) + - [💥 Features](#-features) + - [🧩 Framework Structure](#-framework-structure) + - [🎁 Integrated Algorithms](#-integrated-algorithms) + - [⚙️ Installation](#️-installation) + - [Installation with Docker](#installation-with-docker) + - [🚀 Quick Start](#-quick-start) + - [📚 Documentation](#-documentation) + - [📊 Benchmark](#-benchmark) + - [📝 Awesome-MCTS Notes](#-awesome-mcts-notes) + - [Paper Notes](#paper-notes) + - [Algo. Overview](#algo-overview) + - [Awesome-MCTS Papers](#awesome-mcts-papers) + - [Key Papers](#key-papers) + - [LightZero Implemented series](#lightzero-implemented-series) + - [AlphaGo series](#alphago-series) + - [MuZero series](#muzero-series) + - [MCTS Analysis](#mcts-analysis) + - [MCTS Application](#mcts-application) + - [Other Papers](#other-papers) + - [ICML](#icml) + - [ICLR](#iclr) + - [NeurIPS](#neurips) + - [Other Conference or Journal](#other-conference-or-journal) + - [💬 Feedback and Contribution](#-feedback-and-contribution) + - [🌏 Citation](#-citation) + - [💓 Acknowledgments](#-acknowledgments) + - [🏷️ License](#️-license) ### 💥 Features diff --git a/README.zh.md b/README.zh.md index 850fbdfb2..c544e3f54 100644 --- a/README.zh.md +++ b/README.zh.md @@ -27,7 +27,7 @@ [![Contributors](https://img.shields.io/github/contributors/opendilab/LightZero)](https://github.com/opendilab/LightZero/graphs/contributors) [![GitHub license](https://img.shields.io/github/license/opendilab/LightZero)](https://github.com/opendilab/LightZero/blob/master/LICENSE) -最近更新于 2024.08.18 LightZero-v0.1.0 +最近更新于 2024.11.23 LightZero-v0.1.0 [English](https://github.com/opendilab/LightZero/blob/main/README.md) | 简体中文 | [文档](https://opendilab.github.io/LightZero) | [LightZero 论文](https://arxiv.org/abs/2310.08348) | [🔥UniZero 论文](https://arxiv.org/abs/2406.10667) | [🔥ReZero 论文](https://arxiv.org/abs/2404.16364) diff --git a/requirements.txt b/requirements.txt index b040112b6..bbc723e73 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,14 +1,10 @@ DI-engine>=0.4.7 gymnasium[atari] -moviepy numpy>=1.22.4 pympler minigrid -bsuite moviepy -pycolab pytest -pooltool-billiards>=0.3.1 line_profiler xxhash einops diff --git a/zoo/bsuite/envs/bsuite_lightzero_env.py b/zoo/bsuite/envs/bsuite_lightzero_env.py index f86d5beb7..ab866414f 100644 --- a/zoo/bsuite/envs/bsuite_lightzero_env.py +++ b/zoo/bsuite/envs/bsuite_lightzero_env.py @@ -1,14 +1,18 @@ import copy import os from datetime import datetime -from typing import Union, Optional, Dict, List +from typing import Optional, Dict, List + +try: + import bsuite + from bsuite import sweep + from bsuite.utils import gym_wrapper +except ImportError: + raise ImportError("Please install the bsuite package: pip install bsuite") import gymnasium as gym import matplotlib.pyplot as plt import numpy as np -import bsuite -from bsuite import sweep -from bsuite.utils import gym_wrapper from ding.envs import BaseEnv, BaseEnvTimestep from ding.torch_utils import to_ndarray from ding.utils import ENV_REGISTRY diff --git a/zoo/bsuite/envs/check_bsuite_config.py b/zoo/bsuite/envs/check_bsuite_config.py index 7109b3984..90d6f3682 100644 --- a/zoo/bsuite/envs/check_bsuite_config.py +++ b/zoo/bsuite/envs/check_bsuite_config.py @@ -1,5 +1,9 @@ -import bsuite -from bsuite import sweep +try: + import bsuite + from bsuite import sweep +except ImportError: + raise ImportError("Please install the bsuite package: pip install bsuite") + # List the configurations for the given experiment for bsuite_id in sweep.BANDIT_NOISE: diff --git a/zoo/memory/envs/pycolab_tvt/common.py b/zoo/memory/envs/pycolab_tvt/common.py index f66768228..4c4122dca 100644 --- a/zoo/memory/envs/pycolab_tvt/common.py +++ b/zoo/memory/envs/pycolab_tvt/common.py @@ -19,10 +19,13 @@ import colorsys import numpy as np -from pycolab import ascii_art -from pycolab import cropping -from pycolab import things as plab_things -from pycolab.prefab_parts import sprites as prefab_sprites +try: + from pycolab import ascii_art + from pycolab import cropping + from pycolab import things as plab_things + from pycolab.prefab_parts import sprites as prefab_sprites +except ImportError: + raise ImportError("Please install the pycolab package: pip install pycolab") # Actions. # Those with a negative ID are not allowed for the agent. diff --git a/zoo/memory/envs/pycolab_tvt/human_player.py b/zoo/memory/envs/pycolab_tvt/human_player.py index b5f1b6db7..9b470b1db 100644 --- a/zoo/memory/envs/pycolab_tvt/human_player.py +++ b/zoo/memory/envs/pycolab_tvt/human_player.py @@ -20,7 +20,11 @@ import numpy as np from absl import app from absl import flags -from pycolab import human_ui + +try: + from pycolab import human_ui +except ImportError: + raise ImportError("Please install the pycolab package: pip install pycolab") import common import key_to_door diff --git a/zoo/memory/envs/pycolab_tvt/key_to_door.py b/zoo/memory/envs/pycolab_tvt/key_to_door.py index 753130ac8..f7e617fa3 100644 --- a/zoo/memory/envs/pycolab_tvt/key_to_door.py +++ b/zoo/memory/envs/pycolab_tvt/key_to_door.py @@ -23,9 +23,12 @@ previously collected. """ -from pycolab import ascii_art -from pycolab import storytelling -from pycolab import things as plab_things +try: + from pycolab import ascii_art + from pycolab import storytelling + from pycolab import things as plab_things +except ImportError: + raise ImportError("Please install the pycolab package: pip install pycolab") from zoo.memory.envs.pycolab_tvt import common, game, objects diff --git a/zoo/memory/envs/pycolab_tvt/objects.py b/zoo/memory/envs/pycolab_tvt/objects.py index 6d8e2cac4..789ddc147 100644 --- a/zoo/memory/envs/pycolab_tvt/objects.py +++ b/zoo/memory/envs/pycolab_tvt/objects.py @@ -16,8 +16,11 @@ # ============================================================================ """Pycolab sprites.""" -from pycolab import things as plab_things -from pycolab.prefab_parts import sprites as prefab_sprites +try: + from pycolab import things as plab_things + from pycolab.prefab_parts import sprites as prefab_sprites +except ImportError: + raise ImportError("Please install the pycolab package: pip install pycolab") from . import common diff --git a/zoo/memory/envs/pycolab_tvt/visual_match.py b/zoo/memory/envs/pycolab_tvt/visual_match.py index 0a539cfad..87e2e33a3 100644 --- a/zoo/memory/envs/pycolab_tvt/visual_match.py +++ b/zoo/memory/envs/pycolab_tvt/visual_match.py @@ -22,8 +22,11 @@ the one of the same color as the colour in the first phase. """ -from pycolab import ascii_art -from pycolab import storytelling +try: + from pycolab import ascii_art + from pycolab import storytelling +except ImportError: + raise ImportError("Please install the pycolab package: pip install pycolab") from zoo.memory.envs.pycolab_tvt import common, game, objects diff --git a/zoo/pooltool/sum_to_three/envs/sum_to_three_env.py b/zoo/pooltool/sum_to_three/envs/sum_to_three_env.py index 90b370e3a..8a9e643b8 100644 --- a/zoo/pooltool/sum_to_three/envs/sum_to_three_env.py +++ b/zoo/pooltool/sum_to_three/envs/sum_to_three_env.py @@ -40,14 +40,17 @@ from __future__ import annotations import gc - from dataclasses import dataclass, asdict from typing import Optional + import numpy as np +import pooltool as pt from ding.envs import BaseEnvTimestep from ding.utils import ENV_REGISTRY from easydict import EasyDict +from gym import spaces from numpy.typing import NDArray + from zoo.pooltool.datatypes import ( Bounds, ObservationDict, @@ -56,9 +59,6 @@ Spaces, State, ) -from gym import spaces - -import pooltool as pt from zoo.pooltool.image_representation import PygameRenderer, RenderConfig from zoo.pooltool.sum_to_three.envs.utils import ( ObservationType, diff --git a/zoo/pooltool/sum_to_three/envs/test_sum_to_three_env.py b/zoo/pooltool/sum_to_three/envs/test_sum_to_three_env.py index 5ab565294..96fc722b1 100644 --- a/zoo/pooltool/sum_to_three/envs/test_sum_to_three_env.py +++ b/zoo/pooltool/sum_to_three/envs/test_sum_to_three_env.py @@ -1,6 +1,10 @@ import math -import pytest + import numpy as np +import pooltool as pt +import pytest +from easydict import EasyDict + from zoo.pooltool.datatypes import Spaces from zoo.pooltool.image_representation import PygameRenderer, RenderConfig from zoo.pooltool.sum_to_three.envs.sum_to_three_env import ( @@ -10,15 +14,12 @@ create_initial_state, get_action_space, ) - -import pooltool as pt from zoo.pooltool.sum_to_three.envs.utils import ( ObservationType, get_coordinate_obs_space, get_image_obs_space, get_reward_space, ) -from easydict import EasyDict np.random.seed(42)