You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Exception originated from within Sacred. KeyError: 'Invalid key "DogmaticDict.__setitem__". Config-keys cannot contain "." or start with "$"' #920
When i debug until the line of @ex.automain, the error was raised as follows.
Exception originated from within Sacred.
Traceback (most recent calls):
File "/root/anaconda3/lib/python3.10/site-packages/sacred/config/utils.py", line 42, in assert_is_valid_key
raise KeyError(
KeyError: 'Invalid key "DogmaticDict.setitem". Config-keys cannot contain "." or start with "$"'
I find the error happen in line 42, in assert_is_valid_key
def assert_is_valid_key(key):
if SETTINGS.CONFIG.ENFORCE_KEYS_MONGO_COMPATIBLE and (
isinstance(key, str) and ("." in key or key[0] == "$")
):
raise KeyError(
'Invalid key "{}". Config-keys cannot '
'contain "." or start with "$"'.format(key)
)
And the key is defined as:
def normalize_or_die(obj):
if isinstance(obj, dict):
res = dict()
for key, value in obj.items():
assert_is_valid_key(key)
res[key] = normalize_or_die(value)
return res
elif isinstance(obj, (list, tuple)):
return list([normalize_or_die(value) for value in obj])
return normalize_numpy(obj)
But i cannot find the definition of obj. And I cannot find any solution online.
Hey @Wznnnnn! I just copied your config and added a simple main function. It works for me, I don't see the error. Can you provide a smaller example that reproduces the error?
It could also be related to the way you call the script. Another reason could be a debugger, which sometimes injects symbols into the local namespace. Weird things can happen if you add a breakpoint in a config scope.
Activity
thequilo commentedon Aug 29, 2023
Hey! What does your config look like?
Wznnnnn commentedon Jun 8, 2024
@thequilo
Hey!the same problem
My config is as follow:
thequilo commentedon Jun 10, 2024
Hey @Wznnnnn! I just copied your config and added a simple main function. It works for me, I don't see the error. Can you provide a smaller example that reproduces the error?
It could also be related to the way you call the script. Another reason could be a debugger, which sometimes injects symbols into the local namespace. Weird things can happen if you add a breakpoint in a config scope.