Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gym/rllib] Migrate from ray[rllib]==2.5.0 to 2.9.*. #739

Merged
merged 7 commits into from
Mar 15, 2024
Next Next commit
[gym/common] Minor refactoring.
  • Loading branch information
duburcqa committed Mar 12, 2024
commit eb223569d6938840e9b49943bed8ddee3073e4ab
52 changes: 28 additions & 24 deletions python/gym_jiminy/common/gym_jiminy/common/bases/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,12 +397,12 @@ def __init__(self,
else:
observation['measurement'] = base_observation
if (state := self.observer.get_state()) is not None:
observation.setdefault(
'states', OrderedDict())[ # type: ignore[index]
self.observer.name] = state
observation.setdefault(
'features', OrderedDict())[ # type: ignore[index]
self.observer.name] = self.observer.observation
states = observation.setdefault('states', OrderedDict())
assert isinstance(states, dict)
states[self.observer.name] = state
features = observation.setdefault('features', OrderedDict())
assert isinstance(features, dict)
features[self.observer.name] = self.observer.observation
self.observation = cast(NestedObsT, observation)

# Register the observer's internal state and feature to the telemetry
Expand Down Expand Up @@ -447,12 +447,14 @@ def _initialize_observation_space(self) -> None:
else:
observation_space['measurement'] = base_observation_space
if self.observer.state_space is not None:
observation_space.setdefault( # type: ignore[index]
'states', gym.spaces.Dict())[
self.observer.name] = self.observer.state_space
observation_space.setdefault( # type: ignore[index]
'features', gym.spaces.Dict())[
self.observer.name] = self.observer.observation_space
state_spaces = observation_space.setdefault(
'states', gym.spaces.Dict())
assert isinstance(state_spaces, MutableMapping)
state_spaces[self.observer.name] = self.observer.state_space
feature_spaces = observation_space.setdefault(
'features', gym.spaces.Dict())
assert isinstance(feature_spaces, MutableMapping)
feature_spaces[self.observer.name] = self.observer.observation_space
self.observation_space = gym.spaces.Dict(observation_space)

def refresh_observation(self, measurement: EngineObsType) -> None:
Expand Down Expand Up @@ -614,13 +616,13 @@ def __init__(self,
else:
observation['measurement'] = base_observation
if (state := self.controller.get_state()) is not None:
observation.setdefault(
'states', OrderedDict())[ # type: ignore[index]
self.controller.name] = state
states = observation.setdefault('states', OrderedDict())
assert isinstance(states, dict)
states[self.controller.name] = state
if self.augment_observation:
observation.setdefault(
'actions', OrderedDict())[ # type: ignore[index]
self.controller.name] = self.action
actions = observation.setdefault('actions', OrderedDict())
assert isinstance(actions, dict)
actions[self.controller.name] = self.action
self.observation = cast(NestedObsT, observation)

# Register the controller's internal state and target to the telemetry
Expand Down Expand Up @@ -671,13 +673,15 @@ def _initialize_observation_space(self) -> None:
else:
observation_space['measurement'] = base_observation_space
if self.controller.state_space is not None:
observation_space.setdefault( # type: ignore[index]
'states', gym.spaces.Dict())[
self.controller.name] = self.controller.state_space
state_spaces = observation_space.setdefault(
'states', gym.spaces.Dict())
assert isinstance(state_spaces, MutableMapping)
state_spaces[self.controller.name] = self.controller.state_space
if self.augment_observation:
observation_space.setdefault( # type: ignore[index]
'actions', gym.spaces.Dict())[
self.controller.name] = self.controller.action_space
action_spaces = observation_space.setdefault(
'actions', gym.spaces.Dict())
assert isinstance(action_spaces, MutableMapping)
action_spaces[self.controller.name] = self.controller.action_space
self.observation_space = gym.spaces.Dict(observation_space)

def refresh_observation(self, measurement: EngineObsType) -> None:
Expand Down