Skip to content

Commit

Permalink
Teardown infrastructure after integration tests (feast-dev#1697)
Browse files Browse the repository at this point in the history
* Teardown infrastructure after integration tests

Signed-off-by: Achal Shah <achals@gmail.com>

* Add a teardown method in feature store

Signed-off-by: Achal Shah <achals@gmail.com>

* fix import

Signed-off-by: Achal Shah <achals@gmail.com>

* Rename var to tables

Signed-off-by: Achal Shah <achals@gmail.com>

* Remove incorrect comment

Signed-off-by: Achal Shah <achals@gmail.com>
Signed-off-by: CS <2498638+charliec443@users.noreply.github.com>
  • Loading branch information
achals authored and 8bit-pixies committed Jul 16, 2021
1 parent 7315646 commit 6ffdca8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
18 changes: 18 additions & 0 deletions sdk/python/feast/feature_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,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 @@ -255,6 +256,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:
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}")

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

0 comments on commit 6ffdca8

Please sign in to comment.