language.task
def task(fn: typing.Any = None, schema: type | None = None) -> typing.AnyHydra app task decorator (task **B8**).
Marks a callable as a *task function*: a function that accepts a resolved
:class:`~omegaconf.DictConfig` and receives its configuration fields as
type-instantiated keyword arguments. Only the fields whose names match
declared parameters are extracted and instantiated; the rest are ignored.
This is the inverse of :func:`laco.language.call` — instead of building
a config node from a callable, it unpacks a config node back into a
callable invocation.
Usage::
@L.task
def train(model: nn.Module, optimizer: functools.partial, epochs: int = 10):
for _ in range(epochs):
...
# Combine with laco.main:
@laco.main(config_name="train")
@L.task
def train(...): ...
Parameters
| Name | Type | Description |
|---|---|---|
| fn = None | callable | When used as ``@L.task`` (bare), the decorated callable is passed here. When used as ``@L.task(schema=MySchema)``, ``fn`` is ``None`` and a decorator factory is returned. |
| schema = None | type | Static annotation for the config schema type. Not enforced at runtime; used only for type-checker hints. |
Source: laco/language.py:1532