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

Crash if non dict variables are overwritten with dict values in configs. #325

Closed
mschuwalow opened this issue Jun 24, 2018 · 0 comments
Closed

Comments

@mschuwalow
Copy link

mschuwalow commented Jun 24, 2018

Sacred 0.74 crashes if a non dictionary variable is defined in a config and later overwritten by a dictionary variable in another config.

This works:
##################################################################
from sacred import Experiment

ex = Experiment('hello_config')

@ex.config
def rude():
recipient = "bastard"
message = "Fuck off you {}!".format(recipient)
test_var = {}

@ex.config
def cfg(test_var):
test_var = {'1': 1}
recipient = "world"
message = "Hello {}!".format(recipient)

@ex.automain
def main(message):
print(name)
print(message)
#######################################################

And this doesn't:
########################################################
from sacred import Experiment

ex = Experiment('hello_config')

@ex.config
def rude():
recipient = "bastard"
message = "Fuck off you {}!".format(recipient)
test_var = 1

@ex.config
def cfg(test_var):
test_var = {'1': 1}
recipient = "world"
message = "Hello {}!".format(recipient)

@ex.automain
def main(message):
print(name)
print(message)
########################################################

The cause seems to be at

def recursive_fill_in(config, preset):
for key in preset:
if key not in config:
config[key] = preset[key]
elif isinstance(config[key], dict):
recursive_fill_in(config[key], preset[key])
.

thomasjpfan added a commit to thomasjpfan/sacred that referenced this issue Jul 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant