Skip to main content

decorators.datalayer

Decorators to execute functions in a Datalayer runtimes.

datalayer

def datalayer(runtime_name: CallableOrOptionalString = None,
environment: str = DEFAULT_ENVIRONMENT,
inputs: Optional[list[str]] = None,
output: Optional[str] = None,
snapshot_name: Optional[str] = None,
token: Optional[str] = None,
debug: bool = True,
timeout: Seconds = 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 code sandbox snapshot to use. token : str, optional Authentication token. If not provided, will be resolved from env/keyring. 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