feast package

Subpackages

Submodules

feast.aggregation module

class feast.aggregation.Aggregation(column: Optional[str] = '', function: Optional[str] = '', time_window: Optional[datetime.timedelta] = None, slide_interval: Optional[datetime.timedelta] = None)[source]

Bases: object

NOTE: Feast-handled aggregations are not yet supported. This class provides a way to register user-defined aggregations.

column

str # Column name of the feature we are aggregating.

Type

str

function

str # Provided built in aggregations sum, max, min, count mean

Type

str

time_window

timedelta # The time window for this aggregation.

Type

Optional[datetime.timedelta]

slide_interval

timedelta # The sliding window for these aggregations

Type

Optional[datetime.timedelta]

column: str
classmethod from_proto(agg_proto: feast.core.Aggregation_pb2.Aggregation)[source]
function: str
slide_interval: Optional[datetime.timedelta]
time_window: Optional[datetime.timedelta]
to_proto() feast.core.Aggregation_pb2.Aggregation[source]

feast.base_feature_view module

class feast.base_feature_view.BaseFeatureView(*, name: str, features: Optional[List[feast.field.Field]] = None, description: str = '', tags: Optional[Dict[str, str]] = None, owner: str = '')[source]

Bases: abc.ABC

A BaseFeatureView defines a logical group of features.

name

The unique name of the base feature view.

Type

str

features

The list of features defined as part of this base feature view.

Type

List[feast.field.Field]

description

A human-readable description.

Type

str

tags

A dictionary of key-value pairs to store arbitrary metadata.

Type

Dict[str, str]

owner

The owner of the base feature view, typically the email of the primary maintainer.

Type

str

projection

The feature view projection storing modifications to be applied to this base feature view at retrieval time.

Type

feast.feature_view_projection.FeatureViewProjection

created_timestamp

The time when the base feature view was created.

Type

Optional[datetime.datetime]

last_updated_timestamp

The time when the base feature view was last updated.

Type

Optional[datetime.datetime]

created_timestamp: Optional[datetime.datetime]
description: str
ensure_valid()[source]

Validates the state of this feature view locally.

Raises

ValueError – The feature view is invalid.

features: List[feast.field.Field]
abstract classmethod from_proto(feature_view_proto)[source]
last_updated_timestamp: Optional[datetime.datetime]
name: str
owner: str
projection: feast.feature_view_projection.FeatureViewProjection
abstract property proto_class: Type[proto.message.Message]
set_projection(feature_view_projection: feast.feature_view_projection.FeatureViewProjection) None[source]

Sets the feature view projection of this base feature view to the given projection.

Parameters

feature_view_projection – The feature view projection to be set.

Raises

ValueError – The name or features of the projection do not match.

tags: Dict[str, str]
abstract to_proto() proto.message.Message[source]
with_name(name: str)[source]

Returns a renamed copy of this base feature view. This renamed copy should only be used for query operations and will not modify the underlying base feature view.

Parameters

name – The name to assign to the copy.

with_projection(feature_view_projection: feast.feature_view_projection.FeatureViewProjection)[source]

Returns a copy of this base feature view with the feature view projection set to the given projection.

Parameters

feature_view_projection – The feature view projection to assign to the copy.

Raises

ValueError – The name or features of the projection do not match.

feast.batch_feature_view module

class feast.batch_feature_view.BatchFeatureView(*, name: str, source: feast.data_source.DataSource, entities: Optional[Union[List[feast.entity.Entity], List[str]]] = None, ttl: Optional[datetime.timedelta] = None, tags: Optional[Dict[str, str]] = None, online: bool = True, description: str = '', owner: str = '', schema: Optional[List[feast.field.Field]] = None)[source]

Bases: feast.feature_view.FeatureView

A batch feature view defines a logical group of features that has only a batch data source.

name

The unique name of the batch feature view.

Type

str

entities

List of entities or entity join keys.

Type

List[str]

ttl

The amount of time this group of features lives. A ttl of 0 indicates that this group of features lives forever. Note that large ttl’s or a ttl of 0 can result in extremely computationally intensive queries.

Type

Optional[datetime.timedelta]

schema

The schema of the feature view, including feature, timestamp, and entity columns. If not specified, can be inferred from the underlying data source.

Type

List[feast.field.Field]

source

The batch source of data where this group of features is stored.

Type

feast.data_source.DataSource

online

A boolean indicating whether online retrieval is enabled for this feature view.

Type

bool

description

A human-readable description.

Type

str

tags

A dictionary of key-value pairs to store arbitrary metadata.

Type

Dict[str, str]

owner

The owner of the batch feature view, typically the email of the primary maintainer.

Type

str

description: str
entities: List[str]
entity_columns: List[feast.field.Field]
features: List[feast.field.Field]
materialization_intervals: List[Tuple[datetime.datetime, datetime.datetime]]
name: str
online: bool
owner: str
schema: List[feast.field.Field]
source: feast.data_source.DataSource
tags: Dict[str, str]
timestamp_field: str
ttl: Optional[datetime.timedelta]

feast.cli module

class feast.cli.NoOptionDefaultFormat(name: Optional[str], context_settings: Optional[Dict[str, Any]] = None, callback: Optional[Callable[[...], Any]] = None, params: Optional[List[click.core.Parameter]] = None, help: Optional[str] = None, epilog: Optional[str] = None, short_help: Optional[str] = None, options_metavar: Optional[str] = '[OPTIONS]', add_help_option: bool = True, no_args_is_help: bool = False, hidden: bool = False, deprecated: bool = False)[source]

Bases: click.core.Command

format_options(ctx: click.core.Context, formatter: click.formatting.HelpFormatter)[source]

Writes all the options into the formatter if they exist.

feast.constants module

feast.data_format module

class feast.data_format.AvroFormat(schema_json: str)[source]

Bases: feast.data_format.StreamFormat

Defines the Avro streaming data format that encodes data in Avro format

to_proto()[source]

Convert this StreamFormat into its protobuf representation.

class feast.data_format.FileFormat[source]

Bases: abc.ABC

Defines an abtract file forma used to encode feature data in files

classmethod from_proto(proto)[source]

Construct this FileFormat from its protobuf representation. Raises NotImplementedError if FileFormat specified in given proto is not supported.

abstract to_proto()[source]

Convert this FileFormat into its protobuf representation.

class feast.data_format.JsonFormat(schema_json: str)[source]

Bases: feast.data_format.StreamFormat

Defines the Json streaming data format that encodes data in Json format

to_proto()[source]

Convert this StreamFormat into its protobuf representation.

class feast.data_format.ParquetFormat[source]

Bases: feast.data_format.FileFormat

Defines the Parquet data format

to_proto()[source]

Convert this FileFormat into its protobuf representation.

class feast.data_format.ProtoFormat(class_path: str)[source]

Bases: feast.data_format.StreamFormat

Defines the Protobuf data format

to_proto()[source]

Convert this StreamFormat into its protobuf representation.

class feast.data_format.StreamFormat[source]

Bases: abc.ABC

Defines an abtracts streaming data format used to encode feature data in streams

classmethod from_proto(proto)[source]

Construct this StreamFormat from its protobuf representation.

abstract to_proto()[source]

Convert this StreamFormat into its protobuf representation.

feast.data_source module

class feast.data_source.DataSource(*, name: str, timestamp_field: Optional[str] = None, created_timestamp_column: Optional[str] = None, field_mapping: Optional[Dict[str, str]] = None, description: Optional[str] = '', tags: Optional[Dict[str, str]] = None, owner: Optional[str] = '', date_partition_column: Optional[str] = None)[source]

Bases: abc.ABC

DataSource that can be used to source features.

Parameters
  • name – Name of data source, which should be unique within a project

  • timestamp_field (optional) – Event timestamp field used for point-in-time joins of feature values.

  • created_timestamp_column (optional) – Timestamp column indicating when the row was created, used for deduplicating rows.

  • field_mapping (optional) – A dictionary mapping of column names in this data source to feature names in a feature table or view. Only used for feature columns, not entity or timestamp columns.

  • description (optional) –

  • tags (optional) – A dictionary of key-value pairs to store arbitrary metadata.

  • owner (optional) – The owner of the data source, typically the email of the primary maintainer.

  • timestamp_field – Event timestamp field used for point in time joins of feature values.

  • date_partition_column (optional) – Timestamp column used for partitioning. Not supported by all offline stores.

created_timestamp_column: str
date_partition_column: str
description: str
field_mapping: Dict[str, str]
abstract static from_proto(data_source: feast.core.DataSource_pb2.DataSource) Any[source]

Converts data source config in protobuf spec to a DataSource class object.

Parameters

data_source – A protobuf representation of a DataSource.

Returns

A DataSource class object.

Raises

ValueError – The type of DataSource could not be identified.

get_table_column_names_and_types(config: feast.repo_config.RepoConfig) Iterable[Tuple[str, str]][source]

Returns the list of column names and raw column types.

Parameters

config – Configuration object used to configure a feature store.

get_table_query_string() str[source]

Returns a string that can directly be used to reference this table in SQL.

name: str
owner: str
abstract static source_datatype_to_feast_value_type() Callable[[str], feast.value_type.ValueType][source]

Returns the callable method that returns Feast type given the raw column type.

tags: Dict[str, str]
timestamp_field: str
abstract to_proto() feast.core.DataSource_pb2.DataSource[source]

Converts a DataSourceProto object to its protobuf representation.

validate(config: feast.repo_config.RepoConfig)[source]

Validates the underlying data source.

Parameters

config – Configuration object used to configure a feature store.

class feast.data_source.KafkaOptions(kafka_bootstrap_servers: str, message_format: feast.data_format.StreamFormat, topic: str, watermark_delay_threshold: Optional[datetime.timedelta] = None)[source]

Bases: object

DataSource Kafka options used to source features from Kafka messages

classmethod from_proto(kafka_options_proto: feast.core.DataSource_pb2.KafkaOptions)[source]

Creates a KafkaOptions from a protobuf representation of a kafka option

Parameters

kafka_options_proto – A protobuf representation of a DataSource

Returns

Returns a BigQueryOptions object based on the kafka_options protobuf

to_proto() feast.core.DataSource_pb2.KafkaOptions[source]

Converts an KafkaOptionsProto object to its protobuf representation.

Returns

KafkaOptionsProto protobuf

class feast.data_source.KafkaSource(*, name: str, timestamp_field: str, message_format: feast.data_format.StreamFormat, bootstrap_servers: Optional[str] = None, kafka_bootstrap_servers: Optional[str] = None, topic: Optional[str] = None, created_timestamp_column: Optional[str] = '', field_mapping: Optional[Dict[str, str]] = None, description: Optional[str] = '', tags: Optional[Dict[str, str]] = None, owner: Optional[str] = '', batch_source: Optional[feast.data_source.DataSource] = None, watermark_delay_threshold: Optional[datetime.timedelta] = None)[source]

Bases: feast.data_source.DataSource

created_timestamp_column: str
date_partition_column: str
description: str
field_mapping: Dict[str, str]
static from_proto(data_source: feast.core.DataSource_pb2.DataSource)[source]

Converts data source config in protobuf spec to a DataSource class object.

Parameters

data_source – A protobuf representation of a DataSource.

Returns

A DataSource class object.

Raises

ValueError – The type of DataSource could not be identified.

get_table_column_names_and_types(config: feast.repo_config.RepoConfig) Iterable[Tuple[str, str]][source]

Returns the list of column names and raw column types.

Parameters

config – Configuration object used to configure a feature store.

get_table_query_string() str[source]

Returns a string that can directly be used to reference this table in SQL.

name: str
owner: str
static source_datatype_to_feast_value_type() Callable[[str], feast.value_type.ValueType][source]

Returns the callable method that returns Feast type given the raw column type.

tags: Dict[str, str]
timestamp_field: str
to_proto() feast.core.DataSource_pb2.DataSource[source]

Converts a DataSourceProto object to its protobuf representation.

validate(config: feast.repo_config.RepoConfig)[source]

Validates the underlying data source.

Parameters

config – Configuration object used to configure a feature store.

class feast.data_source.KinesisOptions(record_format: feast.data_format.StreamFormat, region: str, stream_name: str)[source]

Bases: object

DataSource Kinesis options used to source features from Kinesis records

classmethod from_proto(kinesis_options_proto: feast.core.DataSource_pb2.KinesisOptions)[source]

Creates a KinesisOptions from a protobuf representation of a kinesis option

Parameters

kinesis_options_proto – A protobuf representation of a DataSource

Returns

Returns a KinesisOptions object based on the kinesis_options protobuf

to_proto() feast.core.DataSource_pb2.KinesisOptions[source]

Converts an KinesisOptionsProto object to its protobuf representation.

Returns

KinesisOptionsProto protobuf

class feast.data_source.KinesisSource(*, name: str, record_format: feast.data_format.StreamFormat, region: str, stream_name: str, timestamp_field: Optional[str] = '', created_timestamp_column: Optional[str] = '', field_mapping: Optional[Dict[str, str]] = None, description: Optional[str] = '', tags: Optional[Dict[str, str]] = None, owner: Optional[str] = '', batch_source: Optional[feast.data_source.DataSource] = None)[source]

Bases: feast.data_source.DataSource

created_timestamp_column: str
date_partition_column: str
description: str
field_mapping: Dict[str, str]
static from_proto(data_source: feast.core.DataSource_pb2.DataSource)[source]

Converts data source config in protobuf spec to a DataSource class object.

Parameters

data_source – A protobuf representation of a DataSource.

Returns

A DataSource class object.

Raises

ValueError – The type of DataSource could not be identified.

get_table_column_names_and_types(config: feast.repo_config.RepoConfig) Iterable[Tuple[str, str]][source]

Returns the list of column names and raw column types.

Parameters

config – Configuration object used to configure a feature store.

get_table_query_string() str[source]

Returns a string that can directly be used to reference this table in SQL.

name: str
owner: str
static source_datatype_to_feast_value_type() Callable[[str], feast.value_type.ValueType][source]

Returns the callable method that returns Feast type given the raw column type.

tags: Dict[str, str]
timestamp_field: str
to_proto() feast.core.DataSource_pb2.DataSource[source]

Converts a DataSourceProto object to its protobuf representation.

validate(config: feast.repo_config.RepoConfig)[source]

Validates the underlying data source.

Parameters

config – Configuration object used to configure a feature store.

class feast.data_source.PushMode(value)[source]

Bases: enum.Enum

An enumeration.

OFFLINE = 2
ONLINE = 1
ONLINE_AND_OFFLINE = 3
class feast.data_source.PushSource(*, name: str, batch_source: feast.data_source.DataSource, description: Optional[str] = '', tags: Optional[Dict[str, str]] = None, owner: Optional[str] = '')[source]

Bases: feast.data_source.DataSource

A source that can be used to ingest features on request

batch_source: feast.data_source.DataSource
static from_proto(data_source: feast.core.DataSource_pb2.DataSource)[source]

Converts data source config in protobuf spec to a DataSource class object.

Parameters

data_source – A protobuf representation of a DataSource.

Returns

A DataSource class object.

Raises

ValueError – The type of DataSource could not be identified.

get_table_column_names_and_types(config: feast.repo_config.RepoConfig) Iterable[Tuple[str, str]][source]

Returns the list of column names and raw column types.

Parameters

config – Configuration object used to configure a feature store.

get_table_query_string() str[source]

Returns a string that can directly be used to reference this table in SQL.

static source_datatype_to_feast_value_type() Callable[[str], feast.value_type.ValueType][source]

Returns the callable method that returns Feast type given the raw column type.

to_proto() feast.core.DataSource_pb2.DataSource[source]

Converts a DataSourceProto object to its protobuf representation.

validate(config: feast.repo_config.RepoConfig)[source]

Validates the underlying data source.

Parameters

config – Configuration object used to configure a feature store.

class feast.data_source.RequestSource(*, name: str, schema: List[feast.field.Field], description: Optional[str] = '', tags: Optional[Dict[str, str]] = None, owner: Optional[str] = '')[source]

Bases: feast.data_source.DataSource

RequestSource that can be used to provide input features for on demand transforms

name

Name of the request data source

Type

str

schema

Schema mapping from the input feature name to a ValueType

Type

List[feast.field.Field]

description

A human-readable description.

Type

str

tags

A dictionary of key-value pairs to store arbitrary metadata.

Type

Dict[str, str]

owner

The owner of the request data source, typically the email of the primary maintainer.

Type

str

description: str
static from_proto(data_source: feast.core.DataSource_pb2.DataSource)[source]

Converts data source config in protobuf spec to a DataSource class object.

Parameters

data_source – A protobuf representation of a DataSource.

Returns

A DataSource class object.

Raises

ValueError – The type of DataSource could not be identified.

get_table_column_names_and_types(config: feast.repo_config.RepoConfig) Iterable[Tuple[str, str]][source]

Returns the list of column names and raw column types.

Parameters

config – Configuration object used to configure a feature store.

get_table_query_string() str[source]

Returns a string that can directly be used to reference this table in SQL.

name: str
owner: str
schema: List[feast.field.Field]
static source_datatype_to_feast_value_type() Callable[[str], feast.value_type.ValueType][source]

Returns the callable method that returns Feast type given the raw column type.

tags: Dict[str, str]
to_proto() feast.core.DataSource_pb2.DataSource[source]

Converts a DataSourceProto object to its protobuf representation.

validate(config: feast.repo_config.RepoConfig)[source]

Validates the underlying data source.

Parameters

config – Configuration object used to configure a feature store.

feast.driver_test_data module

class feast.driver_test_data.EventTimestampType(value)[source]

Bases: enum.Enum

An enumeration.

TZ_AWARE_FIXED_OFFSET = 2
TZ_AWARE_US_PACIFIC = 3
TZ_AWARE_UTC = 1
TZ_NAIVE = 0
feast.driver_test_data.create_customer_daily_profile_df(customers, start_date, end_date) pandas.core.frame.DataFrame[source]

Example df generated by this function:

event_timestamp | customer_id | current_balance | avg_passenger_count | lifetime_trip_count | created |

|------------------+-------------+-----------------+---------------------+---------------------+------------------| | 2021-03-17 19:31 | 1010 | 0.889188 | 0.049057 | 412 | 2021-03-24 19:38 | | 2021-03-18 19:31 | 1010 | 0.979273 | 0.212630 | 639 | 2021-03-24 19:38 | | 2021-03-19 19:31 | 1010 | 0.976549 | 0.176881 | 70 | 2021-03-24 19:38 | | 2021-03-20 19:31 | 1010 | 0.273697 | 0.325012 | 68 | 2021-03-24 19:38 | | 2021-03-21 19:31 | 1010 | 0.438262 | 0.313009 | 192 | 2021-03-24 19:38 | | | … | … | … | … | | | 2021-03-19 19:31 | 1001 | 0.738860 | 0.857422 | 344 | 2021-03-24 19:38 | | 2021-03-20 19:31 | 1001 | 0.848397 | 0.745989 | 106 | 2021-03-24 19:38 | | 2021-03-21 19:31 | 1001 | 0.301552 | 0.185873 | 812 | 2021-03-24 19:38 | | 2021-03-22 19:31 | 1001 | 0.943030 | 0.561219 | 322 | 2021-03-24 19:38 | | 2021-03-23 19:31 | 1001 | 0.354919 | 0.810093 | 273 | 2021-03-24 19:38 |

feast.driver_test_data.create_driver_hourly_stats_df(drivers, start_date, end_date) pandas.core.frame.DataFrame[source]

Example df generated by this function:

event_timestamp | driver_id | conv_rate | acc_rate | avg_daily_trips | created |

