Skip to main content
Version: Beta 🚧

Functions

mock_realtime_feature_view​

Parameters

  • name (str) -

  • data (Any) -

  • keys (List[str]) -

  • fv_kwargs (Any) -

Returns

RealtimeFeatureView

make_local_batch_feature_view​

Make a local Tecton BatchFeatureView from raw data.

Parameters

  • name (str) - The name of the feature view.

  • data (Any) - The raw data, can be a pandas DataFrame, a dictionary, or a list of dictionaries.

  • entity_keys (List[str]) - The entity keys for dedup and lookup.

  • timestamp_field (Optional[str]) - The timestamp field, defaults to None (will add timestamp field automatically). Default: None

  • max_rows (Optional[int]) - The maximum number of rows allowed in the data, defaults to None. Default: None

  • fv_kwargs (Any) -

Returns

BatchFeatureView: A Tecton BatchFeatureView.

Example

from tecton_gen_ai.testing import make_local_batch_feature_view
# simplest form
my_fv1 = make_local_batch_feature_view("my_fv1", {"user_id": 1, "name": "Jim"}, ["user_id"])
# with a list of dictionaries
data = [
{"user_id": 1, "name": "Jim"},
{"user_id": 2, "name": "John"},
]
my_fv2 = make_local_batch_feature_view("my_fv2", data, ["user_id"])
# with a pandas DataFrame
import pandas as pd
df = pd.DataFrame(data)
my_fv3 = make_local_batch_feature_view("my_fv3", df, ["user_id"])

mock_source​

Parameters

  • name (str) -

  • raw (Any) -

  • auto_timestamp (bool) - Default: false

  • timestamp_field (Optional[str]) - Default: None

  • max_rows (Optional[int]) - Default: None

  • is_stream (bool) - Default: false

  • source_kwargs (Any) -

Returns

Union[BatchSource, StreamSource]

mock_batch_feature_view​

Parameters

  • name (str) -

  • data (Any) -

  • entity_keys (List[str]) -

  • timestamp_field (Optional[str]) - Default: None

  • max_rows (Optional[int]) - Default: None

  • fv_kwargs (Any) -

Returns

BatchFeatureView

local_stream_feature_view​

Make a local Tecton StreamFeatureView from raw data.

Parameters

  • name (str) - The name of the feature view.

  • data (Any) - The raw data, can be a pandas DataFrame, a dictionary, or a list of dictionaries.

  • entity_keys (List[str]) - The entity keys for lookup.

  • timestamp_field (Optional[str]) - The timestamp field, defaults to None (will add timestamp field automatically). Default: None

  • max_rows (Optional[int]) - The maximum number of rows allowed in the data, defaults to None. Default: None

  • fv_kwargs (Any) -

Returns

StreamFeatureView: A Tecton StreamFeatureView.

Example

from tecton_gen_ai.testing import local_stream_feature_view
# simplest form
fv = local_stream_feature_view("fv", {"user_id": "user1", "age": 30}, ["user_id"])
# with a list of dictionaries
data = [
{"user_id": "user1", "age": 30},
{"user_id": "user2", "age": 40},
]
fv = local_stream_feature_view("fv", data, ["user_id"])
# with a pandas DataFrame
import pandas as pd
df = pd.DataFrame(data)
fv = local_stream_feature_view("fv", df, ["user_id"])

make_local_source​

Make a local Tecton DataSource from raw data.

Parameters

  • name (str) - The name of the source.

  • raw (Any) - The raw data, can be a pandas DataFrame, a dictionary, or a list of dictionaries.

  • auto_timestamp (bool) - Whether to automatically add a timestamp field to the data when timestamp_field is None, defaults to True. Default: true

  • timestamp_field (Optional[str]) - The timestamp field, defaults to None (no timestamp field). Default: None

  • max_rows (Optional[int]) - The maximum number of rows allowed in the data, defaults to 100. Default: None

  • is_stream (bool) - Whether the returned source is a stream source, defaults to False. Default: false

  • source_kwargs (Any) -

Returns

Union[BatchSource, StreamSource]: A Tecton DataSource.

Example

from tecton_gen_ai.testing import make_local_source
import pandas as pd
# simplest form
my_src1 = make_local_source("my_src1", {"user_id": [1, 2]}))
# with a list of dictionaries
data = [
{"user_id": 1, "event_time": "2024-01-01T00:00:00", "event_type": "click"},
{"user_id": 2, "event_time": "2024-01-01T00:00:01", "event_type": "click"},
]
my_src2 = make_local_source("my_src2", data, timestamp_field="event_time")
# with a pandas DataFrame
df = pd.DataFrame(data)
my_src3 = make_local_source("my_src3", df, timestamp_field="event_time")

make_local_realtime_feature_view​

Make a local Tecton RealtimeFeatureView from raw data.

Parameters

  • name (str) - The name of the feature view.

  • data (Any) - The raw data, can be a pandas DataFrame, a dictionary, or a list of dictionaries.

  • entity_keys (List[str]) - The entity keys for lookup.

  • fv_kwargs (Any) -

Returns

RealtimeFeatureView: A Tecton RealtimeFeatureView.

Example

from tecton_gen_ai.testing import make_local_realtime_feature_view
fv = make_local_realtime_feature_view("fv", {"user_id": "user1", "age": 30}, ["user_id"])
events = pd.DataFrame([{"user_id": "user1"}])
odf = fv.get_features_for_events(events).to_pandas()

mock_stream_feature_view​

Parameters

  • name (str) -

  • data (Any) -

  • entity_keys (List[str]) -

  • timestamp_field (Optional[str]) - Default: None

  • max_rows (Optional[int]) - Default: None

  • fv_kwargs (Any) -

Returns

StreamFeatureView

Was this page helpful?

🧠 Hi! Ask me anything about Tecton!

Floating button icon