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
tests fix: make foo_provider concrete again | MockRetrievalJob to be …
…concrete

Signed-off-by: Chester Ong <chester.ong.ch@gmail.com>
  • Loading branch information
bushwhackr committed Feb 9, 2024
commit 72ce6c4f0d5510e2f15f4dc9e6b475b921c43046
12 changes: 3 additions & 9 deletions sdk/python/tests/foo_provider.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from abc import abstractmethod
from datetime import datetime
from pathlib import Path
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
Expand Down Expand Up @@ -62,7 +61,6 @@ def materialize_single_feature_view(
) -> None:
pass

@abstractmethod
def get_historical_features(
self,
config: RepoConfig,
Expand All @@ -73,23 +71,20 @@ def get_historical_features(
project: str,
full_feature_names: bool = False,
) -> RetrievalJob:
pass
return RetrievalJob()

@abstractmethod
def online_read(
self,
config: RepoConfig,
table: FeatureView,
entity_keys: List[EntityKeyProto],
requested_features: Optional[List[str]] = None,
) -> List[Tuple[Optional[datetime], Optional[Dict[str, ValueProto]]]]:
pass
return []

@abstractmethod
def retrieve_saved_dataset(self, config: RepoConfig, dataset: SavedDataset):
pass

@abstractmethod
def write_feature_service_logs(
self,
feature_service: FeatureService,
Expand All @@ -99,7 +94,6 @@ def write_feature_service_logs(
):
pass

@abstractmethod
def retrieve_feature_service_logs(
self,
feature_service: FeatureService,
Expand All @@ -108,4 +102,4 @@ def retrieve_feature_service_logs(
config: RepoConfig,
registry: BaseRegistry,
) -> RetrievalJob:
pass
return RetrievalJob()
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,17 @@


class MockRetrievalJob(RetrievalJob):
def to_sql(self) -> str:
return ""

def _to_df_internal(self, timeout: Optional[int] = None) -> pd.DataFrame:
"""
Synchronously executes the underlying query and returns the result as a pandas dataframe.

Does not handle on demand transformations or dataset validation. For either of those,
`to_df` should be used.
"""
raise NotImplementedError
return pd.DataFrame()

def _to_arrow_internal(self, timeout: Optional[int] = None) -> pyarrow.Table:
"""
Expand All @@ -55,17 +58,17 @@ def _to_arrow_internal(self, timeout: Optional[int] = None) -> pyarrow.Table:
Does not handle on demand transformations or dataset validation. For either of those,
`to_arrow` should be used.
"""
raise NotImplementedError
return pyarrow.Table()

@property
def full_feature_names(self) -> bool:
"""Returns True if full feature names should be applied to the results of the query."""
raise NotImplementedError
return False

@property
def on_demand_feature_views(self) -> List[OnDemandFeatureView]:
"""Returns a list containing all the on demand feature views to be handled."""
raise NotImplementedError
return []

def persist(
self,
Expand Down Expand Up @@ -208,7 +211,7 @@ def retrieval_job(request, environment):


def test_to_sql():
assert MockRetrievalJob().to_sql() is None
assert MockRetrievalJob().to_sql() == ""


@pytest.mark.parametrize("timeout", (None, 30))
Expand Down