|------------------+-----------+-----------+----------+-----------------+------------------| | 2021-03-17 19:31 | 5010 | 0.229297 | 0.685843 | 861 | 2021-03-24 19:34 | | 2021-03-17 20:31 | 5010 | 0.781655 | 0.861280 | 769 | 2021-03-24 19:34 | | 2021-03-17 21:31 | 5010 | 0.150333 | 0.525581 | 778 | 2021-03-24 19:34 | | 2021-03-17 22:31 | 5010 | 0.951701 | 0.228883 | 570 | 2021-03-24 19:34 | | 2021-03-17 23:31 | 5010 | 0.819598 | 0.262503 | 473 | 2021-03-24 19:34 | | | … | … | … | … | | | 2021-03-24 16:31 | 5001 | 0.061585 | 0.658140 | 477 | 2021-03-24 19:34 | | 2021-03-24 17:31 | 5001 | 0.088949 | 0.303897 | 618 | 2021-03-24 19:34 | | 2021-03-24 18:31 | 5001 | 0.096652 | 0.747421 | 480 | 2021-03-24 19:34 | | 2021-03-17 19:31 | 5005 | 0.142936 | 0.707596 | 466 | 2021-03-24 19:34 | | 2021-03-17 19:31 | 5005 | 0.142936 | 0.707596 | 466 | 2021-03-24 19:34 |

feast.driver_test_data.create_field_mapping_df(start_date, end_date) pandas.core.frame.DataFrame[source]

Example df generated by this function: | event_timestamp | column_name | created | |------------------+-------------+------------------| | 2021-03-17 19:00 | 99 | 2021-03-24 19:38 | | 2021-03-17 19:00 | 22 | 2021-03-24 19:38 | | 2021-03-17 19:00 | 7 | 2021-03-24 19:38 | | 2021-03-17 19:00 | 45 | 2021-03-24 19:38 |

feast.driver_test_data.create_global_daily_stats_df(start_date, end_date) pandas.core.frame.DataFrame[source]

Example df generated by this function:

event_timestamp | num_rides | avg_ride_length | created |

|------------------+-------------+-----------------+------------------| | 2021-03-17 19:00 | 99 | 0.889188 | 2021-03-24 19:38 | | 2021-03-18 19:00 | 52 | 0.979273 | 2021-03-24 19:38 | | 2021-03-19 19:00 | 66 | 0.976549 | 2021-03-24 19:38 | | 2021-03-20 19:00 | 84 | 0.273697 | 2021-03-24 19:38 | | 2021-03-21 19:00 | 89 | 0.438262 | 2021-03-24 19:38 | | | … | … | | | 2021-03-24 19:00 | 54 | 0.738860 | 2021-03-24 19:38 | | 2021-03-25 19:00 | 58 | 0.848397 | 2021-03-24 19:38 | | 2021-03-26 19:00 | 69 | 0.301552 | 2021-03-24 19:38 | | 2021-03-27 19:00 | 63 | 0.943030 | 2021-03-24 19:38 | | 2021-03-28 19:00 | 79 | 0.354919 | 2021-03-24 19:38 |

feast.driver_test_data.create_location_stats_df(locations, start_date, end_date) pandas.core.frame.DataFrame[source]

Example df generated by this function:

event_timestamp | location_id | temperature | created |
feast.driver_test_data.create_orders_df(customers, drivers, start_date, end_date, order_count, locations=None) pandas.core.frame.DataFrame[source]

Example df generated by this function (if locations):

order_id | driver_id | customer_id | origin_id | destination_id | order_is_success | event_timestamp |

feast.entity module

class feast.entity.Entity(*, name: str, join_keys: Optional[List[str]] = None, value_type: Optional[feast.value_type.ValueType] = None, description: str = '', tags: Optional[Dict[str, str]] = None, owner: str = '')[source]

Bases: object

An entity defines a collection of entities for which features can be defined. An entity can also contain associated metadata.

name

The unique name of the entity.

Type

str

value_type

The type of the entity, such as string or float.

Type

feast.value_type.ValueType

join_key

A property that uniquely identifies different entities within the collection. The join_key property is typically used for joining entities with their associated features. If not specified, defaults to the name.

Type

str

description

A human-readable description.

Type

str

tags

A dictionary of key-value pairs to store arbitrary metadata.

Type

Dict[str, str]

owner

The owner of the entity, typically the email of the primary maintainer.

Type

str

created_timestamp

The time when the entity was created.

Type

Optional[datetime.datetime]

last_updated_timestamp

The time when the entity was last updated.

Type

Optional[datetime.datetime]

created_timestamp: Optional[datetime.datetime]
description: str
classmethod from_proto(entity_proto: feast.core.Entity_pb2.Entity)[source]

Creates an entity from a protobuf representation of an entity.

Parameters

entity_proto – A protobuf representation of an entity.

Returns

An Entity object based on the entity protobuf.

is_valid()[source]

Validates the state of this entity locally.

Raises

ValueError – The entity does not have a name or does not have a type.

join_key: str
last_updated_timestamp: Optional[datetime.datetime]
name: str
owner: str
tags: Dict[str, str]
to_proto() feast.core.Entity_pb2.Entity[source]

Converts an entity object to its protobuf representation.

Returns

An EntityProto protobuf.

value_type: feast.value_type.ValueType

feast.errors module

exception feast.errors.AwsAPIGatewayDoesNotExist(resource_name: str)[source]

Bases: Exception

exception feast.errors.AwsLambdaDoesNotExist(resource_name: str)[source]

Bases: Exception

exception feast.errors.BigQueryJobCancelled(job_id)[source]

Bases: Exception

exception feast.errors.BigQueryJobStillRunning(job_id)[source]

Bases: Exception

exception feast.errors.ConflictingFeatureViewNames(feature_view_name: str)[source]

Bases: Exception

exception feast.errors.DataSourceNoNameException[source]

Bases: Exception

exception feast.errors.DataSourceNotFoundException(path)[source]

Bases: Exception

exception feast.errors.DataSourceObjectNotFoundException(name, project=None)[source]

Bases: feast.errors.FeastObjectNotFoundException

exception feast.errors.DataSourceRepeatNamesException(ds_name: str)[source]

Bases: Exception

exception feast.errors.DockerDaemonNotRunning[source]

Bases: Exception

exception feast.errors.EntityDFNotDateTime[source]

Bases: Exception

exception feast.errors.EntityNotFoundException(name, project=None)[source]

Bases: feast.errors.FeastObjectNotFoundException

exception feast.errors.EntitySQLEmptyResults(entity_sql: str)[source]

Bases: Exception

exception feast.errors.EntityTimestampInferenceException(expected_column_name: str)[source]

Bases: Exception

exception feast.errors.FeastClassImportError(module_name: str, class_name: str)[source]

Bases: Exception

exception feast.errors.FeastEntityDFMissingColumnsError(expected, missing)[source]

Bases: Exception

exception feast.errors.FeastExtrasDependencyImportError(extras_type: str, nested_error: str)[source]

Bases: Exception

exception feast.errors.FeastFeatureServerTypeInvalidError(feature_server_type: str)[source]

Bases: Exception

exception feast.errors.FeastFeatureServerTypeSetError(feature_server_type: str)[source]

Bases: Exception

exception feast.errors.FeastInvalidBaseClass(class_name: str, class_type: str)[source]

Bases: Exception

exception feast.errors.FeastInvalidInfraObjectType[source]

Bases: Exception

exception feast.errors.FeastJoinKeysDuringMaterialization(source: str, join_key_columns: Set[str], source_columns: Set[str])[source]

Bases: Exception

exception feast.errors.FeastModuleImportError(module_name: str, class_name: str)[source]

Bases: Exception

exception feast.errors.FeastObjectNotFoundException[source]

Bases: Exception

exception feast.errors.FeastOfflineStoreInvalidName(offline_store_class_name: str)[source]

Bases: Exception

exception feast.errors.FeastOfflineStoreUnsupportedDataSource(offline_store_name: str, data_source_name: str)[source]

Bases: Exception

exception feast.errors.FeastOnlineStoreInvalidName(online_store_class_name: str)[source]

Bases: Exception

exception feast.errors.FeastOnlineStoreUnsupportedDataSource(online_store_name: str, data_source_name: str)[source]

Bases: Exception

exception feast.errors.FeastProviderLoginError[source]

Bases: Exception

Error class that indicates a user has not authenticated with their provider.

exception feast.errors.FeastProviderNotImplementedError(provider_name)[source]

Bases: Exception

exception feast.errors.FeastProviderNotSetError[source]

Bases: Exception

exception feast.errors.FeatureNameCollisionError(feature_refs_collisions: List[str], full_feature_names: bool)[source]

Bases: Exception

exception feast.errors.FeatureServiceNotFoundException(name, project=None)[source]

Bases: feast.errors.FeastObjectNotFoundException

exception feast.errors.FeatureViewMissingDuringFeatureServiceInference(feature_view_name: str, feature_service_name: str)[source]

Bases: Exception

exception feast.errors.FeatureViewNotFoundException(name, project=None)[source]

Bases: feast.errors.FeastObjectNotFoundException

exception feast.errors.IncompatibleRegistryStoreClass(actual_class: str, expected_class: str)[source]

Bases: Exception

exception feast.errors.InvalidEntityType(entity_type: type)[source]

Bases: Exception

exception feast.errors.InvalidFeaturesParameterType(features: Any)[source]

Bases: Exception

exception feast.errors.OnDemandFeatureViewNotFoundException(name, project=None)[source]

Bases: feast.errors.FeastObjectNotFoundException

exception feast.errors.PushSourceNotFoundException(push_source_name: str)[source]

Bases: Exception

exception feast.errors.RedshiftCredentialsError[source]

Bases: Exception

exception feast.errors.RedshiftQueryError(details)[source]

Bases: Exception

exception feast.errors.RedshiftTableNameTooLong(table_name: str)[source]

Bases: Exception

exception feast.errors.RegistryInferenceFailure(repo_obj_type: str, specific_issue: str)[source]

Bases: Exception

exception feast.errors.RepoConfigPathDoesNotExist[source]

Bases: Exception

exception feast.errors.RequestDataNotFoundInEntityDfException(feature_name, feature_view_name)[source]

Bases: feast.errors.FeastObjectNotFoundException

exception feast.errors.RequestDataNotFoundInEntityRowsException(feature_names)[source]

Bases: feast.errors.FeastObjectNotFoundException

exception feast.errors.S3RegistryBucketForbiddenAccess(bucket)[source]

Bases: feast.errors.FeastObjectNotFoundException

exception feast.errors.S3RegistryBucketNotExist(bucket)[source]

Bases: feast.errors.FeastObjectNotFoundException

exception feast.errors.SavedDatasetLocationAlreadyExists(location: str)[source]

Bases: Exception

exception feast.errors.SavedDatasetNotFound(name: str, project: str)[source]

Bases: feast.errors.FeastObjectNotFoundException

exception feast.errors.SnowflakeCredentialsError[source]

Bases: Exception

exception feast.errors.SnowflakeIncompleteConfig(e: KeyError)[source]

Bases: Exception

exception feast.errors.SnowflakeQueryError(details)[source]

Bases: Exception

exception feast.errors.SnowflakeQueryUnknownError(query: str)[source]

Bases: Exception

exception feast.errors.SpecifiedFeaturesNotPresentError(specified_features: List[feast.field.Field], inferred_features: List[feast.field.Field], feature_view_name: str)[source]

Bases: Exception

exception feast.errors.ValidationReferenceNotFound(name: str, project: str)[source]

Bases: feast.errors.FeastObjectNotFoundException

feast.feast_object module

feast.feature module

class feast.feature.Feature(name: str, dtype: feast.value_type.ValueType, labels: Optional[Dict[str, str]] = None)[source]

Bases: object

A Feature represents a class of serveable feature.

Parameters
  • name – Name of the feature.

  • dtype – The type of the feature, such as string or float.

  • labels (optional) – User-defined metadata in dictionary form.

property dtype: feast.value_type.ValueType

Gets the data type of this feature.

classmethod from_proto(feature_proto: feast.core.Feature_pb2.FeatureSpecV2)[source]
Parameters

feature_proto – FeatureSpecV2 protobuf object

Returns

Feature object

property labels: Dict[str, str]

Gets the labels of this feature.

property name

Gets the name of this feature.

to_proto() feast.core.Feature_pb2.FeatureSpecV2[source]

Converts Feature object to its Protocol Buffer representation.

Returns

A FeatureSpecProto protobuf.

feast.feature_logging module

class feast.feature_logging.FeatureServiceLoggingSource(feature_service: FeatureService, project: str)[source]

Bases: feast.feature_logging.LoggingSource

get_log_timestamp_column() str[source]

Return timestamp column that must exist in generated schema.

get_schema(registry: BaseRegistry) pyarrow.lib.Schema[source]

Generate schema for logs destination.

class feast.feature_logging.LoggingConfig(destination: feast.feature_logging.LoggingDestination, sample_rate: float = 1.0)[source]

Bases: object

destination: feast.feature_logging.LoggingDestination
classmethod from_proto(config_proto: feast.core.FeatureService_pb2.LoggingConfig) Optional[feast.feature_logging.LoggingConfig][source]
sample_rate: float
to_proto() feast.core.FeatureService_pb2.LoggingConfig[source]
class feast.feature_logging.LoggingDestination[source]

Bases: object

Logging destination contains details about where exactly logs should be written inside an offline store. It is implementation specific - each offline store must implement LoggingDestination subclass.

Kind of logging destination will be determined by matching attribute name in LoggingConfig protobuf message and “_proto_kind” property of each subclass.

abstract classmethod from_proto(config_proto: feast.core.FeatureService_pb2.LoggingConfig) feast.feature_logging.LoggingDestination[source]
abstract to_data_source() feast.data_source.DataSource[source]

Convert this object into a data source to read logs from an offline store.

abstract to_proto() feast.core.FeatureService_pb2.LoggingConfig[source]
class feast.feature_logging.LoggingSource[source]

Bases: object

Logging source describes object that produces logs (eg, feature service produces logs of served features). It should be able to provide schema of produced logs table and additional metadata that describes logs data.

abstract get_log_timestamp_column() str[source]

Return timestamp column that must exist in generated schema.

abstract get_schema(registry: BaseRegistry) pyarrow.lib.Schema[source]

Generate schema for logs destination.

feast.feature_server module

class feast.feature_server.PushFeaturesRequest(*, push_source_name: str, df: dict, allow_registry_cache: bool = True, to: str = 'online')[source]

Bases: pydantic.main.BaseModel

allow_registry_cache: bool
df: dict
push_source_name: str
to: str
class feast.feature_server.WriteToFeatureStoreRequest(*, feature_view_name: str, df: dict, allow_registry_cache: bool = True)[source]

Bases: pydantic.main.BaseModel

allow_registry_cache: bool
df: dict
feature_view_name: str
feast.feature_server.get_app(store: feast.feature_store.FeatureStore)[source]
feast.feature_server.start_server(store: feast.feature_store.FeatureStore, host: str, port: int, no_access_log: bool)[source]

feast.feature_service module

class feast.feature_service.FeatureService(*, name: str, features: List[Union[feast.feature_view.FeatureView, feast.on_demand_feature_view.OnDemandFeatureView]], tags: Dict[str, str] = None, description: str = '', owner: str = '', logging_config: Optional[feast.feature_logging.LoggingConfig] = None)[source]

Bases: object

A feature service defines a logical group of features from one or more feature views. This group of features can be retrieved together during training or serving.

name

The unique name of the feature service.

Type

str

feature_view_projections

A list containing feature views and feature view projections, representing the features in the feature service.

Type

List[feast.feature_view_projection.FeatureViewProjection]

description

A human-readable description.

Type

str

tags

A dictionary of key-value pairs to store arbitrary metadata.

Type

Dict[str, str]

owner

The owner of the feature service, typically the email of the primary maintainer.

Type

str

created_timestamp

The time when the feature service was created.

Type

Optional[datetime.datetime]

last_updated_timestamp

The time when the feature service was last updated.

Type

Optional[datetime.datetime]

created_timestamp: Optional[datetime.datetime] = None
description: str
feature_view_projections: List[feast.feature_view_projection.FeatureViewProjection]
classmethod from_proto(feature_service_proto: feast.core.FeatureService_pb2.FeatureService)[source]

Converts a FeatureServiceProto to a FeatureService object.

Parameters

feature_service_proto – A protobuf representation of a FeatureService.

infer_features(fvs_to_update: Dict[str, feast.feature_view.FeatureView])[source]

Infers the features for the projections of this feature service, and updates this feature service in place.

This method is necessary since feature services may rely on feature views which require feature inference.

Parameters

fvs_to_update – A mapping of feature view names to corresponding feature views that contains all the feature views necessary to run inference.

last_updated_timestamp: Optional[datetime.datetime] = None
logging_config: Optional[feast.feature_logging.LoggingConfig] = None
name: str
owner: str
tags: Dict[str, str]
to_proto() feast.core.FeatureService_pb2.FeatureService[source]

Converts a feature service to its protobuf representation.

Returns

A FeatureServiceProto protobuf.

validate()[source]

feast.feature_store module

class feast.feature_store.FeatureStore(repo_path: Optional[str] = None, config: Optional[feast.repo_config.RepoConfig] = None, fs_yaml_file: Optional[pathlib.Path] = None)[source]

Bases: object

A FeatureStore object is used to define, create, and retrieve features.

config

The config for the feature store.

Type

feast.repo_config.RepoConfig

repo_path

The path to the feature repo.

Type

pathlib.Path

_registry

The registry for the feature store.

Type

feast.infra.registry.base_registry.BaseRegistry

_provider

The provider for the feature store.

Type

feast.infra.provider.Provider

_go_server

The (optional) Go feature server for the feature store.

Type

Optional[EmbeddedOnlineFeatureServer]

apply(objects: Union[feast.data_source.DataSource, feast.entity.Entity, feast.feature_view.FeatureView, feast.on_demand_feature_view.OnDemandFeatureView, feast.request_feature_view.RequestFeatureView, feast.batch_feature_view.BatchFeatureView, feast.stream_feature_view.StreamFeatureView, feast.feature_service.FeatureService, feast.saved_dataset.ValidationReference, List[Union[feast.feature_view.FeatureView, feast.on_demand_feature_view.OnDemandFeatureView, feast.request_feature_view.RequestFeatureView, feast.batch_feature_view.BatchFeatureView, feast.stream_feature_view.StreamFeatureView, feast.entity.Entity, feast.feature_service.FeatureService, feast.data_source.DataSource, feast.saved_dataset.ValidationReference]]], objects_to_delete: Optional[List[Union[feast.feature_view.FeatureView, feast.on_demand_feature_view.OnDemandFeatureView, feast.request_feature_view.RequestFeatureView, feast.batch_feature_view.BatchFeatureView, feast.stream_feature_view.StreamFeatureView, feast.entity.Entity, feast.feature_service.FeatureService, feast.data_source.DataSource, feast.saved_dataset.ValidationReference]]] = None, partial: bool = True)[source]

Register objects to metadata store and update related infrastructure.

The apply method registers one or more definitions (e.g., Entity, FeatureView) and registers or updates these objects in the Feast registry. Once the apply method has updated the infrastructure (e.g., create tables in an online store), it will commit the updated registry. All operations are idempotent, meaning they can safely be rerun.

Parameters
  • objects – A single object, or a list of objects that should be registered with the Feature Store.

  • objects_to_delete – A list of objects to be deleted from the registry and removed from the provider’s infrastructure. This deletion will only be performed if partial is set to False.

  • partial – If True, apply will only handle the specified objects; if False, apply will also delete all the objects in objects_to_delete, and tear down any associated cloud resources.

Raises

ValueError – The ‘objects’ parameter could not be parsed properly.

Examples

Register an Entity and a FeatureView.

