-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathlabel_views.py
More file actions
69 lines (58 loc) · 1.56 KB
/
label_views.py
File metadata and controls
69 lines (58 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import click
import yaml
from feast import utils
from feast.cli.cli_options import tagsOption
from feast.errors import FeastObjectNotFoundException
from feast.repo_operations import create_feature_store
@click.group(name="label-views")
def label_views_cmd():
"""
Access label views
"""
pass
@label_views_cmd.command("describe")
@click.argument("name", type=click.STRING)
@click.pass_context
def label_view_describe(ctx: click.Context, name: str):
"""
Describe a label view
"""
store = create_feature_store(ctx)
try:
label_view = store.get_label_view(name)
except FeastObjectNotFoundException as e:
print(e)
exit(1)
print(
yaml.dump(
yaml.safe_load(str(label_view)),
default_flow_style=False,
sort_keys=False,
)
)
@label_views_cmd.command(name="list")
@tagsOption
@click.pass_context
def label_view_list(ctx: click.Context, tags: list[str]):
"""
List all label views
"""
store = create_feature_store(ctx)
table = []
tags_filter = utils.tags_list_to_dict(tags)
for label_view in store.list_label_views(tags=tags_filter):
table.append(
[
label_view.name,
", ".join(label_view.entities) if label_view.entities else "n/a",
str(label_view.conflict_policy.value),
]
)
from tabulate import tabulate
print(
tabulate(
table,
headers=["NAME", "ENTITIES", "CONFLICT_POLICY"],
tablefmt="plain",
)
)