ds_common_placeholder_py_lib.functions ====================================== .. py:module:: ds_common_placeholder_py_lib.functions .. autoapi-nested-parse:: **File:** ``functions/__init__.py`` **Region:** ``ds-common-placeholder-py-lib`` Description ----------- The function registry (contract ยง5). Adding a function is a contract change: registry, vectors, and version bump together. Submodules ---------- .. toctree:: :maxdepth: 1 /reference/ds_common_placeholder_py_lib/functions/secrets/index /reference/ds_common_placeholder_py_lib/functions/strings/index /reference/ds_common_placeholder_py_lib/functions/tables/index /reference/ds_common_placeholder_py_lib/functions/time/index /reference/ds_common_placeholder_py_lib/functions/values/index Attributes ---------- .. autoapisummary:: ds_common_placeholder_py_lib.functions.FUNCTIONS Classes ------- .. autoapisummary:: ds_common_placeholder_py_lib.functions.Param ds_common_placeholder_py_lib.functions.FunctionSpec Functions --------- .. autoapisummary:: ds_common_placeholder_py_lib.functions.service_function Package Contents ---------------- .. py:class:: Param A function parameter. ``default`` is ``None`` for a required one; ``check`` validates a string value and raises ``argument``. .. py:attribute:: name :type: str .. py:attribute:: default :type: Any :value: None .. py:attribute:: check :type: collections.abc.Callable[[str], object] | None :value: None .. py:class:: FunctionSpec One registry entry. .. py:attribute:: name :type: str .. py:attribute:: impl :type: collections.abc.Callable[..., Any] Called with the argument list; a ``secret`` function, which needs the context's tenant and records what it reads, with the context first. .. py:attribute:: params :type: tuple[Param, ...] :value: () .. py:attribute:: variadic :type: bool :value: False .. py:attribute:: secret :type: bool :value: False .. py:attribute:: lazy :type: bool :value: False ``impl`` gets one zero-argument callable per argument instead of its value; calling it reads the value, or raises ``MissingValue``. .. py:attribute:: min_variadic :type: int :value: 1 .. py:attribute:: raw :type: bool :value: False any JSON value, or what a provider returned (a DataFrame), ``None`` for ``null`` or blank. Its result is converted to plain JSON. :type: ``impl`` gets each argument's value as it is .. py:method:: call(ctx: ds_common_placeholder_py_lib.context.Context, args: list[Any]) -> Any Run the function: built-ins depend only on *args*; the secret functions also get *ctx*. .. py:property:: min_args :type: int Smallest accepted argument count. .. py:property:: max_args :type: int | None Largest accepted argument count, ``None`` for no limit. .. py:data:: FUNCTIONS :type: collections.abc.Mapping[str, FunctionSpec] ``secret`` marks the functions that read secrets. :type: Function name to spec .. py:function:: service_function(name: str, fn: collections.abc.Callable[..., Any]) -> FunctionSpec A function a service adds to its context: called with each argument's value, positionally, as a ``raw`` function. Its signature gives the argument counts it accepts. :raises ValueError: If *name* is not a function name, is a built-in one, or *fn* has a required keyword-only parameter. :raises TypeError: If *fn* is not callable.