>>> from feast import FeatureStore, Entity, FeatureView, Feature, FileSource, RepoConfig
>>> from datetime import timedelta
>>> fs = FeatureStore(repo_path="project/feature_repo")
>>> driver = Entity(name="driver_id", description="driver id")
>>> driver_hourly_stats = FileSource(
...     path="project/feature_repo/data/driver_stats.parquet",
...     timestamp_field="event_timestamp",
...     created_timestamp_column="created",
... )
>>> driver_hourly_stats_view = FeatureView(
...     name="driver_hourly_stats",
...     entities=[driver],
...     ttl=timedelta(seconds=86400 * 1),
...     source=driver_hourly_stats,
... )
>>> fs.apply([driver_hourly_stats_view, driver]) # register entity and feature view
config: feast.repo_config.RepoConfig
create_saved_dataset(from_: feast.infra.offline_stores.offline_store.RetrievalJob, name: str, storage: feast.saved_dataset.SavedDatasetStorage, tags: Optional[Dict[str, str]] = None, feature_service: Optional[feast.feature_service.FeatureService] = None, allow_overwrite: bool = False) feast.saved_dataset.SavedDataset[source]

Execute provided retrieval job and persist its outcome in given storage. Storage type (eg, BigQuery or Redshift) must be the same as globally configured offline store. After data successfully persisted saved dataset object with dataset metadata is committed to the registry. Name for the saved dataset should be unique within project, since it’s possible to overwrite previously stored dataset with the same name.

Parameters
  • from – The retrieval job whose result should be persisted.

  • name – The name of the saved dataset.

  • storage – The saved dataset storage object indicating where the result should be persisted.

  • tags (optional) – A dictionary of key-value pairs to store arbitrary metadata.

  • feature_service (optional) – The feature service that should be associated with this saved dataset.

  • allow_overwrite (optional) – If True, the persisted result can overwrite an existing table or file.

Returns

SavedDataset object with attached RetrievalJob

Raises

ValueError if given retrieval job doesn't have metadata

delete_feature_service(name: str)[source]

Deletes a feature service.

Parameters

name – Name of feature service.

Raises

FeatureServiceNotFoundException – The feature view could not be found.

delete_feature_view(name: str)[source]

Deletes a feature view.

Parameters

name – Name of feature view.

Raises

FeatureViewNotFoundException – The feature view could not be found.

static ensure_request_data_values_exist(needed_request_data: Set[str], needed_request_fv_features: Set[str], request_data_features: Dict[str, List[Any]])[source]
get_data_source(name: str) feast.data_source.DataSource[source]

Retrieves the list of data sources from the registry.

Parameters

name – Name of the data source.

Returns

The specified data source.

Raises

DataSourceObjectNotFoundException – The data source could not be found.

get_entity(name: str, allow_registry_cache: bool = False) feast.entity.Entity[source]

Retrieves an entity.

Parameters
  • name – Name of entity.

  • allow_registry_cache – (Optional) Whether to allow returning this entity from a cached registry

Returns

The specified entity.

Raises

EntityNotFoundException – The entity could not be found.

get_feature_server_endpoint() Optional[str][source]

Returns endpoint for the feature server, if it exists.

get_feature_service(name: str, allow_cache: bool = False) feast.feature_service.FeatureService[source]

Retrieves a feature service.

Parameters
  • name – Name of feature service.

  • allow_cache – Whether to allow returning feature services from a cached registry.

Returns

The specified feature service.

Raises

FeatureServiceNotFoundException – The feature service could not be found.

get_feature_view(name: str, allow_registry_cache: bool = False) feast.feature_view.FeatureView[source]

Retrieves a feature view.

Parameters
  • name – Name of feature view.

  • allow_registry_cache – (Optional) Whether to allow returning this entity from a cached registry

Returns

The specified feature view.

Raises

FeatureViewNotFoundException – The feature view could not be found.

get_historical_features(entity_df: Union[pandas.core.frame.DataFrame, str], features: Union[List[str], feast.feature_service.FeatureService], full_feature_names: bool = False) feast.infra.offline_stores.offline_store.RetrievalJob[source]

Enrich an entity dataframe with historical feature values for either training or batch scoring.

This method joins historical feature data from one or more feature views to an entity dataframe by using a time travel join.

Each feature view is joined to the entity dataframe using all entities configured for the respective feature view. All configured entities must be available in the entity dataframe. Therefore, the entity dataframe must contain all entities found in all feature views, but the individual feature views can have different entities.

Time travel is based on the configured TTL for each feature view. A shorter TTL will limit the amount of scanning that will be done in order to find feature data for a specific entity key. Setting a short TTL may result in null values being returned.

Parameters
  • entity_df (Union[pd.DataFrame, str]) – An entity dataframe is a collection of rows containing all entity columns (e.g., customer_id, driver_id) on which features need to be joined, as well as a event_timestamp column used to ensure point-in-time correctness. Either a Pandas DataFrame can be provided or a string SQL query. The query must be of a format supported by the configured offline store (e.g., BigQuery)

  • features – The list of features that should be retrieved from the offline store. These features can be specified either as a list of string feature references or as a feature service. String feature references must have format “feature_view:feature”, e.g. “customer_fv:daily_transactions”.

  • full_feature_names – If True, feature names will be prefixed with the corresponding feature view name, changing them from the format “feature” to “feature_view__feature” (e.g. “daily_transactions” changes to “customer_fv__daily_transactions”).

Returns

RetrievalJob which can be used to materialize the results.

Raises

ValueError – Both or neither of features and feature_refs are specified.

Examples

Retrieve historical features from a local offline store.

>>> from feast import FeatureStore, RepoConfig
>>> import pandas as pd
>>> fs = FeatureStore(repo_path="project/feature_repo")
>>> entity_df = pd.DataFrame.from_dict(
...     {
...         "driver_id": [1001, 1002],
...         "event_timestamp": [
...             datetime(2021, 4, 12, 10, 59, 42),
...             datetime(2021, 4, 12, 8, 12, 10),
...         ],
...     }
... )
>>> retrieval_job = fs.get_historical_features(
...     entity_df=entity_df,
...     features=[
...         "driver_hourly_stats:conv_rate",
...         "driver_hourly_stats:acc_rate",
...         "driver_hourly_stats:avg_daily_trips",
...     ],
... )
>>> feature_data = retrieval_job.to_df()
static get_needed_request_data(grouped_odfv_refs: List[Tuple[feast.on_demand_feature_view.OnDemandFeatureView, List[str]]], grouped_request_fv_refs: List[Tuple[feast.request_feature_view.RequestFeatureView, List[str]]]) Tuple[Set[str], Set[str]][source]
get_on_demand_feature_view(name: str) feast.on_demand_feature_view.OnDemandFeatureView[source]

Retrieves a feature view.

Parameters

name – Name of feature view.

Returns

The specified feature view.

Raises

FeatureViewNotFoundException – The feature view could not be found.

get_online_features(features: Union[List[str], feast.feature_service.FeatureService], entity_rows: List[Dict[str, Any]], full_feature_names: bool = False) feast.online_response.OnlineResponse[source]

Retrieves the latest online feature data.

Note: This method will download the full feature registry the first time it is run. If you are using a remote registry like GCS or S3 then that may take a few seconds. The registry remains cached up to a TTL duration (which can be set to infinity). If the cached registry is stale (more time than the TTL has passed), then a new registry will be downloaded synchronously by this method. This download may introduce latency to online feature retrieval. In order to avoid synchronous downloads, please call refresh_registry() prior to the TTL being reached. Remember it is possible to set the cache TTL to infinity (cache forever).

Parameters
  • features – The list of features that should be retrieved from the online store. These features can be specified either as a list of string feature references or as a feature service. String feature references must have format “feature_view:feature”, e.g. “customer_fv:daily_transactions”.

  • entity_rows – A list of dictionaries where each key-value is an entity-name, entity-value pair.

  • full_feature_names – If True, feature names will be prefixed with the corresponding feature view name, changing them from the format “feature” to “feature_view__feature” (e.g. “daily_transactions” changes to “customer_fv__daily_transactions”).

Returns

OnlineResponse containing the feature data in records.

Raises

Exception – No entity with the specified name exists.

Examples

Retrieve online features from an online store.

>>> from feast import FeatureStore, RepoConfig
>>> fs = FeatureStore(repo_path="project/feature_repo")
>>> online_response = fs.get_online_features(
...     features=[
...         "driver_hourly_stats:conv_rate",
...         "driver_hourly_stats:acc_rate",
...         "driver_hourly_stats:avg_daily_trips",
...     ],
...     entity_rows=[{"driver_id": 1001}, {"driver_id": 1002}, {"driver_id": 1003}, {"driver_id": 1004}],
... )
>>> online_response_dict = online_response.to_dict()
get_saved_dataset(name: str) feast.saved_dataset.SavedDataset[source]

Find a saved dataset in the registry by provided name and create a retrieval job to pull whole dataset from storage (offline store).

If dataset couldn’t be found by provided name SavedDatasetNotFound exception will be raised.

Data will be retrieved from globally configured offline store.

Returns

SavedDataset with RetrievalJob attached

Raises

SavedDatasetNotFound

get_stream_feature_view(name: str, allow_registry_cache: bool = False) feast.stream_feature_view.StreamFeatureView[source]

Retrieves a stream feature view.

Parameters
  • name – Name of stream feature view.

  • allow_registry_cache – (Optional) Whether to allow returning this entity from a cached registry

Returns

The specified stream feature view.

Raises

FeatureViewNotFoundException – The feature view could not be found.

get_validation_reference(name: str, allow_cache: bool = False) feast.saved_dataset.ValidationReference[source]

Retrieves a validation reference.

Raises

ValidationReferenceNotFoundException – The validation reference could not be found.

list_data_sources(allow_cache: bool = False) List[feast.data_source.DataSource][source]

Retrieves the list of data sources from the registry.

Parameters

allow_cache – Whether to allow returning data sources from a cached registry.

Returns

A list of data sources.

list_entities(allow_cache: bool = False) List[feast.entity.Entity][source]

Retrieves the list of entities from the registry.

Parameters

allow_cache – Whether to allow returning entities from a cached registry.

Returns

A list of entities.

list_feature_services() List[feast.feature_service.FeatureService][source]

Retrieves the list of feature services from the registry.

Returns

A list of feature services.

list_feature_views(allow_cache: bool = False) List[feast.feature_view.FeatureView][source]

Retrieves the list of feature views from the registry.

Parameters

allow_cache – Whether to allow returning entities from a cached registry.

Returns

A list of feature views.

list_on_demand_feature_views(allow_cache: bool = False) List[feast.on_demand_feature_view.OnDemandFeatureView][source]

Retrieves the list of on demand feature views from the registry.

Returns

A list of on demand feature views.

list_request_feature_views(allow_cache: bool = False) List[feast.request_feature_view.RequestFeatureView][source]

Retrieves the list of feature views from the registry.

Parameters

allow_cache – Whether to allow returning entities from a cached registry.

Returns

A list of feature views.

list_stream_feature_views(allow_cache: bool = False) List[feast.stream_feature_view.StreamFeatureView][source]

Retrieves the list of stream feature views from the registry.

Returns

A list of stream feature views.

materialize(start_date: datetime.datetime, end_date: datetime.datetime, feature_views: Optional[List[str]] = None) None[source]

Materialize data from the offline store into the online store.

This method loads feature data in the specified interval from either the specified feature views, or all feature views if none are specified, into the online store where it is available for online serving.

Parameters
  • start_date (datetime) – Start date for time range of data to materialize into the online store

  • end_date (datetime) – End date for time range of data to materialize into the online store

  • feature_views (List[str]) – Optional list of feature view names. If selected, will only run materialization for the specified feature views.

Examples

Materialize all features into the online store over the interval from 3 hours ago to 10 minutes ago. >>> from feast import FeatureStore, RepoConfig >>> from datetime import datetime, timedelta >>> fs = FeatureStore(repo_path=”project/feature_repo”) >>> fs.materialize( … start_date=datetime.utcnow() - timedelta(hours=3), end_date=datetime.utcnow() - timedelta(minutes=10) … ) Materializing… <BLANKLINE> …

materialize_incremental(end_date: datetime.datetime, feature_views: Optional[List[str]] = None) None[source]

Materialize incremental new data from the offline store into the online store.

This method loads incremental new feature data up to the specified end time from either the specified feature views, or all feature views if none are specified, into the online store where it is available for online serving. The start time of the interval materialized is either the most recent end time of a prior materialization or (now - ttl) if no such prior materialization exists.

Parameters
  • end_date (datetime) – End date for time range of data to materialize into the online store

  • feature_views (List[str]) – Optional list of feature view names. If selected, will only run materialization for the specified feature views.

Raises

Exception – A feature view being materialized does not have a TTL set.

Examples

Materialize all features into the online store up to 5 minutes ago.

>>> from feast import FeatureStore, RepoConfig
>>> from datetime import datetime, timedelta
>>> fs = FeatureStore(repo_path="project/feature_repo")
>>> fs.materialize_incremental(end_date=datetime.utcnow() - timedelta(minutes=5))
Materializing...

...
plan(desired_repo_contents: feast.repo_contents.RepoContents) Tuple[feast.diff.registry_diff.RegistryDiff, feast.diff.infra_diff.InfraDiff, feast.infra.infra_object.Infra][source]

Dry-run registering objects to metadata store.

The plan method dry-runs registering one or more definitions (e.g., Entity, FeatureView), and produces a list of all the changes the that would be introduced in the feature repo. The changes computed by the plan command are for informational purposes, and are not actually applied to the registry.

Parameters

desired_repo_contents – The desired repo state.

Raises

ValueError – The ‘objects’ parameter could not be parsed properly.

Examples

Generate a plan adding an Entity and a FeatureView.

>>> from feast import FeatureStore, Entity, FeatureView, Feature, FileSource, RepoConfig
>>> from feast.feature_store import RepoContents
>>> from datetime import timedelta
>>> fs = FeatureStore(repo_path="project/feature_repo")
>>> driver = Entity(name="driver_id", description="driver id")
>>> driver_hourly_stats = FileSource(
...     path="project/feature_repo/data/driver_stats.parquet",
...     timestamp_field="event_timestamp",
...     created_timestamp_column="created",
... )
>>> driver_hourly_stats_view = FeatureView(
...     name="driver_hourly_stats",
...     entities=[driver],
...     ttl=timedelta(seconds=86400 * 1),
...     source=driver_hourly_stats,
... )
>>> registry_diff, infra_diff, new_infra = fs.plan(RepoContents(
...     data_sources=[driver_hourly_stats],
...     feature_views=[driver_hourly_stats_view],
...     on_demand_feature_views=list(),
...     stream_feature_views=list(),
...     request_feature_views=list(),
...     entities=[driver],
...     feature_services=list())) # register entity and feature view
property project: str

Gets the project of this feature store.

push(push_source_name: str, df: pandas.core.frame.DataFrame, allow_registry_cache: bool = True, to: feast.data_source.PushMode = PushMode.ONLINE)[source]

Push features to a push source. This updates all the feature views that have the push source as stream source.

Parameters
  • push_source_name – The name of the push source we want to push data to.

  • df – The data being pushed.

  • allow_registry_cache – Whether to allow cached versions of the registry.

  • to – Whether to push to online or offline store. Defaults to online store only.

refresh_registry()[source]

Fetches and caches a copy of the feature registry in memory.

Explicitly calling this method allows for direct control of the state of the registry cache. Every time this method is called the complete registry state will be retrieved from the remote registry store backend (e.g., GCS, S3), and the cache timer will be reset. If refresh_registry() is run before get_online_features() is called, then get_online_features() will use the cached registry instead of retrieving (and caching) the registry itself.

Additionally, the TTL for the registry cache can be set to infinity (by setting it to 0), which means that refresh_registry() will become the only way to update the cached registry. If the TTL is set to a value greater than 0, then once the cache becomes stale (more time than the TTL has passed), a new cache will be downloaded synchronously, which may increase latencies if the triggering method is get_online_features().

property registry: feast.infra.registry.base_registry.BaseRegistry

Gets the registry of this feature store.

repo_path: pathlib.Path
serve(host: str, port: int, type_: str, no_access_log: bool, no_feature_log: bool) None[source]

Start the feature consumption server locally on a given port.

serve_transformations(port: int) None[source]

Start the feature transformation server locally on a given port.

serve_ui(host: str, port: int, get_registry_dump: Callable, registry_ttl_sec: int) None[source]

Start the UI server locally

teardown()[source]

Tears down all local and cloud resources for the feature store.

validate_logged_features(source: feast.feature_service.FeatureService, start: datetime.datetime, end: datetime.datetime, reference: feast.saved_dataset.ValidationReference, throw_exception: bool = True, cache_profile: bool = True) Optional[feast.dqm.errors.ValidationFailed][source]

Load logged features from an offline store and validate them against provided validation reference.

Parameters
  • source – Logs source object (currently only feature services are supported)

  • start – lower bound for loading logged features

  • end – upper bound for loading logged features

  • reference – validation reference

  • throw_exception – throw exception or return it as a result

  • cache_profile – store cached profile in Feast registry

Returns

Throw or return (depends on parameter) ValidationFailed exception if validation was not successful or None if successful.

version() str[source]

Returns the version of the current Feast SDK/CLI.

write_logged_features(logs: Union[pyarrow.lib.Table, pathlib.Path], source: feast.feature_service.FeatureService)[source]

Write logs produced by a source (currently only feature service is supported as a source) to an offline store.

Parameters
  • logs – Arrow Table or path to parquet dataset directory on disk

  • source – Object that produces logs

write_to_offline_store(feature_view_name: str, df: pandas.core.frame.DataFrame, allow_registry_cache: bool = True, reorder_columns: bool = True)[source]

Persists the dataframe directly into the batch data source for the given feature view.

Fails if the dataframe columns do not match the columns of the batch data source. Optionally reorders the columns of the dataframe to match.

write_to_online_store(feature_view_name: str, df: pandas.core.frame.DataFrame, allow_registry_cache: bool = True)[source]

Persists a dataframe to the online store.

Parameters
  • feature_view_name – The feature view to which the dataframe corresponds.

  • df – The dataframe to be persisted.

  • allow_registry_cache (optional) – Whether to allow retrieving feature views from a cached registry.

feast.feature_store.apply_list_mapping(lst: Iterable[Any], mapping_indexes: Iterable[List[int]]) Iterable[Any][source]

feast.feature_view module

class feast.feature_view.FeatureView(*, name: str, source: feast.data_source.DataSource, schema: Optional[List[feast.field.Field]] = None, entities: List[feast.entity.Entity] = None, ttl: Optional[datetime.timedelta] = datetime.timedelta(0), online: bool = True, description: str = '', tags: Optional[Dict[str, str]] = None, owner: str = '')[source]

Bases: feast.base_feature_view.BaseFeatureView

A FeatureView defines a logical group of features.

name

The unique name of the feature view.

Type

str

entities

The list of names of entities that this feature view is associated with.

Type

List[str]

ttl

The amount of time this group of features lives. A ttl of 0 indicates that this group of features lives forever. Note that large ttl’s or a ttl of 0 can result in extremely computationally intensive queries.

Type

Optional[datetime.timedelta]

batch_source

The batch source of data where this group of features is stored. This is optional ONLY if a push source is specified as the stream_source, since push sources contain their own batch sources.

Type

feast.data_source.DataSource

stream_source

The stream source of data where this group of features is stored.

Type

Optional[feast.data_source.DataSource]

schema

The schema of the feature view, including feature, timestamp, and entity columns. If not specified, can be inferred from the underlying data source.

Type

List[feast.field.Field]

entity_columns

The list of entity columns contained in the schema. If not specified, can be inferred from the underlying data source.

Type

List[feast.field.Field]

features

The list of feature columns contained in the schema. If not specified, can be inferred from the underlying data source.

Type

List[feast.field.Field]

online

A boolean indicating whether online retrieval is enabled for this feature view.

Type

