Coverage for /usr/local/lib/python3.12/site-packages/prefect/assets/materialize.py: 50%
16 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-05 10:48 +0000
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-05 10:48 +0000
1from __future__ import annotations 1a
3from typing import TYPE_CHECKING, Callable, TypeVar, Union 1a
5from typing_extensions import ParamSpec, Unpack 1a
7from .core import Asset 1a
9T = TypeVar("T") 1a
10P = ParamSpec("P") 1a
11R = TypeVar("R") 1a
13if TYPE_CHECKING: 13 ↛ 14line 13 didn't jump to line 14 because the condition on line 13 was never true1a
14 from prefect.tasks import MaterializingTask, TaskOptions
17def materialize( 1a
18 *assets: Union[str, Asset],
19 by: str | None = None,
20 **task_kwargs: Unpack[TaskOptions],
21) -> Callable[[Callable[P, R]], MaterializingTask[P, R]]:
22 """
23 Decorator for materializing assets.
25 Args:
26 *assets: Assets to materialize
27 by: An optional tool that is ultimately responsible for materializing the asset e.g. "dbt" or "spark"
28 **task_kwargs: Additional task configuration
29 """
30 if not assets:
31 raise TypeError(
32 "materialize requires at least one asset argument, e.g. `@materialize(asset)`"
33 )
35 from prefect.tasks import MaterializingTask
37 def decorator(fn: Callable[P, R]) -> MaterializingTask[P, R]:
38 return MaterializingTask(
39 fn=fn, assets=assets, materialized_by=by, **task_kwargs
40 )
42 return decorator