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

feat: Add the ability to list objects by tags #4246

Merged
merged 1 commit into from
Jun 18, 2024
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
12 changes: 10 additions & 2 deletions docs/reference/feast-cli-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ List all registered entities

```text
feast entities list

Options:
--tags TEXT Filter by tags (e.g. --tags 'key:value' --tags 'key:value,
key:value, ...'). Items return when ALL tags match.
```

```text
Expand All @@ -79,11 +83,15 @@ List all registered feature views

```text
feast feature-views list

Options:
--tags TEXT Filter by tags (e.g. --tags 'key:value' --tags 'key:value,
key:value, ...'). Items return when ALL tags match.
```

```text
NAME ENTITIES
driver_hourly_stats ['driver_id']
NAME ENTITIES TYPE
driver_hourly_stats {'driver'} FeatureView
```

## Init
Expand Down
6 changes: 6 additions & 0 deletions protos/feast/registry/RegistryServer.proto
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ message GetEntityRequest {
message ListEntitiesRequest {
string project = 1;
bool allow_cache = 2;
map<string,string> tags = 3;
}

message ListEntitiesResponse {
Expand Down Expand Up @@ -146,6 +147,7 @@ message GetDataSourceRequest {
message ListDataSourcesRequest {
string project = 1;
bool allow_cache = 2;
map<string,string> tags = 3;
}

message ListDataSourcesResponse {
Expand Down Expand Up @@ -179,6 +181,7 @@ message GetFeatureViewRequest {
message ListFeatureViewsRequest {
string project = 1;
bool allow_cache = 2;
map<string,string> tags = 3;
}

message ListFeatureViewsResponse {
Expand All @@ -202,6 +205,7 @@ message GetStreamFeatureViewRequest {
message ListStreamFeatureViewsRequest {
string project = 1;
bool allow_cache = 2;
map<string,string> tags = 3;
}

message ListStreamFeatureViewsResponse {
Expand All @@ -219,6 +223,7 @@ message GetOnDemandFeatureViewRequest {
message ListOnDemandFeatureViewsRequest {
string project = 1;
bool allow_cache = 2;
map<string,string> tags = 3;
}

message ListOnDemandFeatureViewsResponse {
Expand All @@ -242,6 +247,7 @@ message GetFeatureServiceRequest {
message ListFeatureServicesRequest {
string project = 1;
bool allow_cache = 2;
map<string,string> tags = 3;
}

message ListFeatureServicesResponse {
Expand Down
38 changes: 27 additions & 11 deletions sdk/python/feast/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
from feast.utils import maybe_local_tz

_logger = logging.getLogger(__name__)
tagsOption = click.option(
"--tags",
help="Filter by tags (e.g. --tags 'key:value' --tags 'key:value, key:value, ...'). Items return when ALL tags match.",
default=[""],
multiple=True,
tchughesiv marked this conversation as resolved.
Show resolved Hide resolved
)


class NoOptionDefaultFormat(click.Command):
Expand Down Expand Up @@ -226,14 +232,16 @@ def data_source_describe(ctx: click.Context, name: str):


@data_sources_cmd.command(name="list")
@tagsOption
@click.pass_context
def data_source_list(ctx: click.Context):
def data_source_list(ctx: click.Context, tags: list[str]):
tchughesiv marked this conversation as resolved.
Show resolved Hide resolved
"""
List all data sources
"""
store = create_feature_store(ctx)
table = []
for datasource in store.list_data_sources():
tags_filter = utils.tags_list_to_dict(tags)
for datasource in store.list_data_sources(tags=tags_filter):
table.append([datasource.name, datasource.__class__])

from tabulate import tabulate
Expand Down Expand Up @@ -272,14 +280,16 @@ def entity_describe(ctx: click.Context, name: str):


@entities_cmd.command(name="list")
@tagsOption
@click.pass_context
def entity_list(ctx: click.Context):
def entity_list(ctx: click.Context, tags: list[str]):
"""
List all entities
"""
store = create_feature_store(ctx)
table = []
for entity in store.list_entities():
tags_filter = utils.tags_list_to_dict(tags)
for entity in store.list_entities(tags=tags_filter):
table.append([entity.name, entity.description, entity.value_type])

from tabulate import tabulate
Expand Down Expand Up @@ -320,14 +330,16 @@ def feature_service_describe(ctx: click.Context, name: str):


@feature_services_cmd.command(name="list")
@tagsOption
@click.pass_context
def feature_service_list(ctx: click.Context):
def feature_service_list(ctx: click.Context, tags: list[str]):
"""
List all feature services
"""
store = create_feature_store(ctx)
feature_services = []
for feature_service in store.list_feature_services():
tags_filter = utils.tags_list_to_dict(tags)
for feature_service in store.list_feature_services(tags=tags_filter):
feature_names = []
for projection in feature_service.feature_view_projections:
feature_names.extend(
Expand Down Expand Up @@ -371,16 +383,18 @@ def feature_view_describe(ctx: click.Context, name: str):


@feature_views_cmd.command(name="list")
@tagsOption
@click.pass_context
def feature_view_list(ctx: click.Context):
def feature_view_list(ctx: click.Context, tags: list[str]):
"""
List all feature views
"""
store = create_feature_store(ctx)
table = []
tags_filter = utils.tags_list_to_dict(tags)
for feature_view in [
*store.list_feature_views(),
*store.list_on_demand_feature_views(),
*store.list_batch_feature_views(tags=tags_filter),
*store.list_on_demand_feature_views(tags=tags_filter),
]:
entities = set()
if isinstance(feature_view, FeatureView):
Expand Down Expand Up @@ -434,14 +448,16 @@ def on_demand_feature_view_describe(ctx: click.Context, name: str):


@on_demand_feature_views_cmd.command(name="list")
@tagsOption
@click.pass_context
def on_demand_feature_view_list(ctx: click.Context):
def on_demand_feature_view_list(ctx: click.Context, tags: list[str]):
"""
[Experimental] List all on demand feature views
"""
store = create_feature_store(ctx)
table = []
for on_demand_feature_view in store.list_on_demand_feature_views():
tags_filter = utils.tags_list_to_dict(tags)
for on_demand_feature_view in store.list_on_demand_feature_views(tags=tags_filter):
table.append([on_demand_feature_view.name])

from tabulate import tabulate
Expand Down
Loading
Loading