bool

description

A human-readable description.

Type

str

tags

A dictionary of key-value pairs to store arbitrary metadata.

Type

Dict[str, str]

owner

The owner of the feature view, typically the email of the primary maintainer.

Type

str

batch_source: feast.data_source.DataSource
description: str
ensure_valid()[source]

Validates the state of this feature view locally.

Raises

ValueError – The feature view does not have a name or does not have entities.

entities: List[str]
entity_columns: List[feast.field.Field]
features: List[feast.field.Field]
classmethod from_proto(feature_view_proto: feast.core.FeatureView_pb2.FeatureView)[source]

Creates a feature view from a protobuf representation of a feature view.

Parameters

feature_view_proto – A protobuf representation of a feature view.

Returns

A FeatureViewProto object based on the feature view protobuf.

get_ttl_duration()[source]
property join_keys: List[str]

Returns a list of all the join keys.

materialization_intervals: List[Tuple[datetime.datetime, datetime.datetime]]
property most_recent_end_time: Optional[datetime.datetime]

Retrieves the latest time up to which the feature view has been materialized.

Returns

The latest time, or None if the feature view has not been materialized.

name: str
online: bool
owner: str
property proto_class: Type[feast.core.FeatureView_pb2.FeatureView]
schema: List[feast.field.Field]
stream_source: Optional[feast.data_source.DataSource]
tags: Dict[str, str]
to_proto() feast.core.FeatureView_pb2.FeatureView[source]

Converts a feature view object to its protobuf representation.

Returns

A FeatureViewProto protobuf.

to_proto_meta()[source]
ttl: Optional[datetime.timedelta]
with_join_key_map(join_key_map: Dict[str, str])[source]

Returns a copy of this feature view with the join key map set to the given map. This join_key mapping operation is only used as part of query operations and will not modify the underlying FeatureView.

Parameters

join_key_map – A map of join keys in which the left is the join_key that corresponds with the feature data and the right corresponds with the entity data.

Examples

Join a location feature data table to both the origin column and destination column of the entity data.

temperatures_feature_service = FeatureService(

name=”temperatures”, features=[

location_stats_feature_view

.with_name(“origin_stats”) .with_join_key_map(

{“location_id”: “origin_id”}

),

location_stats_feature_view

.with_name(“destination_stats”) .with_join_key_map(

{“location_id”: “destination_id”}

),

],

)

feast.feature_view_projection module

class feast.feature_view_projection.FeatureViewProjection(name: str, name_alias: Optional[str], desired_features: List[str], features: List[feast.field.Field], join_key_map: Dict[str, str] = {})[source]

Bases: object

A feature view projection represents a selection of one or more features from a single feature view.

name

The unique name of the feature view from which this projection is created.

Type

str

name_alias

An optional alias for the name.

Type

Optional[str]

features

The list of features represented by the feature view projection.

Type

List[feast.field.Field]

desired_features

The list of features that this feature view projection intends to select. If empty, the projection intends to select all features. This attribute is only used for feature service inference. It should only be set if the underlying feature view is not ready to be projected, i.e. still needs to go through feature inference.

Type

List[str]

join_key_map

A map to modify join key columns during retrieval of this feature view projection.

Type

Dict[str, str]

desired_features: List[str]
features: List[feast.field.Field]
static from_definition(base_feature_view: BaseFeatureView)[source]
static from_proto(proto: feast.core.FeatureViewProjection_pb2.FeatureViewProjection)[source]
get_feature(feature_name: str) feast.field.Field[source]
join_key_map: Dict[str, str]
name: str
name_alias: Optional[str]
name_to_use()[source]
to_proto() feast.core.FeatureViewProjection_pb2.FeatureViewProjection[source]

feast.field module

class feast.field.Field(*, name: str, dtype: Union[feast.types.ComplexFeastType, feast.types.PrimitiveFeastType], tags: Optional[Dict[str, str]] = None)[source]

Bases: object

A Field represents a set of values with the same structure.

name

The name of the field.

Type

str

dtype

The type of the field, such as string or float.

Type

Union[feast.types.ComplexFeastType, feast.types.PrimitiveFeastType]

tags

User-defined metadata in dictionary form.

Type

Dict[str, str]

dtype: Union[feast.types.ComplexFeastType, feast.types.PrimitiveFeastType]
classmethod from_feature(feature: feast.feature.Feature)[source]

Creates a Field object from a Feature object.

Parameters

feature – Feature object to convert.

classmethod from_proto(field_proto: feast.core.Feature_pb2.FeatureSpecV2)[source]

Creates a Field object from a protobuf representation.

Parameters

field_proto – FieldProto protobuf object

name: str
tags: Dict[str, str]
to_proto() feast.core.Feature_pb2.FeatureSpecV2[source]

Converts a Field object to its protobuf representation.

feast.file_utils module

feast.file_utils.remove_lines_from_file(file_path, match_str, partial=True)[source]

Edit an ascii file (in-place) by removing all lines that match a given string (partially or totally). Does not return anything, side-effect only. Inputs are:

file_path, a string with the path to the ascii file to edit match_str, the string to look for in the file lines partial, a boolean: if True, any line with match_str as substring

will be removed; if False, only lines matching it entirely.

NOTE: not suitable for very large files (it does all in-memory).

feast.file_utils.replace_str_in_file(file_path, match_str, sub_str)[source]

Replace a string, in-place, in a text file, throughout. Does not return anything, side-effect only. Inputs are:

file_path, a string with the path to the ascii file to edit match_str, the substring to be replaced (as many times as it’s found) sub_str, the string to insert in place of match_str

NOTE: not suitable for very large files (it does all in-memory).

feast.file_utils.write_setting_or_remove(file_path, setting_value, setting_name, setting_placeholder_value)[source]

Utility to adapt a settings-file template to some provided values. Assumes the file has lines such as

” username: c_username”

(quotes excluded) where the placeholder might be replaced with actual value or the line might not be needed altogether. Then, calling

write_settings_or_remove(file_path, new_username, ‘username’, ‘c_username’)

the file is edited in-place in one of two ways:
  1. if new_username is None, the line disappears completely

  2. if e.g. new_username == ‘jenny’, the line becomes

    ” username: jenny”

This utility is called repeatedly (a bit inefficiently, admittedly) to refine the template feature-store yaml config to suit the parameters supplied during a “feast init” feature store setup.

feast.flags_helper module

feast.flags_helper.is_test() bool[source]

feast.importer module

feast.importer.import_class(module_name: str, class_name: str, class_type: Optional[str] = None)[source]

Dynamically loads and returns a class from a module.

Parameters
  • module_name – The name of the module.

  • class_name – The name of the class.

  • class_type – Optional name of a base class of the class.

Raises

feast.inference module

feast.inference.update_data_sources_with_inferred_event_timestamp_col(data_sources: List[feast.data_source.DataSource], config: feast.repo_config.RepoConfig) None[source]
feast.inference.update_feature_views_with_inferred_features_and_entities(fvs: Union[List[feast.feature_view.FeatureView], List[feast.stream_feature_view.StreamFeatureView]], entities: List[feast.entity.Entity], config: feast.repo_config.RepoConfig) None[source]

Infers the features and entities associated with each feature view and updates it in place.

Columns whose names match a join key of an entity are considered to be entity columns; all other columns except designated timestamp columns are considered to be feature columns. If the feature view already has features, feature inference is skipped.

Note that this inference logic currently does not take any transformations (either a UDF or aggregations) into account. For example, even if a stream feature view has a transformation, this method assumes that the batch source contains transformed data with the correct final schema.

Parameters
  • fvs – The feature views to be updated.

  • entities – A list containing entities associated with the feature views.

  • config – The config for the current feature store.

feast.names module

feast.on_demand_feature_view module

class feast.on_demand_feature_view.OnDemandFeatureView(*, name: str, schema: List[feast.field.Field], sources: List[Union[feast.feature_view.FeatureView, feast.data_source.RequestSource, feast.feature_view_projection.FeatureViewProjection]], udf: function, udf_string: str = '', description: str = '', tags: Optional[Dict[str, str]] = None, owner: str = '')[source]

Bases: feast.base_feature_view.BaseFeatureView

[Experimental] An OnDemandFeatureView defines a logical group of features that are generated by applying a transformation on a set of input sources, such as feature views and request data sources.

name

The unique name of the on demand feature view.

Type

str

features

The list of features in the output of the on demand feature view.

Type

List[feast.field.Field]

source_feature_view_projections

A map from input source names to actual input sources with type FeatureViewProjection.

Type

Dict[str, feast.feature_view_projection.FeatureViewProjection]

source_request_sources

A map from input source names to the actual input sources with type RequestSource.

Type

Dict[str, feast.data_source.RequestSource]

udf

The user defined transformation function, which must take pandas dataframes as inputs.

Type

function

description

A human-readable description.

Type

str

tags

A dictionary of key-value pairs to store arbitrary metadata.

Type

Dict[str, str]

owner

The owner of the on demand feature view, typically the email of the primary maintainer.

Type

str

description: str
features: List[feast.field.Field]
classmethod from_proto(on_demand_feature_view_proto: feast.core.OnDemandFeatureView_pb2.OnDemandFeatureView)[source]

Creates an on demand feature view from a protobuf representation.

Parameters

on_demand_feature_view_proto – A protobuf representation of an on-demand feature view.

Returns

A OnDemandFeatureView object based on the on-demand feature view protobuf.

get_request_data_schema() Dict[str, feast.value_type.ValueType][source]
static get_requested_odfvs(feature_refs, project, registry)[source]
get_transformed_features_df(df_with_features: pandas.core.frame.DataFrame, full_feature_names: bool = False) pandas.core.frame.DataFrame[source]
infer_features()[source]

Infers the set of features associated to this feature view from the input source.

Raises

RegistryInferenceFailure – The set of features could not be inferred.

name: str
owner: str
property proto_class: Type[feast.core.OnDemandFeatureView_pb2.OnDemandFeatureView]
source_feature_view_projections: Dict[str, feast.feature_view_projection.FeatureViewProjection]
source_request_sources: Dict[str, feast.data_source.RequestSource]
tags: Dict[str, str]
to_proto() feast.core.OnDemandFeatureView_pb2.OnDemandFeatureView[source]

Converts an on demand feature view object to its protobuf representation.

Returns

A OnDemandFeatureViewProto protobuf.

udf: function
udf_string: str
feast.on_demand_feature_view.feature_view_to_batch_feature_view(fv: feast.feature_view.FeatureView) feast.batch_feature_view.BatchFeatureView[source]
feast.on_demand_feature_view.on_demand_feature_view(*, schema: List[feast.field.Field], sources: List[Union[feast.feature_view.FeatureView, feast.data_source.RequestSource, feast.feature_view_projection.FeatureViewProjection]], description: str = '', tags: Optional[Dict[str, str]] = None, owner: str = '')[source]

Creates an OnDemandFeatureView object with the given user function as udf.

Parameters
  • schema – The list of features in the output of the on demand feature view, after the transformation has been applied.

  • sources – A map from input source names to the actual input sources, which may be feature views, or request data sources. These sources serve as inputs to the udf, which will refer to them by name.

  • description (optional) – A human-readable description.

  • tags (optional) – A dictionary of key-value pairs to store arbitrary metadata.

  • owner (optional) – The owner of the on demand feature view, typically the email of the primary maintainer.

feast.online_response module

class feast.online_response.OnlineResponse(online_response_proto: feast.serving.ServingService_pb2.GetOnlineFeaturesResponse)[source]

Bases: object

Defines an online response in feast.

to_df(include_event_timestamps: bool = False) pandas.core.frame.DataFrame[source]

Converts GetOnlineFeaturesResponse features into Panda dataframe form.

Args: is_with_event_timestamps: bool Optionally include feature timestamps in the dataframe

to_dict(include_event_timestamps: bool = False) Dict[str, Any][source]

Converts GetOnlineFeaturesResponse features into a dictionary form.

Args: is_with_event_timestamps: bool Optionally include feature timestamps in the dictionary

feast.project_metadata module

class feast.project_metadata.ProjectMetadata(*args, project_name: Optional[str] = None, project_uuid: Optional[str] = None)[source]

Bases: object

Tracks project level metadata

project_name

The registry-scoped unique name of the project.

Type

str

project_uuid

The UUID for this project

Type

str

classmethod from_proto(project_metadata_proto: feast.core.Registry_pb2.ProjectMetadata)[source]

Creates project metadata from a protobuf representation.

Parameters

project_metadata_proto – A protobuf representation of project metadata.

Returns

A ProjectMetadata object based on the protobuf.

project_name: str
project_uuid: str
to_proto() feast.core.Registry_pb2.ProjectMetadata[source]

Converts a project metadata object to its protobuf representation.

Returns

An ProjectMetadataProto protobuf.

feast.proto_json module

feast.proto_json.patch()[source]

Patch Protobuf JSON Encoder / Decoder with all desired Feast types.

feast.repo_config module

class feast.repo_config.FeastBaseModel(**extra_data: Any)[source]

Bases: pydantic.main.BaseModel

Feast Pydantic Configuration Class

class Config[source]

Bases: object

arbitrary_types_allowed = True
extra = 'allow'
class feast.repo_config.FeastConfigBaseModel[source]

Bases: pydantic.main.BaseModel

Feast Pydantic Configuration Class

class Config[source]

Bases: object

arbitrary_types_allowed = True
extra = 'forbid'
exception feast.repo_config.FeastConfigError(error_message, config_path)[source]

Bases: Exception

class feast.repo_config.RegistryConfig(*, registry_type: pydantic.types.StrictStr = 'file', registry_store_type: Optional[pydantic.types.StrictStr] = None, path: pydantic.types.StrictStr, cache_ttl_seconds: pydantic.types.StrictInt = 600, s3_additional_kwargs: Optional[Dict[str, str]] = None, **extra_data: Any)[source]

Bases: feast.repo_config.FeastBaseModel

Metadata Store Configuration. Configuration that relates to reading from and writing to the Feast registry.

cache_ttl_seconds: pydantic.types.StrictInt

The cache TTL is the amount of time registry state will be cached in memory. If this TTL is exceeded then the registry will be refreshed when any feature store method asks for access to registry state. The TTL can be set to infinity by setting TTL to 0 seconds, which means the cache will only be loaded once and will never expire. Users can manually refresh the cache by calling feature_store.refresh_registry()

Type

int

path: pydantic.types.StrictStr

Path to metadata store. Can be a local path, or remote object storage path, e.g. a GCS URI

Type

str

registry_store_type: Optional[pydantic.types.StrictStr]

Provider name or a class name that implements RegistryStore.

Type

str

registry_type: pydantic.types.StrictStr

Provider name or a class name that implements RegistryStore. If specified, registry_store_type should be redundant.

Type

str

s3_additional_kwargs: Optional[Dict[str, str]]

Extra arguments to pass to boto3 when writing the registry file to S3.

Type

Dict[str, str]

class feast.repo_config.RepoConfig(*, registry: Union[pydantic.types.StrictStr, feast.repo_config.RegistryConfig] = 'data/registry.db', project: pydantic.types.StrictStr, provider: pydantic.types.StrictStr, feature_server: Optional[Any] = None, flags: Any = None, repo_path: Optional[pathlib.Path] = None, go_feature_serving: Optional[bool] = False, go_feature_retrieval: Optional[bool] = False, entity_key_serialization_version: pydantic.types.StrictInt = 1, coerce_tz_aware: Optional[bool] = True, **data: Any)[source]

Bases: feast.repo_config.FeastBaseModel

Repo config. Typically loaded from feature_store.yaml

class Config[source]

Bases: object

allow_population_by_field_name = True
property batch_engine
coerce_tz_aware: Optional[bool]

If True, coerces entity_df timestamp columns to be timezone aware (to UTC by default).

entity_key_serialization_version: pydantic.types.StrictInt

This version is used to control what serialization scheme is used when writing data to the online store. A value <= 1 uses the serialization scheme used by feast up to Feast 0.22. A value of 2 uses a newer serialization scheme, supported as of Feast 0.23. The main difference between the two scheme is that the serialization scheme v1 stored long values as `int`s, which would result in errors trying to serialize a range of values. v2 fixes this error, but v1 is kept around to ensure backwards compatibility - specifically the ability to read feature values for entities that have already been written into the online store.

Type

Entity key serialization version

feature_server: Optional[Any]

Feature server configuration (optional depending on provider)

Type

FeatureServerConfig

flags: Any

Feature flags for experimental features

Type

Flags (deprecated field)

get_registry_config()[source]
go_feature_retrieval: Optional[bool]

If True, use the embedded Go code to retrieve features instead of the Python SDK.

go_feature_serving: Optional[bool]

If True, use the Go feature server instead of the Python feature server.

property offline_store
property online_store
project: pydantic.types.StrictStr

Feast project id. This can be any alphanumeric string up to 16 characters. You can have multiple independent feature repositories deployed to the same cloud provider account, as long as they have different project ids.

Type

str

provider: pydantic.types.StrictStr

local or gcp or aws

Type

str

registry: Union[pydantic.types.StrictStr, feast.repo_config.RegistryConfig]

Path to metadata store. Can be a local path, or remote object storage path, e.g. a GCS URI

Type

str

repo_path: Optional[pathlib.Path]
write_to_path(repo_path: pathlib.Path)[source]
feast.repo_config.get_batch_engine_config_from_type(batch_engine_type: str)[source]
feast.repo_config.get_data_source_class_from_type(data_source_type: str)[source]
feast.repo_config.get_feature_server_config_from_type(feature_server_type: str)[source]
feast.repo_config.get_offline_config_from_type(offline_store_type: str)[source]
feast.repo_config.get_online_config_from_type(online_store_type: str)[source]
feast.repo_config.load_repo_config(repo_path: pathlib.Path, fs_yaml_file: pathlib.Path) feast.repo_config.RepoConfig[source]

feast.repo_contents module

class feast.repo_contents.RepoContents(data_sources: List[feast.data_source.DataSource], feature_views: List[feast.feature_view.FeatureView], on_demand_feature_views: List[feast.on_demand_feature_view.OnDemandFeatureView], request_feature_views: List[feast.request_feature_view.RequestFeatureView], stream_feature_views: List[feast.stream_feature_view.StreamFeatureView], entities: List[feast.entity.Entity], feature_services: List[feast.feature_service.FeatureService])[source]

Bases: tuple

Represents the objects in a Feast feature repo.

data_sources: List[feast.data_source.DataSource]

Alias for field number 0

entities: List[feast.entity.Entity]

Alias for field number 5

feature_services: List[feast.feature_service.FeatureService]

Alias for field number 6

feature_views: List[feast.feature_view.FeatureView]

Alias for field number 1

on_demand_feature_views: List[feast.on_demand_feature_view.OnDemandFeatureView]

Alias for field number 2

request_feature_views: List[feast.request_feature_view.RequestFeatureView]

Alias for field number 3

stream_feature_views: List[feast.stream_feature_view.StreamFeatureView]

Alias for field number 4

to_registry_proto() feast.core.Registry_pb2.Registry[source]

feast.repo_operations module

feast.repo_operations.apply_total(repo_config: feast.repo_config.RepoConfig, repo_path: pathlib.Path, skip_source_validation: bool)[source]
feast.repo_operations.apply_total_with_repo_instance(store: feast.feature_store.FeatureStore, project: str, registry: feast.infra.registry.registry.Registry, repo: feast.repo_contents.RepoContents, skip_source_validation: bool)[source]
feast.repo_operations.cli_check_repo(repo_path: pathlib.Path, fs_yaml_file: pathlib.Path)[source]
feast.repo_operations.extract_objects_for_apply_delete(project, registry, repo)[source]
feast.repo_operations.generate_project_name() str[source]

Generates a unique project name

feast.repo_operations.get_ignore_files(repo_root: pathlib.Path, ignore_paths: List[str]) Set[pathlib.Path][source]

