Skip to content

temporian.compile #

compile(
    fn: Optional[F] = None,
    *,
    verbose: int = 0,
    force_garbage_collector_interval: Optional[float] = 10
) -> F

Compiles a Temporian function.

A Temporian function is a function that takes EventSetOrNodes as arguments and returns EventSetOrNodes as outputs.

Compiling a function allows Temporian to optimize the underlying graph defined by the operators used inside the function, making it run on EventSets more efficiently than if it weren't compiled, both in terms of memory and speed.

Compiling a function is a necessary step before saving it to a file with tp.save().

The output can be a single EventSetOrNode, a list of EventSetOrNodes, or a dictionary of names to EventSetOrNodes.

Example usage:

>>> @tp.compile
... def f(x: tp.EventSetNode, y: tp.EventSetNode) -> tp.EventSetNode:
...     return x.prefix("pre_").cumsum() + y

>>> evset = tp.event_set(
...     timestamps=[1, 2, 3],
...     features={"value": [10, 20, 30]},
... )

>>> result = f(evset, evset)
>>> isinstance(result, tp.EventSet)
True

Example usage with arguments:

>>> @tp.compile(verbose=1)
... def f(x: tp.EventSetNode) -> tp.EventSetNode:
...     return x.prefix("pre_")

Parameters:

Name Type Description Default
fn Optional[F]

The function to compile. The function must take EventSetNodes as arguments (and may have other arguments of arbitrary types) and return EventSetNodes as outputs.

None
verbose int

If >0, prints details about the execution on the standard error output when the wrapped function is applied eagerly on EventSets. The larger the number, the more information is displayed.

0
force_garbage_collector_interval Optional[float]

If set, triggers the garbage collection every "force_garbage_collector_interval" seconds.

10

Returns:

Type Description
F

The compiled function.