automl / labwatch

An extension to Sacred for automated hyperparameter optimization.
59 stars 19 forks source link

assert Fallback raises error #15

Closed totifra closed 6 years ago

totifra commented 6 years ago

Hi there!

I am currently testing labwatch to do some hyperparamater optimization. Unfortunately I get an error due to a non-empty fallback dict thrown in line 196 of assistant.py.

When the create_run() of initialize.py is executed, the scaffold in line 363 calls gather_fallback() and hence setting self.fallback to a dict including the root logger. This will be passed to the _search_space_wrapper() (line 172 in assistant.py) leading to this error. It seems to me that there is no way to end up at line 196 of assistant.py with an empty fallback dict or fallback=None.

Does anybody have an idea if this is an bug or am I doing something wrong?

Cheers Thomas

LucasAnders1 commented 6 years ago

I got the same error when I tried to install RoBo:

File "/usr/local/lib/python3.6/site-packages/sacred/experiment.py", line 137, in automain
    self.run_commandline()
  File "/usr/local/lib/python3.6/site-packages/sacred/experiment.py", line 260, in run_commandline
    return self.run(cmd_name, config_updates, named_configs, {}, args)
  File "/usr/local/lib/python3.6/site-packages/sacred/experiment.py", line 208, in run
    meta_info, options)
  File "/usr/local/lib/python3.6/site-packages/sacred/experiment.py", line 433, in _create_run
    None))
  File "/usr/local/lib/python3.6/site-packages/sacred/initialize.py", line 368, in create_run
    ncfg_updates = scaff.run_named_config(cfg_name)
  File "/usr/local/lib/python3.6/site-packages/sacred/initialize.py", line 92, in run_named_config
    fallback=self.fallback)
  File "/usr/local/lib/python3.6/site-packages/labwatch/assistant.py", line 196, in _search_space_wrapper
    assert not fallback, "{}".format(fallback)
AssertionError: {'_log': <RootLogger root (INFO)>}

@totifra Did you find a solution yet?

shocho3858 commented 6 years ago

same problem in running "branin.py" example.

File "/home/anaconda3/lib/python3.6/site-packages/labwatch/assistant.py", line 196, in _search_space_wrapper

assert not fallback, "{}".format(fallback) AssertionError: {'_log': <RootLogger root (INFO)>}

totifra commented 6 years ago

@LucasAnders1 I just commented/removed line 196 of assistant.py. Then everything seems to works. I am not sure if this is on behalf of the developers, but there is no way to pass this assertion in line 196 since the fallback dict always contains the key "_log" with value self.logger. Hence I removed the assert statement.

I guess the following change in sacred is the reason for this error: https://github.com/IDSIA/sacred/commit/5abcfbb45cc6362d75d61e1b6eef4e0261cf239e

@Qwlouse I do not understand the idea of the fallback attribute. Why does it have to contain the self.logger? I guess I am not familiar with the idea of a "fallback" here.

Qwlouse commented 6 years ago

@totifra The fallback contains arguments that can be accepted and thus accessed by the config scope, but by default will not be part of the final configuration. So you can do this:

@ex.config
def my_config(_log):
    a = 10
    _log.info('Hi!')

and the configuration will only contain a (and seed).

SearchSpaces work by mimicking ConfigScopes and so they need to adhere to the same interface. I guess that assert was just a way to catch problems with cases where the fallback was actually used, so it might be safe to remove.

totifra commented 6 years ago

@Qwlouse Thanks for your response and your valuation.