-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'OpenRL-Lab:main' into main
- Loading branch information
Showing
26 changed files
with
1,229 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
callbacks: | ||
- id: "CheckpointCallback" | ||
args: { | ||
"save_freq": 500, | ||
"save_path": "./checkpoints/", | ||
"name_prefix": "ppo", | ||
"save_replay_buffer": True | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,4 +53,4 @@ def evaluation(agent): | |
|
||
if __name__ == "__main__": | ||
agent = train() | ||
evaluation(agent) | ||
evaluation(agent) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,49 @@ | ||
from typing import Optional, Type, Union | ||
|
||
from gymnasium import Env as GymEnv | ||
|
||
from openrl.envs.vec_env.async_venv import AsyncVectorEnv | ||
from openrl.envs.vec_env.base_venv import BaseVecEnv | ||
from openrl.envs.vec_env.sync_venv import SyncVectorEnv | ||
from openrl.envs.vec_env.wrappers.base_wrapper import VecEnvWrapper | ||
from openrl.envs.vec_env.wrappers.reward_wrapper import RewardWrapper | ||
from openrl.envs.vec_env.wrappers.vec_monitor_wrapper import VecMonitorWrapper | ||
|
||
__all__ = ["SyncVectorEnv", "AsyncVectorEnv", "VecMonitorWrapper", "RewardWrapper"] | ||
__all__ = [ | ||
"BaseVecEnv", | ||
"SyncVectorEnv", | ||
"AsyncVectorEnv", | ||
"VecMonitorWrapper", | ||
"RewardWrapper", | ||
] | ||
|
||
|
||
def unwrap_vec_wrapper( | ||
env: Union[GymEnv, BaseVecEnv], vec_wrapper_class: Type[VecEnvWrapper] | ||
) -> Optional[VecEnvWrapper]: | ||
""" | ||
Retrieve a ``VecEnvWrapper`` object by recursively searching. | ||
:param env: | ||
:param vec_wrapper_class: | ||
:return: | ||
""" | ||
env_tmp = env | ||
while isinstance(env_tmp, VecEnvWrapper): | ||
if isinstance(env_tmp, vec_wrapper_class): | ||
return env_tmp | ||
env_tmp = env_tmp.venv | ||
return None | ||
|
||
|
||
def is_vecenv_wrapped( | ||
env: Union[GymEnv, BaseVecEnv], vec_wrapper_class: Type[VecEnvWrapper] | ||
) -> bool: | ||
""" | ||
Check if an environment is already wrapped by a given ``VecEnvWrapper``. | ||
:param env: | ||
:param vec_wrapper_class: | ||
:return: | ||
""" | ||
return unwrap_vec_wrapper(env, vec_wrapper_class) is not None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.