-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
store.py
55 lines (48 loc) · 1.54 KB
/
store.py
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
from great_expectations.cli import toolkit
from great_expectations.cli.pretty_printing import cli_message, cli_message_dict
from great_expectations.core.usage_statistics.events import UsageStatsEvents
from great_expectations.core.usage_statistics.util import send_usage_message
@click.group()
@click.pass_context
def store(ctx):
"""Store operations"""
ctx.obj.data_context = ctx.obj.get_data_context_from_config_file()
cli_event_noun: str = "store"
(
begin_event_name,
end_event_name,
) = UsageStatsEvents.get_cli_begin_and_end_event_names(
noun=cli_event_noun,
verb=ctx.invoked_subcommand,
)
send_usage_message(
data_context=ctx.obj.data_context,
event=begin_event_name,
success=True,
)
ctx.obj.usage_event_end = end_event_name
@store.command(name="list")
@click.pass_context
def store_list(ctx):
"""List active Stores."""
context = ctx.obj.data_context
usage_event_end: str = ctx.obj.usage_event_end
try:
stores = context.list_active_stores()
cli_message(f"{len(stores)} active Stores found:")
for store in stores:
cli_message("")
cli_message_dict(store)
send_usage_message(
data_context=context,
event=usage_event_end,
success=True,
)
except Exception as e:
toolkit.exit_with_failure_message_and_stats(
context=context,
usage_event=usage_event_end,
message=f"<red>{e}</red>",
)
return