recce-nightly 0.62.0.20250417__py3-none-any.whl → 1.30.0.20251221__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of recce-nightly might be problematic. Click here for more details.
- recce/VERSION +1 -1
- recce/__init__.py +27 -22
- recce/adapter/base.py +11 -14
- recce/adapter/dbt_adapter/__init__.py +845 -461
- recce/adapter/dbt_adapter/dbt_version.py +3 -0
- recce/adapter/sqlmesh_adapter.py +24 -35
- recce/apis/check_api.py +59 -42
- recce/apis/check_events_api.py +353 -0
- recce/apis/check_func.py +41 -35
- recce/apis/run_api.py +25 -19
- recce/apis/run_func.py +64 -25
- recce/artifact.py +119 -51
- recce/cli.py +1301 -324
- recce/config.py +43 -34
- recce/connect_to_cloud.py +138 -0
- recce/core.py +55 -47
- recce/data/404/index.html +2 -0
- recce/data/404.html +2 -1
- recce/data/__next.@lineage.!KHNsb3Qp.__PAGE__.txt +7 -0
- recce/data/__next.@lineage.!KHNsb3Qp.txt +4 -0
- recce/data/__next.__PAGE__.txt +6 -0
- recce/data/__next._full.txt +32 -0
- recce/data/__next._head.txt +8 -0
- recce/data/__next._index.txt +14 -0
- recce/data/__next._tree.txt +8 -0
- recce/data/_next/static/chunks/025a7e3e3f9f40ae.js +1 -0
- recce/data/_next/static/chunks/0ce56d67ef5779ca.js +4 -0
- recce/data/_next/static/chunks/1a6a78780155dac7.js +48 -0
- recce/data/_next/static/chunks/1de8485918b9182a.css +2 -0
- recce/data/_next/static/chunks/1e4b1b50d1e34993.js +1 -0
- recce/data/_next/static/chunks/206d5d181e4c738e.js +1 -0
- recce/data/_next/static/chunks/2c357efc34c5b859.js +25 -0
- recce/data/_next/static/chunks/2e9d95d2d48c479c.js +1 -0
- recce/data/_next/static/chunks/2f016dc4a3edad2e.js +2 -0
- recce/data/_next/static/chunks/313251962d698f7c.js +1 -0
- recce/data/_next/static/chunks/3a9f021f38eb5574.css +1 -0
- recce/data/_next/static/chunks/40079da8d2b8f651.js +1 -0
- recce/data/_next/static/chunks/4599182bffb64661.js +38 -0
- recce/data/_next/static/chunks/4e62f6e184173580.js +1 -0
- recce/data/_next/static/chunks/5c4dfb0d09eaa401.js +1 -0
- recce/data/_next/static/chunks/69e4f06ccfdfc3ac.js +1 -0
- recce/data/_next/static/chunks/6b206cb4707d6bee.js +1 -0
- recce/data/_next/static/chunks/6d8557f062aa4386.css +1 -0
- recce/data/_next/static/chunks/7fbe3650bd83b6b5.js +1 -0
- recce/data/_next/static/chunks/83fa823a825674f6.js +1 -0
- recce/data/_next/static/chunks/848a6c9b5f55f7ed.js +1 -0
- recce/data/_next/static/chunks/859462b0858aef88.css +2 -0
- recce/data/_next/static/chunks/923964f18c87d0f1.css +1 -0
- recce/data/_next/static/chunks/939390f911895d7c.js +48 -0
- recce/data/_next/static/chunks/99a9817237a07f43.js +1 -0
- recce/data/_next/static/chunks/9fed8b4b2b924054.js +5 -0
- recce/data/_next/static/chunks/b6949f6c5892110c.js +1 -0
- recce/data/_next/static/chunks/b851a1d3f8149828.js +1 -0
- recce/data/_next/static/chunks/c734f9ad957de0b4.js +1 -0
- recce/data/_next/static/chunks/cdde321b0ec75717.js +2 -0
- recce/data/_next/static/chunks/d0f91117d77ff844.css +1 -0
- recce/data/_next/static/chunks/d6c8667911c2500f.js +1 -0
- recce/data/_next/static/chunks/da8dab68c02752cf.js +74 -0
- recce/data/_next/static/chunks/dc074049c9d12d97.js +109 -0
- recce/data/_next/static/chunks/ee7f1a8227342421.js +1 -0
- recce/data/_next/static/chunks/fa2f4e56c2fccc73.js +1 -0
- recce/data/_next/static/chunks/turbopack-1fad664f62979b93.js +3 -0
- recce/data/_next/static/media/favicon.a8d38d84.ico +0 -0
- recce/data/_next/static/media/montserrat-cyrillic-800-normal.d80d830d.woff2 +0 -0
- recce/data/_next/static/media/montserrat-cyrillic-800-normal.f9d58125.woff +0 -0
- recce/data/_next/static/media/montserrat-cyrillic-ext-800-normal.076c2a93.woff2 +0 -0
- recce/data/_next/static/media/montserrat-cyrillic-ext-800-normal.a4fa76b5.woff +0 -0
- recce/data/_next/static/media/montserrat-latin-800-normal.cde454cc.woff2 +0 -0
- recce/data/_next/static/media/montserrat-latin-800-normal.d5761935.woff +0 -0
- recce/data/_next/static/media/montserrat-latin-ext-800-normal.40ec0659.woff2 +0 -0
- recce/data/_next/static/media/montserrat-latin-ext-800-normal.b671449b.woff +0 -0
- recce/data/_next/static/media/montserrat-vietnamese-800-normal.9f7b8541.woff +0 -0
- recce/data/_next/static/media/montserrat-vietnamese-800-normal.f9eb854e.woff2 +0 -0
- recce/data/_next/static/nX-Uz0AH6Tc6hIQUFGqaB/_buildManifest.js +11 -0
- recce/data/_next/static/nX-Uz0AH6Tc6hIQUFGqaB/_clientMiddlewareManifest.json +1 -0
- recce/data/_not-found/__next._full.txt +24 -0
- recce/data/_not-found/__next._head.txt +8 -0
- recce/data/_not-found/__next._index.txt +13 -0
- recce/data/_not-found/__next._not-found.__PAGE__.txt +5 -0
- recce/data/_not-found/__next._not-found.txt +4 -0
- recce/data/_not-found/__next._tree.txt +6 -0
- recce/data/_not-found/index.html +2 -0
- recce/data/_not-found/index.txt +24 -0
- recce/data/auth_callback.html +68 -0
- recce/data/checks/__next.@lineage.__DEFAULT__.txt +7 -0
- recce/data/checks/__next._full.txt +39 -0
- recce/data/checks/__next._head.txt +8 -0
- recce/data/checks/__next._index.txt +14 -0
- recce/data/checks/__next._tree.txt +8 -0
- recce/data/checks/__next.checks.__PAGE__.txt +10 -0
- recce/data/checks/__next.checks.txt +4 -0
- recce/data/checks/index.html +2 -0
- recce/data/checks/index.txt +39 -0
- recce/data/imgs/reload-image.svg +4 -0
- recce/data/index.html +2 -27
- recce/data/index.txt +32 -7
- recce/data/lineage/__next.@lineage.__DEFAULT__.txt +7 -0
- recce/data/lineage/__next._full.txt +39 -0
- recce/data/lineage/__next._head.txt +8 -0
- recce/data/lineage/__next._index.txt +14 -0
- recce/data/lineage/__next._tree.txt +8 -0
- recce/data/lineage/__next.lineage.__PAGE__.txt +10 -0
- recce/data/lineage/__next.lineage.txt +4 -0
- recce/data/lineage/index.html +2 -0
- recce/data/lineage/index.txt +39 -0
- recce/data/query/__next.@lineage.__DEFAULT__.txt +7 -0
- recce/data/query/__next._full.txt +37 -0
- recce/data/query/__next._head.txt +8 -0
- recce/data/query/__next._index.txt +14 -0
- recce/data/query/__next._tree.txt +8 -0
- recce/data/query/__next.query.__PAGE__.txt +9 -0
- recce/data/query/__next.query.txt +4 -0
- recce/data/query/index.html +2 -0
- recce/data/query/index.txt +37 -0
- recce/diff.py +6 -12
- recce/event/CONFIG.bak +1 -0
- recce/event/__init__.py +86 -74
- recce/event/collector.py +33 -22
- recce/event/track.py +49 -27
- recce/exceptions.py +1 -1
- recce/git.py +7 -7
- recce/github.py +57 -53
- recce/mcp_server.py +725 -0
- recce/models/__init__.py +4 -1
- recce/models/check.py +438 -21
- recce/models/run.py +1 -0
- recce/models/types.py +134 -28
- recce/pull_request.py +27 -25
- recce/run.py +179 -122
- recce/server.py +394 -104
- recce/state/__init__.py +31 -0
- recce/state/cloud.py +644 -0
- recce/state/const.py +26 -0
- recce/state/local.py +56 -0
- recce/state/state.py +119 -0
- recce/state/state_loader.py +174 -0
- recce/summary.py +196 -149
- recce/tasks/__init__.py +19 -3
- recce/tasks/core.py +11 -13
- recce/tasks/dataframe.py +82 -18
- recce/tasks/histogram.py +69 -34
- recce/tasks/lineage.py +2 -2
- recce/tasks/profile.py +152 -86
- recce/tasks/query.py +180 -89
- recce/tasks/rowcount.py +37 -31
- recce/tasks/schema.py +18 -15
- recce/tasks/top_k.py +35 -35
- recce/tasks/utils.py +147 -0
- recce/tasks/valuediff.py +247 -155
- recce/util/__init__.py +3 -0
- recce/util/api_token.py +80 -0
- recce/util/breaking.py +105 -100
- recce/util/cll.py +274 -219
- recce/util/cloud/__init__.py +15 -0
- recce/util/cloud/base.py +115 -0
- recce/util/cloud/check_events.py +190 -0
- recce/util/cloud/checks.py +242 -0
- recce/util/io.py +22 -17
- recce/util/lineage.py +65 -16
- recce/util/logger.py +1 -1
- recce/util/onboarding_state.py +45 -0
- recce/util/perf_tracking.py +85 -0
- recce/util/recce_cloud.py +347 -72
- recce/util/singleton.py +4 -4
- recce/util/startup_perf.py +121 -0
- recce/yaml/__init__.py +7 -10
- recce_nightly-1.30.0.20251221.dist-info/METADATA +195 -0
- recce_nightly-1.30.0.20251221.dist-info/RECORD +183 -0
- {recce_nightly-0.62.0.20250417.dist-info → recce_nightly-1.30.0.20251221.dist-info}/WHEEL +1 -2
- recce/data/_next/static/chunks/1f229bf6-d9fe92e56db8d93b.js +0 -1
- recce/data/_next/static/chunks/29e3cc0d-8c150e37dff9631b.js +0 -1
- recce/data/_next/static/chunks/36e1c10d-bb0210cbd6573a8d.js +0 -1
- recce/data/_next/static/chunks/3998a672-eaad84bdd88cc73e.js +0 -1
- recce/data/_next/static/chunks/450c323b-1bb5db526e54435a.js +0 -1
- recce/data/_next/static/chunks/47d8844f-79a1b53c66a7d7ec.js +0 -1
- recce/data/_next/static/chunks/500-e51c92a025a51234.js +0 -65
- recce/data/_next/static/chunks/6dc81886-c94b9b91bc2c3caf.js +0 -1
- recce/data/_next/static/chunks/700-3b65fc3666820d00.js +0 -2
- recce/data/_next/static/chunks/7a8a3e83-d7fa409d97b38b2b.js +0 -1
- recce/data/_next/static/chunks/7f27ae6c-413f6b869a04183a.js +0 -1
- recce/data/_next/static/chunks/9746af58-d74bef4d03eea6ab.js +0 -1
- recce/data/_next/static/chunks/a30376cd-7d806e1602f2dc3a.js +0 -1
- recce/data/_next/static/chunks/app/_not-found/page-8a886fa0855c3105.js +0 -1
- recce/data/_next/static/chunks/app/layout-9102e22cb73f74d6.js +0 -1
- recce/data/_next/static/chunks/app/page-9adc25782272ed2e.js +0 -1
- recce/data/_next/static/chunks/b63b1b3f-7395c74e11a14e95.js +0 -1
- recce/data/_next/static/chunks/c132bf7d-8102037f9ccf372a.js +0 -1
- recce/data/_next/static/chunks/c1ceaa8b-a1e442154d23515e.js +0 -1
- recce/data/_next/static/chunks/cd9f8d63-cf0d5a7b0f7a92e8.js +0 -54
- recce/data/_next/static/chunks/ce84277d-f42c2c58049cea2d.js +0 -1
- recce/data/_next/static/chunks/e24bf851-0f8cbc99656833e7.js +0 -1
- recce/data/_next/static/chunks/fee69bc6-f17d36c080742e74.js +0 -1
- recce/data/_next/static/chunks/framework-ded83d71b51ce901.js +0 -1
- recce/data/_next/static/chunks/main-a0859f1f36d0aa6c.js +0 -1
- recce/data/_next/static/chunks/main-app-0225a2255968e566.js +0 -1
- recce/data/_next/static/chunks/pages/_app-d5672bf3d8b6371b.js +0 -1
- recce/data/_next/static/chunks/pages/_error-ed75be3f25588548.js +0 -1
- recce/data/_next/static/chunks/webpack-567d72f0bc0820d5.js +0 -1
- recce/data/_next/static/css/c9ecb46a4b21c126.css +0 -14
- recce/data/_next/static/media/montserrat-cyrillic-800-normal.22628180.woff2 +0 -0
- recce/data/_next/static/media/montserrat-cyrillic-800-normal.31d693bb.woff +0 -0
- recce/data/_next/static/media/montserrat-cyrillic-ext-800-normal.7e2c1e62.woff +0 -0
- recce/data/_next/static/media/montserrat-cyrillic-ext-800-normal.94a63aea.woff2 +0 -0
- recce/data/_next/static/media/montserrat-latin-800-normal.6f8fa298.woff2 +0 -0
- recce/data/_next/static/media/montserrat-latin-800-normal.97e20d5e.woff +0 -0
- recce/data/_next/static/media/montserrat-latin-ext-800-normal.013b84f9.woff2 +0 -0
- recce/data/_next/static/media/montserrat-latin-ext-800-normal.aff52ab0.woff +0 -0
- recce/data/_next/static/media/montserrat-vietnamese-800-normal.5f21869b.woff +0 -0
- recce/data/_next/static/media/montserrat-vietnamese-800-normal.c0035377.woff2 +0 -0
- recce/data/_next/static/qiyFlux77VkhxiceAJe_F/_buildManifest.js +0 -1
- recce/state.py +0 -753
- recce_nightly-0.62.0.20250417.dist-info/METADATA +0 -311
- recce_nightly-0.62.0.20250417.dist-info/RECORD +0 -139
- recce_nightly-0.62.0.20250417.dist-info/top_level.txt +0 -2
- tests/__init__.py +0 -0
- tests/adapter/__init__.py +0 -0
- tests/adapter/dbt_adapter/__init__.py +0 -0
- tests/adapter/dbt_adapter/conftest.py +0 -13
- tests/adapter/dbt_adapter/dbt_test_helper.py +0 -283
- tests/adapter/dbt_adapter/test_dbt_adapter.py +0 -40
- tests/adapter/dbt_adapter/test_dbt_cll.py +0 -102
- tests/adapter/dbt_adapter/test_selector.py +0 -177
- tests/tasks/__init__.py +0 -0
- tests/tasks/conftest.py +0 -4
- tests/tasks/test_histogram.py +0 -137
- tests/tasks/test_lineage.py +0 -42
- tests/tasks/test_preset_checks.py +0 -50
- tests/tasks/test_profile.py +0 -73
- tests/tasks/test_query.py +0 -151
- tests/tasks/test_row_count.py +0 -116
- tests/tasks/test_schema.py +0 -99
- tests/tasks/test_top_k.py +0 -73
- tests/tasks/test_valuediff.py +0 -74
- tests/test_cli.py +0 -122
- tests/test_config.py +0 -45
- tests/test_core.py +0 -27
- tests/test_dbt.py +0 -36
- tests/test_pull_request.py +0 -130
- tests/test_server.py +0 -98
- tests/test_state.py +0 -123
- tests/test_summary.py +0 -57
- /recce/data/_next/static/chunks/{polyfills-42372ed130431b0a.js → a6dad97d9634a72d.js} +0 -0
- /recce/data/_next/static/{qiyFlux77VkhxiceAJe_F → nX-Uz0AH6Tc6hIQUFGqaB}/_ssgManifest.js +0 -0
- {recce_nightly-0.62.0.20250417.dist-info → recce_nightly-1.30.0.20251221.dist-info}/entry_points.txt +0 -0
- {recce_nightly-0.62.0.20250417.dist-info → recce_nightly-1.30.0.20251221.dist-info}/licenses/LICENSE +0 -0
recce/artifact.py
CHANGED
|
@@ -9,9 +9,9 @@ from urllib.parse import urlencode
|
|
|
9
9
|
import requests
|
|
10
10
|
from rich.console import Console
|
|
11
11
|
|
|
12
|
-
from recce.git import
|
|
12
|
+
from recce.git import commit_hash_from_branch, current_branch, hosting_repo
|
|
13
13
|
from recce.state import s3_sse_c_headers
|
|
14
|
-
from recce.util.recce_cloud import
|
|
14
|
+
from recce.util.recce_cloud import PresignedUrlMethod, RecceCloud
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
def verify_artifacts_path(target_path: str) -> bool:
|
|
@@ -30,10 +30,7 @@ def verify_artifacts_path(target_path: str) -> bool:
|
|
|
30
30
|
if not os.path.isdir(target_path):
|
|
31
31
|
return False
|
|
32
32
|
|
|
33
|
-
required_artifacts_files = [
|
|
34
|
-
'manifest.json',
|
|
35
|
-
'catalog.json'
|
|
36
|
-
]
|
|
33
|
+
required_artifacts_files = ["manifest.json", "catalog.json"]
|
|
37
34
|
|
|
38
35
|
if all(f in os.listdir(target_path) for f in required_artifacts_files):
|
|
39
36
|
# Check if the required files are present in the target path
|
|
@@ -43,35 +40,35 @@ def verify_artifacts_path(target_path: str) -> bool:
|
|
|
43
40
|
|
|
44
41
|
|
|
45
42
|
def parse_dbt_version(file_path: str) -> str:
|
|
46
|
-
with open(file_path,
|
|
43
|
+
with open(file_path, "r", encoding="utf-8") as f:
|
|
47
44
|
data = json.load(f)
|
|
48
45
|
|
|
49
|
-
dbt_version = data.get(
|
|
46
|
+
dbt_version = data.get("metadata", {}).get("dbt_version", None)
|
|
50
47
|
return dbt_version
|
|
51
48
|
|
|
52
49
|
|
|
53
50
|
def archive_artifacts(target_path: str) -> (str, str):
|
|
54
51
|
if verify_artifacts_path(target_path) is False:
|
|
55
|
-
raise Exception(f
|
|
52
|
+
raise Exception(f"Invalid target path: {target_path}")
|
|
56
53
|
|
|
57
|
-
manifest_path = os.path.join(target_path,
|
|
58
|
-
catalog_path = os.path.join(target_path,
|
|
54
|
+
manifest_path = os.path.join(target_path, "manifest.json")
|
|
55
|
+
catalog_path = os.path.join(target_path, "catalog.json")
|
|
59
56
|
|
|
60
57
|
dbt_version = parse_dbt_version(manifest_path)
|
|
61
58
|
if dbt_version is None:
|
|
62
|
-
raise Exception(
|
|
59
|
+
raise Exception("Failed to parse dbt version from manifest.json")
|
|
63
60
|
|
|
64
61
|
# prepare the temporary artifacts path
|
|
65
62
|
tmp_dir = tempfile.mkdtemp()
|
|
66
|
-
artifacts_tar_path = os.path.join(tmp_dir,
|
|
67
|
-
artifacts_tar_gz_path = artifacts_tar_path +
|
|
63
|
+
artifacts_tar_path = os.path.join(tmp_dir, "dbt_artifacts.tar")
|
|
64
|
+
artifacts_tar_gz_path = artifacts_tar_path + ".gz"
|
|
68
65
|
|
|
69
|
-
with tarfile.open(artifacts_tar_path,
|
|
70
|
-
tar.add(manifest_path, arcname=
|
|
71
|
-
tar.add(catalog_path, arcname=
|
|
66
|
+
with tarfile.open(artifacts_tar_path, "w") as tar:
|
|
67
|
+
tar.add(manifest_path, arcname="manifest.json")
|
|
68
|
+
tar.add(catalog_path, arcname="catalog.json")
|
|
72
69
|
|
|
73
70
|
# Compress the tar file
|
|
74
|
-
with open(artifacts_tar_path,
|
|
71
|
+
with open(artifacts_tar_path, "rb") as f_in, gzip.open(artifacts_tar_gz_path, "wb") as f_out:
|
|
75
72
|
f_out.writelines(f_in)
|
|
76
73
|
|
|
77
74
|
# Clean up the temporary directory
|
|
@@ -83,6 +80,64 @@ def archive_artifacts(target_path: str) -> (str, str):
|
|
|
83
80
|
return artifacts_tar_gz_path, dbt_version
|
|
84
81
|
|
|
85
82
|
|
|
83
|
+
def upload_artifacts_to_session(target_path: str, session_id: str, token: str, debug: bool = False):
|
|
84
|
+
"""Upload dbt artifacts to a specific session ID in Recce Cloud."""
|
|
85
|
+
console = Console()
|
|
86
|
+
if verify_artifacts_path(target_path) is False:
|
|
87
|
+
console.print(f"[[red]Error[/red]] Invalid target path: {target_path}")
|
|
88
|
+
console.print("Please provide a valid target path containing manifest.json and catalog.json.")
|
|
89
|
+
return 1
|
|
90
|
+
|
|
91
|
+
manifest_path = os.path.join(target_path, "manifest.json")
|
|
92
|
+
catalog_path = os.path.join(target_path, "catalog.json")
|
|
93
|
+
|
|
94
|
+
# get the adapter type from the manifest file
|
|
95
|
+
with open(manifest_path, "r", encoding="utf-8") as f:
|
|
96
|
+
manifest_data = json.load(f)
|
|
97
|
+
adapter_type = manifest_data.get("metadata", {}).get("adapter_type")
|
|
98
|
+
if adapter_type is None:
|
|
99
|
+
raise Exception("Failed to parse adapter type from manifest.json")
|
|
100
|
+
|
|
101
|
+
recce_cloud = RecceCloud(token)
|
|
102
|
+
|
|
103
|
+
session = recce_cloud.get_session(session_id)
|
|
104
|
+
|
|
105
|
+
org_id = session.get("org_id")
|
|
106
|
+
if org_id is None:
|
|
107
|
+
raise Exception(f"Session ID {session_id} does not belong to any organization.")
|
|
108
|
+
|
|
109
|
+
project_id = session.get("project_id")
|
|
110
|
+
if project_id is None:
|
|
111
|
+
raise Exception(f"Session ID {session_id} does not belong to any project.")
|
|
112
|
+
|
|
113
|
+
# Get the presigned URL for uploading the artifacts using session ID
|
|
114
|
+
console.print(f'Uploading artifacts for session ID "{session_id}"')
|
|
115
|
+
presigned_urls = recce_cloud.get_upload_urls_by_session_id(org_id, project_id, session_id)
|
|
116
|
+
if debug:
|
|
117
|
+
console.rule("Debug information", style="blue")
|
|
118
|
+
console.print(f"Org ID: {org_id}")
|
|
119
|
+
console.print(f"Project ID: {project_id}")
|
|
120
|
+
console.print(f"Session ID: {session_id}")
|
|
121
|
+
console.print(f"Manifest path: {presigned_urls['manifest_url']}")
|
|
122
|
+
console.print(f"Catalog path: {presigned_urls['catalog_url']}")
|
|
123
|
+
console.print(f"Adapter type: {adapter_type}")
|
|
124
|
+
|
|
125
|
+
# Upload the compressed artifacts (no password needed for session uploads)
|
|
126
|
+
console.print(f'Uploading manifest from path "{manifest_path}"')
|
|
127
|
+
response = requests.put(presigned_urls["manifest_url"], data=open(manifest_path, "rb").read())
|
|
128
|
+
if response.status_code != 200 and response.status_code != 204:
|
|
129
|
+
raise Exception(response.text)
|
|
130
|
+
console.print(f'Uploading catalog from path "{catalog_path}"')
|
|
131
|
+
response = requests.put(presigned_urls["catalog_url"], data=open(catalog_path, "rb").read())
|
|
132
|
+
if response.status_code != 200 and response.status_code != 204:
|
|
133
|
+
raise Exception(response.text)
|
|
134
|
+
|
|
135
|
+
# Update the session metadata
|
|
136
|
+
recce_cloud.update_session(org_id, project_id, session_id, adapter_type)
|
|
137
|
+
|
|
138
|
+
return 0
|
|
139
|
+
|
|
140
|
+
|
|
86
141
|
def upload_dbt_artifacts(target_path: str, branch: str, token: str, password: str, debug: bool = False):
|
|
87
142
|
console = Console()
|
|
88
143
|
if verify_artifacts_path(target_path) is False:
|
|
@@ -100,36 +155,33 @@ def upload_dbt_artifacts(target_path: str, branch: str, token: str, password: st
|
|
|
100
155
|
compress_file_path, dbt_version = archive_artifacts(target_path)
|
|
101
156
|
repo = hosting_repo()
|
|
102
157
|
sha = commit_hash_from_branch(branch)
|
|
103
|
-
metadata = {
|
|
104
|
-
'commit': sha,
|
|
105
|
-
'dbt_version': dbt_version
|
|
106
|
-
}
|
|
158
|
+
metadata = {"commit": sha, "dbt_version": dbt_version}
|
|
107
159
|
|
|
108
160
|
# Get the presigned URL for uploading the artifacts
|
|
109
|
-
presigned_url = RecceCloud(token).
|
|
161
|
+
presigned_url = RecceCloud(token).get_presigned_url_by_github_repo(
|
|
110
162
|
method=PresignedUrlMethod.UPLOAD,
|
|
111
163
|
repository=repo,
|
|
112
|
-
artifact_name=
|
|
164
|
+
artifact_name="dbt_artifacts.tar.gz",
|
|
113
165
|
branch=branch,
|
|
114
|
-
metadata=metadata
|
|
166
|
+
metadata=metadata,
|
|
115
167
|
)
|
|
116
168
|
|
|
117
169
|
if debug:
|
|
118
|
-
console.rule(
|
|
119
|
-
console.print(f
|
|
120
|
-
console.print(f
|
|
121
|
-
console.print(f
|
|
122
|
-
console.print(f
|
|
123
|
-
console.print(f
|
|
124
|
-
console.print(f
|
|
170
|
+
console.rule("Debug information", style="blue")
|
|
171
|
+
console.print(f"Branch: {branch}")
|
|
172
|
+
console.print(f"Commit hash: {sha}")
|
|
173
|
+
console.print(f"GitHub repository: {repo}")
|
|
174
|
+
console.print(f"Artifact path: {compress_file_path}")
|
|
175
|
+
console.print(f"DBT version: {dbt_version}")
|
|
176
|
+
console.print(f"Presigned URL: {presigned_url}")
|
|
125
177
|
console.print(f'Uploading the dbt artifacts from path "{target_path}" to branch "{branch}"')
|
|
126
178
|
|
|
127
179
|
# Upload the compressed artifacts
|
|
128
180
|
|
|
129
181
|
headers = s3_sse_c_headers(password)
|
|
130
182
|
if metadata:
|
|
131
|
-
headers[
|
|
132
|
-
response = requests.put(presigned_url, data=open(compress_file_path,
|
|
183
|
+
headers["x-amz-tagging"] = urlencode(metadata)
|
|
184
|
+
response = requests.put(presigned_url, data=open(compress_file_path, "rb").read(), headers=headers)
|
|
133
185
|
if response.status_code != 200:
|
|
134
186
|
raise Exception({response.text})
|
|
135
187
|
|
|
@@ -143,29 +195,29 @@ def upload_dbt_artifacts(target_path: str, branch: str, token: str, password: st
|
|
|
143
195
|
pass
|
|
144
196
|
|
|
145
197
|
|
|
146
|
-
def download_dbt_artifacts(
|
|
147
|
-
|
|
148
|
-
|
|
198
|
+
def download_dbt_artifacts(
|
|
199
|
+
target_path: str, branch: str, token: str, password: str, force: bool = False, debug: bool = False
|
|
200
|
+
):
|
|
149
201
|
console = Console()
|
|
150
202
|
repo = hosting_repo()
|
|
151
203
|
sha = None
|
|
152
204
|
dbt_version = None
|
|
153
205
|
|
|
154
|
-
presigned_url, tags = RecceCloud(token).
|
|
206
|
+
presigned_url, tags = RecceCloud(token).get_download_presigned_url_by_github_repo_with_tags(
|
|
155
207
|
repository=repo,
|
|
156
|
-
artifact_name=
|
|
208
|
+
artifact_name="dbt_artifacts.tar.gz",
|
|
157
209
|
branch=branch,
|
|
158
210
|
)
|
|
159
211
|
if tags:
|
|
160
|
-
sha = tags.get(
|
|
161
|
-
dbt_version = tags.get(
|
|
212
|
+
sha = tags.get("commit")
|
|
213
|
+
dbt_version = tags.get("dbt_version")
|
|
162
214
|
|
|
163
215
|
if debug:
|
|
164
|
-
console.rule(
|
|
165
|
-
console.print(f
|
|
166
|
-
console.print(f
|
|
167
|
-
console.print(f
|
|
168
|
-
console.print(f
|
|
216
|
+
console.rule("Debug information", style="blue")
|
|
217
|
+
console.print(f"Git Branch: {branch}")
|
|
218
|
+
console.print(f"Git Commit: {sha}")
|
|
219
|
+
console.print(f"GitHub repository: {repo}")
|
|
220
|
+
console.print(f"DBT version: {dbt_version}")
|
|
169
221
|
console.print(f'Downloading from branch: "{branch}" and extracting to "{target_path}"')
|
|
170
222
|
|
|
171
223
|
headers = s3_sse_c_headers(password)
|
|
@@ -177,16 +229,17 @@ def download_dbt_artifacts(target_path: str, branch: str, token: str, password:
|
|
|
177
229
|
if os.path.exists(target_path):
|
|
178
230
|
if not force:
|
|
179
231
|
raise Exception(
|
|
180
|
-
f
|
|
181
|
-
|
|
232
|
+
f"Path {target_path} already exists. Please provide a new path or use '--force' option to overwrite the existing folder."
|
|
233
|
+
)
|
|
234
|
+
console.print(f"[[yellow]Warning[/yellow]] Overwrite existing path: {target_path}")
|
|
182
235
|
shutil.rmtree(target_path)
|
|
183
236
|
os.mkdir(target_path)
|
|
184
237
|
|
|
185
|
-
tar_gz_file = os.path.join(target_path,
|
|
186
|
-
with open(tar_gz_file,
|
|
238
|
+
tar_gz_file = os.path.join(target_path, "dbt_artifacts.tar.gz")
|
|
239
|
+
with open(tar_gz_file, "wb") as f:
|
|
187
240
|
f.write(response.content)
|
|
188
241
|
|
|
189
|
-
with tarfile.open(tar_gz_file,
|
|
242
|
+
with tarfile.open(tar_gz_file, "r") as tar:
|
|
190
243
|
tar.extractall(path=target_path)
|
|
191
244
|
|
|
192
245
|
# Clean up the compressed artifacts
|
|
@@ -196,3 +249,18 @@ def download_dbt_artifacts(target_path: str, branch: str, token: str, password:
|
|
|
196
249
|
except FileNotFoundError:
|
|
197
250
|
pass
|
|
198
251
|
return 0
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
def delete_dbt_artifacts(branch: str, token: str, debug: bool = False):
|
|
255
|
+
"""Delete dbt artifacts from a specific branch in Recce Cloud."""
|
|
256
|
+
console = Console()
|
|
257
|
+
repo = hosting_repo()
|
|
258
|
+
|
|
259
|
+
if debug:
|
|
260
|
+
console.rule("Debug information", style="blue")
|
|
261
|
+
console.print(f"Git Branch: {branch}")
|
|
262
|
+
console.print(f"GitHub repository: {repo}")
|
|
263
|
+
|
|
264
|
+
console.print(f'Deleting dbt artifacts from branch: "{branch}"')
|
|
265
|
+
|
|
266
|
+
RecceCloud(token).purge_artifacts(repo, branch=branch)
|