Skip to content

Commit

Permalink
set upper limit on gymnasium version
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre Schumacher committed Oct 16, 2024
1 parent 60f1646 commit 8d41b9a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
10 changes: 5 additions & 5 deletions deprl/custom_distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(
if env_args is not None:
[x.merge_args(env_args) for x in self.environments]
[x.apply_args() for x in self.environments]
self._max_episode_steps = max_episode_steps
self.max_episode_steps = max_episode_steps
self.observation_space = self.environments[0].observation_space
self.action_space = self.environments[0].action_space
self.name = self.environments[0].name
Expand Down Expand Up @@ -85,7 +85,7 @@ def step(self, actions):
muscle = self.environments[i].muscle_states
self.lengths[i] += 1
# Timeouts trigger resets but are not true terminations.
reset = term or self.lengths[i] == self._max_episode_steps
reset = term or self.lengths[i] == self.max_episode_steps
next_observations.append(ob)
rewards.append(rew)
resets.append(reset)
Expand Down Expand Up @@ -138,7 +138,7 @@ def __init__(
self.build_dict = build_dict
self.worker_groups = worker_groups
self.workers_per_group = workers_per_group
self._max_episode_steps = max_episode_steps
self.max_episode_steps = max_episode_steps
self.env_args = env_args
self.header = header

Expand Down Expand Up @@ -171,7 +171,7 @@ def initialize(self, seed):
"output_queue": self.output_queue,
"group_seed": group_seed,
"build_dict": self.build_dict,
"max_episode_steps": self._max_episode_steps,
"max_episode_steps": self.max_episode_steps,
"index": i,
"workers": self.workers_per_group,
"env_args": self.env_args
Expand Down Expand Up @@ -267,7 +267,7 @@ def distribute(
if "header" in tonic_conf:
exec(tonic_conf["header"])
dummy_environment = build_env_from_dict(build_dict)
max_episode_steps = dummy_environment._max_episode_steps
max_episode_steps = dummy_environment.max_episode_steps
del dummy_environment

if parallel < 2:
Expand Down
2 changes: 1 addition & 1 deletion deprl/env_wrappers/dm_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def muscle_activity(self):
return self.unwrapped.environment.physics.data.act

@property
def _max_episode_steps(self):
def max_episode_steps(self):
return self.unwrapped.max_episode_steps


Expand Down
2 changes: 1 addition & 1 deletion deprl/env_wrappers/gym_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def muscle_activity(self):
return self.unwrapped.sim.data.act

@property
def _max_episode_steps(self):
def max_episode_steps(self):
if hasattr(self.unwrapped, "max_episode_steps"):
return self.unwrapped.max_episode_steps
else:
Expand Down
6 changes: 2 additions & 4 deletions deprl/vendor/tonic/environments/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,10 @@ def build_environment(

# Get the default time limit.
if max_episode_steps == "default":
if hasattr(environment, "_max_episode_steps"):
max_episode_steps = environment._max_episode_steps
if hasattr(environment, "max_episode_steps"):
max_episode_steps = environment.max_episode_steps
elif hasattr(environment, "horizon"):
max_episode_steps = environment.horizon
elif hasattr(environment, "max_episode_steps"):
max_episode_steps = environment.max_episode_steps

else:
logger.log("No max episode steps found, setting them to 1000")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ numpy = "^1.22.4"
termcolor = "^2.2.0"
pandas = "^2.0.1"
gdown = "^5.1.0"
gymnasium = "*"
gymnasium = "<=0.30"
wandb = "^0.15.4"
# torch = {version="2.1.0", source="pytorch-cpu"}
torch = ">=2.1.0"
Expand Down

0 comments on commit 8d41b9a

Please sign in to comment.