Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teardown infrastructure after integration tests #1697

Merged
merged 5 commits into from
Jul 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
18 changes: 18 additions & 0 deletions sdk/python/feast/feature_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from feast import utils
from feast.entity import Entity
from feast.errors import FeatureNameCollisionError, FeatureViewNotFoundException
from feast.feature_table import FeatureTable
from feast.feature_view import FeatureView
from feast.inference import (
update_data_sources_with_inferred_event_timestamp_col,
Expand Down Expand Up @@ -254,6 +255,23 @@ def apply(
partial=True,
)

@log_exceptions_and_usage
def teardown(self):
tables: List[Union[FeatureView, FeatureTable]] = []
feature_views = self.list_feature_views()
feature_tables = self._registry.list_feature_tables(self.project)

tables.extend(feature_views)
tables.extend(feature_tables)

entities = self.list_entities()

self._get_provider().teardown_infra(self.project, tables, entities)
for feature_view in feature_views:
felixwang9817 marked this conversation as resolved.
Show resolved Hide resolved
self.delete_feature_view(feature_view.name)
for feature_table in feature_tables:
self._registry.delete_feature_table(feature_table.name, self.project)

@log_exceptions_and_usage
def get_historical_features(
self,
Expand Down
21 changes: 18 additions & 3 deletions sdk/python/tests/test_offline_online_store_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ def prep_bq_fs_and_fv(

yield fs, fv

fs.teardown()


@contextlib.contextmanager
def prep_local_fs_and_fv() -> Iterator[Tuple[FeatureStore, FeatureView]]:
Expand All @@ -133,10 +135,13 @@ def prep_local_fs_and_fv() -> Iterator[Tuple[FeatureStore, FeatureView]]:
join_key="driver_id",
value_type=ValueType.INT32,
)
project = f"test_local_correctness_{str(uuid.uuid4()).replace('-', '')}"
print(f"Using project: {project}")
woop marked this conversation as resolved.
Show resolved Hide resolved

with tempfile.TemporaryDirectory() as repo_dir_name, tempfile.TemporaryDirectory() as data_dir_name:
config = RepoConfig(
registry=str(Path(repo_dir_name) / "registry.db"),
project=f"test_bq_correctness_{str(uuid.uuid4()).replace('-', '')}",
project=project,
provider="local",
online_store=SqliteOnlineStoreConfig(
path=str(Path(data_dir_name) / "online_store.db")
Expand All @@ -147,6 +152,8 @@ def prep_local_fs_and_fv() -> Iterator[Tuple[FeatureStore, FeatureView]]:

yield fs, fv

fs.teardown()


@contextlib.contextmanager
def prep_redis_fs_and_fv() -> Iterator[Tuple[FeatureStore, FeatureView]]:
Expand All @@ -169,10 +176,12 @@ def prep_redis_fs_and_fv() -> Iterator[Tuple[FeatureStore, FeatureView]]:
join_key="driver_id",
value_type=ValueType.INT32,
)
project = f"test_redis_correctness_{str(uuid.uuid4()).replace('-', '')}"
print(f"Using project: {project}")
with tempfile.TemporaryDirectory() as repo_dir_name:
config = RepoConfig(
registry=str(Path(repo_dir_name) / "registry.db"),
project=f"test_bq_correctness_{str(uuid.uuid4()).replace('-', '')}",
project=project,
provider="local",
online_store=RedisOnlineStoreConfig(
type="redis",
Expand All @@ -185,6 +194,8 @@ def prep_redis_fs_and_fv() -> Iterator[Tuple[FeatureStore, FeatureView]]:

yield fs, fv

fs.teardown()


@contextlib.contextmanager
def prep_dynamodb_fs_and_fv() -> Iterator[Tuple[FeatureStore, FeatureView]]:
Expand All @@ -207,10 +218,12 @@ def prep_dynamodb_fs_and_fv() -> Iterator[Tuple[FeatureStore, FeatureView]]:
join_key="driver_id",
value_type=ValueType.INT32,
)
project = f"test_dynamo_correctness_{str(uuid.uuid4()).replace('-', '')}"
print(f"Using project {project}")
with tempfile.TemporaryDirectory() as repo_dir_name:
config = RepoConfig(
registry=str(Path(repo_dir_name) / "registry.db"),
project=f"test_bq_correctness_{str(uuid.uuid4()).replace('-', '')}",
project=project,
provider="aws",
online_store=DynamoDBOnlineStoreConfig(region="us-west-2"),
offline_store=FileOfflineStoreConfig(),
Expand All @@ -220,6 +233,8 @@ def prep_dynamodb_fs_and_fv() -> Iterator[Tuple[FeatureStore, FeatureView]]:

yield fs, fv

fs.teardown()


# Checks that both offline & online store values are as expected
def check_offline_and_online_features(
Expand Down