INNER CODE UNIT · Python
_from_box
CogStack/OpenGPT · opengpt/config.py:16
def _from_box(self):
# Convert all dicts to boxes
for key, val in self.__dict__.items():
if isinstance(val, Box):
self.__setattr__(key, val.to_dict())
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'})