fix a bug in config
This commit is contained in:
parent
2ed26d3416
commit
598d813908
parakeet/utils
|
@ -21,17 +21,17 @@ class Config(attrdict.AttrDict):
|
||||||
def merge_file(self, path):
|
def merge_file(self, path):
|
||||||
with open(path, 'rt') as f:
|
with open(path, 'rt') as f:
|
||||||
other = yaml.safe_load(f)
|
other = yaml.safe_load(f)
|
||||||
self.update(other)
|
self.update(self + other)
|
||||||
|
|
||||||
def merge_args(self, args):
|
def merge_args(self, args):
|
||||||
args_dict = vars(args)
|
args_dict = vars(args)
|
||||||
args_dict.pop("config") # exclude config file path
|
args_dict.pop("config") # exclude config file path
|
||||||
args_dict = {k: v for k, v in args_dict.items() if v is not None}
|
args_dict = {k: v for k, v in args_dict.items() if v is not None}
|
||||||
nested_dict = flatdict.FlatDict(args_dict, delimiter=".").as_dict()
|
nested_dict = flatdict.FlatDict(args_dict, delimiter=".").as_dict()
|
||||||
self.update(nested_dict)
|
self.update(self + nested_dict)
|
||||||
|
|
||||||
def merge(self, other):
|
def merge(self, other):
|
||||||
self.update(other)
|
self.update(self + other)
|
||||||
|
|
||||||
def flatten(self):
|
def flatten(self):
|
||||||
flat = flatdict.FlatDict(self, delimiter='.')
|
flat = flatdict.FlatDict(self, delimiter='.')
|
||||||
|
|
Loading…
Reference in New Issue