Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix for yaml dump due to the Argument class #358

Merged
merged 3 commits into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion federatedscope/core/auxiliaries/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,9 @@ def init_wandb(cfg):
tmp_cfg = copy.deepcopy(cfg)
if tmp_cfg.is_frozen():
tmp_cfg.defrost()
tmp_cfg.clear_check_funcs(
tmp_cfg.clear_aux_info(
) # in most cases, no need to save the cfg_check_funcs via wandb
tmp_cfg.de_arguments()
import yaml
cfg_yaml = yaml.safe_load(tmp_cfg.dump())

Expand Down
22 changes: 16 additions & 6 deletions federatedscope/core/configs/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,22 @@ def __getattr__(self, name):
else:
raise AttributeError(name)

def clear_check_funcs(self):
self.__cfg_check_funcs__.clear()
def __delattr__(self, name):
if name in self:
del self[name]
else:
raise AttributeError(name)

def clear_help_info(self):
self.__help_info__.clear()
def clear_aux_info(self):
if hasattr(self, "__cfg_check_funcs__"):
delattr(self, "__cfg_check_funcs__")
if hasattr(self, "__help_info__"):
delattr(self, "__help_info__")
if hasattr(self, "is_ready_for_run"):
delattr(self, "is_ready_for_run")
for v in self.values():
if isinstance(v, CN):
v.clear_aux_info()

def print_help(self, arg_name=""):
"""
Expand Down Expand Up @@ -197,8 +208,7 @@ def freeze(self, inform=True, save=True, check_cfg=True):
from contextlib import redirect_stdout
with redirect_stdout(outfile):
tmp_cfg = copy.deepcopy(self)
tmp_cfg.clear_check_funcs()
tmp_cfg.clear_help_info()
tmp_cfg.clear_aux_info()
print(tmp_cfg.dump())
if self.wandb.use:
# update the frozen config
Expand Down