INNER CODE UNIT · Python
save
CogStack/OpenGPT · opengpt/config.py:22
def save(self, save_path=None):
r''' Save the config into a .json file
Args:
save_path (`str`):
Where to save the created json file, if nothing we use the default from paths.
'''
if save_path is None:
save_path = self.path.self
# We want to save the dict here, not the whole class
self._from_box()
json_string = jsonpickle.encode({k:v for k,v in self.__dict__.items() if k != 'path'})
with open(save_path, 'w') as f:
f.write(json_string)
self._to_box()
@classmethod