-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathentities.py
More file actions
55 lines (44 loc) · 1.27 KB
/
entities.py
File metadata and controls
55 lines (44 loc) · 1.27 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
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="entities")
def entities_cmd():
"""
Access entities
"""
pass
@entities_cmd.command("describe")
@click.argument("name", type=click.STRING)
@click.pass_context
def entity_describe(ctx: click.Context, name: str):
"""
Describe an entity
"""
store = create_feature_store(ctx)
try:
entity = store.get_entity(name)
except FeastObjectNotFoundException as e:
print(e)
exit(1)
print(
yaml.dump(
yaml.safe_load(str(entity)), default_flow_style=False, sort_keys=False
)
)
@entities_cmd.command(name="list")
@tagsOption
@click.pass_context
def entity_list(ctx: click.Context, tags: list[str]):
"""
List all entities
"""
store = create_feature_store(ctx)
table = []
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
print(tabulate(table, headers=["NAME", "DESCRIPTION", "TYPE"], tablefmt="plain"))