How to pass arbitrary dict like kwargs in config without warnings
nidnesandne opened this issue · 4 comments
When I define kwargs in config as follows and overwrite it in named_config, I get warnings.
@ex.config
def default_config():
env_id = "CartPole-v1"
n_envs = 1
rl_kwargs = {
"n_steps": 100,
}
@ex.named_config
def custom1():
env_id = "MountainCar-v0"
n_envs = 8
rl_kwargs = {
"n_steps": 1000,
"n_epochs": 10,
}
$ test.py with custom1
WARNING - root - Added new config entry: "rl_kwargs.n_epochs"
I appreciate the warnings when there are variables that I forgot to define in the config.
However, in the case of an arbitrary dict like this one, I don't want to display the warnings.
Is there any way to suppress them?
There is no way to silence just these warnings. They are hard-coded. You could disable all logging output using the logging
module
Thank you for your prompt reply.
So how is it correct to configure for such a use case?
Should we not use kwargs as config variables, and should we define the config individually for each algorithm using Ingredient?
That is a very good question and I myself had this issue a few times already. I simply ignored the warnings. I think an ingredient wouldn't solve the issue since you can't choose which ingredient to use based on the configuration. So you would just move the problem into the ingredient.
Here's another way how you could do it, but this breaks tracking of config changes:
@ex.config
def default_config():
env_id = "CartPole-v1"
if env_id == "CartPole-v1":
n_envs = 1
rl_kwargs = {
"n_steps": 100,
}
elif env_id == "MountainCar-v0":
n_envs = 8
rl_kwargs = {
"n_steps": 1000,
"n_epochs": 10,
}
(This was something that I hoped would change a few years back, when the original maintainer planned a rewrite of the configuration engined, which then never happened.)
I see... It looks like there is no ideal solution. Then I will ignore the warning too.
Thanks.