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 ::: capsula.FunctionContext.init
!!! warning
Configuring the FunctionContext
via capsula.toml
is not recommended because capsula enc
will fail as there is no target function to capture.
[pre-run]
contexts = [
{ type = "FunctionContext" },
]
import capsula
@capsula.run()
@capsula.context(capsula.FunctionContext.builder(), mode="pre")
def func(arg1, arg2): ...
The following is an example of the output of the FunctionContext
, reported by the JsonDumpReporter
:
"function": {
"calculate_pi": {
"file_path": "examples/simple_decorator.py",
"first_line_no": 6,
"bound_args": {
"n_samples": 1000,
"seed": 42
}
}
}