Visitar URL original
feat: Local compute engine by haoxu0 · Pull Request #5278 · feast-dev/feast · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update backend
Signed-off-by: HaoXuAI <sduxuhao@gmail.com>
  • Loading branch information
haoxu0 committed Apr 17, 2025
commit 4b801ba032eb3c8f09b3801760f7ee4bf7fe86ba
5 changes: 3 additions & 2 deletions docs/reference/compute-engine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ This system builds and executes DAGs (Directed Acyclic Graphs) of typed operatio
- Supports point-in-time joins and large-scale materialization
- Integrates with `SparkOfflineStore` and `SparkMaterializationJob`

### 🧪 LocalComputeEngine (WIP)
### 🧪 LocalComputeEngine

- Runs on Arrow + Pandas (or optionally DuckDB)
- Runs on Arrow + Specified backend (e.g., Pandas, Polars)
- Designed for local dev, testing, or lightweight feature generation
- Supports `LocalMaterializationJob` and `LocalHistoricalRetrievalJob`

---

Expand Down
6 changes: 3 additions & 3 deletions sdk/python/feast/infra/compute_engines/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import pyarrow as pa

from feast import RepoConfig
from feast.infra.compute_engines.dag.context import ColumnInfo, ExecutionContext
from feast.infra.compute_engines.tasks import HistoricalRetrievalTask
from feast.infra.materialization.batch_materialization_engine import (
from feast.infra.common.materialization_job import (
MaterializationJob,
MaterializationTask,
)
from feast.infra.common.retrieval_task import HistoricalRetrievalTask
from feast.infra.compute_engines.dag.context import ColumnInfo, ExecutionContext
from feast.infra.offline_stores.offline_store import OfflineStore
from feast.infra.online_stores.online_store import OnlineStore
from feast.infra.registry.registry import Registry
Expand Down
4 changes: 2 additions & 2 deletions sdk/python/feast/infra/compute_engines/feature_builder.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from abc import ABC, abstractmethod
from typing import Union

from feast.infra.common.materialization_job import MaterializationTask
from feast.infra.common.retrieval_task import HistoricalRetrievalTask
from feast.infra.compute_engines.dag.node import DAGNode
from feast.infra.compute_engines.dag.plan import ExecutionPlan
from feast.infra.compute_engines.tasks import HistoricalRetrievalTask
from feast.infra.materialization.batch_materialization_engine import MaterializationTask


class FeatureBuilder(ABC):
Expand Down
47 changes: 47 additions & 0 deletions sdk/python/feast/infra/compute_engines/local/backends/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,53 @@


class DataFrameBackend(ABC):
"""
Abstract interface for DataFrame operations used by the LocalComputeEngine.

This interface defines the contract for implementing pluggable DataFrame backends
such as Pandas, Polars, or DuckDB. Each backend must support core table operations
such as joins, filtering, aggregation, conversion to/from Arrow, and deduplication.

The purpose of this abstraction is to allow seamless swapping of execution backends
without changing DAGNode or ComputeEngine logic. All nodes operate on pyarrow.Table
as the standard input/output format, while the backend defines how the computation
is actually performed.

Expected implementations include:
- PandasBackend
- PolarsBackend
- DuckDBBackend (future)

Methods
-------
from_arrow(table: pa.Table) -> Any
Convert a pyarrow.Table to the backend-native DataFrame format.

to_arrow(df: Any) -> pa.Table
Convert a backend-native DataFrame to pyarrow.Table.

join(left: Any, right: Any, on: List[str], how: str) -> Any
Join two dataframes on specified keys with given join type.

groupby_agg(df: Any, group_keys: List[str], agg_ops: Dict[str, Tuple[str, str]]) -> Any
Group and aggregate the dataframe. `agg_ops` maps output column names
to (aggregation function, source column name) pairs.

filter(df: Any, expr: str) -> Any
Apply a filter expression (string-based) to the DataFrame.

to_timedelta_value(delta: timedelta) -> Any
Convert a Python timedelta object to a backend-compatible value
that can be subtracted from a timestamp column.

drop_duplicates(df: Any, keys: List[str], sort_by: List[str], ascending: bool = False) -> Any
Deduplicate the DataFrame by key columns, keeping the first row
by descending or ascending sort order.

rename_columns(df: Any, columns: Dict[str, str]) -> Any
Rename columns in the DataFrame according to the provided mapping.
"""

@abstractmethod
def columns(self, df): ...

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@


class BackendFactory:
"""
Factory class for constructing DataFrameBackend implementations based on backend name
or runtime entity_df type.
"""

@staticmethod
def from_name(name: str) -> DataFrameBackend:
if name == "pandas":
Expand Down
20 changes: 0 additions & 20 deletions sdk/python/feast/infra/compute_engines/local/config.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
MaterializationJobStatus,
MaterializationTask,
)
from feast.infra.common.retrieval_job import HistoricalRetrievalTask
from feast.infra.common.retrieval_task import HistoricalRetrievalTask
from feast.infra.compute_engines.spark.compute import SparkComputeEngine
from feast.infra.compute_engines.spark.job import SparkDAGRetrievalJob
from feast.infra.offline_stores.contrib.spark_offline_store.spark import (
Expand Down