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

Update "child" params when "parent" params are modified #59

Open
andretag opened this issue Aug 1, 2023 · 0 comments
Open

Update "child" params when "parent" params are modified #59

andretag opened this issue Aug 1, 2023 · 0 comments

Comments

@andretag
Copy link

andretag commented Aug 1, 2023

Thank you for your great software! I often find myself needing a pattern where I define some "child" parameter that depends on other "parent" parameters; is it possible/is there a way to ensure that a "child" parameter (e.g., B) that depends on other parameters (e.g., A) gets updated when the "parent" parameter (A) is updated?

For example:

# in config.py
from yacs.config import CfgNode as CN
_C  = CN()

_C.A = 1.0
_C.B = 2.0*_C.A
cfg = _C
# in main.py
from config import cfg

if __name__ == "__main__":
  cfg.merge_from_list(["A", 3.0])
  cfg.B # <-------- Expected 6.0, it is 2.0

Thanks,
Andrea

@andretag andretag changed the title Allow for params update Update "child" params when "parent" params are modified Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant