Skip to main content

decorators

Decorators to execute functions in a Datalayer runtimes.

def datalayer(runtime_name: Union[Callable[..., Any], str, NoneType] = None, environment: str = 'python-cpu-env', inputs: Optional[list[str]] = None, output: Optional[str] = None, snapshot_name: Optional[str] = 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.sdk.decorators import datalayer
@datalayer
def example(x: float, y: float) -> float:
return x + y
from datalayer_core.sdk.decorators import datalayer
@datalayer(runtime_name="example-runtime", inputs=["x", "y"], output="z")
def example(x: float, y: float) -> float:
return x + y