Skip to content

Commit

Permalink
don't print __is_set for recursive objects (#1573)
Browse files Browse the repository at this point in the history
  • Loading branch information
ifrit98 authored Nov 15, 2023
1 parent 91449d7 commit 8133a07
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions bittensor/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,22 @@ def __deepcopy__(self, memo) -> "config":
def __repr__(self) -> str:
return self.__str__()

def _remove_private_keys(self, d):
if "__parser" in d:
d.pop("__parser", None)
if "__is_set" in d:
d.pop("__is_set", None)
for k, v in list(d.items()):
if isinstance(v, dict):
self._remove_private_keys(v)
return d

def __str__(self) -> str:
# remove the parser and is_set map from the visible config
visible = self.toDict()
visible.pop("__parser", None)
visible.pop("__is_set", None)
return "\n" + yaml.dump(visible)
cleaned = self.remove_private_keys(visible)
return "\n" + yaml.dump(cleaned, sort_keys=False)

def copy(self) -> "config":
return copy.deepcopy(self)
Expand Down

0 comments on commit 8133a07

Please sign in to comment.