Get all ignore files that match any of the user-defined ignore paths

feast.repo_operations.get_repo_files(repo_root: pathlib.Path) List[pathlib.Path][source]

Get the list of all repo files, ignoring undesired files & directories specified in .feastignore

feast.repo_operations.init_repo(repo_name: str, template: str)[source]
feast.repo_operations.is_valid_name(name: str) bool[source]

A name should be alphanumeric values and underscores but not start with an underscore

feast.repo_operations.log_infra_changes(views_to_keep: Set[feast.feature_view.FeatureView], views_to_delete: Set[feast.feature_view.FeatureView])[source]
feast.repo_operations.parse_repo(repo_root: pathlib.Path) feast.repo_contents.RepoContents[source]

Collects unique Feast object definitions from the given feature repo.

Specifically, if an object foo has already been added, bar will still be added if (bar == foo), but not if (bar is foo). This ensures that import statements will not result in duplicates, but defining two equal objects will.

feast.repo_operations.plan(repo_config: feast.repo_config.RepoConfig, repo_path: pathlib.Path, skip_source_validation: bool)[source]
feast.repo_operations.py_path_to_module(path: pathlib.Path) str[source]
feast.repo_operations.read_feastignore(repo_root: pathlib.Path) List[str][source]

Read .feastignore in the repo root directory (if exists) and return the list of user-defined ignore paths

feast.repo_operations.registry_dump(repo_config: feast.repo_config.RepoConfig, repo_path: pathlib.Path) str[source]

For debugging only: output contents of the metadata registry

feast.repo_operations.teardown(repo_config: feast.repo_config.RepoConfig, repo_path: pathlib.Path)[source]

feast.repo_upgrade module

class feast.repo_upgrade.RepoUpgrader(repo_path: str, write: bool)[source]

Bases: object

static import_remover(class_name)[source]
static remove_argument_transform(node: fissix.pytree.Node, argument: str)[source]

Removes the specified argument. For example, if the argument is “join_key”, this method transforms driver = Entity(

name=”driver_id”, join_key=”driver_id”,

) into driver = Entity(

name=”driver_id”,

) This method assumes that node represents a class call that already has an arglist.

remove_date_partition_column()[source]
static rename_arguments_in_children(children: List[fissix.pytree.Node], renames: Dict[str, str]) None[source]

Renames the arguments in the children list of a node by searching for the argument list or trailing list and renaming all keys in renames dict to corresponding value.

static rename_class_call(node: fissix.pytree.Node, new_class_name: str)[source]

Rename the class being instantiated. f = Feature(

name=”driver_id”, join_key=”driver_id”,

) into f = Field(

name=”driver_id”,

) This method assumes that node represents a class call that already has an arglist.

rename_features_to_schema()[source]
rename_inputs_to_sources()[source]
upgrade()[source]

feast.request_feature_view module

class feast.request_feature_view.RequestFeatureView(name: str, request_data_source: feast.data_source.RequestSource, description: str = '', tags: Optional[Dict[str, str]] = None, owner: str = '')[source]

Bases: feast.base_feature_view.BaseFeatureView

[Experimental] A RequestFeatureView defines a logical group of features that should be available as an input to an on demand feature view at request time.

name

The unique name of the request feature view.

Type

str

request_source

The request source that specifies the schema and features of the request feature view.

Type

feast.data_source.RequestSource

features

The list of features defined as part of this request feature view.

Type

List[feast.field.Field]

description

A human-readable description.

Type

str

tags

A dictionary of key-value pairs to store arbitrary metadata.

Type

Dict[str, str]

owner

The owner of the request feature view, typically the email of the primary maintainer.

Type

str

description: str
features: List[feast.field.Field]
classmethod from_proto(request_feature_view_proto: feast.core.RequestFeatureView_pb2.RequestFeatureView)[source]

Creates a request feature view from a protobuf representation.

Parameters

request_feature_view_proto – A protobuf representation of an request feature view.

Returns

A RequestFeatureView object based on the request feature view protobuf.

name: str
owner: str
property proto_class: Type[feast.core.RequestFeatureView_pb2.RequestFeatureView]
request_source: feast.data_source.RequestSource
tags: Dict[str, str]
to_proto() feast.core.RequestFeatureView_pb2.RequestFeatureView[source]

Converts an request feature view object to its protobuf representation.

Returns

A RequestFeatureViewProto protobuf.

feast.saved_dataset module

class feast.saved_dataset.SavedDataset(name: str, features: List[str], join_keys: List[str], storage: feast.saved_dataset.SavedDatasetStorage, full_feature_names: bool = False, tags: Optional[Dict[str, str]] = None, feature_service_name: Optional[str] = None)[source]

Bases: object

as_reference(name: str, profiler: feast.dqm.profilers.profiler.Profiler) feast.saved_dataset.ValidationReference[source]
created_timestamp: Optional[datetime.datetime] = None
feature_service_name: Optional[str] = None
features: List[str]
static from_proto(saved_dataset_proto: feast.core.SavedDataset_pb2.SavedDataset)[source]

Converts a SavedDatasetProto to a SavedDataset object.

Parameters

saved_dataset_proto – A protobuf representation of a SavedDataset.

full_feature_names: bool
get_profile(profiler: feast.dqm.profilers.profiler.Profiler) feast.dqm.profilers.profiler.Profile[source]
join_keys: List[str]
last_updated_timestamp: Optional[datetime.datetime] = None
max_event_timestamp: Optional[datetime.datetime] = None
min_event_timestamp: Optional[datetime.datetime] = None
name: str
storage: feast.saved_dataset.SavedDatasetStorage
tags: Dict[str, str]
to_arrow() pyarrow.lib.Table[source]
to_df() pandas.core.frame.DataFrame[source]
to_proto() feast.core.SavedDataset_pb2.SavedDataset[source]

Converts a SavedDataset to its protobuf representation.

Returns

A SavedDatasetProto protobuf.

with_retrieval_job(retrieval_job: RetrievalJob) SavedDataset[source]
class feast.saved_dataset.SavedDatasetStorage[source]

Bases: object

static from_data_source(data_source: feast.data_source.DataSource) feast.saved_dataset.SavedDatasetStorage[source]
static from_proto(storage_proto: feast.core.SavedDataset_pb2.SavedDatasetStorage) feast.saved_dataset.SavedDatasetStorage[source]
abstract to_data_source() feast.data_source.DataSource[source]
abstract to_proto() feast.core.SavedDataset_pb2.SavedDatasetStorage[source]
class feast.saved_dataset.ValidationReference(name: str, dataset_name: str, profiler: feast.dqm.profilers.profiler.Profiler, description: str = '', tags: Optional[Dict[str, str]] = None)[source]

Bases: object

dataset_name: str
description: str
classmethod from_proto(proto: feast.core.ValidationProfile_pb2.ValidationReference) feast.saved_dataset.ValidationReference[source]
classmethod from_saved_dataset(name: str, dataset: feast.saved_dataset.SavedDataset, profiler: feast.dqm.profilers.profiler.Profiler)[source]

Internal constructor to create validation reference object with actual saved dataset object (regular constructor requires only its name).

name: str
property profile: feast.dqm.profilers.profiler.Profile
profiler: feast.dqm.profilers.profiler.Profiler
tags: Dict[str, str]
to_proto() feast.core.ValidationProfile_pb2.ValidationReference[source]
feast.saved_dataset.get_saved_dataset_storage_class_from_path(saved_dataset_storage_path: str)[source]

feast.stream_feature_view module

class feast.stream_feature_view.StreamFeatureView(*, name: str, source: feast.data_source.DataSource, entities: Optional[Union[List[feast.entity.Entity], List[str]]] = None, ttl: datetime.timedelta = datetime.timedelta(0), tags: Optional[Dict[str, str]] = None, online: Optional[bool] = True, description: Optional[str] = '', owner: Optional[str] = '', schema: Optional[List[feast.field.Field]] = None, aggregations: Optional[List[feast.aggregation.Aggregation]] = None, mode: Optional[str] = 'spark', timestamp_field: Optional[str] = '', udf: Optional[function] = None, udf_string: Optional[str] = '')[source]

Bases: feast.feature_view.FeatureView

A stream feature view defines a logical group of features that has both a stream data source and a batch data source.

name

The unique name of the stream feature view.

Type

str

entities

List of entities or entity join keys.

Type

List[str]

ttl

The amount of time this group of features lives. A ttl of 0 indicates that this group of features lives forever. Note that large ttl’s or a ttl of 0 can result in extremely computationally intensive queries.

Type

Optional[datetime.timedelta]

schema

The schema of the feature view, including feature, timestamp, and entity columns. If not specified, can be inferred from the underlying data source.

Type

List[feast.field.Field]

source

The stream source of data where this group of features is stored.

Type

feast.data_source.DataSource

aggregations

List of aggregations registered with the stream feature view.

Type

List[feast.aggregation.Aggregation]

mode

The mode of execution.

Type

str

timestamp_field

Must be specified if aggregations are specified. Defines the timestamp column on which to aggregate windows.

Type

str

online

A boolean indicating whether online retrieval is enabled for this feature view.

Type

bool

description

A human-readable description.

Type

str

tags

A dictionary of key-value pairs to store arbitrary metadata.

Type

Dict[str, str]

owner

The owner of the stream feature view, typically the email of the primary maintainer.

Type

str

udf

The user defined transformation function. This transformation function should have all of the corresponding imports imported within the function.

Type

Optional[function]

aggregations: List[feast.aggregation.Aggregation]
description: str
entities: List[str]
entity_columns: List[feast.field.Field]
features: List[feast.field.Field]
classmethod from_proto(sfv_proto)[source]

Creates a feature view from a protobuf representation of a feature view.

Parameters

feature_view_proto – A protobuf representation of a feature view.

Returns

A FeatureViewProto object based on the feature view protobuf.

materialization_intervals: List[Tuple[datetime.datetime, datetime.datetime]]
mode: str
name: str
online: bool
owner: str
schema: List[feast.field.Field]
source: feast.data_source.DataSource
tags: Dict[str, str]
timestamp_field: str
to_proto()[source]

Converts a feature view object to its protobuf representation.

Returns

A FeatureViewProto protobuf.

ttl: Optional[datetime.timedelta]
udf: Optional[function]
udf_string: Optional[str]
feast.stream_feature_view.stream_feature_view(*, entities: Optional[Union[List[feast.entity.Entity], List[str]]] = None, ttl: Optional[datetime.timedelta] = None, tags: Optional[Dict[str, str]] = None, online: Optional[bool] = True, description: Optional[str] = '', owner: Optional[str] = '', schema: Optional[List[feast.field.Field]] = None, source: Optional[feast.data_source.DataSource] = None, aggregations: Optional[List[feast.aggregation.Aggregation]] = None, mode: Optional[str] = 'spark', timestamp_field: Optional[str] = '')[source]

Creates an StreamFeatureView object with the given user function as udf. Please make sure that the udf contains all non-built in imports within the function to ensure that the execution of a deserialized function does not miss imports.

feast.transformation_server module

class feast.transformation_server.TransformationServer(fs: feast.feature_store.FeatureStore)[source]

Bases: feast.protos.feast.serving.TransformationService_pb2_grpc.TransformationServiceServicer

GetTransformationServiceInfo(request, context)[source]

Missing associated documentation comment in .proto file.

TransformFeatures(request, context)[source]

Missing associated documentation comment in .proto file.

feast.transformation_server.start_server(store: feast.feature_store.FeatureStore, port: int)[source]

feast.type_map module

feast.type_map.arrow_to_pg_type(t_str: str) str[source]
feast.type_map.athena_to_feast_value_type(athena_type_as_str: str) feast.value_type.ValueType[source]
feast.type_map.bq_to_feast_value_type(bq_type_as_str: str) feast.value_type.ValueType[source]
feast.type_map.feast_value_type_to_pa(feast_type: feast.value_type.ValueType) pyarrow.DataType[source]
feast.type_map.feast_value_type_to_pandas_type(value_type: feast.value_type.ValueType) Any[source]
feast.type_map.feast_value_type_to_python_type(field_value_proto: feast.types.Value_pb2.Value) Any[source]

Converts field value Proto to Dict and returns each field’s Feast Value Type value in their respective Python value.

Parameters

field_value_proto – Field value Proto

Returns

Python native type representation/version of the given field_value_proto

feast.type_map.mssql_to_feast_value_type(mssql_type_as_str: str) feast.value_type.ValueType[source]
feast.type_map.pa_to_athena_value_type(pa_type: pyarrow.DataType) str[source]
feast.type_map.pa_to_feast_value_type(pa_type_as_str: str) feast.value_type.ValueType[source]
feast.type_map.pa_to_mssql_type(pa_type: pyarrow.DataType) str[source]
feast.type_map.pa_to_redshift_value_type(pa_type: pyarrow.DataType) str[source]
feast.type_map.pg_type_code_to_arrow(code: int) str[source]
feast.type_map.pg_type_code_to_pg_type(code: int) str[source]
feast.type_map.pg_type_to_feast_value_type(type_str: str) feast.value_type.ValueType[source]
feast.type_map.python_type_to_feast_value_type(name: str, value: Optional[Any] = None, recurse: bool = True, type_name: Optional[str] = None) feast.value_type.ValueType[source]

Finds the equivalent Feast Value Type for a Python value. Both native and Pandas types are supported. This function will recursively look for nested types when arrays are detected. All types must be homogenous.

Parameters
  • name – Name of the value or field

  • value – Value that will be inspected

  • recurse – Whether to recursively look for nested types in arrays

Returns

Feast Value Type

feast.type_map.python_values_to_feast_value_type(name: str, values: Any, recurse: bool = True) feast.value_type.ValueType[source]
feast.type_map.python_values_to_proto_values(values: List[Any], feature_type: feast.value_type.ValueType = ValueType.UNKNOWN) List[feast.types.Value_pb2.Value][source]
feast.type_map.redshift_to_feast_value_type(redshift_type_as_str: str) feast.value_type.ValueType[source]
feast.type_map.snowflake_type_to_feast_value_type(snowflake_type: str) feast.value_type.ValueType[source]
feast.type_map.spark_schema_to_np_dtypes(dtypes: List[Tuple[str, str]]) Iterator[numpy.dtype][source]
feast.type_map.spark_to_feast_value_type(spark_type_as_str: str) feast.value_type.ValueType[source]

feast.types module

class feast.types.Array(base_type: Union[feast.types.PrimitiveFeastType, feast.types.ComplexFeastType])[source]

Bases: feast.types.ComplexFeastType

An Array represents a list of types.

base_type

The base type of the array.

Type

Union[feast.types.PrimitiveFeastType, feast.types.ComplexFeastType]

base_type: Union[feast.types.PrimitiveFeastType, feast.types.ComplexFeastType]
to_value_type() feast.value_type.ValueType[source]

Converts a ComplexFeastType object to the corresponding ValueType enum.

class feast.types.ComplexFeastType[source]

Bases: abc.ABC

A ComplexFeastType represents a structured type that is recognized by Feast.

abstract to_value_type() feast.value_type.ValueType[source]

Converts a ComplexFeastType object to the corresponding ValueType enum.

class feast.types.PrimitiveFeastType(value)[source]

Bases: enum.Enum

A PrimitiveFeastType represents a primitive type in Feast.

Note that these values must match the values in /feast/protos/types/Value.proto.

BOOL = 7
BYTES = 1
FLOAT32 = 6
FLOAT64 = 5
INT32 = 3
INT64 = 4
INVALID = 0
STRING = 2
UNIX_TIMESTAMP = 8
to_value_type() feast.value_type.ValueType[source]

Converts a PrimitiveFeastType object to the corresponding ValueType enum.

feast.types.from_value_type(value_type: feast.value_type.ValueType) Union[feast.types.ComplexFeastType, feast.types.PrimitiveFeastType][source]

Converts a ValueType enum to a Feast type.

Parameters

value_type – The ValueType to be converted.

Raises

ValueError – The conversion could not be performed.

feast.ui_server module

feast.ui_server.get_app(store: feast.feature_store.FeatureStore, get_registry_dump: Callable, project_id: str, registry_ttl_secs: int, host: str, port: int)[source]
feast.ui_server.start_server(store: feast.feature_store.FeatureStore, host: str, port: int, get_registry_dump: Callable, project_id: str, registry_ttl_sec: int)[source]

feast.usage module

class feast.usage.AlwaysSampler[source]

Bases: feast.usage.Sampler

should_record(event) bool[source]
class feast.usage.FnCall(fn_name: str, id: str, start: datetime.datetime, end: Union[datetime.datetime, NoneType] = None, parent_id: Union[str, NoneType] = None)[source]

Bases: object

end: Optional[datetime.datetime] = None
fn_name: str
id: str
parent_id: Optional[str] = None
start: datetime.datetime
class feast.usage.RatioSampler(ratio)[source]

Bases: feast.usage.Sampler

MAX_COUNTER = 4294967295
property priority
should_record(event) bool[source]
class feast.usage.Sampler[source]

Bases: object

property priority
should_record(event) bool[source]
class feast.usage.UsageContext[source]

Bases: object

attributes: Dict[str, Any]
call_stack: List[feast.usage.FnCall]
completed_calls: List[feast.usage.FnCall]
exception: Optional[Exception] = None
sampler: feast.usage.Sampler = <feast.usage.AlwaysSampler object>
traceback: Optional[Tuple[str, int, str]] = None
feast.usage.get_user_agent()[source]
feast.usage.log_exceptions(*args, **attrs)[source]

Function decorator that track errors and send them to Feast Developers

feast.usage.log_exceptions_and_usage(*args, **attrs)[source]

This function decorator enables three components: 1. Error tracking 2. Usage statistic collection 3. Time profiling

This data is being collected, anonymized and sent to Feast Developers. All events from nested decorated functions are being grouped into single event to build comprehensive context useful for profiling and error tracking.

Usage example (will result in one output event):

@log_exceptions_and_usage def fn(…):

nested()

@log_exceptions_and_usage(attr=’value’) def nested(…):

deeply_nested()

@log_exceptions_and_usage(attr2=’value2’, sample=RateSampler(rate=0.1)) def deeply_nested(…):

feast.usage.set_current_project_uuid(project_uuid: str)[source]
feast.usage.set_usage_attribute(name, value)[source]

Extend current context with custom attribute

feast.usage.tracing_span(name)[source]

Context manager for wrapping heavy parts of code in tracing span

feast.utils module

feast.utils.make_df_tzaware(t: pandas.core.frame.DataFrame) pandas.core.frame.DataFrame[source]

Make all datetime type columns tzaware; leave everything else intact.

feast.utils.make_tzaware(t: datetime.datetime) datetime.datetime[source]

We assume tz-naive datetimes are UTC

feast.utils.maybe_local_tz(t: datetime.datetime) datetime.datetime[source]
feast.utils.to_naive_utc(ts: datetime.datetime) datetime.datetime[source]

feast.value_type module

class feast.value_type.ValueType(value)[source]

Bases: enum.Enum

Feature value type. Used to define data types in Feature Tables.

BOOL = 7
BOOL_LIST = 17
BYTES = 1
BYTES_LIST = 11
DOUBLE = 5
DOUBLE_LIST = 15
FLOAT = 6
FLOAT_LIST = 16
INT32 = 3
INT32_LIST = 13
INT64 = 4
INT64_LIST = 14
NULL = 19
STRING = 2
STRING_LIST = 12
UNIX_TIMESTAMP = 8
UNIX_TIMESTAMP_LIST = 18
UNKNOWN = 0

feast.version module

feast.version.get_version()[source]

Returns version information of the Feast Python Package.

feast.wait module

feast.wait.wait_retry_backoff(retry_fn: Callable[[], Tuple[Any, bool]], timeout_secs: int = 0, timeout_msg: Optional[str] = 'Timeout while waiting for retry_fn() to return True', max_interval_secs: int = 60) Any[source]

