ugly fix: dont traverse dots in sweep config

This commit is contained in:
Dominik Moritz Roth 2023-07-27 13:07:18 +02:00
parent e926714275
commit 15381955fa

View File

@ -78,17 +78,22 @@ class Slate():
return doc, stack
raise Exception(f'Unable to find experiment <{name}> in <{filename}>')
def deep_update(self, d, u):
def deep_update(self, d, u, traverse_dot_notation=True):
for kstr, v in u.items():
ks = kstr.split('.')
if traverse_dot_notation:
ks = kstr.split('.')
else:
ks = [kstr]
head = d
for k in ks:
if k in ['parameters']:
traverse_dot_notation = False
last_head = head
if k not in head:
head[k] = {}
head = head[k]
if isinstance(v, collections.abc.Mapping):
last_head[ks[-1]] = self.deep_update(d.get(k, {}), v)
last_head[ks[-1]] = self.deep_update(d.get(k, {}), v, traverse_dot_notation=traverse_dot_notation)
else:
last_head[ks[-1]] = v
return d