rename handle -> task

This commit is contained in:
Cadene 2024-04-08 14:54:52 +00:00
parent 6c792f0d3d
commit 1149894e1d
6 changed files with 12 additions and 16 deletions

View File

@ -26,12 +26,14 @@ def make_env(cfg, num_parallel_envs=0) -> gym.Env | gym.vector.SyncVectorEnv:
) )
raise e raise e
handle = f"{package_name}/{cfg.env.handle}" gym_handle = f"{package_name}/{cfg.env.task}"
if num_parallel_envs == 0: if num_parallel_envs == 0:
# non-batched version of the env that returns an observation of shape (c) # non-batched version of the env that returns an observation of shape (c)
env = gym.make(handle, **kwargs) env = gym.make(gym_handle, **kwargs)
else: else:
# batched version of the env that returns an observation of shape (b, c) # batched version of the env that returns an observation of shape (b, c)
env = gym.vector.SyncVectorEnv([lambda: gym.make(handle, **kwargs) for _ in range(num_parallel_envs)]) env = gym.vector.SyncVectorEnv(
[lambda: gym.make(gym_handle, **kwargs) for _ in range(num_parallel_envs)]
)
return env return env

View File

@ -14,9 +14,7 @@ dataset_id: aloha_sim_insertion_human
env: env:
name: aloha name: aloha
handle: AlohaInsertion-v0 task: AlohaInsertion-v0
# TODO(aliberts): replace task with handle
task: insertion
from_pixels: True from_pixels: True
pixels_only: False pixels_only: False
image_size: [3, 480, 640] image_size: [3, 480, 640]

View File

@ -14,9 +14,7 @@ dataset_id: pusht
env: env:
name: pusht name: pusht
handle: PushT-v0 task: PushT-v0
# TODO(aliberts): replace task with handle
task: pusht
from_pixels: True from_pixels: True
pixels_only: False pixels_only: False
image_size: 96 image_size: 96

View File

@ -13,9 +13,7 @@ dataset_id: xarm_lift_medium
env: env:
name: xarm name: xarm
handle: XarmLift-v0 task: XarmLift-v0
# TODO(aliberts): replace task with handle
task: lift
from_pixels: True from_pixels: True
pixels_only: False pixels_only: False
image_size: 84 image_size: 84

View File

@ -162,7 +162,7 @@ def train(cfg: dict, out_dir=None, job_name=None):
logger = Logger(out_dir, job_name, cfg) logger = Logger(out_dir, job_name, cfg)
log_output_dir(out_dir) log_output_dir(out_dir)
logging.info(f"{cfg.env.handle=}") logging.info(f"{cfg.env.task=}")
logging.info(f"{cfg.offline_steps=} ({format_big_number(cfg.offline_steps)})") logging.info(f"{cfg.offline_steps=} ({format_big_number(cfg.offline_steps)})")
logging.info(f"{cfg.online_steps=}") logging.info(f"{cfg.online_steps=}")
logging.info(f"{cfg.env.action_repeat=}") logging.info(f"{cfg.env.action_repeat=}")

View File

@ -14,7 +14,7 @@ from .utils import DEVICE, DEFAULT_CONFIG_PATH
@pytest.mark.parametrize( @pytest.mark.parametrize(
"env_name, handle, obs_type", "env_name, task, obs_type",
[ [
# ("AlohaInsertion-v0", "state"), # ("AlohaInsertion-v0", "state"),
("aloha", "AlohaInsertion-v0", "pixels"), ("aloha", "AlohaInsertion-v0", "pixels"),
@ -29,10 +29,10 @@ from .utils import DEVICE, DEFAULT_CONFIG_PATH
("pusht", "PushT-v0", "pixels_agent_pos"), ("pusht", "PushT-v0", "pixels_agent_pos"),
], ],
) )
def test_env(env_name, handle, obs_type): def test_env(env_name, task, obs_type):
package_name = f"gym_{env_name}" package_name = f"gym_{env_name}"
importlib.import_module(package_name) importlib.import_module(package_name)
env = gym.make(f"{package_name}/{handle}", obs_type=obs_type) env = gym.make(f"{package_name}/{task}", obs_type=obs_type)
check_env(env.unwrapped) check_env(env.unwrapped)