Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
A production deployment of Feast is deployed using Kubernetes.
This guide installs Feast into an existing Kubernetes cluster using Helm. The installation is not specific to any cloud platform or environment, but requires Kubernetes and Helm.
Kubernetes (with Helm)This guide installs Feast into an AWS environment using Terraform. The Terraform script is opinionated and intended to allow you to start quickly.
Amazon EKS (with Terraform)This guide installs Feast into an Azure AKS environment with Helm.
Azure AKS (with Helm)This guide installs Feast into an Azure environment using Terraform. The Terraform script is opinionated and intended to allow you to start quickly.
Azure AKS (with Terraform)This guide installs Feast into a Google Cloud environment using Terraform. The Terraform script is opinionated and intended to allow you to start quickly.
Google Cloud GKE (with Terraform)This guide installs Feast into an existing IBM Cloud Kubernetes Service or Red Hat OpenShift on IBM Cloud using Kustomize.
IBM Cloud Kubernetes Service (IKS) and Red Hat OpenShift (with Kustomize)Install Feast using pip:
pip install feastInstall Feast with GCP dependencies (required when using BigQuery or Firestore):
pip install 'feast[gcp]'Feast uses offline stores as storage and compute systems. Offline stores store historic time-series feature values. Feast does not generate these features, but instead uses the offline store as the interface for querying existing features in your organization.
Offline stores are used primarily for two reasons
Building training datasets from time-series features.
Materializing (loading) features from the offline store into an online store in order to serve those features at low latency for prediction.
Offline stores are configured through the feature_store.yaml. When building training datasets or materializing features into an online store, Feast will use the configured offline store along with the data sources you have defined as part of feature views to execute the necessary data operations.
It is not possible to query all data sources from all offline stores, and only a single offline store can be used at a time. For example, it is not possible to query a BigQuery table from a File offline store, nor is it possible for a BigQuery offline store to query files from your local file system.
Please see the reference for more details on configuring offline stores.
A feature repository is a directory that contains the configuration of the feature store and individual features. This configuration is written as code (Python/YAML) and it's highly recommended that teams track it centrally using git. See for a detailed explanation of feature repositories.
The easiest way to create a new feature repository to use feast init command:
The init command creates a Python file with feature definitions, sample data, and a Feast configuration file for local development:
Enter the directory:
An entity is any domain object that can be modeled and about which information can be stored. Entities are usually recognizable concepts, either concrete or abstract, such as persons, places, things, or events.
Examples of entities in the context of ride-hailing and food delivery: customer, order, driver, restaurant, dish, area.
Entities are important in the context of feature stores since features are always properties of a specific entity. For example, we could have a feature total_trips_24h for driver
The Feast Python SDK allows users to retrieve feature values from an online store. This API is used to look up feature values at low latency during model serving in order to make online predictions.
Please ensure that you have materialized (loaded) your feature values into the online store before starting
Create a list of features that you would like to retrieve. This list typically comes from the model training step and should accompany the model binary.
Next, we will create a feature store object and call get_online_features() which reads the relevant feature values directly from the online store.
are objects in an organization like customers, transactions, and drivers, products, etc.
are external sources of data where feature data can be found.
are objects that define logical groupings of features, data sources, and other related metadata.
Feast contains the following core concepts:
Projects: Serve as a top level namespace for all Feast resources. Each project is a completely independent environment in Feast. Users can only work in a single project at a time.
Feast Components export metrics that can provide insight into Feast behavior:
See the for documentation on metrics are exported by Feast.
Feast Ingestion Job can be configured to push Ingestion metrics to a StatsD instance. Metrics export to StatsD for Ingestion Job is configured in Job Controller's application.yml
The Feast CLI can be used to deploy a feature store to your infrastructure, spinning up any necessary persistent resources like buckets or tables in data stores. The deployment target and effects depend on the provider that has been configured in your file, as well as the feature definitions found in your feature repository.
To have Feast deploy your infrastructure, run feast apply from your command line while inside a feature repository:
Depending on whether the feature repository is configured to use a local provider or one of the cloud providers like GCP or AWS, it may take from a couple of seconds to a minute to run to completion.
If you need to clean up the infrastructure created by
Feast allows users to load their feature data into an online store in order to serve the latest features to models for online prediction.
Before proceeding, please ensure that you have applied (registered) the feature views that should be materialized.
The materialize command allows users to materialize features over a specific historical time range into the online store.
The above command will query the batch sources for all feature views over the provided time range, and load the latest feature values into the configured online store.
It is also possible to materialize for specific feature views by using the -v / --views argument.
The materialize command is completely stateless. It requires the user to provide the time ranges that will be loaded into the online store. This command is best used from a scheduler that tracks state, like Airflow.
For simplicity, Feast also provides a materialize command that will only ingest new data that has arrived in the offline store. Unlike
A provider is an implementation of a feature store using specific feature store components targeting a specific environment. More specifically, a provider is the target environment to which you have configured your feature store to deploy and run.
Providers are built to orchestrate various components (offline store, online store, infrastructure, compute) inside an environment. For example, the gcp provider supports as an offline store and as an online store, ensuring that these components can work together seamlessly.
Providers also come with default configurations which makes it easier for users to start a feature store in a specific environment.
Please see for configuring providers.
In Feast, a store is a database that is populated with feature data that will ultimately be served to models.
The offline store maintains historical copies of feature values. These features are grouped and stored in feature tables. During retrieval of historical data, features are queries from these feature tables in order to produce training datasets.
The online store maintains only the latest values for a specific feature.
Feature values are stored based on their
Feast currently supports Redis as an online store.
Online stores are meant for very high throughput writes from ingestion jobs and very low latency access to features during online serving.
Run feast apply to apply these definitions to Feast.
Edit the example feature definitions in example.py and run feast apply again to change feature definitions.
Initialize a git repository in the same directory and checking the feature repository into version control.
feast init -t gcp
Creating a new Feast repository in /<...>/tiny_pika.feast init
Creating a new Feast repository in /<...>/tiny_pika.D01123411Feast uses entities in the following way:
Entities serve as the keys used to look up features for producing training datasets and online feature values.
Entities serve as a natural grouping of features in a feature table. A feature table must belong to an entity (which could be a composite entity)
When creating an entity specification, consider the following fields:
Name: Name of the entity
Description: Description of the entity
Value Type: Value type of the entity. Feast will attempt to coerce entity columns in your data sources into this type.
Labels: Labels are maps that allow users to attach their own metadata to entities
A valid entity specification is shown below:
Permitted changes include:
The entity's description and labels
The following changes are not permitted:
Project
Name of an entity
Type
feast applyteardown****
At this point, no data has been materialized to your online store. Feast apply simply registers the feature definitions with Feast and spins up any necessary infrastructure such as tables. To load data into the online store, run feast materialize. See Load data into the online store for more details.
Warning: teardown is an irreversible command and will remove all feature store infrastructure. Proceed with caution!
materializematerialize-incrementalThe example command below will load only new data that has arrived for each feature view up to the end date and time (2021-04-08T00:00:00).
The materialize-incremental command functions similarly to materialize in that it loads data over a specific time range for all feature views (or the selected feature views) into the online store.
Unlike materialize, materialize-incremental automatically determines the start time from which to load features from batch sources of each feature view. The first time materialize-incremental is executed it will set the start time to the oldest timestamp of each data source, and the end time as the one provided by the user. For each run of materialize-incremental, the end timestamp will be tracked.
Subsequent runs of materialize-incremental will then set the start time to the end time of the previous run, thus only loading new data that has arrived into the online store. Note that the end time that is tracked for each run is at the feature view level, not globally for all feature views, i.e, different feature views may have different periods that have been materialized into the online store.
$ tree
.
└── tiny_pika
├── data
│ └── driver_stats.parquet
├── example.py
└── feature_store.yaml
1 directory, 3 files# Replace "tiny_pika" with your auto-generated dir name
cd tiny_pikafeature_refs = [
"driver_hourly_stats:conv_rate",
"driver_hourly_stats:acc_rate"
]fs = FeatureStore(repo_path="path/to/feature/repo")
online_features = fs.get_online_features(
feature_refs=feature_refs,
entity_rows=[
{"driver_id": 1001},
{"driver_id": 1002}]
).to_dict(){
"driver_hourly_stats__acc_rate":[
0.2897740304470062,
0.6447265148162842
],
"driver_hourly_stats__conv_rate":[
0.6508077383041382,
0.14802511036396027
],
"driver_id":[
1001,
1002
]
}customer = Entity(
name="customer_id",
description="Customer id for ride customer",
value_type=ValueType.INT64,
labels={}
)# Create a customer entity
customer_entity = Entity(name="customer_id", description="ID of car customer")
client.apply(customer_entity)# Update a customer entity
customer_entity = client.get_entity("customer_id")
customer_entity.description = "ID of bike customer"
client.apply(customer_entity)feast apply
# Processing example.py as example
# Done!feast teardownfeast materialize 2021-04-07T00:00:00 2021-04-08T00:00:00feast materialize 2021-04-07T00:00:00 2021-04-08T00:00:00 \
--views driver_hourly_statsfeast materialize-incremental 2021-04-08T00:00:00Entities: Entities are the objects in an organization on which features occur. They map to your business domain (users, products, transactions, locations).
Feature Tables: Defines a group of features that occur on a specific entity.
Features: Individual feature within a feature table.
feast.jobs.metricsFeast Core and Serving exports metrics to a Prometheus instance via Prometheus scraping its /metrics endpoint. Metrics export to Prometheus for Core and Serving can be configured via their corresponding application.yml
Direct Prometheus to scrape directly from Core and Serving's /metrics endpoint.
See the Metrics Reference for documentation on metrics are exported by Feast.
This page applies to Feast 0.7. The content may be out of date for Feast 0.8+
feast:
jobs:
metrics:
# Enables Statd metrics export if true.
enabled: true
type: statsd
# Host and port of the StatsD instance to export to.
host: localhost
port: 9125server:
# Configures the port where metrics are exposed via /metrics for Prometheus to scrape.
port: 8081Feast allows users to build a training dataset from time-series feature data that already exists in an offline store. Users are expected to provide a list of features to retrieve (which may span multiple feature views), and a dataframe to join the resulting features onto. Feast will then execute a point-in-time join of multiple feature views onto the provided dataframe, and return the full resulting dataframe.
Please ensure that you have created a feature repository and that you have registered (applied) your feature views with Feast.
Deploy a feature storeStart by defining the feature references (e.g., driver_trips:average_daily_rides) for the features that you would like to retrieve from the offline store. These features can come from multiple feature tables. The only requirement is that the feature tables that make up the feature references have the same entity (or composite entity), and that they aren't located in the same offline store.
feature_refs = [
"driver_trips:average_daily_rides",
"driver_trips:maximum_daily_rides",
"driver_trips:rating",
"driver_trips:rating:trip_completed",
]3. Create an entity dataframe
An entity dataframe is the target dataframe on which you would like to join feature values. The entity dataframe must contain a timestamp column called event_timestamp and all entities (primary keys) necessary to join feature tables onto. All entities found in feature views that are being joined onto the entity dataframe must be found as column on the entity dataframe.
It is possible to provide entity dataframes as either a Pandas dataframe or a SQL query.
Pandas:
In the example below we create a Pandas based entity dataframe that has a single row with an event_timestamp column and a driver_id entity column. Pandas based entity dataframes may need to be uploaded into an offline store, which may result in longer wait times compared to a SQL based entity dataframe.
SQL (Alternative):
Below is an example of an entity dataframe built from a BigQuery SQL query. It is only possible to use this query when all feature views being queried are available in the same offline store (BigQuery).
4. Launch historical retrieval
Once the feature references and an entity dataframe are defined, it is possible to call get_historical_features(). This method launches a job that executes a point-in-time join of features from the offline store onto the entity dataframe. Once completed, a job reference will be returned. This job reference can then be converted to a Pandas dataframe by calling to_df().
This guide installs Feast on an existing Kubernetes cluster, and ensures the following services are running:
Feast Core
Feast Online Serving
Postgres
Redis
Feast Jupyter (Optional)
Prometheus (Optional)
Install and configure
Install
Add the Feast Helm repository and download the latest charts:
Feast includes a Helm chart that installs all necessary components to run Feast Core, Feast Online Serving, and an example Jupyter notebook.
Feast Core requires Postgres to run, which requires a secret to be set on Kubernetes:
Install Feast using Helm. The pods may take a few minutes to initialize.
After all the pods are in a RUNNING state, port-forward to the Jupyter Notebook Server in the cluster:
You can now connect to the bundled Jupyter Notebook Server at localhost:8888 and follow the example Jupyter notebook.
This guide installs Feast on GKE using our reference Terraform configuration.
This Terraform configuration creates the following resources:
GKE cluster
Feast services running on GKE
Google Memorystore (Redis) as online store
Dataproc cluster
Kafka running on GKE, exposed to the dataproc cluster via internal load balancer
Install > = 0.12 (tested with 0.13.3)
Install (tested with v3.3.4)
GCP and sufficient to create the resources listed above.
Create a .tfvars file underfeast/infra/terraform/gcp. Name the file. In our example, we use my_feast.tfvars. You can see the full list of configuration variables in variables.tf. Sample configurations are provided below:
After completing the configuration, initialize Terraform and apply:
This guide installs Feast on Azure using our reference Terraform configuration.
This Terraform configuration creates the following resources:
Kubernetes cluster on Azure AKS
Kafka managed by HDInsight
Postgres database for Feast metadata, running as a pod on AKS
Redis cluster, using Azure Cache for Redis
to run Spark
Staging Azure blob storage container to store temporary data
Create an Azure account and
Install (tested with 0.13.5)
Install (tested with v3.4.2)
Create a .tfvars file underfeast/infra/terraform/azure. Name the file. In our example, we use my_feast.tfvars. You can see the full list of configuration variables in variables.tf. At a minimum, you need to set name_prefix and resource_group:
After completing the configuration, initialize Terraform and apply:
After all pods are running, connect to the Jupyter Notebook Server running in the cluster.
To connect to the remote Feast server you just created, forward a port from the remote k8s cluster to your local machine.
You can now connect to the bundled Jupyter Notebook Server at localhost:8888 and follow the example Jupyter notebook.
This guide installs Feast on AWS using our .
This Terraform configuration creates the following resources:
Kubernetes cluster on Amazon EKS (3x r3.large nodes)
Kafka managed by Amazon MSK (2x kafka.t3.small nodes)
import pandas as pd
from datetime import datetime
entity_df = pd.DataFrame(
{
"event_timestamp": [pd.Timestamp(datetime.now(), tz="UTC")],
"driver_id": [1001]
}
)entity_df = "SELECT event_timestamp, driver_id FROM my_gcp_project.table"from feast import FeatureStore
fs = FeatureStore(repo_path="path/to/your/feature/repo")
training_df = fs.get_historical_features(
feature_refs=[
"driver_hourly_stats:conv_rate",
"driver_hourly_stats:acc_rate"
],
entity_df=entity_df
).to_df()gcp_project_name = "kf-feast"
name_prefix = "feast-0-8"
region = "asia-east1"
gke_machine_type = "n1-standard-2"
network = "default"
subnetwork = "default"
dataproc_staging_bucket = "feast-dataproc"$ cd feast/infra/terraform/gcp
$ terraform init
$ terraform apply -var-file=my_feast.tfvarsname_prefix = "feast"
resource_group = "Feast" # pre-existing resource group$ cd feast/infra/terraform/azure
$ terraform init
$ terraform apply -var-file=my_feast.tfvarskubectl port-forward $(kubectl get pod -o custom-columns=:metadata.name | grep jupyter) 8888:8888Forwarding from 127.0.0.1:8888 -> 8888
Forwarding from [::1]:8888 -> 8888helm repo add feast-charts https://feast-helm-charts.storage.googleapis.com
helm repo updatekubectl create secret generic feast-postgresql --from-literal=postgresql-password=passwordhelm install feast-release feast-charts/feastkubectl port-forward \
$(kubectl get pod -l app=feast-jupyter -o custom-columns=:metadata.name) 8888:8888Forwarding from 127.0.0.1:8888 -> 8888
Forwarding from [::1]:8888 -> 8888Redis cluster, using Amazon Elasticache (1x cache.t2.micro)
Amazon EMR cluster to run Spark (3x spot m4.xlarge)
Staging S3 bucket to store temporary data
Create an AWS account and configure credentials locally
Install Terraform > = 0.12 (tested with 0.13.3)
Install Helm (tested with v3.3.4)
Create a .tfvars file underfeast/infra/terraform/aws. Name the file. In our example, we use my_feast.tfvars. You can see the full list of configuration variables in variables.tf. At a minimum, you need to set name_prefix and an AWS region:
After completing the configuration, initialize Terraform and apply:
Starting may take a minute. A kubectl configuration file is also created in this directory, and the file's name will start with kubeconfig_ and end with a random suffix.
After all pods are running, connect to the Jupyter Notebook Server running in the cluster.
To connect to the remote Feast server you just created, forward a port from the remote k8s cluster to your local machine. Replace kubeconfig_XXXXXXX below with the kubeconfig file name Terraform generates for you.
You can now connect to the bundled Jupyter Notebook Server at localhost:8888 and follow the example Jupyter notebook.
name_prefix = "my-feast"
region = "us-east-1"$ cd feast/infra/terraform/aws
$ terraform init
$ terraform apply -var-file=my_feast.tfvarsKUBECONFIG=kubeconfig_XXXXXXX kubectl port-forward \
$(kubectl get pod -o custom-columns=:metadata.name | grep jupyter) 8888:8888Forwarding from 127.0.0.1:8888 -> 8888
Forwarding from [::1]:8888 -> 8888A feature view is an object that represents a logical group of time-series feature data as it is found in a data source. Feature views consist of one or more entities, features, and a data source. Feature views allow Feast to model your existing feature data in a consistent way in both an offline (training) and online (serving) environment.
driver_stats_fv = FeatureView(
name=
Feature views are used during
The generation of training datasets by querying the data source of feature views in order to find historical feature values. A single training dataset may consist of features from multiple feature views.
Loading of feature values into an online store. Feature views determine the storage schema in the online store.
Retrieval of features from the online store. Feature views provide the schema definition to Feast in order to look up features from the online store.
Feast uses a time-series data model to represent data. This data model is used to interpret feature data in data sources in order to build training datasets or when materializing features into an online store.
Below is an example data source with a single entity (driver) and two features (trips_today, and rating).
An entity is a collection of semantically related features. Users define entities to map to the domain of their use case. For example, a ride-hailing service could have customers and drivers as their entities, which group related features that correspond to these customers and drivers.
Entities are defined as part of feature views. Entities are used to identify the primary key on which feature values should be stored and retrieved. These keys are used during the lookup of feature values from the online store and the join process in point-in-time joins. It is possible to define composite entities (more than one entity object) in a feature view.
Entities should be reused across feature views.
A feature is an individual measurable property observed on an entity. For example, a feature of a customer entity could be the number of transactions they have made on an average month.
Features are defined as part of feature views. Since Feast does not transform data, a feature is essentially a schema that only contains a name and a type:
Together with , they indicate to Feast where to find your feature values, e.g., in a specific parquet file or BigQuery table. Feature definitions are also used when reading features from the feature store, using .
Feature names must be unique within a .
Sources are descriptions of external feature data and are registered to Feast as part of feature tables. Once registered, Feast can ingest feature data from these sources into stores.
Currently, Feast supports the following source types:
File (as in Spark): Parquet (only).
BigQuery
Kafka
Kinesis
The following encodings are supported on streams
Avro
Protobuf
For both batch and stream sources, the following configurations are necessary:
Event timestamp column: Name of column containing timestamp when event data occurred. Used during point-in-time join of feature values to .
Created timestamp column: Name of column containing timestamp when data is created. Used to deduplicate data when multiple copies of the same is ingested.
Example data source specifications:
The provides more information about options to specify for the above sources.
Sources are defined as part of :
Feast ensures that the source complies with the schema of the feature table. These specified data sources can then be included inside a feature table specification and registered to Feast Core.
Log Raw Events: Production backend applications are configured to emit internal state changes as events to a stream.
Create Stream Features: Stream processing systems like Flink, Spark, and Beam are used to transform and refine events and to produce features that are logged back to the stream.
Log Streaming Features:
This guide shows you how to deploy Feast using . Docker Compose allows you to explore the functionality provided by Feast while requiring only minimal infrastructure.
This guide includes the following containerized components:
Feast Core with Postgres

from feast import FileSource
from feast.data_format import ParquetFormat
batch_file_source = FileSource(
file_format=ParquetFormat(),
file_url="file:///feast/customer.parquet",
event_timestamp_column="event_timestamp",
created_timestamp_column="created_timestamp",
)from feast import KafkaSource
from feast.data_format import ProtoFormat
stream_kafka_source = KafkaSource(
bootstrap_servers="localhost:9094",
message_format=ProtoFormat(class_path="class.path"),
topic="driver_trips",
event_timestamp_column="event_timestamp",
created_timestamp_column="created_timestamp",
)batch_bigquery_source = BigQuerySource(
table_ref="gcp_project:bq_dataset.bq_table",
event_timestamp_column="event_timestamp",
created_timestamp_column="created_timestamp",
)
stream_kinesis_source = KinesisSource(
bootstrap_servers="localhost:9094",
record_format=ProtoFormat(class_path="class.path"),
region="us-east-1",
stream_name="driver_trips",
event_timestamp_column="event_timestamp",
created_timestamp_column="created_timestamp",
)driver = Entity(name='driver', value_type=ValueType.STRING, join_key='driver_id')trips_today = Feature(
name="trips_today",
dtype=ValueType.FLOAT
)Create Batch Features: ELT/ETL systems like Spark and SQL are used to transform data in the batch store.
Define and Ingest Features: The Feast user defines feature tables based on the features available in batch and streaming sources and publish these definitions to Feast Core.
Poll Feature Definitions: The Feast Job Service polls for new or changed feature definitions.
Start Ingestion Jobs: Every new feature table definition results in a new ingestion job being provisioned (see limitations).
Batch Ingestion: Batch ingestion jobs are short-lived jobs that load data from batch sources into either an offline or online store (see limitations).
Stream Ingestion: Streaming ingestion jobs are long-lived jobs that load data from stream sources into online stores. A stream source and batch source on a feature table must have the same features/fields.
Model Training: A model training pipeline is launched. It uses the Feast Python SDK to retrieve a training dataset and trains a model.
Get Historical Features: Feast exports a point-in-time correct training dataset based on the list of features and entity DataFrame provided by the model training pipeline.
Deploy Model: The trained model binary (and list of features) are deployed into a model serving system.
Get Prediction: A backend system makes a request for a prediction from the model serving service.
Retrieve Online Features: The model serving service makes a request to the Feast Online Serving service for online features using a Feast SDK.
Return Prediction: The model serving service makes a prediction using the returned features and returns the outcome.
A complete Feast deployment contains the following components:
Feast Core: Acts as the central registry for feature and entity definitions in Feast.
Feast Job Service: Manages data processing jobs that load data from sources into stores, and jobs that export training datasets.
Feast Serving: Provides low-latency access to feature values in an online store.
Feast Python SDK CLI: The primary user facing SDK. Used to:
Manage feature definitions with Feast Core.
Launch jobs through the Feast Job Service.
Retrieve training datasets.
Retrieve online features.
Online Store: The online store is a database that stores only the latest feature values for each entity. The online store can be populated by either batch ingestion jobs (in the case the user has no streaming source), or can be populated by a streaming ingestion job from a streaming source. Feast Online Serving looks up feature values from the online store.
Offline Store: The offline store persists batch data that has been ingested into Feast. This data is used for producing training datasets.
Feast Spark SDK: A Spark specific Feast SDK. Allows teams to use Spark for loading features into an online store and for building training datasets over offline sources.
Please see the configuration reference for more details on configuring these components.
Limitations
Only Redis is supported for online storage.
Batch ingestion jobs must be triggered from your own scheduler like Airflow. Streaming ingestion jobs are automatically launched by the Feast Job Service.
Feast Online Serving with Redis.
Feast Job Service
A Jupyter Notebook Server with built in Feast example(s). For demo purposes only.
A Kafka cluster for testing streaming ingestion. For demo purposes only.
Clone the latest stable version of Feast from the Feast repository:
Create a new configuration file:
Start Feast with Docker Compose:
Wait until all all containers are in a running state:
You can now connect to the bundled Jupyter Notebook Server running at localhost:8888 and follow the example Jupyter notebook.
Please ensure that the following ports are available on your host machine:
6565
6566
8888
9094
5432
If a port conflict cannot be resolved, you can modify the port mappings in the provided docker-compose.yml file to use different ports on the host.
If some of the containers continue to restart, or you are unable to access a service, inspect the logs using the following command:
If you are unable to resolve the problem, visit GitHub to create an issue.
The Feast Docker Compose setup can be configured by modifying properties in your .env file.
To access Google Cloud Storage as a data source, the Docker Compose installation requires access to a GCP service account.
Create a new service account and save a JSON key.
Grant the service account access to your bucket(s).
Copy the service account to the path you have configured in .env under GCP_SERVICE_ACCOUNT.
Restart your Docker Compose setup of Feast.
This guide is meant for exploratory purposes only. It allows users to run Feast locally using Docker Compose instead of Kubernetes. The goal of this guide is for users to be able to quickly try out the full Feast stack without needing to deploy to Kubernetes. It is not meant for production use.
git clone https://github.com/feast-dev/feast.git
cd feast/infra/docker-composecp .env.sample .envdocker-compose pull && docker-compose up -ddocker-compose psdocker-compose logs -f -tFeature tables are both a schema and a logical means of grouping features, data sources, and other related metadata.
Feature tables serve the following purposes:
Feature tables are a means for defining the location and properties of data sources.
Feature tables are used to create within Feast a database-level structure for the storage of feature values.
The data sources described within feature tables allow Feast to find and ingest feature data into stores within Feast.
Feature tables ensure data is efficiently stored during by providing a grouping mechanism of features values that occur on the same event timestamp.
A feature is an individual measurable property observed on an entity. For example the amount of transactions (feature) a customer (entity) has completed. Features are used for both model training and scoring (batch, online).
Features are defined as part of feature tables. Since Feast does not apply transformations, a feature is basically a schema that only contains a name and a type:
Visit for the complete feature specification API.
Feature tables contain the following fields:
Name: Name of feature table. This name must be unique within a project.
Entities: List of to associate with the features defined in this feature table. Entities are used as lookup keys when retrieving features from a feature table.
Features: List of features within a feature table.
Here is a ride-hailing example of a valid feature table specification:
By default, Feast assumes that features specified in the feature-table specification corresponds one-to-one to the fields found in the sources. All features defined in a feature table should be available in the defined sources.
Field mappings can be used to map features defined in Feast to fields as they occur in data sources.
In the example feature-specification table above, we use field mappings to ensure the feature named rating in the batch source is mapped to the field named driver_rating.
Adding new features.
Removing features.
Updating source, max age, and labels.
Changes to the project or name of a feature table.
Changes to entities related to a feature table.
Changes to names and types of existing features.
This guide installs Feast on Azure Kubernetes cluster (known as AKS), and ensures the following services are running:
Feast Core
Feast Online Serving
Postgres
Max age: Max age affect the retrieval of features from a feature table. Age is measured as the duration of time between the event timestamp of a feature and the lookup time on an entity key used to retrieve the feature. Feature values outside max age will be returned as unset values. Max age allows for eviction of keys from online stores and limits the amount of historical scanning required for historical feature values during retrieval.
Batch Source: The batch data source from which Feast will ingest feature values into stores. This can either be used to back-fill stores before switching over to a streaming source, or it can be used as the primary source of data for a feature table. Visit Sources to learn more about batch sources.
Stream Source: The streaming data source from which you can ingest streaming feature values into Feast. Streaming sources must be paired with a batch source containing the same feature values. A streaming source is only used to populate online stores. The batch equivalent source that is paired with a streaming source is used during the generation of historical feature datasets. Visit Sources to learn more about stream sources.
Deleted features are archived, rather than removed completely. Importantly, new features cannot use the names of these deleted features.
Feast currently does not support the deletion of feature tables.
avg_daily_ride = Feature("average_daily_rides", ValueType.FLOAT)from feast import BigQuerySource, FeatureTable, Feature, ValueType
from google.protobuf.duration_pb2 import Duration
driver_ft = FeatureTable(
name="driver_trips",
entities=["driver_id"],
features=[
Feature("average_daily_rides", ValueType.FLOAT),
Feature("rating", ValueType.FLOAT)
],
max_age=Duration(seconds=3600),
labels={
"team": "driver_matching"
},
batch_source=BigQuerySource(
table_ref="gcp_project:bq_dataset.bq_table",
event_timestamp_column="datetime",
created_timestamp_column="timestamp",
field_mapping={
"rating": "driver_rating"
}
)
)driver_ft = FeatureTable(...)
client.apply(driver_ft)driver_ft = FeatureTable()
client.apply(driver_ft)
driver_ft.labels = {"team": "marketplace"}
client.apply(driver_ft)Redis
Spark
Kafka
Feast Jupyter (Optional)
Prometheus (Optional)
Create an AKS cluster with Azure CLI. The detailed steps can be found here, and a high-level walk through includes:
Add the Feast Helm repository and download the latest charts:
Feast includes a Helm chart that installs all necessary components to run Feast Core, Feast Online Serving, and an example Jupyter notebook.
Feast Core requires Postgres to run, which requires a secret to be set on Kubernetes:
Install Feast using Helm. The pods may take a few minutes to initialize.
Follow the documentation to install Spark operator on Kubernetes , and Feast documentation to configure Spark roles
and ensure the service account used by Feast has permissions to manage Spark Application resources. This depends on your k8s setup, but typically you'd need to configure a Role and a RoleBinding like the one below:
After all the pods are in a RUNNING state, port-forward to the Jupyter Notebook Server in the cluster:
You can now connect to the bundled Jupyter Notebook Server at localhost:8888 and follow the example Jupyter notebook.
If you are running the Minimal Ride Hailing Example, you may want to make sure the following environment variables are correctly set:
az group create --name myResourceGroup --location eastus
az acr create --resource-group myResourceGroup --name feast-AKS-ACR --sku Basic
az aks create -g myResourceGroup -n feast-AKS --location eastus --attach-acr feast-AKS-ACR --generate-ssh-keys
az aks install-cli
az aks get-credentials --resource-group myResourceGroup --name feast-AKShelm version # make sure you have the latest Helm installed
helm repo add feast-charts https://feast-helm-charts.storage.googleapis.com
helm repo updatekubectl create secret generic feast-postgresql --from-literal=postgresql-password=passwordhelm install feast-release feast-charts/feasthelm repo add spark-operator https://googlecloudplatform.github.io/spark-on-k8s-operator
helm install my-release spark-operator/spark-operator --set serviceAccounts.spark.name=spark --set image.tag=v1beta2-1.1.2-2.4.5cat <<EOF | kubectl apply -f -
kind: Role
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: use-spark-operator
namespace: <REPLACE ME>
rules:
- apiGroups: ["sparkoperator.k8s.io"]
resources: ["sparkapplications"]
verbs: ["create", "delete", "deletecollection", "get", "list", "update", "watch", "patch"]
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: RoleBinding
metadata:
name: use-spark-operator
namespace: <REPLACE ME>
roleRef:
kind: Role
name: use-spark-operator
apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
name: default
EOFkubectl port-forward \
$(kubectl get pod -o custom-columns=:metadata.name | grep jupyter) 8888:8888Forwarding from 127.0.0.1:8888 -> 8888
Forwarding from [::1]:8888 -> 8888demo_data_location = "wasbs://<container_name>@<storage_account_name>.blob.core.windows.net/"
os.environ["FEAST_AZURE_BLOB_ACCOUNT_NAME"] = "<storage_account_name>"
os.environ["FEAST_AZURE_BLOB_ACCOUNT_ACCESS_KEY"] = <Insert your key here>
os.environ["FEAST_HISTORICAL_FEATURE_OUTPUT_LOCATION"] = "wasbs://<container_name>@<storage_account_name>.blob.core.windows.net/out/"
os.environ["FEAST_SPARK_STAGING_LOCATION"] = "wasbs://<container_name>@<storage_account_name>.blob.core.windows.net/artifacts/"
os.environ["FEAST_SPARK_LAUNCHER"] = "k8s"
os.environ["FEAST_SPARK_K8S_NAMESPACE"] = "default"
os.environ["FEAST_HISTORICAL_FEATURE_OUTPUT_FORMAT"] = "parquet"
os.environ["FEAST_REDIS_HOST"] = "feast-release-redis-master.default.svc.cluster.local"
os.environ["DEMO_KAFKA_BROKERS"] = "feast-release-kafka.default.svc.cluster.local:9092"This guide installs Feast on an existing IBM Cloud Kubernetes cluster or Red Hat OpenShift on IBM Cloud , and ensures the following services are running:
Feast Core
Feast Online Serving
Postgres
Redis
Kafka (Optional)
Feast Jupyter (Optional)
Prometheus (Optional)
or
Install that matches the major.minor versions of your IKS or Install the that matches your local operating system and OpenShift cluster version.
Install
:warning: If you have Red Hat OpenShift Cluster on IBM Cloud skip to this .
By default, IBM Cloud Kubernetes cluster uses based on NFS as the default storage class, and non-root users do not have write permission on the volume mount path for NFS-backed storage. Some common container images in Feast, such as Redis, Postgres, and Kafka specify a non-root user to access the mount path in the images. When containers are deployed using these images, the containers fail to start due to insufficient permissions of the non-root user creating folders on the mount path.
allows for the creation of raw storage volumes and provides faster performance without the permission restriction of NFS-backed storage
Therefore, to deploy Feast we need to set up as the default storage class so that you can have all the functionalities working and get the best experience from Feast.
to install the Helm version 3 client on your local machine.
Add the IBM Cloud Helm chart repository to the cluster where you want to use the IBM Cloud Block Storage plug-in.
Install the IBM Cloud Block Storage plug-in. When you install the plug-in, pre-defined block storage classes are added to your cluster.
Example output:
By default, in OpenShift, all pods or containers will use the which limits the UIDs pods can run with, causing the Feast installation to fail. To overcome this, you can allow Feast pods to run with any UID by executing the following:
Install Feast using kustomize. The pods may take a few minutes to initialize.
You may optionally enable the Feast Jupyter component which contains code examples to demonstrate Feast. Some examples require Kafka to stream real time features to the Feast online serving. To enable, edit the following properties in the values.yaml under the manifests/contrib/feast folder:
Then regenerate the resource manifests and deploy:
After all the pods are in a RUNNING state, port-forward to the Jupyter Notebook Server in the cluster:
You can now connect to the bundled Jupyter Notebook Server at localhost:8888 and follow the example Jupyter notebook.
When running the minimal_ride_hailing_example Jupyter Notebook example the following errors may occur:
When running job = client.get_historical_features(...):
or
Add the following environment variable:
When running job.get_status()
Add the following environment variable:
Verify that all block storage plugin pods are in a "Running" state.
Verify that the storage classes for Block Storage were added to your cluster.
Set the Block Storage as the default storageclass.
Example output:
Security Context Constraint Setup (OpenShift only)
When running job = client.start_stream_to_online_ingestion(...)
Add the following environment variable:
helm repo add iks-charts https://icr.io/helm/iks-charts
helm repo update helm install v2.0.2 iks-charts/ibmcloud-block-storage-plugin -n kube-systemNAME: v2.0.2
LAST DEPLOYED: Fri Feb 5 12:29:50 2021
NAMESPACE: kube-system
STATUS: deployed
REVISION: 1
NOTES:
Thank you for installing: ibmcloud-block-storage-plugin. Your release is named: v2.0.2
...oc adm policy add-scc-to-user anyuid -z default,kf-feast-kafka -n feastgit clone https://github.com/kubeflow/manifests
cd manifests/contrib/feast/
kustomize build feast/base | kubectl apply -n feast -f -kafka.enabled: true
feast-jupyter.enabled: truemake feast/base
kustomize build feast/base | kubectl apply -n feast -f -kubectl port-forward \
$(kubectl get pod -l app=feast-jupyter -o custom-columns=:metadata.name) 8888:8888 -n feastForwarding from 127.0.0.1:8888 -> 8888
Forwarding from [::1]:8888 -> 8888kustomize build feast/base | kubectl delete -n feast -f - KeyError: 'historical_feature_output_location' KeyError: 'spark_staging_location' os.environ["FEAST_HISTORICAL_FEATURE_OUTPUT_LOCATION"] = "file:///home/jovyan/historical_feature_output"
os.environ["FEAST_SPARK_STAGING_LOCATION"] = "file:///home/jovyan/test_data" <SparkJobStatus.FAILED: 2> os.environ["FEAST_REDIS_HOST"] = "feast-release-redis-master"
kubectl get pods -n kube-system | grep ibmcloud-block-storage kubectl get storageclasses | grep ibmc-block kubectl patch storageclass ibmc-block-gold -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
kubectl patch storageclass ibmc-file-gold -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}'
# Check the default storageclass is block storage
kubectl get storageclass | grep \(default\) ibmc-block-gold (default) ibm.io/ibmc-block 65s org.apache.kafka.vendor.common.KafkaException: Failed to construct kafka consumer os.environ["DEMO_KAFKA_BROKERS"] = "feast-release-kafka:9092"
This page applies to Feast 0.7. The content may be out of date for Feast 0.8+
Feast provides audit logging functionality in order to debug problems and to trace the lineage of events.
Audit Logs produced by Feast come in three favors:
Audit Log Type
Description
Message Audit Log
Audit Logs produced by Feast are written to the console similar to normal logs but in a structured, machine parsable JSON. Example of a Message Audit Log JSON entry produced:
Fields common to all Audit Log Types:
Fields in Message Audit Log Type
Fields in Action Audit Log Type
Fields in Transition Audit Log Type
Feast currently only supports forwarding Request/Response (Message Audit Log Type) logs to an external fluentD service with feast.** Fluentd tag.
The Fluentd Log Forwarder configured with the with the following configuration options in application.yml:
When using Fluentd as the Log forwarder, a Feast release_name can be logged instead of the IP address (eg. IP of Kubernetes pod deployment), by setting an environment variable RELEASE_NAME when deploying Feast.
Logs service calls that can be used to track Feast request handling. Currently only gRPC request/response is supported. Enabling Message Audit Logs can be resource intensive and significantly increase latency, as such is not recommended on Online Serving.
Transition Audit Log
Logs transitions in status in resources managed by Feast (ie an Ingestion Job becoming RUNNING).
Action Audit Log
Logs actions performed on a specific resource managed by Feast (ie an Ingestion Job is aborted).
Audit Log Type
Description
Message Audit Log
Enabled when both feast.logging.audit.enabled and feast.logging.audit.messageLogging.enabled is set to true
Transition Audit Log
Enabled when feast.logging.audit.enabled is set to true
{
"message": {
"logType": "FeastAuditLogEntry",
"kind": "MESSAGE",
"statusCode": "OK",
"request": {
"filter": {
"project": "dummy",
}
},
"application": "Feast",
"response": {},
"method": "ListFeatureTables",
"identity": "105960238928959148073",
"service": "CoreService",
"component": "feast-core",
"id": "45329ea9-0d48-46c5-b659-4604f6193711",
"version": "0.10.0-SNAPSHOT"
},
"hostname": "feast.core"
"timestamp": "2020-10-20T04:45:24Z",
"severity": "INFO",
}Field
Description
logType
Log Type. Always set to FeastAuditLogEntry. Useful for filtering out Feast audit logs.
application
Application. Always set to Feast.
Field
Description
id
Generated UUID that uniquely identifies the service call.
service
Name of the Service that handled the service call.
Field
Description
action
Name of the action taken on the resource.
resource.type
Type of resource of which the action was taken on (i.e FeatureTable)
Field
Description
status
The new status that the resource transitioned to
resource.type
Type of resource of which the transition occurred (i.e FeatureTable)
{
"id": "45329ea9-0d48-46c5-b659-4604f6193711",
"service": "CoreService"
"status_code": "OK",
"identity": "105960238928959148073",
"method": "ListProjects",
"request": {},
"response": {
"projects": [
"default", "project1", "project2"
]
}
"release_name": 506.457.14.512
}Settings
Description
feast.logging.audit.messageLogging.destination
fluentd
feast.logging.audit.messageLogging.fluentdHost
localhost
Action Audit Log
Enabled when feast.logging.audit.enabled is set to true
component
Feast Component producing the Audit Log. Set to feast-core for Feast Core and feast-serving for Feast Serving. Use to filtering out Audit Logs by component.
version
Version of Feast producing this Audit Log. Use to filtering out Audit Logs by version.
method
Name of the Method that handled the service call. Useful for filtering Audit Logs by method (ie ApplyFeatureTable calls)
request
Full request submitted by client in the service call as JSON.
response
Full response returned to client by the service after handling the service call as JSON.
identity
Identity of the client making the service call as an user Id. Only set when Authentication is enabled.
statusCode
The status code returned by the service handling the service call (ie OK if service call handled without error).
resource.id
Identifier specifying the specific resource of which the action was taken on.
resource.id
Identifier specifying the specific resource of which the transition occurred.
feast.logging.audit.messageLogging.fluentdPort
24224
