Hello,
During the training my costume environment in gym with Rllib(new API Stack) I get this error and couldn’t solve it up to now I have defined my observations as Dictionary. It works well by old API Stack but not with new one. It completely blocks me to go forward. In order to have a better and simpler understanding I started to train the example in Rllib github in below link:
Unfortunately I get the same error. as clarification I define the config as below :
config = (
PPOConfig()
.api_stack(
enable_rl_module_and_learner=True,
enable_env_runner_and_connector_v2=True,
)
.environment(
env=“CartPoleWithDictObservationSpace”,
)
.training(
lr = agent_params[“lr”], # Learning rate
entropy_coeff= agent_params[“entropy_coeff”], # Encourage exploration with entropy regularization
)
.env_runners(num_env_runners = agent_params[“num_env”]) # Number of parallel environments
.framework(“torch”)
Hi Christina ,
firstly , thanks for your reply.
yes, I’ve seen that lots of times. As you see I arranged the rlmodule according the new API’s arrangement and also warning deprecation. I think New API module can not handle the dictionary observation. Actually I couldn’t find some resources for training the agent with dict observation and New API stack . For some reasons I need to define my observations as dictionary and I’m eager to train it with new API stack. I would be so appreciable if you give me some hints or resources to address the issue more direct.
Thanks
Hello @sven1977
is there any update? As I’m working on another issue related to masking some actions, something as below :
it uses Dict observations again. The example explains that is suitable just to train with Old API stack .Because I don’t want to use Old API stack, I’ve been blocked again!!
@sven1977
Ah.., Nice,
could you please take a look at example for train(or tune) the observation as dictionary(DictObservationSpace) with New API stack?
@Ali_Zargarian , I don’t understand what you mean exactly. Could you elaborate? The observation_space in action masking is always dictionary. Do you mean using a dictionary observation space under the observations key?
Hi @Lars_Simon_Zehnder ,
I tried to use a dictionary observation space under the observations key , but I get this error :
(PPO pid=10788) ValueError: This RLModule requires the environment to provide a gym.spaces.Dict observation space of the form: [repeated 2x across cluster]
(PPO pid=10788) {‘action_mask’: Box(0.0, 1.0, shape=(self.action_space.n,)), ‘observation_space’: self.observation_space} [repeated 2x across cluster]
in spite of I get this when I print observation_space’s type :
<class ‘gymnasium.spaces.dict.Dict’>
I only skimmed trough your topic. If it is the same warning message I am aware of you can safely ignore it. Currently there will always be a deprecation warning for the very first RLModuleConfig config created.
There still exists deprecated code that creates a self.config = RLModuleConfig(... from your new stack options for backwards compatibility, this instantiation throws the error
I wrote myself a snippet to run before my code to suppress this misleading warning
from ray.rllib.utils.deprecation import logger as __deprecation_logger
# This suppresses a deprecation warning from RLModuleConfig
__old_level = __deprecation_logger.getEffectiveLevel()
__deprecation_logger.setLevel(logging.ERROR)
RLModuleConfig()
__deprecation_logger.setLevel(__old_level)
del __deprecation_logger
Try if that hides the error. To be sure run it with a debugger and find the location, it could be a false postive and unrelated to your code.