diff --git a/parakeet/utils/conf.py b/parakeet/utils/conf.py deleted file mode 100644 index 3e9eb7b..0000000 --- a/parakeet/utils/conf.py +++ /dev/null @@ -1,48 +0,0 @@ -import attrdict -import flatdict -import argparse -import yaml - - -class Config(attrdict.AttrDict): - def dump(self, path): - with open(path, 'wt') as f: - yaml.safe_dump(dict(self), f, default_flow_style=None) - - def dumps(self): - return yaml.safe_dump(dict(self), default_flow_style=None) - - @classmethod - def from_file(cls, path): - with open(path, 'rt') as f: - c = yaml.safe_load(f) - return cls(c) - - def merge_file(self, path): - with open(path, 'rt') as f: - other = yaml.safe_load(f) - self.update(self + other) - - def merge_args(self, args): - args_dict = vars(args) - args_dict.pop("config") # exclude config file path - 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() - self.update(self + nested_dict) - - def merge(self, other): - self.update(self + other) - - def flatten(self): - flat = flatdict.FlatDict(self, delimiter='.') - return flat - - def add_options_to_parser(self, parser): - parser.add_argument( - "--config", type=str, - help="extra config file to override the default config") - flat = self.flatten() - g = parser.add_argument_group("config file options") - for k, v in flat.items(): - g.add_argument("--{}".format(k), type=type(v), - help="config file option: {}".format(k)) \ No newline at end of file diff --git a/setup.py b/setup.py index bc1ff1d..3fd99ad 100644 --- a/setup.py +++ b/setup.py @@ -66,7 +66,8 @@ setup_info = dict( 'llvmlite==0.31.0', 'opencc', 'g2p_en', - 'g2pM' + 'g2pM', + 'yacs', ], # Package info