Repeatedly try calling given retry_fn until it returns a True boolean success flag. Waits with a exponential backoff between retries until timeout when it throws TimeoutError. :param retry_fn: Callable that returns a result and a boolean success flag. :param timeout_secs: timeout in seconds to give up retrying and throw TimeoutError,

or 0 to retry perpetually.

Parameters
  • timeout_msg – Message to use when throwing TimeoutError.

  • max_interval_secs – max wait in seconds to wait between retries.

Returns

Returned Result from retry_fn() if success flag is True.

Module contents

class feast.AthenaSource(*, timestamp_field: Optional[str] = '', table: Optional[str] = None, database: Optional[str] = None, data_source: Optional[str] = None, created_timestamp_column: Optional[str] = None, field_mapping: Optional[Dict[str, str]] = None, date_partition_column: Optional[str] = None, query: Optional[str] = None, name: Optional[str] = None, description: Optional[str] = '', tags: Optional[Dict[str, str]] = None, owner: Optional[str] = '')[source]

Bases: feast.data_source.DataSource

created_timestamp_column: str
property data_source

Returns the Athena data_source of this Athena source.

property database

Returns the database of this Athena source.

date_partition_column: str
description: str
field_mapping: Dict[str, str]
static from_proto(data_source: feast.core.DataSource_pb2.DataSource)[source]

Creates a AthenaSource from a protobuf representation of a AthenaSource.

Parameters

data_source – A protobuf representation of a AthenaSource

Returns

A AthenaSource object based on the data_source protobuf.

get_table_column_names_and_types(config: feast.repo_config.RepoConfig) Iterable[Tuple[str, str]][source]

Returns a mapping of column names to types for this Athena source.

Parameters

config – A RepoConfig describing the feature repo

get_table_query_string(config: Optional[feast.repo_config.RepoConfig] = None) str[source]

Returns a string that can directly be used to reference this table in SQL.

name: str
owner: str
property query

Returns the Athena query of this Athena source.

static source_datatype_to_feast_value_type() Callable[[str], feast.value_type.ValueType][source]

Returns the callable method that returns Feast type given the raw column type.

property table

Returns the table of this Athena source.

tags: Dict[str, str]
timestamp_field: str
to_proto() feast.core.DataSource_pb2.DataSource[source]

Converts a RedshiftSource object to its protobuf representation.

Returns

A DataSourceProto object.

validate(config: feast.repo_config.RepoConfig)[source]

Validates the underlying data source.

Parameters

config – Configuration object used to configure a feature store.

class feast.BatchFeatureView(*, name: str, source: feast.data_source.DataSource, entities: Optional[Union[List[feast.entity.Entity], List[str]]] = None, ttl: Optional[datetime.timedelta] = None, tags: Optional[Dict[str, str]] = None, online: bool = True, description: str = '', owner: str = '', schema: Optional[List[feast.field.Field]] = None)[source]

Bases: feast.feature_view.FeatureView

A batch feature view defines a logical group of features that has only a batch data source.

name

The unique name of the batch feature view.

Type

str

entities

List of entities or entity join keys.

Type

List[str]

ttl

The amount of time this group of features lives. A ttl of 0 indicates that this group of features lives forever. Note that large ttl’s or a ttl of 0 can result in extremely computationally intensive queries.

Type

Optional[datetime.timedelta]

schema

The schema of the feature view, including feature, timestamp, and entity columns. If not specified, can be inferred from the underlying data source.

Type

List[feast.field.Field]

source

The batch source of data where this group of features is stored.

Type

feast.data_source.DataSource

online

A boolean indicating whether online retrieval is enabled for this feature view.

Type

bool

description

A human-readable description.

Type

str

tags

A dictionary of key-value pairs to store arbitrary metadata.

Type

Dict[str, str]

owner

The owner of the batch feature view, typically the email of the primary maintainer.

Type

str

batch_source: DataSource
created_timestamp: Optional[datetime]
description: str
entities: List[str]
entity_columns: List[feast.field.Field]
features: List[feast.field.Field]
last_updated_timestamp: Optional[datetime]
materialization_intervals: List[Tuple[datetime.datetime, datetime.datetime]]
name: str
online: bool
owner: str
projection: FeatureViewProjection
schema: List[feast.field.Field]
source: feast.data_source.DataSource
stream_source: Optional[DataSource]
tags: Dict[str, str]
timestamp_field: str
ttl: Optional[datetime.timedelta]
class feast.BigQuerySource(*, name: Optional[str] = None, timestamp_field: Optional[str] = None, table: Optional[str] = None, created_timestamp_column: Optional[str] = '', field_mapping: Optional[Dict[str, str]] = None, query: Optional[str] = None, description: Optional[str] = '', tags: Optional[Dict[str, str]] = None, owner: Optional[str] = '')[source]

Bases: feast.data_source.DataSource

created_timestamp_column: str
date_partition_column: str
description: str
field_mapping: Dict[str, str]
static from_proto(data_source: feast.core.DataSource_pb2.DataSource)[source]

Converts data source config in protobuf spec to a DataSource class object.

Parameters

data_source – A protobuf representation of a DataSource.

Returns

A DataSource class object.

Raises

ValueError – The type of DataSource could not be identified.

get_table_column_names_and_types(config: feast.repo_config.RepoConfig) Iterable[Tuple[str, str]][source]

Returns the list of column names and raw column types.

Parameters

config – Configuration object used to configure a feature store.

get_table_query_string() str[source]

Returns a string that can directly be used to reference this table in SQL

name: str
owner: str
property query
static source_datatype_to_feast_value_type() Callable[[str], feast.value_type.ValueType][source]

Returns the callable method that returns Feast type given the raw column type.

property table
tags: Dict[str, str]
timestamp_field: str
to_proto() feast.core.DataSource_pb2.DataSource[source]

Converts a DataSourceProto object to its protobuf representation.

validate(config: feast.repo_config.RepoConfig)[source]

Validates the underlying data source.

Parameters

config – Configuration object used to configure a feature store.

class feast.Entity(*, name: str, join_keys: Optional[List[str]] = None, value_type: Optional[feast.value_type.ValueType] = None, description: str = '', tags: Optional[Dict[str, str]] = None, owner: str = '')[source]

Bases: object

An entity defines a collection of entities for which features can be defined. An entity can also contain associated metadata.

name

The unique name of the entity.

Type

str

value_type

The type of the entity, such as string or float.

Type

feast.value_type.ValueType

join_key

A property that uniquely identifies different entities within the collection. The join_key property is typically used for joining entities with their associated features. If not specified, defaults to the name.

Type

str

description

A human-readable description.

Type

str

tags

A dictionary of key-value pairs to store arbitrary metadata.

Type

Dict[str, str]

owner

The owner of the entity, typically the email of the primary maintainer.

Type

str

created_timestamp

The time when the entity was created.

Type

Optional[datetime.datetime]

last_updated_timestamp

The time when the entity was last updated.

Type

Optional[datetime.datetime]

created_timestamp: Optional[datetime.datetime]
description: str
classmethod from_proto(entity_proto: feast.core.Entity_pb2.Entity)[source]

Creates an entity from a protobuf representation of an entity.

Parameters

entity_proto – A protobuf representation of an entity.

Returns

An Entity object based on the entity protobuf.

is_valid()[source]

Validates the state of this entity locally.

Raises

ValueError – The entity does not have a name or does not have a type.

join_key: str
last_updated_timestamp: Optional[datetime.datetime]
name: str
owner: str
tags: Dict[str, str]
to_proto() feast.core.Entity_pb2.Entity[source]

Converts an entity object to its protobuf representation.

Returns

An EntityProto protobuf.

value_type: feast.value_type.ValueType
class feast.Feature(name: str, dtype: feast.value_type.ValueType, labels: Optional[Dict[str, str]] = None)[source]

Bases: object

A Feature represents a class of serveable feature.

Parameters
  • name – Name of the feature.

  • dtype – The type of the feature, such as string or float.

  • labels (optional) – User-defined metadata in dictionary form.

property dtype: feast.value_type.ValueType

Gets the data type of this feature.

classmethod from_proto(feature_proto: feast.core.Feature_pb2.FeatureSpecV2)[source]
Parameters

feature_proto – FeatureSpecV2 protobuf object

Returns

Feature object

property labels: Dict[str, str]

Gets the labels of this feature.

property name

Gets the name of this feature.

to_proto() feast.core.Feature_pb2.FeatureSpecV2[source]

Converts Feature object to its Protocol Buffer representation.

Returns

A FeatureSpecProto protobuf.

class feast.FeatureService(*, name: str, features: List[Union[feast.feature_view.FeatureView, feast.on_demand_feature_view.OnDemandFeatureView]], tags: Dict[str, str] = None, description: str = '', owner: str = '', logging_config: Optional[feast.feature_logging.LoggingConfig] = None)[source]

Bases: object

A feature service defines a logical group of features from one or more feature views. This group of features can be retrieved together during training or serving.

name

The unique name of the feature service.

Type

str

feature_view_projections

A list containing feature views and feature view projections, representing the features in the feature service.

Type

List[feast.feature_view_projection.FeatureViewProjection]

description

A human-readable description.

Type

str

tags

A dictionary of key-value pairs to store arbitrary metadata.

Type

Dict[str, str]

owner

The owner of the feature service, typically the email of the primary maintainer.

Type

str

created_timestamp

The time when the feature service was created.

Type

Optional[datetime.datetime]

last_updated_timestamp

The time when the feature service was last updated.

Type

Optional[datetime.datetime]

created_timestamp: Optional[datetime.datetime] = None
description: str
feature_view_projections: List[feast.feature_view_projection.FeatureViewProjection]
classmethod from_proto(feature_service_proto: feast.core.FeatureService_pb2.FeatureService)[source]

Converts a FeatureServiceProto to a FeatureService object.

Parameters

feature_service_proto – A protobuf representation of a FeatureService.

infer_features(fvs_to_update: Dict[str, feast.feature_view.FeatureView])[source]

Infers the features for the projections of this feature service, and updates this feature service in place.

This method is necessary since feature services may rely on feature views which require feature inference.

Parameters

fvs_to_update – A mapping of feature view names to corresponding feature views that contains all the feature views necessary to run inference.

last_updated_timestamp: Optional[datetime.datetime] = None
logging_config: Optional[feast.feature_logging.LoggingConfig] = None
name: str
owner: str
tags: Dict[str, str]
to_proto() feast.core.FeatureService_pb2.FeatureService[source]

Converts a feature service to its protobuf representation.

Returns

A FeatureServiceProto protobuf.

validate()[source]
class feast.FeatureStore(repo_path: Optional[str] = None, config: Optional[feast.repo_config.RepoConfig] = None, fs_yaml_file: Optional[pathlib.Path] = None)[source]

Bases: object

A FeatureStore object is used to define, create, and retrieve features.

config

The config for the feature store.

Type

feast.repo_config.RepoConfig

repo_path

The path to the feature repo.

Type

pathlib.Path

_registry

The registry for the feature store.

Type

feast.infra.registry.base_registry.BaseRegistry

_provider

The provider for the feature store.

Type

feast.infra.provider.Provider

_go_server

The (optional) Go feature server for the feature store.

Type

Optional[EmbeddedOnlineFeatureServer]

apply(objects: Union[feast.data_source.DataSource, feast.entity.Entity, feast.feature_view.FeatureView, feast.on_demand_feature_view.OnDemandFeatureView, feast.request_feature_view.RequestFeatureView, feast.batch_feature_view.BatchFeatureView, feast.stream_feature_view.StreamFeatureView, feast.feature_service.FeatureService, feast.saved_dataset.ValidationReference, List[Union[feast.feature_view.FeatureView, feast.on_demand_feature_view.OnDemandFeatureView, feast.request_feature_view.RequestFeatureView, feast.batch_feature_view.BatchFeatureView, feast.stream_feature_view.StreamFeatureView, feast.entity.Entity, feast.feature_service.FeatureService, feast.data_source.DataSource, feast.saved_dataset.ValidationReference]]], objects_to_delete: Optional[List[Union[feast.feature_view.FeatureView, feast.on_demand_feature_view.OnDemandFeatureView, feast.request_feature_view.RequestFeatureView, feast.batch_feature_view.BatchFeatureView, feast.stream_feature_view.StreamFeatureView, feast.entity.Entity, feast.feature_service.FeatureService, feast.data_source.DataSource, feast.saved_dataset.ValidationReference]]] = None, partial: bool = True)[source]

Register objects to metadata store and update related infrastructure.

The apply method registers one or more definitions (e.g., Entity, FeatureView) and registers or updates these objects in the Feast registry. Once the apply method has updated the infrastructure (e.g., create tables in an online store), it will commit the updated registry. All operations are idempotent, meaning they can safely be rerun.

Parameters
  • objects – A single object, or a list of objects that should be registered with the Feature Store.

  • objects_to_delete – A list of objects to be deleted from the registry and removed from the provider’s infrastructure. This deletion will only be performed if partial is set to False.

  • partial – If True, apply will only handle the specified objects; if False, apply will also delete all the objects in objects_to_delete, and tear down any associated cloud resources.

Raises

ValueError – The ‘objects’ parameter could not be parsed properly.

Examples

Register an Entity and a FeatureView.

>>> from feast import FeatureStore, Entity, FeatureView, Feature, FileSource, RepoConfig
>>> from datetime import timedelta
>>> fs = FeatureStore(repo_path="project/feature_repo")
>>> driver = Entity(name="driver_id", description="driver id")
>>> driver_hourly_stats = FileSource(
...     path="project/feature_repo/data/driver_stats.parquet",
...     timestamp_field="event_timestamp",
...     created_timestamp_column="created",
... )
>>> driver_hourly_stats_view = FeatureView(
...     name="driver_hourly_stats",
...     entities=[driver],
...     ttl=timedelta(seconds=86400 * 1),
...     source=driver_hourly_stats,
... )
>>> fs.apply([driver_hourly_stats_view, driver]) # register entity and feature view
config: feast.repo_config.RepoConfig
create_saved_dataset(from_: feast.infra.offline_stores.offline_store.RetrievalJob, name: str, storage: feast.saved_dataset.SavedDatasetStorage, tags: Optional[Dict[str, str]] = None, feature_service: Optional[feast.feature_service.FeatureService] = None, allow_overwrite: bool = False) feast.saved_dataset.SavedDataset[source]

Execute provided retrieval job and persist its outcome in given storage. Storage type (eg, BigQuery or Redshift) must be the same as globally configured offline store. After data successfully persisted saved dataset object with dataset metadata is committed to the registry. Name for the saved dataset should be unique within project, since it’s possible to overwrite previously stored dataset with the same name.

Parameters
  • from – The retrieval job whose result should be persisted.

  • name – The name of the saved dataset.

  • storage – The saved dataset storage object indicating where the result should be persisted.

  • tags (optional) – A dictionary of key-value pairs to store arbitrary metadata.

  • feature_service (optional) – The feature service that should be associated with this saved dataset.

  • allow_overwrite (optional) – If True, the persisted result can overwrite an existing table or file.

Returns

SavedDataset object with attached RetrievalJob

Raises

ValueError if given retrieval job doesn't have metadata

delete_feature_service(name: str)[source]

Deletes a feature service.

Parameters

name – Name of feature service.

Raises

FeatureServiceNotFoundException – The feature view could not be found.

delete_feature_view(name: str)[source]

Deletes a feature view.

Parameters

name – Name of feature view.

Raises

FeatureViewNotFoundException – The feature view could not be found.

static ensure_request_data_values_exist(needed_request_data: Set[str], needed_request_fv_features: Set[str], request_data_features: Dict[str, List[Any]])[source]
get_data_source(name: str) feast.data_source.DataSource[source]

Retrieves the list of data sources from the registry.

Parameters

name – Name of the data source.

Returns

The specified data source.

Raises

DataSourceObjectNotFoundException – The data source could not be found.

get_entity(name: str, allow_registry_cache: bool = False) feast.entity.Entity[source]

Retrieves an entity.

Parameters
  • name – Name of entity.

  • allow_registry_cache – (Optional) Whether to allow returning this entity from a cached registry

Returns

The specified entity.

Raises

EntityNotFoundException – The entity could not be found.

get_feature_server_endpoint() Optional[str][source]

Returns endpoint for the feature server, if it exists.

get_feature_service(name: str, allow_cache: bool = False) feast.feature_service.FeatureService[source]

Retrieves a feature service.

Parameters
  • name – Name of feature service.

  • allow_cache – Whether to allow returning feature services from a cached registry.

Returns

The specified feature service.

Raises

FeatureServiceNotFoundException – The feature service could not be found.

get_feature_view(name: str, allow_registry_cache: bool = False) feast.feature_view.FeatureView[source]

Retrieves a feature view.

Parameters
  • name – Name of feature view.

  • allow_registry_cache – (Optional) Whether to allow returning this entity from a cached registry

Returns

The specified feature view.

Raises

FeatureViewNotFoundException – The feature view could not be found.

get_historical_features(entity_df: Union[pandas.core.frame.DataFrame, str], features: Union[List[str], feast.feature_service.FeatureService], full_feature_names: bool = False) feast.infra.offline_stores.offline_store.RetrievalJob[source]

Enrich an entity dataframe with historical feature values for either training or batch scoring.

This method joins historical feature data from one or more feature views to an entity dataframe by using a time travel join.

Each feature view is joined to the entity dataframe using all entities configured for the respective feature view. All configured entities must be available in the entity dataframe. Therefore, the entity dataframe must contain all entities found in all feature views, but the individual feature views can have different entities.

Time travel is based on the configured TTL for each feature view. A shorter TTL will limit the amount of scanning that will be done in order to find feature data for a specific entity key. Setting a short TTL may result in null values being returned.

Parameters
  • entity_df (Union[pd.DataFrame, str]) – An entity dataframe is a collection of rows containing all entity columns (e.g., customer_id, driver_id) on which features need to be joined, as well as a event_timestamp column used to ensure point-in-time correctness. Either a Pandas DataFrame can be provided or a string SQL query. The query must be of a format supported by the configured offline store (e.g., BigQuery)

  • features – The list of features that should be retrieved from the offline store. These features can be specified either as a list of string feature references or as a feature service. String feature references must have format “feature_view:feature”, e.g. “customer_fv:daily_transactions”.

  • full_feature_names – If True, feature names will be prefixed with the corresponding feature view name, changing them from the format “feature” to “feature_view__feature” (e.g. “daily_transactions” changes to “customer_fv__daily_transactions”).

Returns

RetrievalJob which can be used to materialize the results.

Raises

ValueError – Both or neither of features and feature_refs are specified.

Examples

Retrieve historical features from a local offline store.

>>> from feast import FeatureStore, RepoConfig
>>> import pandas as pd
>>> fs = FeatureStore(repo_path="project/feature_repo")
>>> entity_df = pd.DataFrame.from_dict(
...     {
...         "driver_id": [1001, 1002],
...         "event_timestamp": [
...             datetime(2021, 4, 12, 10, 59, 42),
...             datetime(2021, 4, 12, 8, 12, 10),
...         ],
...     }
... )
>>> retrieval_job = fs.get_historical_features(
...     entity_df=entity_df,
...     features=[
...         "driver_hourly_stats:conv_rate",
...         "driver_hourly_stats:acc_rate",
...         "driver_hourly_stats:avg_daily_trips",
...     ],
... )
>>> feature_data = retrieval_job.to_df()
static get_needed_request_data(grouped_odfv_refs: List[Tuple[feast.on_demand_feature_view.OnDemandFeatureView, List[str]]], grouped_request_fv_refs: List[Tuple[feast.request_feature_view.RequestFeatureView, List[str]]]) Tuple[Set[str], Set[str]][source]
get_on_demand_feature_view(name: str) feast.on_demand_feature_view.OnDemandFeatureView[source]

