FunctionContext
The FunctionContext
captures the arguments of a function.
It can be created using the capsula.FunctionContext.builder
method or the capsula.FunctionContext.__init__
method.
capsula.FunctionContext.builder
classmethod
builder(
*, ignore: Container[str] = ()
) -> Callable[[CapsuleParams], FunctionContext]
PARAMETER | DESCRIPTION |
---|---|
ignore |
Parameters to ignore when capturing the arguments. This is useful when you pass values that you don't want to be in the output, such as a large data structure or a function that is not serializable, or a secret.
TYPE:
|
Source code in capsula/_context/_function.py
capsula.FunctionContext.__init__
__init__(
function: Callable[..., Any],
*,
args: Sequence[Any],
kwargs: Mapping[str, Any],
ignore: Container[str] = (),
_remove_pre_run_capsule_before_binding: bool = False
)
PARAMETER | DESCRIPTION |
---|---|
function |
TYPE:
|
args |
TYPE:
|
kwargs |
TYPE:
|
ignore |
TYPE:
|
_remove_pre_run_capsule_before_binding |
TYPE:
|
Source code in capsula/_context/_function.py
Configuration example
Via capsula.toml
Warning
Configuring the FunctionContext
via capsula.toml
is not recommended because capsula enc
will fail as there is no target function to capture.
Via @capsula.context
decorator
import capsula
@capsula.run()
@capsula.context(capsula.FunctionContext.builder(), mode="pre")
def func(arg1, arg2): ...
Output example
The following is an example of the output of the FunctionContext
, reported by the JsonDumpReporter
: