datalayer
Decorators to execute functions in a Datalayer runtimes.
def datalayer(runtime_name: Callable[..., Any] | str | None = None, environment: str = 'python-cpu-env', inputs: list[str] | None = None, output: str | None = None, snapshot_name: str | None = None, debug: bool = True, timeout: float = 10.0) -> Any
Decorator to execute a function in a Datalayer runtime.
Parameters
-
runtime_name : str, optional
The name of the runtime to use. If not provided, a default runtime will be used.
-
environment : str, optional
The name of the environment to use. If not provided, a default environment will be used.
-
inputs : list[str], optional
A list of input variable names for the function.
-
output : str, optional
The name of the output variable for the function.
-
snapshot_name : str, optional
The name of the runtime snapshot to use.
-
debug : bool
Whether to enable debug mode. If
True, the output and error streams will be printed. -
timeout : Seconds
Timeout for the execution.
Returns
-
Callable[..., Any]
A decorator that wraps the function to be executed in a Datalayer runtime.
Examples
from datalayer_core.client.decorators import datalayer
@datalayer
def example(x: float, y: float) -> float:
return x + y
from datalayer_core.client.decorators import datalayer
@datalayer(runtime_name="example-runtime", inputs=["x", "y"], output="z")
def example(x: float, y: float) -> float:
return x + y