Retrieves a feature view.

Parameters

name – Name of feature view.

Returns

The specified feature view.

Raises

FeatureViewNotFoundException – The feature view could not be found.

get_online_features(features: Union[List[str], feast.feature_service.FeatureService], entity_rows: List[Dict[str, Any]], full_feature_names: bool = False) feast.online_response.OnlineResponse[source]

Retrieves the latest online feature data.

Note: This method will download the full feature registry the first time it is run. If you are using a remote registry like GCS or S3 then that may take a few seconds. The registry remains cached up to a TTL duration (which can be set to infinity). If the cached registry is stale (more time than the TTL has passed), then a new registry will be downloaded synchronously by this method. This download may introduce latency to online feature retrieval. In order to avoid synchronous downloads, please call refresh_registry() prior to the TTL being reached. Remember it is possible to set the cache TTL to infinity (cache forever).

Parameters
  • features – The list of features that should be retrieved from the online store. These features can be specified either as a list of string feature references or as a feature service. String feature references must have format “feature_view:feature”, e.g. “customer_fv:daily_transactions”.

  • entity_rows – A list of dictionaries where each key-value is an entity-name, entity-value pair.

  • full_feature_names – If True, feature names will be prefixed with the corresponding feature view name, changing them from the format “feature” to “feature_view__feature” (e.g. “daily_transactions” changes to “customer_fv__daily_transactions”).

Returns

OnlineResponse containing the feature data in records.

Raises

Exception – No entity with the specified name exists.

Examples

Retrieve online features from an online store.

>>> from feast import FeatureStore, RepoConfig
>>> fs = FeatureStore(repo_path="project/feature_repo")
>>> online_response = fs.get_online_features(
...     features=[
...         "driver_hourly_stats:conv_rate",
...         "driver_hourly_stats:acc_rate",
...         "driver_hourly_stats:avg_daily_trips",
...     ],
...     entity_rows=[{"driver_id": 1001}, {"driver_id": 1002}, {"driver_id": 1003}, {"driver_id": 1004}],
... )
>>> online_response_dict = online_response.to_dict()
get_saved_dataset(name: str) feast.saved_dataset.SavedDataset[source]

Find a saved dataset in the registry by provided name and create a retrieval job to pull whole dataset from storage (offline store).

If dataset couldn’t be found by provided name SavedDatasetNotFound exception will be raised.

Data will be retrieved from globally configured offline store.

Returns

SavedDataset with RetrievalJob attached

Raises

SavedDatasetNotFound

get_stream_feature_view(name: str, allow_registry_cache: bool = False) feast.stream_feature_view.StreamFeatureView[source]

Retrieves a stream feature view.

Parameters
  • name – Name of stream feature view.

  • allow_registry_cache – (Optional) Whether to allow returning this entity from a cached registry

Returns

The specified stream feature view.

Raises

FeatureViewNotFoundException – The feature view could not be found.

get_validation_reference(name: str, allow_cache: bool = False) feast.saved_dataset.ValidationReference[source]

Retrieves a validation reference.

Raises

ValidationReferenceNotFoundException – The validation reference could not be found.

list_data_sources(allow_cache: bool = False) List[feast.data_source.DataSource][source]

Retrieves the list of data sources from the registry.

Parameters

allow_cache – Whether to allow returning data sources from a cached registry.

Returns

A list of data sources.

list_entities(allow_cache: bool = False) List[feast.entity.Entity][source]

Retrieves the list of entities from the registry.

Parameters

allow_cache – Whether to allow returning entities from a cached registry.

Returns

A list of entities.

list_feature_services() List[feast.feature_service.FeatureService][source]

Retrieves the list of feature services from the registry.

Returns

A list of feature services.

list_feature_views(allow_cache: bool = False) List[feast.feature_view.FeatureView][source]

Retrieves the list of feature views from the registry.

Parameters

allow_cache – Whether to allow returning entities from a cached registry.

Returns

A list of feature views.

list_on_demand_feature_views(allow_cache: bool = False) List[feast.on_demand_feature_view.OnDemandFeatureView][source]

Retrieves the list of on demand feature views from the registry.

Returns

A list of on demand feature views.

list_request_feature_views(allow_cache: bool = False) List[feast.request_feature_view.RequestFeatureView][source]

Retrieves the list of feature views from the registry.

Parameters

allow_cache – Whether to allow returning entities from a cached registry.

Returns

A list of feature views.

list_stream_feature_views(allow_cache: bool = False) List[feast.stream_feature_view.StreamFeatureView][source]

Retrieves the list of stream feature views from the registry.

Returns

A list of stream feature views.

materialize(start_date: datetime.datetime, end_date: datetime.datetime, feature_views: Optional[List[str]] = None) None[source]

Materialize data from the offline store into the online store.

This method loads feature data in the specified interval from either the specified feature views, or all feature views if none are specified, into the online store where it is available for online serving.

Parameters
  • start_date (datetime) – Start date for time range of data to materialize into the online store

  • end_date (datetime) – End date for time range of data to materialize into the online store

  • feature_views (List[str]) – Optional list of feature view names. If selected, will only run materialization for the specified feature views.

Examples

Materialize all features into the online store over the interval from 3 hours ago to 10 minutes ago. >>> from feast import FeatureStore, RepoConfig >>> from datetime import datetime, timedelta >>> fs = FeatureStore(repo_path=”project/feature_repo”) >>> fs.materialize( … start_date=datetime.utcnow() - timedelta(hours=3), end_date=datetime.utcnow() - timedelta(minutes=10) … ) Materializing… <BLANKLINE> …

materialize_incremental(end_date: datetime.datetime, feature_views: Optional[List[str]] = None) None[source]

Materialize incremental new data from the offline store into the online store.

This method loads incremental new feature data up to the specified end time from either the specified feature views, or all feature views if none are specified, into the online store where it is available for online serving. The start time of the interval materialized is either the most recent end time of a prior materialization or (now - ttl) if no such prior materialization exists.

Parameters
  • end_date (datetime) – End date for time range of data to materialize into the online store

  • feature_views (List[str]) – Optional list of feature view names. If selected, will only run materialization for the specified feature views.

Raises

Exception – A feature view being materialized does not have a TTL set.

Examples

Materialize all features into the online store up to 5 minutes ago.

>>> from feast import FeatureStore, RepoConfig
>>> from datetime import datetime, timedelta
>>> fs = FeatureStore(repo_path="project/feature_repo")
>>> fs.materialize_incremental(end_date=datetime.utcnow() - timedelta(minutes=5))
Materializing...

...
plan(desired_repo_contents: feast.repo_contents.RepoContents) Tuple[feast.diff.registry_diff.RegistryDiff, feast.diff.infra_diff.InfraDiff, feast.infra.infra_object.Infra][source]

Dry-run registering objects to metadata store.

The plan method dry-runs registering one or more definitions (e.g., Entity, FeatureView), and produces a list of all the changes the that would be introduced in the feature repo. The changes computed by the plan command are for informational purposes, and are not actually applied to the registry.

Parameters

desired_repo_contents – The desired repo state.

Raises

ValueError – The ‘objects’ parameter could not be parsed properly.

Examples

Generate a plan adding an Entity and a FeatureView.

>>> from feast import FeatureStore, Entity, FeatureView, Feature, FileSource, RepoConfig
>>> from feast.feature_store import RepoContents
>>> from datetime import timedelta
>>> fs = FeatureStore(repo_path="project/feature_repo")
>>> driver = Entity(name="driver_id", description="driver id")
>>> driver_hourly_stats = FileSource(
...     path="project/feature_repo/data/driver_stats.parquet",
...     timestamp_field="event_timestamp",
...     created_timestamp_column="created",
... )
>>> driver_hourly_stats_view = FeatureView(
...     name="driver_hourly_stats",
...     entities=[driver],
...     ttl=timedelta(seconds=86400 * 1),
...     source=driver_hourly_stats,
... )
>>> registry_diff, infra_diff, new_infra = fs.plan(RepoContents(
...     data_sources=[driver_hourly_stats],
...     feature_views=[driver_hourly_stats_view],
...     on_demand_feature_views=list(),
...     stream_feature_views=list(),
...     request_feature_views=list(),
...     entities=[driver],
...     feature_services=list())) # register entity and feature view
property project: str

Gets the project of this feature store.

push(push_source_name: str, df: pandas.core.frame.DataFrame, allow_registry_cache: bool = True, to: feast.data_source.PushMode = PushMode.ONLINE)[source]

Push features to a push source. This updates all the feature views that have the push source as stream source.

Parameters
  • push_source_name – The name of the push source we want to push data to.

  • df – The data being pushed.

  • allow_registry_cache – Whether to allow cached versions of the registry.

  • to – Whether to push to online or offline store. Defaults to online store only.

refresh_registry()[source]

Fetches and caches a copy of the feature registry in memory.

Explicitly calling this method allows for direct control of the state of the registry cache. Every time this method is called the complete registry state will be retrieved from the remote registry store backend (e.g., GCS, S3), and the cache timer will be reset. If refresh_registry() is run before get_online_features() is called, then get_online_features() will use the cached registry instead of retrieving (and caching) the registry itself.

Additionally, the TTL for the registry cache can be set to infinity (by setting it to 0), which means that refresh_registry() will become the only way to update the cached registry. If the TTL is set to a value greater than 0, then once the cache becomes stale (more time than the TTL has passed), a new cache will be downloaded synchronously, which may increase latencies if the triggering method is get_online_features().

property registry: feast.infra.registry.base_registry.BaseRegistry

Gets the registry of this feature store.

repo_path: pathlib.Path
serve(host: str, port: int, type_: str, no_access_log: bool, no_feature_log: bool) None[source]

Start the feature consumption server locally on a given port.

serve_transformations(port: int) None[source]

Start the feature transformation server locally on a given port.

serve_ui(host: str, port: int, get_registry_dump: Callable, registry_ttl_sec: int) None[source]

Start the UI server locally

teardown()[source]

Tears down all local and cloud resources for the feature store.

validate_logged_features(source: feast.feature_service.FeatureService, start: datetime.datetime, end: datetime.datetime, reference: feast.saved_dataset.ValidationReference, throw_exception: bool = True, cache_profile: bool = True) Optional[feast.dqm.errors.ValidationFailed][source]

Load logged features from an offline store and validate them against provided validation reference.

Parameters
  • source – Logs source object (currently only feature services are supported)

  • start – lower bound for loading logged features

  • end – upper bound for loading logged features

  • reference – validation reference

  • throw_exception – throw exception or return it as a result

  • cache_profile – store cached profile in Feast registry

Returns

Throw or return (depends on parameter) ValidationFailed exception if validation was not successful or None if successful.

version() str[source]

Returns the version of the current Feast SDK/CLI.

write_logged_features(logs: Union[pyarrow.lib.Table, pathlib.Path], source: feast.feature_service.FeatureService)[source]

Write logs produced by a source (currently only feature service is supported as a source) to an offline store.

Parameters
  • logs – Arrow Table or path to parquet dataset directory on disk

  • source – Object that produces logs

write_to_offline_store(feature_view_name: str, df: pandas.core.frame.DataFrame, allow_registry_cache: bool = True, reorder_columns: bool = True)[source]

Persists the dataframe directly into the batch data source for the given feature view.

Fails if the dataframe columns do not match the columns of the batch data source. Optionally reorders the columns of the dataframe to match.

write_to_online_store(feature_view_name: str, df: pandas.core.frame.DataFrame, allow_registry_cache: bool = True)[source]

Persists a dataframe to the online store.

Parameters
  • feature_view_name – The feature view to which the dataframe corresponds.

  • df – The dataframe to be persisted.

  • allow_registry_cache (optional) – Whether to allow retrieving feature views from a cached registry.

class feast.FeatureView(*, name: str, source: feast.data_source.DataSource, schema: Optional[List[feast.field.Field]] = None, entities: List[feast.entity.Entity] = None, ttl: Optional[datetime.timedelta] = datetime.timedelta(0), online: bool = True, description: str = '', tags: Optional[Dict[str, str]] = None, owner: str = '')[source]

Bases: feast.base_feature_view.BaseFeatureView

A FeatureView defines a logical group of features.

name

The unique name of the feature view.

Type

str

entities

The list of names of entities that this feature view is associated with.

Type

List[str]

ttl

The amount of time this group of features lives. A ttl of 0 indicates that this group of features lives forever. Note that large ttl’s or a ttl of 0 can result in extremely computationally intensive queries.

Type

Optional[datetime.timedelta]

batch_source

The batch source of data where this group of features is stored. This is optional ONLY if a push source is specified as the stream_source, since push sources contain their own batch sources.

Type

feast.data_source.DataSource

stream_source

The stream source of data where this group of features is stored.

Type

Optional[feast.data_source.DataSource]

schema

The schema of the feature view, including feature, timestamp, and entity columns. If not specified, can be inferred from the underlying data source.

Type

List[feast.field.Field]

entity_columns

The list of entity columns contained in the schema. If not specified, can be inferred from the underlying data source.

Type

List[feast.field.Field]

features

The list of feature columns contained in the schema. If not specified, can be inferred from the underlying data source.

Type

List[feast.field.Field]

online

A boolean indicating whether online retrieval is enabled for this feature view.

Type

bool

description

A human-readable description.

Type

str

tags

A dictionary of key-value pairs to store arbitrary metadata.

Type

Dict[str, str]

owner

The owner of the feature view, typically the email of the primary maintainer.

Type

str

batch_source: feast.data_source.DataSource
created_timestamp: Optional[datetime.datetime]
description: str
ensure_valid()[source]

Validates the state of this feature view locally.

Raises

ValueError – The feature view does not have a name or does not have entities.

entities: List[str]
entity_columns: List[feast.field.Field]
features: List[feast.field.Field]
classmethod from_proto(feature_view_proto: feast.core.FeatureView_pb2.FeatureView)[source]

Creates a feature view from a protobuf representation of a feature view.

Parameters

feature_view_proto – A protobuf representation of a feature view.

Returns

A FeatureViewProto object based on the feature view protobuf.

get_ttl_duration()[source]
property join_keys: List[str]

Returns a list of all the join keys.

last_updated_timestamp: Optional[datetime.datetime]
materialization_intervals: List[Tuple[datetime.datetime, datetime.datetime]]
property most_recent_end_time: Optional[datetime.datetime]

Retrieves the latest time up to which the feature view has been materialized.

Returns

The latest time, or None if the feature view has not been materialized.

name: str
online: bool
owner: str
projection: feast.feature_view_projection.FeatureViewProjection
property proto_class: Type[feast.core.FeatureView_pb2.FeatureView]
schema: List[feast.field.Field]
stream_source: Optional[feast.data_source.DataSource]
tags: Dict[str, str]
to_proto() feast.core.FeatureView_pb2.FeatureView[source]

Converts a feature view object to its protobuf representation.

Returns

A FeatureViewProto protobuf.

to_proto_meta()[source]
ttl: Optional[datetime.timedelta]
with_join_key_map(join_key_map: Dict[str, str])[source]

Returns a copy of this feature view with the join key map set to the given map. This join_key mapping operation is only used as part of query operations and will not modify the underlying FeatureView.

Parameters

join_key_map – A map of join keys in which the left is the join_key that corresponds with the feature data and the right corresponds with the entity data.

Examples

Join a location feature data table to both the origin column and destination column of the entity data.

temperatures_feature_service = FeatureService(

name=”temperatures”, features=[

location_stats_feature_view

.with_name(“origin_stats”) .with_join_key_map(

{“location_id”: “origin_id”}

),

location_stats_feature_view

.with_name(“destination_stats”) .with_join_key_map(

{“location_id”: “destination_id”}

),

],

)

class feast.Field(*, name: str, dtype: Union[feast.types.ComplexFeastType, feast.types.PrimitiveFeastType], tags: Optional[Dict[str, str]] = None)[source]

Bases: object

A Field represents a set of values with the same structure.

name

The name of the field.

Type

str

dtype

The type of the field, such as string or float.

Type

Union[feast.types.ComplexFeastType, feast.types.PrimitiveFeastType]

tags

User-defined metadata in dictionary form.

Type

Dict[str, str]

dtype: Union[feast.types.ComplexFeastType, feast.types.PrimitiveFeastType]
classmethod from_feature(feature: feast.feature.Feature)[source]

Creates a Field object from a Feature object.

Parameters

feature – Feature object to convert.

classmethod from_proto(field_proto: feast.core.Feature_pb2.FeatureSpecV2)[source]

Creates a Field object from a protobuf representation.

Parameters

field_proto – FieldProto protobuf object

name: str
tags: Dict[str, str]
to_proto() feast.core.Feature_pb2.FeatureSpecV2[source]

Converts a Field object to its protobuf representation.

class feast.FileSource(*, path: str, name: Optional[str] = '', event_timestamp_column: Optional[str] = '', file_format: Optional[feast.data_format.FileFormat] = None, created_timestamp_column: Optional[str] = '', field_mapping: Optional[Dict[str, str]] = None, s3_endpoint_override: Optional[str] = None, description: Optional[str] = '', tags: Optional[Dict[str, str]] = None, owner: Optional[str] = '', timestamp_field: Optional[str] = '')[source]

Bases: feast.data_source.DataSource

static create_filesystem_and_path(path: str, s3_endpoint_override: str) Tuple[Optional[pyarrow._fs.FileSystem], str][source]
created_timestamp_column: str
date_partition_column: str
description: str
field_mapping: Dict[str, str]
property file_format: Optional[feast.data_format.FileFormat]

Returns the file format of this file data source.

static from_proto(data_source: feast.core.DataSource_pb2.DataSource)[source]

Converts data source config in protobuf spec to a DataSource class object.

Parameters

data_source – A protobuf representation of a DataSource.

Returns

A DataSource class object.

Raises

ValueError – The type of DataSource could not be identified.

get_table_column_names_and_types(config: feast.repo_config.RepoConfig) Iterable[Tuple[str, str]][source]

Returns the list of column names and raw column types.

Parameters

config – Configuration object used to configure a feature store.

get_table_query_string() str[source]

Returns a string that can directly be used to reference this table in SQL.

name: str
owner: str
property path: str

Returns the path of this file data source.

property s3_endpoint_override: Optional[str]

Returns the s3 endpoint override of this file data source.

static source_datatype_to_feast_value_type() Callable[[str], feast.value_type.ValueType][source]

Returns the callable method that returns Feast type given the raw column type.

tags: Dict[str, str]
timestamp_field: str
to_proto() feast.core.DataSource_pb2.DataSource[source]

Converts a DataSourceProto object to its protobuf representation.

validate(config: feast.repo_config.RepoConfig)[source]

Validates the underlying data source.

Parameters

config – Configuration object used to configure a feature store.

class feast.KafkaSource(*, name: str, timestamp_field: str, message_format: feast.data_format.StreamFormat, bootstrap_servers: Optional[str] = None, kafka_bootstrap_servers: Optional[str] = None, topic: Optional[str] = None, created_timestamp_column: Optional[str] = '', field_mapping: Optional[Dict[str, str]] = None, description: Optional[str] = '', tags: Optional[Dict[str, str]] = None, owner: Optional[str] = '', batch_source: Optional[feast.data_source.DataSource] = None, watermark_delay_threshold: Optional[datetime.timedelta] = None)[source]

Bases: feast.data_source.DataSource

created_timestamp_column: str
date_partition_column: str
description: str
field_mapping: Dict[str, str]
static from_proto(data_source: feast.core.DataSource_pb2.DataSource)[source]

Converts data source config in protobuf spec to a DataSource class object.

Parameters

data_source – A protobuf representation of a DataSource.

Returns

A DataSource class object.

Raises

ValueError – The type of DataSource could not be identified.

