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

Adds the ability to manually override _target_ in builds #597

Merged
merged 4 commits into from Nov 24, 2023
Merged

Conversation

rsokl
Copy link
Contributor

@rsokl rsokl commented Nov 24, 2023

E.g., here we use foo as a target and lift the parameters from its signature, but then specify the _target_ to actually instantiate bar:

from hydra_zen import builds, instantiate, to_yaml

def pyaml(x):
    print(to_yaml(x))

def foo(x=1, y=2):
    ...

def bar(**kw):
    return f"bar({kw=})"

Conf = builds(
    foo,
    populate_full_signature=True,
    zen_dataclass={"target": "__main__.bar"},
)

pyaml(Conf)
instantiate(Conf)
_target_: __main__.bar
x: 1
'y': 2

"bar(kw={'x': 1, 'y': 2})"

@rsokl rsokl added this to the v0.12.0 milestone Nov 24, 2023
@rsokl rsokl merged commit d553757 into main Nov 24, 2023
18 checks passed
@rsokl rsokl deleted the manual-target branch November 24, 2023 16:27
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

Successfully merging this pull request may close these issues.

None yet

1 participant