Skip to content

Commit d9ccdde

Browse files
committed
improve --tags docs, add tests, small utils fix
Signed-off-by: Tommy Hughes <[email protected]>
1 parent 681905c commit d9ccdde

File tree

4 files changed

+26
-17
lines changed

4 files changed

+26
-17
lines changed

docs/reference/feast-cli-commands.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ List all registered entities
6666

6767
```text
6868
feast entities list
69+
70+
Options:
71+
--tags TEXT Filter by tags (e.g. --tags 'key:value' --tags 'key:value,
72+
key:value, ...'). Items return when ALL tags match.
6973
```
7074

7175
```text
@@ -79,11 +83,15 @@ List all registered feature views
7983

8084
```text
8185
feast feature-views list
86+
87+
Options:
88+
--tags TEXT Filter by tags (e.g. --tags 'key:value' --tags 'key:value,
89+
key:value, ...'). Items return when ALL tags match.
8290
```
8391

8492
```text
85-
NAME ENTITIES
86-
driver_hourly_stats ['driver_id']
93+
NAME ENTITIES TYPE
94+
driver_hourly_stats {'driver'} FeatureView
8795
```
8896

8997
## Init

sdk/python/feast/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
_logger = logging.getLogger(__name__)
5050
tagsOption = click.option(
5151
"--tags",
52-
help="Filter by tags (e.g. 'key:value, key:value, ...')",
52+
help="Filter by tags (e.g. --tags 'key:value' --tags 'key:value, key:value, ...'). Items return when ALL tags match.",
5353
default=[""],
5454
multiple=True,
5555
)

sdk/python/feast/utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,7 @@ def tags_list_to_dict(
278278

279279

280280
def tags_str_to_dict(tags: str = "") -> dict[str, str]:
281-
tags_list = (
282-
str(tags).strip().strip("()").replace('"', "").replace("'", "").split(",")
283-
)
281+
tags_list = tags.strip().strip("()").replace('"', "").replace("'", "").split(",")
284282
return {
285283
key.strip(): value.strip()
286284
for key, value in dict(

sdk/python/tests/integration/registration/test_universal_registry.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def test_apply_entity_success(test_registry):
285285
assert len(project_metadata[0].project_uuid) == 36
286286
assert_project_uuid(project, project_uuid, test_registry)
287287

288-
entities = test_registry.list_entities(project)
288+
entities = test_registry.list_entities(project, tags=entity.tags)
289289
assert_project_uuid(project, project_uuid, test_registry)
290290

291291
entity = entities[0]
@@ -359,7 +359,7 @@ def test_apply_feature_view_success(test_registry):
359359
# Register Feature View
360360
test_registry.apply_feature_view(fv1, project)
361361

362-
feature_views = test_registry.list_feature_views(project)
362+
feature_views = test_registry.list_feature_views(project, tags=fv1.tags)
363363

364364
# List Feature Views
365365
assert (
@@ -530,7 +530,7 @@ def test_apply_data_source(test_registry):
530530
test_registry.apply_data_source(batch_source, project, commit=False)
531531
test_registry.apply_feature_view(fv1, project, commit=True)
532532

533-
registry_feature_views = test_registry.list_feature_views(project)
533+
registry_feature_views = test_registry.list_feature_views(project, tags=fv1.tags)
534534
registry_data_sources = test_registry.list_data_sources(project)
535535
assert len(registry_feature_views) == 1
536536
assert len(registry_data_sources) == 1
@@ -543,7 +543,7 @@ def test_apply_data_source(test_registry):
543543
batch_source.timestamp_field = "new_ts_col"
544544
test_registry.apply_data_source(batch_source, project, commit=False)
545545
test_registry.apply_feature_view(fv1, project, commit=True)
546-
registry_feature_views = test_registry.list_feature_views(project)
546+
registry_feature_views = test_registry.list_feature_views(project, tags=fv1.tags)
547547
registry_data_sources = test_registry.list_data_sources(project)
548548
assert len(registry_feature_views) == 1
549549
assert len(registry_data_sources) == 1
@@ -656,7 +656,7 @@ def odfv1(feature_df: pd.DataFrame) -> pd.DataFrame:
656656
)
657657

658658
# Make sure fv1 is untouched
659-
feature_views = test_registry.list_feature_views(project)
659+
feature_views = test_registry.list_feature_views(project, tags=fv1.tags)
660660

661661
# List Feature Views
662662
assert (
@@ -722,6 +722,7 @@ def test_registry_cache(test_registry):
722722
path="file://feast/*",
723723
timestamp_field="ts_col",
724724
created_timestamp_column="timestamp",
725+
tags={"team": "matchmaking"},
725726
)
726727

727728
entity = Entity(name="fs1_my_entity_1", join_keys=["test"])
@@ -758,10 +759,10 @@ def test_registry_cache(test_registry):
758759
test_registry.refresh(project)
759760
# Now objects exist
760761
registry_feature_views_cached = test_registry.list_feature_views(
761-
project, allow_cache=True
762+
project, allow_cache=True, tags=fv1.tags
762763
)
763764
registry_data_sources_cached = test_registry.list_data_sources(
764-
project, allow_cache=True
765+
project, allow_cache=True, tags=batch_source.tags
765766
)
766767
assert len(registry_feature_views_cached) == 1
767768
assert len(registry_data_sources_cached) == 1
@@ -819,15 +820,17 @@ def simple_udf(x: int):
819820
mode="spark",
820821
source=stream_source,
821822
udf=simple_udf,
822-
tags={},
823+
tags={"team": "matchmaking"},
823824
)
824825

825826
project = "project"
826827

827828
# Register Feature View
828829
test_registry.apply_feature_view(sfv, project)
829830

830-
stream_feature_views = test_registry.list_stream_feature_views(project)
831+
stream_feature_views = test_registry.list_stream_feature_views(
832+
project, tags=sfv.tags
833+
)
831834

832835
# List Feature Views
833836
assert len(stream_feature_views) == 1
@@ -864,7 +867,7 @@ def test_commit():
864867
validate_project_uuid(project_uuid, test_registry)
865868

866869
# Retrieving the entity should still succeed
867-
entities = test_registry.list_entities(project, allow_cache=True)
870+
entities = test_registry.list_entities(project, allow_cache=True, tags=entity.tags)
868871
entity = entities[0]
869872
assert (
870873
len(entities) == 1
@@ -899,7 +902,7 @@ def test_commit():
899902
registry_with_same_store = Registry("project", registry_config, None)
900903

901904
# Retrieving the entity should now succeed
902-
entities = registry_with_same_store.list_entities(project)
905+
entities = registry_with_same_store.list_entities(project, tags=entity.tags)
903906
entity = entities[0]
904907
assert (
905908
len(entities) == 1

0 commit comments

Comments
 (0)