get_table_column_names_and_types(config: feast.repo_config.RepoConfig) Iterable[Tuple[str, str]][source]

Returns the list of column names and raw column types.

Parameters

config – Configuration object used to configure a feature store.

get_table_query_string() str[source]

Returns a string that can directly be used to reference this table in SQL.

name: str
owner: str
static source_datatype_to_feast_value_type() Callable[[str], feast.value_type.ValueType][source]

Returns the callable method that returns Feast type given the raw column type.

tags: Dict[str, str]
timestamp_field: str
to_proto() feast.core.DataSource_pb2.DataSource[source]

Converts a DataSourceProto object to its protobuf representation.

validate(config: feast.repo_config.RepoConfig)[source]

Validates the underlying data source.

Parameters

config – Configuration object used to configure a feature store.

class feast.KinesisSource(*, name: str, record_format: feast.data_format.StreamFormat, region: str, stream_name: str, timestamp_field: Optional[str] = '', created_timestamp_column: Optional[str] = '', field_mapping: Optional[Dict[str, str]] = None, description: Optional[str] = '', tags: Optional[Dict[str, str]] = None, owner: Optional[str] = '', batch_source: Optional[feast.data_source.DataSource] = None)[source]

Bases: feast.data_source.DataSource

created_timestamp_column: str
date_partition_column: str
description: str
field_mapping: Dict[str, str]
static from_proto(data_source: feast.core.DataSource_pb2.DataSource)[source]

Converts data source config in protobuf spec to a DataSource class object.

Parameters

data_source – A protobuf representation of a DataSource.

Returns

A DataSource class object.

Raises

ValueError – The type of DataSource could not be identified.

get_table_column_names_and_types(config: feast.repo_config.RepoConfig) Iterable[Tuple[str, str]][source]

Returns the list of column names and raw column types.

Parameters

config – Configuration object used to configure a feature store.

get_table_query_string() str[source]

Returns a string that can directly be used to reference this table in SQL.

name: str
owner: str
static source_datatype_to_feast_value_type() Callable[[str], feast.value_type.ValueType][source]

Returns the callable method that returns Feast type given the raw column type.

tags: Dict[str, str]
timestamp_field: str
to_proto() feast.core.DataSource_pb2.DataSource[source]

Converts a DataSourceProto object to its protobuf representation.

validate(config: feast.repo_config.RepoConfig)[source]

Validates the underlying data source.

Parameters

config – Configuration object used to configure a feature store.

class feast.OnDemandFeatureView(*, name: str, schema: List[feast.field.Field], sources: List[Union[feast.feature_view.FeatureView, feast.data_source.RequestSource, feast.feature_view_projection.FeatureViewProjection]], udf: function, udf_string: str = '', description: str = '', tags: Optional[Dict[str, str]] = None, owner: str = '')[source]

Bases: feast.base_feature_view.BaseFeatureView

[Experimental] An OnDemandFeatureView defines a logical group of features that are generated by applying a transformation on a set of input sources, such as feature views and request data sources.

name

The unique name of the on demand feature view.

Type

str

features

The list of features in the output of the on demand feature view.

Type

List[feast.field.Field]

source_feature_view_projections

A map from input source names to actual input sources with type FeatureViewProjection.

Type

Dict[str, feast.feature_view_projection.FeatureViewProjection]

source_request_sources

A map from input source names to the actual input sources with type RequestSource.

Type

Dict[str, feast.data_source.RequestSource]

udf

The user defined transformation function, which must take pandas dataframes as inputs.

Type

function

description

A human-readable description.

Type

str

tags

A dictionary of key-value pairs to store arbitrary metadata.

Type

Dict[str, str]

owner

The owner of the on demand feature view, typically the email of the primary maintainer.

Type

str

created_timestamp: Optional[datetime.datetime]
description: str
features: List[feast.field.Field]
classmethod from_proto(on_demand_feature_view_proto: feast.core.OnDemandFeatureView_pb2.OnDemandFeatureView)[source]

Creates an on demand feature view from a protobuf representation.

Parameters

on_demand_feature_view_proto – A protobuf representation of an on-demand feature view.

Returns

A OnDemandFeatureView object based on the on-demand feature view protobuf.

get_request_data_schema() Dict[str, feast.value_type.ValueType][source]
static get_requested_odfvs(feature_refs, project, registry)[source]
get_transformed_features_df(df_with_features: pandas.core.frame.DataFrame, full_feature_names: bool = False) pandas.core.frame.DataFrame[source]
infer_features()[source]

Infers the set of features associated to this feature view from the input source.

Raises

RegistryInferenceFailure – The set of features could not be inferred.

last_updated_timestamp: Optional[datetime.datetime]
name: str
owner: str
projection: feast.feature_view_projection.FeatureViewProjection
property proto_class: Type[feast.core.OnDemandFeatureView_pb2.OnDemandFeatureView]
source_feature_view_projections: Dict[str, feast.feature_view_projection.FeatureViewProjection]
source_request_sources: Dict[str, feast.data_source.RequestSource]
tags: Dict[str, str]
to_proto() feast.core.OnDemandFeatureView_pb2.OnDemandFeatureView[source]

Converts an on demand feature view object to its protobuf representation.

Returns

A OnDemandFeatureViewProto protobuf.

udf: function
udf_string: str
class feast.PushSource(*, name: str, batch_source: feast.data_source.DataSource, description: Optional[str] = '', tags: Optional[Dict[str, str]] = None, owner: Optional[str] = '')[source]

Bases: feast.data_source.DataSource

A source that can be used to ingest features on request

batch_source: feast.data_source.DataSource
created_timestamp_column: str
date_partition_column: str
description: str
field_mapping: Dict[str, str]
static from_proto(data_source: feast.core.DataSource_pb2.DataSource)[source]

Converts data source config in protobuf spec to a DataSource class object.

Parameters

data_source – A protobuf representation of a DataSource.

Returns

A DataSource class object.

Raises

ValueError – The type of DataSource could not be identified.

get_table_column_names_and_types(config: feast.repo_config.RepoConfig) Iterable[Tuple[str, str]][source]

Returns the list of column names and raw column types.

Parameters

config – Configuration object used to configure a feature store.

get_table_query_string() str[source]

Returns a string that can directly be used to reference this table in SQL.

name: str
owner: str
static source_datatype_to_feast_value_type() Callable[[str], feast.value_type.ValueType][source]

Returns the callable method that returns Feast type given the raw column type.

tags: Dict[str, str]
timestamp_field: str
to_proto() feast.core.DataSource_pb2.DataSource[source]

Converts a DataSourceProto object to its protobuf representation.

validate(config: feast.repo_config.RepoConfig)[source]

Validates the underlying data source.

Parameters

config – Configuration object used to configure a feature store.

class feast.RedshiftSource(*, name: Optional[str] = None, timestamp_field: Optional[str] = '', table: Optional[str] = None, schema: Optional[str] = None, created_timestamp_column: Optional[str] = '', field_mapping: Optional[Dict[str, str]] = None, query: Optional[str] = None, description: Optional[str] = '', tags: Optional[Dict[str, str]] = None, owner: Optional[str] = '', database: Optional[str] = '')[source]

Bases: feast.data_source.DataSource

created_timestamp_column: str
property database

Returns the Redshift database of this Redshift source.

date_partition_column: str
description: str
field_mapping: Dict[str, str]
static from_proto(data_source: feast.core.DataSource_pb2.DataSource)[source]

Creates a RedshiftSource from a protobuf representation of a RedshiftSource.

Parameters

data_source – A protobuf representation of a RedshiftSource

Returns

A RedshiftSource object based on the data_source protobuf.

get_table_column_names_and_types(config: feast.repo_config.RepoConfig) Iterable[Tuple[str, str]][source]

Returns a mapping of column names to types for this Redshift source.

Parameters

config – A RepoConfig describing the feature repo

get_table_query_string() str[source]

Returns a string that can directly be used to reference this table in SQL.

name: str
owner: str
property query

Returns the Redshift query of this Redshift source.

property schema

Returns the schema of this Redshift source.

static source_datatype_to_feast_value_type() Callable[[str], feast.value_type.ValueType][source]

Returns the callable method that returns Feast type given the raw column type.

property table

Returns the table of this Redshift source.

tags: Dict[str, str]
timestamp_field: str
to_proto() feast.core.DataSource_pb2.DataSource[source]

Converts a RedshiftSource object to its protobuf representation.

Returns

A DataSourceProto object.

validate(config: feast.repo_config.RepoConfig)[source]

Validates the underlying data source.

Parameters

config – Configuration object used to configure a feature store.

class feast.RepoConfig(*, registry: Union[pydantic.types.StrictStr, feast.repo_config.RegistryConfig] = 'data/registry.db', project: pydantic.types.StrictStr, provider: pydantic.types.StrictStr, feature_server: Optional[Any] = None, flags: Any = None, repo_path: Optional[pathlib.Path] = None, go_feature_serving: Optional[bool] = False, go_feature_retrieval: Optional[bool] = False, entity_key_serialization_version: pydantic.types.StrictInt = 1, coerce_tz_aware: Optional[bool] = True, **data: Any)[source]

Bases: feast.repo_config.FeastBaseModel

Repo config. Typically loaded from feature_store.yaml

class Config[source]

Bases: object

allow_population_by_field_name = True
property batch_engine
coerce_tz_aware: Optional[bool]

If True, coerces entity_df timestamp columns to be timezone aware (to UTC by default).

entity_key_serialization_version: pydantic.types.StrictInt

This version is used to control what serialization scheme is used when writing data to the online store. A value <= 1 uses the serialization scheme used by feast up to Feast 0.22. A value of 2 uses a newer serialization scheme, supported as of Feast 0.23. The main difference between the two scheme is that the serialization scheme v1 stored long values as `int`s, which would result in errors trying to serialize a range of values. v2 fixes this error, but v1 is kept around to ensure backwards compatibility - specifically the ability to read feature values for entities that have already been written into the online store.

Type

Entity key serialization version

feature_server: Optional[Any]

Feature server configuration (optional depending on provider)

Type

FeatureServerConfig

flags: Any

Feature flags for experimental features

Type

Flags (deprecated field)

get_registry_config()[source]
go_feature_retrieval: Optional[bool]

If True, use the embedded Go code to retrieve features instead of the Python SDK.

go_feature_serving: Optional[bool]

If True, use the Go feature server instead of the Python feature server.

property offline_store
property online_store
project: pydantic.types.StrictStr

Feast project id. This can be any alphanumeric string up to 16 characters. You can have multiple independent feature repositories deployed to the same cloud provider account, as long as they have different project ids.

Type

str

provider: pydantic.types.StrictStr

local or gcp or aws

Type

str

registry: Union[pydantic.types.StrictStr, feast.repo_config.RegistryConfig]

Path to metadata store. Can be a local path, or remote object storage path, e.g. a GCS URI

Type

str

repo_path: Optional[pathlib.Path]
write_to_path(repo_path: pathlib.Path)[source]
class feast.RequestFeatureView(name: str, request_data_source: feast.data_source.RequestSource, description: str = '', tags: Optional[Dict[str, str]] = None, owner: str = '')[source]

Bases: feast.base_feature_view.BaseFeatureView

[Experimental] A RequestFeatureView defines a logical group of features that should be available as an input to an on demand feature view at request time.

name

The unique name of the request feature view.

Type

str

request_source

The request source that specifies the schema and features of the request feature view.

Type

feast.data_source.RequestSource

features

The list of features defined as part of this request feature view.

Type

List[feast.field.Field]

description

A human-readable description.

Type

str

tags

A dictionary of key-value pairs to store arbitrary metadata.

Type

Dict[str, str]

owner

The owner of the request feature view, typically the email of the primary maintainer.

Type

str

created_timestamp: Optional[datetime]
description: str
features: List[feast.field.Field]
classmethod from_proto(request_feature_view_proto: feast.core.RequestFeatureView_pb2.RequestFeatureView)[source]

Creates a request feature view from a protobuf representation.

Parameters

request_feature_view_proto – A protobuf representation of an request feature view.

Returns

A RequestFeatureView object based on the request feature view protobuf.

last_updated_timestamp: Optional[datetime]
name: str
owner: str
projection: FeatureViewProjection
property proto_class: Type[feast.core.RequestFeatureView_pb2.RequestFeatureView]
request_source: feast.data_source.RequestSource
tags: Dict[str, str]
to_proto() feast.core.RequestFeatureView_pb2.RequestFeatureView[source]

Converts an request feature view object to its protobuf representation.

Returns

A RequestFeatureViewProto protobuf.

class feast.RequestSource(*, name: str, schema: List[feast.field.Field], description: Optional[str] = '', tags: Optional[Dict[str, str]] = None, owner: Optional[str] = '')[source]

Bases: feast.data_source.DataSource

RequestSource that can be used to provide input features for on demand transforms

name

Name of the request data source

Type

str

schema

Schema mapping from the input feature name to a ValueType

Type

List[feast.field.Field]

description

A human-readable description.

Type

str

tags

A dictionary of key-value pairs to store arbitrary metadata.

Type

Dict[str, str]

owner

The owner of the request data source, typically the email of the primary maintainer.

Type

str

created_timestamp_column: str
date_partition_column: str
description: str
field_mapping: Dict[str, str]
static from_proto(data_source: feast.core.DataSource_pb2.DataSource)[source]

Converts data source config in protobuf spec to a DataSource class object.

Parameters

data_source – A protobuf representation of a DataSource.

Returns

A DataSource class object.

Raises

ValueError – The type of DataSource could not be identified.

get_table_column_names_and_types(config: feast.repo_config.RepoConfig) Iterable[Tuple[str, str]][source]

Returns the list of column names and raw column types.

Parameters

config – Configuration object used to configure a feature store.

get_table_query_string() str[source]

Returns a string that can directly be used to reference this table in SQL.

name: str
owner: str
schema: List[feast.field.Field]
static source_datatype_to_feast_value_type() Callable[[str], feast.value_type.ValueType][source]

Returns the callable method that returns Feast type given the raw column type.

tags: Dict[str, str]
timestamp_field: str
to_proto() feast.core.DataSource_pb2.DataSource[source]

Converts a DataSourceProto object to its protobuf representation.

validate(config: feast.repo_config.RepoConfig)[source]

Validates the underlying data source.

Parameters

config – Configuration object used to configure a feature store.

class feast.SnowflakeSource(*, name: Optional[str] = None, timestamp_field: Optional[str] = '', database: Optional[str] = None, warehouse: Optional[str] = None, schema: Optional[str] = None, table: Optional[str] = None, query: Optional[str] = None, created_timestamp_column: Optional[str] = '', field_mapping: Optional[Dict[str, str]] = None, description: Optional[str] = '', tags: Optional[Dict[str, str]] = None, owner: Optional[str] = '')[source]

Bases: feast.data_source.DataSource

created_timestamp_column: str
property database

Returns the database of this snowflake source.

date_partition_column: str
description: str
field_mapping: Dict[str, str]
static from_proto(data_source: feast.core.DataSource_pb2.DataSource)[source]

Creates a SnowflakeSource from a protobuf representation of a SnowflakeSource.

Parameters

data_source – A protobuf representation of a SnowflakeSource

Returns

A SnowflakeSource object based on the data_source protobuf.

get_table_column_names_and_types(config: feast.repo_config.RepoConfig) Iterable[Tuple[str, str]][source]

Returns a mapping of column names to types for this snowflake source.

Parameters

config – A RepoConfig describing the feature repo

get_table_query_string() str[source]

Returns a string that can directly be used to reference this table in SQL.

name: str
owner: str
property query

Returns the snowflake options of this snowflake source.

property schema

Returns the schema of this snowflake source.

static source_datatype_to_feast_value_type() Callable[[str], feast.value_type.ValueType][source]

Returns the callable method that returns Feast type given the raw column type.

property table

Returns the table of this snowflake source.

tags: Dict[str, str]
timestamp_field: str
to_proto() feast.core.DataSource_pb2.DataSource[source]

Converts a SnowflakeSource object to its protobuf representation.

Returns

A DataSourceProto object.

validate(config: feast.repo_config.RepoConfig)[source]

Validates the underlying data source.

Parameters

config – Configuration object used to configure a feature store.

property warehouse

Returns the warehouse of this snowflake source.

class feast.StreamFeatureView(*, name: str, source: feast.data_source.DataSource, entities: Optional[Union[List[feast.entity.Entity], List[str]]] = None, ttl: datetime.timedelta = datetime.timedelta(0), tags: Optional[Dict[str, str]] = None, online: Optional[bool] = True, description: Optional[str] = '', owner: Optional[str] = '', schema: Optional[List[feast.field.Field]] = None, aggregations: Optional[List[feast.aggregation.Aggregation]] = None, mode: Optional[str] = 'spark', timestamp_field: Optional[str] = '', udf: Optional[function] = None, udf_string: Optional[str] = '')[source]

Bases: feast.feature_view.FeatureView

A stream feature view defines a logical group of features that has both a stream data source and a batch data source.

name

The unique name of the stream feature view.

Type

str

entities

List of entities or entity join keys.

Type

List[str]

ttl

The amount of time this group of features lives. A ttl of 0 indicates that this group of features lives forever. Note that large ttl’s or a ttl of 0 can result in extremely computationally intensive queries.

Type

Optional[datetime.timedelta]

schema

The schema of the feature view, including feature, timestamp, and entity columns. If not specified, can be inferred from the underlying data source.

Type

List[feast.field.Field]

source

The stream source of data where this group of features is stored.

Type

feast.data_source.DataSource

aggregations

List of aggregations registered with the stream feature view.

Type

List[feast.aggregation.Aggregation]

mode

The mode of execution.

Type

str

timestamp_field

Must be specified if aggregations are specified. Defines the timestamp column on which to aggregate windows.

Type

str

online

A boolean indicating whether online retrieval is enabled for this feature view.

Type

bool

description

A human-readable description.

Type

str

tags

A dictionary of key-value pairs to store arbitrary metadata.

Type

Dict[str, str]

owner

The owner of the stream feature view, typically the email of the primary maintainer.

Type

str

udf

The user defined transformation function. This transformation function should have all of the corresponding imports imported within the function.

Type

Optional[function]

aggregations: List[feast.aggregation.Aggregation]
batch_source: DataSource
created_timestamp: Optional[datetime]
description: str
entities: List[str]
entity_columns: List[feast.field.Field]
features: List[feast.field.Field]
classmethod from_proto(sfv_proto)[source]

Creates a feature view from a protobuf representation of a feature view.

Parameters

feature_view_proto – A protobuf representation of a feature view.

Returns

A FeatureViewProto object based on the feature view protobuf.

last_updated_timestamp: Optional[datetime]
materialization_intervals: List[Tuple[datetime.datetime, datetime.datetime]]
mode: str
name: str
online: bool
owner: str
projection: FeatureViewProjection
schema: List[feast.field.Field]
source: feast.data_source.DataSource
stream_source: Optional[DataSource]
tags: Dict[str, str]
timestamp_field: str
to_proto()[source]

Converts a feature view object to its protobuf representation.

Returns

A FeatureViewProto protobuf.

ttl: Optional[datetime.timedelta]
udf: Optional[function]
udf_string: Optional[str]
class feast.ValueType(value)[source]

Bases: enum.Enum

Feature value type. Used to define data types in Feature Tables.

BOOL = 7
BOOL_LIST = 17
BYTES = 1
BYTES_LIST = 11
DOUBLE = 5
DOUBLE_LIST = 15
FLOAT = 6
FLOAT_LIST = 16
INT32 = 3
INT32_LIST = 13
INT64 = 4
INT64_LIST = 14
NULL = 19
STRING = 2
STRING_LIST = 12
UNIX_TIMESTAMP = 8
UNIX_TIMESTAMP_LIST = 18
UNKNOWN = 0