hydra_zen.wrapper.default_to_config#
- hydra_zen.wrapper.default_to_config(target, CustomBuildsFn=<class 'hydra_zen.structured_configs._implementations.DefaultBuilds'>, **kw)[source]#
Creates a config that describes
target
.This function is designed to selectively apply
hydra_zen.builds
orhydra_zen.just
in a way that permits maximum compatibility with common inputs tohydra_zen.ZenStore
. It behavior can be summarized based on the type oftarget
OmegaConf containers and dataclass instances are returned unchanged
A dataclass type is processed as
builds(target, **kw, populate_full_signature=True, builds_bases=(target,))
Lists and dictionaries are processed by
hydra_zen.just
All other inputs are processed as
builds(target, **kw, populate_full_signature=True)
- Parameters:
- targetCallable[…, Any] | DataClass | Type[DataClass] | list | dict
- CustomBuildsFnType[BuildsFn[Any]], optional (default=DefaultBuilds)
Provides the config-creation functions (
builds
,just
) used by this function.- **kwAny
Keyword arguments to be passed to
builds
.
- Returns:
- target_configDataClass | Type[DataClass] | list | dict
Examples
Lists and dictionaries
>>> from hydra_zen.wrapper import default_to_config >>> default_to_config([1, {"z": 2+2j}]) [1, {'z': ConfigComplex(real=2.0, imag=2.0, _target_='builtins.complex')}]
Dataclass types
>>> from dataclasses import dataclass >>> >>> @dataclass ... class A: ... x: int ... y: int
>>> Builds_A = default_to_config(A, y=22) >>> Builds_A(x=1) Builds_A(x=1, y=22, _target_='__main__.A') >>> issubclass(Builds_A, A) True
A function