ds_common_placeholder_py_lib.functions¶
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¶
Attributes¶
|
Classes¶
A function parameter. |
|
One registry entry. |
Functions¶
|
A function a service adds to its context: called with each |
Package Contents¶
- class ds_common_placeholder_py_lib.functions.Param[source]¶
A function parameter.
defaultisNonefor a required one;checkvalidates a string value and raisesargument.- name: str¶
- default: Any = None¶
- check: collections.abc.Callable[[str], object] | None = None¶
- class ds_common_placeholder_py_lib.functions.FunctionSpec[source]¶
One registry entry.
- name: str¶
- impl: collections.abc.Callable[..., Any]¶
Called with the argument list; a
secretfunction, which needs the context’s tenant and records what it reads, with the context first.
- variadic: bool = False¶
- secret: bool = False¶
- lazy: bool = False¶
implgets one zero-argument callable per argument instead of its value; calling it reads the value, or raisesMissingValue.
- min_variadic: int = 1¶
- raw: bool = False¶
any JSON value, or what a provider returned (a DataFrame),
Nonefornullor blank. Its result is converted to plain JSON.- Type:
implgets each argument’s value as it is
- call(ctx: ds_common_placeholder_py_lib.context.Context, args: list[Any]) Any[source]¶
Run the function: built-ins depend only on args; the secret functions also get ctx.
- property min_args: int¶
Smallest accepted argument count.
- property max_args: int | None¶
Largest accepted argument count,
Nonefor no limit.
- ds_common_placeholder_py_lib.functions.FUNCTIONS: collections.abc.Mapping[str, FunctionSpec]¶
secretmarks the functions that read secrets.- Type:
Function name to spec
- ds_common_placeholder_py_lib.functions.service_function(name: str, fn: collections.abc.Callable[..., Any]) FunctionSpec[source]¶
A function a service adds to its context: called with each argument’s value, positionally, as a
rawfunction. 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.
TypeError – If fn is not callable.