-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.py
46 lines (33 loc) · 1.29 KB
/
utils.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
import os
from gooddata_sdk import GoodDataSdk
from pathlib import Path
from shutil import rmtree
BOOTSTRAP_FOLDER = Path("bootstrap")
LAYOUT_FOLDER = BOOTSTRAP_FOLDER / "gooddata"
HOST = os.environ.get("HOST", "http://localhost:3000")
TOKEN = os.environ.get("TOKEN", "YWRtaW46Ym9vdHN0cmFwOmFkbWluMTIz")
sdk = GoodDataSdk.create(host_=HOST, token_=TOKEN)
"""
The following script should be run locally and not inside container.
"""
def clean_dir(path: str = LAYOUT_FOLDER) -> None:
if os.path.exists(path):
rmtree(path)
os.makedirs(path)
def invalidate_cache(data_source_id: str = "dbt-ds"):
sdk.catalog_data_source.register_upload_notification(data_source_id)
def load():
print("Loading declarative data sources...")
sdk.catalog_data_source.load_and_put_declarative_data_sources(
LAYOUT_FOLDER, BOOTSTRAP_FOLDER / "ds-credentials.yaml"
)
print("Loading declarative workspaces...")
sdk.catalog_workspace.load_and_put_declarative_workspaces(LAYOUT_FOLDER)
print("Done")
def store():
clean_dir()
print("Storing declarative data sources...")
sdk.catalog_data_source.store_declarative_data_sources(LAYOUT_FOLDER)
print("Storing declarative workspaces...")
sdk.catalog_workspace.store_declarative_workspaces(LAYOUT_FOLDER)
print("Done")