INNER CODE UNIT · Python
load
CogStack/OpenGPT · opengpt/config.py:40
def load(cls, save_path):
config = cls(to_box=False)
# Read the jsonpickle string
with open(save_path) as f:
config_dict = jsonpickle.decode(f.read())
config.merge_config(config_dict)
config._to_box()
return config
def merge_config(self, config_dict):
r''' Merge a config_dict with the existing config object.
Args:
config_dict (`dict`):
A dictionary which key/values should be added to this class.
'''
for key in config_dict.keys():
if key in self.__dict__ and isinstance(self.__dict__[key], dict):
self.__dict__[key].update(config_dict[key])