hydra.overlay.python.tools module
Tools for Hydra.
- hydra.overlay.python.tools.primitive(func: Callable[[A], B]) Callable[[TypedTerm[A]], TypedTerm[B]]
- hydra.overlay.python.tools.primitive(*, name: str | None = None, namespace: str | None = None) Callable[[Callable[[A], B]], Callable[[TypedTerm[A]], TypedTerm[B]]]
Lift a regular Python function to a Hydra DSL primitive.
- Takes a function like:
- def to_lower(s: str) -> str:
return s.lower()
- And transforms it into:
- def to_lower(s: TypedTerm[str]) -> TypedTerm[str]:
return primitive1(to_lower_name, s)
- Parameters:
func (Callable[[A], B] | None) – The function to lift.
name (str | None) – The name of the primitive.
namespace (str | None) – The namespace of the primitive.
- Return type:
Either the lifted function directly or a decorator function.