Functional¶
Sorry, the person who is responsible for the description was eaten by hydras last week.
- hydra_slayer.functional.get_factory(name_or_object: Union[str, hydra_slayer.functional.T]) Union[Type, Callable[[...], Any], hydra_slayer.functional.T] [source]¶
Retrieves factory, without creating any objects with it.
- Parameters
name_or_object – factory name or any valid python object
- Returns
factory
- Raises
LookupError – if no factory with provided name was registered
Examples
>>> to_int = get_factory("int") >>> to_int("42") 42
- hydra_slayer.functional.get_from_params(*, shared_params: Optional[Dict[str, Any]] = None, **kwargs) Any [source]¶
Creates instance based in configuration dict with
instantiation_fn
.Note
The name of the factory to use should be provided by
'_target_'
keyword.- Parameters
shared_params – params to pass on all levels in case of recursive creation
**kwargs – named parameters for factory
- Returns
result of calling
instantiate_fn(factory, **sub_kwargs)
Examples
>>> get_from_params(_target_="torch.nn.Linear", in_features=20, out_features=30) Linear(in_features=20, out_features=30, bias=True)
- hydra_slayer.functional.get_instance(*args, **kwargs) Any [source]¶
Creates instance by calling specified factory with
instantiate_fn
.Note
The name of the factory to use should be provided as the first argument or directly by
'_target_'
keyword.- Parameters
*args – positional arguments to pass to the factory
**kwargs – named parameters to pass to the factory
- Returns
created instance
Examples
>>> get_instance(int, "42", base=10) 42