feast.infra.online_stores.contrib.cassandra_online_store package

Submodules

feast.infra.online_stores.contrib.cassandra_online_store.cassandra_online_store module

Cassandra/Astra DB online store for Feast.

exception feast.infra.online_stores.contrib.cassandra_online_store.cassandra_online_store.CassandraInvalidConfig(msg: str)[source]

Bases: Exception

class feast.infra.online_stores.contrib.cassandra_online_store.cassandra_online_store.CassandraOnlineStore[source]

Bases: OnlineStore

Cassandra/Astra DB online store implementation for Feast.

_cluster

Cassandra cluster to connect to.

Type:

cassandra.cluster.Cluster

_session

(DataStax Cassandra drivers) session object to issue commands.

Type:

cassandra.cluster.Session

_keyspace

Cassandra keyspace all tables live in.

Type:

str

_prepared_statements

cache of statements prepared by the driver.

Type:

Dict[str, cassandra.query.PreparedStatement]

online_read(config: RepoConfig, table: FeatureView, entity_keys: List[EntityKey], requested_features: List[str] | None = None) List[Tuple[datetime | None, Dict[str, Value] | None]][source]

Read feature values pertaining to the requested entities from the online store.

Parameters:
  • config – The RepoConfig for the current FeatureStore.

  • table – Feast FeatureView.

  • entity_keys – a list of entity keys that should be read from the FeatureStore.

online_write_batch(config: RepoConfig, table: FeatureView, data: List[Tuple[EntityKey, Dict[str, Value], datetime, datetime | None]], progress: Callable[[int], Any] | None) None[source]

Write a batch of features of several entities to the database.

Parameters:
  • config – The RepoConfig for the current FeatureStore.

  • table – Feast FeatureView.

  • data – a list of quadruplets containing Feature data. Each quadruplet contains an Entity Key, a dict containing feature values, an event timestamp for the row, and the created timestamp for the row if it exists.

  • progress – Optional function to be called once every mini-batch of rows is written to the online store. Can be used to display progress.

teardown(config: RepoConfig, tables: Sequence[FeatureView], entities: Sequence[Entity])[source]

Delete tables from the database.

Parameters:
  • config – The RepoConfig for the current FeatureStore.

  • tables – Tables to delete from the feature repo.

update(config: RepoConfig, tables_to_delete: Sequence[FeatureView], tables_to_keep: Sequence[FeatureView], entities_to_delete: Sequence[Entity], entities_to_keep: Sequence[Entity], partial: bool)[source]

Update schema on DB, by creating and destroying tables accordingly.

Parameters:
  • config – The RepoConfig for the current FeatureStore.

  • tables_to_delete – Tables to delete from the Online Store.

  • tables_to_keep – Tables to keep in the Online Store.

class feast.infra.online_stores.contrib.cassandra_online_store.cassandra_online_store.CassandraOnlineStoreConfig(*, type: typing_extensions.Literal[cassandra] = 'cassandra', hosts: List[StrictStr] | None = None, secure_bundle_path: StrictStr | None = None, port: StrictInt | None = None, keyspace: StrictStr = 'feast_keyspace', username: StrictStr | None = None, password: StrictStr | None = None, protocol_version: StrictInt | None = None, request_timeout: StrictFloat | None = None, load_balancing: CassandraLoadBalancingPolicy | None = None, read_concurrency: StrictInt | None = 100, write_concurrency: StrictInt | None = 100)[source]

Bases: FeastConfigBaseModel

Configuration for the Cassandra/Astra DB online store.

Exactly one of hosts and secure_bundle_path must be provided; depending on which one, the connection will be to a regular Cassandra or an Astra DB instance (respectively).

If connecting to Astra DB, authentication must be provided with username and password being the Client ID and Client Secret of the database token.

class CassandraLoadBalancingPolicy(*, load_balancing_policy: StrictStr, local_dc: StrictStr = 'datacenter1')[source]

Bases: FeastConfigBaseModel

Configuration block related to the Cluster’s load-balancing policy.

load_balancing_policy: StrictStr

A stringy description of the load balancing policy to instantiate the cluster with. Supported values:

“DCAwareRoundRobinPolicy” “TokenAwarePolicy(DCAwareRoundRobinPolicy)”

local_dc: StrictStr

The local datacenter, usually necessary to create the policy.

hosts: List[StrictStr] | None

List of host addresses to reach the cluster.

keyspace: StrictStr

Target Cassandra keyspace where all tables will be.

load_balancing: CassandraLoadBalancingPolicy | None

it will be wrapped into an execution profile if present.

Type:

Details on the load-balancing policy

password: StrictStr | None

Password for DB auth, possibly Astra DB token Client Secret.

port: StrictInt | None

Port number for connecting to the cluster (optional).

protocol_version: StrictInt | None

Explicit specification of the CQL protocol version used.

read_concurrency: StrictInt | None

Value of the concurrency parameter internally passed to Cassandra driver’s execute_concurrent_with_args call when reading rows from tables. See https://docs.datastax.com/en/developer/python-driver/3.25/api/cassandra/concurrent/#module-cassandra.concurrent . Default: 100.

request_timeout: StrictFloat | None

Request timeout in seconds.

secure_bundle_path: StrictStr | None

Path to the secure connect bundle (for Astra DB; replaces hosts).

type: typing_extensions.Literal[cassandra]

Online store type selector.

username: StrictStr | None

Username for DB auth, possibly Astra DB token Client ID.

write_concurrency: StrictInt | None

Value of the concurrency parameter internally passed to Cassandra driver’s execute_concurrent_with_args call when writing rows to tables. See https://docs.datastax.com/en/developer/python-driver/3.25/api/cassandra/concurrent/#module-cassandra.concurrent . Default: 100.

Module contents