Skip to content

compiler

Phase 2: the single lazy query plan built from feature definitions.

Nothing here materializes a table, and neither does the caller. The only collect() calls in tusk are the ones tusk.validation makes when a check is explicitly requested.

compile_features

compile_features(features, database, cutoff_time=None)

Compute a lazy feature matrix from feature definitions.

It raises SchemaError, from require_primary_key, if the target table has no primary key. It raises ValidationError, from _require_cutoff_time, if a primitive measures against cutoff_time and none was given.

Parameters:

Name Type Description Default
features FeatureList

Features to compute.

required
database Database

The database holding the tables.

required
cutoff_time datetime | None

Only rows whose row_creation_time is at or before this value are visible. None disables filtering.

None

Returns:

Name Type Description
feature_matrix LazyFrame

A narwhals LazyFrame with the target's primary key plus one column per feature output, and one row per target row visible at cutoff_time. This may have fewer rows than the target table holds, because the target is filtered like any other table.