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

Change behavior of pop-full-sig to take priority over inherited fields #174

Merged
merged 2 commits into from
Dec 3, 2021

Conversation

rsokl
Copy link
Contributor

@rsokl rsokl commented Dec 3, 2021

This PR changes the behavior of builds when populate_full_signature=True and one or more base-classes are specified for inheritance. Note that this a compatibility-breaking change. Although the old behavior was likely not what one wanted/expected.

Previously, fields specified by the parent class would take priority over those that would be auto-populated:

from hydra_zen import builds, make_config
    
def f(x=1):
    pass

Parent = make_config(x="hi")

Before

>>> builds(f, populate_full_signature=True, builds_bases=(Parent,))  # x comes from parent
Builds_f(x='hi', _target_='__main__.f')

>>> builds(f, x=1, builds_bases=(Parent,))() 
Builds_f(x=1, _target_='__main__.f')

However, this behavior is unintuitive, as populate_full_signature=True should behave identically as the case where one manually-specifies the arguments from a target's signature. Thus we have have changed this behavior such that auto-populating and manually-populating fields from a signature always produces the same behavior:

After

>>> builds(f, populate_full_signature=True, builds_bases=(Parent,))  # parent no longer takes priority
Builds_f(x=1, _target_='__main__.f')

>>> builds(f, x=1, builds_bases=(Parent,))() 
Builds_f(x=1, _target_='__main__.f')

@rsokl rsokl added the enhancement New feature or request label Dec 3, 2021
@rsokl rsokl added this to the hydra-zen 0.4.0 milestone Dec 3, 2021
@rsokl rsokl merged commit 931fc4f into main Dec 3, 2021
@rsokl rsokl deleted the pop-sig-behavior branch December 3, 2021 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant