Decorators Reference
Complete reference for all Thyme Python decorators.
@dataset
Registers a class as a dataset with schema metadata. Transforms the class into a dataclass.
from thyme.dataset import dataset, field
@dataset(index=True, version=1)
class MyDataset:
key_field: str = field(key=True)
ts: datetime = field(timestamp=True)
value: floatParameters
| Parameter | Type | Default | Description |
|---|---|---|---|
index | bool | False | Maintain a keyed lookup index in the state store |
version | int | 1 | Schema version for migration tracking |
Constraints
- Exactly one field must be marked
field(key=True). - Exactly one field must be marked
field(timestamp=True). - The key field cannot be
Optional.
field()
Declares metadata for a dataset field. Used as the default value in a dataset class annotation.
from thyme.dataset import field
user_id: str = field(key=True)
ts: datetime = field(timestamp=True)
amount: float # plain field — no descriptor neededParameters
| Parameter | Type | Default | Description |
|---|---|---|---|
key | bool | False | Mark this field as the entity key |
timestamp | bool | False | Mark this field as the event timestamp |
@pipeline
Marks a method on a dataset class as a pipeline. Must be combined with @inputs.
from thyme.pipeline import pipeline, inputs
@dataset(index=True)
class OutputDataset:
...
@pipeline(version=1)
@inputs(InputDataset)
def my_pipeline(cls, inp: InputDataset):
return inp.groupby("key").aggregate(...)Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
version | int | 1 | Pipeline version for tracking changes |
@inputs
Declares the input datasets for a pipeline method.
from thyme.pipeline import inputs
@inputs(DatasetA) # single input
@inputs(DatasetA, DatasetB) # multiple inputsParameters
| Parameter | Type | Description |
|---|---|---|
*dataset_classes | dataset classes | One or more @dataset-decorated classes |
@featureset
Registers a class as a featureset. No parameters — use as a bare decorator.
from thyme.featureset import featureset
@featureset
class MyFeatures:
...feature()
Declares a feature in a featureset. Used as the default value in a featureset class annotation.
from thyme.featureset import feature
uid: str = feature(id=1)
score: float = feature(id=2)Parameters
| Parameter | Type | Description |
|---|---|---|
id | int | Stable integer identifier. Must be unique within the featureset. Never reuse. |
@extractor
Marks a method on a featureset class as an extractor. Can be used with or without arguments.
from thyme.featureset import extractor
# Without arguments
@extractor
def my_extractor(cls, ts, inputs): ...
# With arguments
@extractor(deps=[OtherFeatureset], version=2)
def my_extractor(cls, ts, inputs): ...Parameters (when called with arguments)
| Parameter | Type | Default | Description |
|---|---|---|---|
deps | list | [] | Featureset classes this extractor depends on |
version | int | 1 | Extractor version |
Method signature
def extractor_method(cls, ts, inputs):
# cls: the featureset class
# ts: query timestamp (datetime)
# inputs: dict[str, Any] — input feature values
return output_value_1, output_value_2@extractor_inputs
Declares the feature names an extractor reads from inputs.
from thyme.featureset import extractor_inputs
@extractor_inputs("uid")
@extractor_inputs("uid", "age") # multipleParameters
| Parameter | Type | Description |
|---|---|---|
*feature_names | str | Names of features available in inputs dict |
@extractor_outputs
Declares the feature names an extractor returns. Must match the return value order.
from thyme.featureset import extractor_outputs
@extractor_outputs("score")
@extractor_outputs("avg_spend_7d", "txn_count_30d") # multiple — return tupleParameters
| Parameter | Type | Description |
|---|---|---|
*feature_names | str | Names of features produced, in return-value order |
@source
Attaches a source connector to a dataset class. Must be the outermost decorator.
from thyme.connectors import IcebergSource, source
@source(
IcebergSource(catalog="prod", database="events", table="transactions"),
cursor="ts",
every="1m",
disorder="5m",
cdc="append",
)
@dataset(index=True)
class MyDataset: ...Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
connector | connector object | required | The source connector instance |
cursor | str | "" | Incremental cursor field name |
every | str | "" | Poll interval ("1m", "5m", "1h") |
disorder | str | "" | Late-arrival tolerance ("5m", "1h", "1d") |
cdc | str | "append" | CDC mode: "append", "upsert", or "debezium" |