-
Notifications
You must be signed in to change notification settings - Fork 1
/
list_metrics_sync.py
52 lines (37 loc) · 1.37 KB
/
list_metrics_sync.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
"""Fetch all available metrics from the metadata API and display them."""
from argparse import ArgumentParser
from dbtsl import SemanticLayerClient
def get_arg_parser() -> ArgumentParser:
p = ArgumentParser()
p.add_argument("--env-id", required=True, help="The dbt environment ID", type=int)
p.add_argument("--token", required=True, help="The API auth token")
p.add_argument("--host", required=True, help="The API host")
return p
def main() -> None:
arg_parser = get_arg_parser()
args = arg_parser.parse_args()
client = SemanticLayerClient(
environment_id=args.env_id,
auth_token=args.token,
host=args.host,
)
with client.session():
metrics = client.metrics()
for m in metrics:
print(f"📈 {m.name}")
print(f" type={m.type}")
print(f" description={m.description}")
print(" dimensions=[")
for dim in m.dimensions:
print(f" {dim.name},")
print(" ]")
print(" measures=[")
for measure in m.measures:
print(f" {measure.name},")
print(" ]")
print(" entities=[")
for entity in m.entities:
print(f" {entity.name},")
print(" ]")
if __name__ == "__main__":
main()