recce-nightly 1.9.0.20250623__py3-none-any.whl → 1.25.0.20251112a2066__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.
- recce/VERSION +1 -1
- recce/__init__.py +5 -0
- recce/adapter/dbt_adapter/__init__.py +318 -240
- recce/artifact.py +76 -3
- recce/cli.py +703 -71
- recce/config.py +3 -3
- recce/connect_to_cloud.py +138 -0
- recce/core.py +3 -3
- recce/data/404.html +1 -22
- recce/data/__next.__PAGE__.txt +10 -0
- recce/data/__next._full.txt +23 -0
- recce/data/__next._index.txt +8 -0
- recce/data/__next._tree.txt +12 -0
- recce/data/_next/static/6LypcDXgyuSaiSCrsmUub/_buildManifest.js +11 -0
- recce/data/_next/static/6LypcDXgyuSaiSCrsmUub/_clientMiddlewareManifest.json +1 -0
- recce/data/_next/static/chunks/0a2b2dd4b57049c2.js +1 -0
- recce/data/_next/static/chunks/19c10d219a6a21ff.js +1 -0
- recce/data/_next/static/chunks/24fd885c7180a612.js +1 -0
- recce/data/_next/static/chunks/27e66b2eab4adc32.js +19 -0
- recce/data/_next/static/chunks/71f88fcc615bf282.js +1 -0
- recce/data/_next/static/chunks/917619ab62a32388.js +1 -0
- recce/data/_next/static/chunks/93ba5a62932b704f.js +4 -0
- recce/data/_next/static/chunks/a43a2a5e06d5a92b.js +1 -0
- recce/data/_next/static/chunks/a6c78b24bd8b84fc.js +1 -0
- recce/data/_next/static/chunks/b2610ba997ff8c4f.js +110 -0
- recce/data/_next/static/chunks/ba2d87265a68599d.css +2 -0
- recce/data/_next/static/chunks/c117fd1c1382dd83.js +11 -0
- recce/data/_next/static/chunks/c9425ca46eebdde9.js +1 -0
- recce/data/_next/static/chunks/cc8a9eadba012be0.css +6 -0
- recce/data/_next/static/chunks/e124bccf574a3361.css +1 -0
- recce/data/_next/static/chunks/e392ad92847c3e17.js +1 -0
- recce/data/_next/static/chunks/e4ce95efe88dae79.js +11 -0
- recce/data/_next/static/chunks/e69c777814fea6ed.js +2 -0
- recce/data/_next/static/chunks/turbopack-21cfd73037ff57ab.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.bd5c9f50.woff → 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-latin-800-normal.cde454cc.woff2 +0 -0
- recce/data/_next/static/media/{montserrat-latin-800-normal.fc315020.woff → 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.2e5381b2.woff → montserrat-latin-ext-800-normal.b671449b.woff} +0 -0
- recce/data/_next/static/media/{montserrat-vietnamese-800-normal.20c545e6.woff → montserrat-vietnamese-800-normal.9f7b8541.woff} +0 -0
- recce/data/_next/static/media/montserrat-vietnamese-800-normal.f9eb854e.woff2 +0 -0
- recce/data/_not-found/__next._full.txt +17 -0
- recce/data/_not-found/__next._index.txt +8 -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 +10 -0
- recce/data/_not-found.html +1 -0
- recce/data/_not-found.txt +17 -0
- recce/data/auth_callback.html +68 -0
- recce/data/index.html +1 -27
- recce/data/index.txt +23 -8
- recce/event/__init__.py +9 -8
- recce/event/collector.py +6 -2
- recce/event/track.py +10 -0
- recce/github.py +1 -1
- recce/mcp_server.py +632 -0
- recce/models/types.py +23 -2
- recce/pull_request.py +1 -1
- recce/run.py +23 -16
- recce/server.py +194 -19
- recce/state/__init__.py +31 -0
- recce/state/cloud.py +632 -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 +2 -1
- recce/tasks/dataframe.py +59 -2
- recce/tasks/rowcount.py +4 -1
- recce/tasks/schema.py +4 -1
- recce/tasks/valuediff.py +1 -1
- recce/util/api_token.py +11 -2
- recce/util/breaking.py +9 -0
- recce/util/cll.py +1 -2
- recce/util/io.py +2 -2
- recce/util/lineage.py +19 -18
- recce/util/perf_tracking.py +85 -0
- recce/util/recce_cloud.py +229 -5
- recce/yaml/__init__.py +2 -2
- recce_cloud/__init__.py +15 -0
- recce_cloud/api/__init__.py +17 -0
- recce_cloud/api/base.py +104 -0
- recce_cloud/api/client.py +150 -0
- recce_cloud/api/exceptions.py +26 -0
- recce_cloud/api/factory.py +63 -0
- recce_cloud/api/github.py +72 -0
- recce_cloud/api/gitlab.py +78 -0
- recce_cloud/artifact.py +57 -0
- recce_cloud/ci_providers/__init__.py +9 -0
- recce_cloud/ci_providers/base.py +82 -0
- recce_cloud/ci_providers/detector.py +147 -0
- recce_cloud/ci_providers/github_actions.py +136 -0
- recce_cloud/ci_providers/gitlab_ci.py +130 -0
- recce_cloud/cli.py +303 -0
- recce_cloud/upload.py +213 -0
- {recce_nightly-1.9.0.20250623.dist-info → recce_nightly-1.25.0.20251112a2066.dist-info}/METADATA +31 -27
- recce_nightly-1.25.0.20251112a2066.dist-info/RECORD +178 -0
- {recce_nightly-1.9.0.20250623.dist-info → recce_nightly-1.25.0.20251112a2066.dist-info}/top_level.txt +1 -0
- tests/adapter/dbt_adapter/test_dbt_cll.py +412 -79
- tests/recce_cloud/__init__.py +0 -0
- tests/recce_cloud/test_ci_providers.py +351 -0
- tests/recce_cloud/test_cli.py +372 -0
- tests/recce_cloud/test_client.py +273 -0
- tests/recce_cloud/test_platform_clients.py +279 -0
- tests/test_cli.py +106 -3
- tests/test_cli_mcp_optional.py +45 -0
- tests/test_cloud_listing_cli.py +324 -0
- tests/test_connect_to_cloud.py +82 -0
- tests/test_core.py +148 -3
- tests/test_mcp_server.py +332 -0
- tests/test_server.py +6 -6
- tests/test_summary.py +14 -6
- recce/data/_next/static/WrRUb3nV8BhAZG_R8kVma/_buildManifest.js +0 -1
- recce/data/_next/static/chunks/181-acc61ddada3bc0ca.js +0 -43
- recce/data/_next/static/chunks/1bff33f1-1ef85cf5e658a751.js +0 -1
- recce/data/_next/static/chunks/217-879a84d70f7a907c.js +0 -2
- recce/data/_next/static/chunks/29e3cc0d-60045b2e47aa3916.js +0 -1
- recce/data/_next/static/chunks/36e1c10d-8e7be4a6c1f6ab2d.js +0 -1
- recce/data/_next/static/chunks/3998a672-03adacad07b346ac.js +0 -1
- recce/data/_next/static/chunks/3a92ee20-1081c360214f9602.js +0 -1
- recce/data/_next/static/chunks/42-cd3c06533f5fd47c.js +0 -9
- recce/data/_next/static/chunks/450c323b-fd94e7ffaa4a5efa.js +0 -1
- recce/data/_next/static/chunks/47d8844f-929aed9b1c73a905.js +0 -1
- recce/data/_next/static/chunks/608-3b079b544e5d5f5e.js +0 -15
- recce/data/_next/static/chunks/6dc81886-adbfa45836061d79.js +0 -1
- recce/data/_next/static/chunks/7a8a3e83-edf6dc64b5d5f0a5.js +0 -1
- recce/data/_next/static/chunks/7f27ae6c-d5f0438edd5c2a5b.js +0 -1
- recce/data/_next/static/chunks/86730205-cfb14e3f051bab35.js +0 -1
- recce/data/_next/static/chunks/8d700b6a.8bb140898499c512.js +0 -1
- recce/data/_next/static/chunks/92-7ab55ae02606193c.js +0 -1
- recce/data/_next/static/chunks/9746af58-a42b7d169cacadf0.js +0 -1
- recce/data/_next/static/chunks/a30376cd-de84559016d7e133.js +0 -1
- recce/data/_next/static/chunks/app/_not-found/page-01ed58b7f971d311.js +0 -1
- recce/data/_next/static/chunks/app/layout-177a410a97e0d018.js +0 -1
- recce/data/_next/static/chunks/app/page-59241c42b7dd4fcf.js +0 -1
- recce/data/_next/static/chunks/b63b1b3f-4282bdcf459e075c.js +0 -1
- recce/data/_next/static/chunks/bbda5537-9ec25eb1dd62348a.js +0 -1
- recce/data/_next/static/chunks/c132bf7d-08cb668a789d6afd.js +0 -1
- recce/data/_next/static/chunks/ce84277d-2e5d1d46910cf052.js +0 -1
- recce/data/_next/static/chunks/febdd86e-c6b525341634b860.js +0 -54
- recce/data/_next/static/chunks/fee69bc6-2dbccaf9b90474e6.js +0 -1
- recce/data/_next/static/chunks/framework-ded83d71b51ce901.js +0 -1
- recce/data/_next/static/chunks/main-app-39061b0166c47f55.js +0 -1
- recce/data/_next/static/chunks/main-b5b3ae20a1405261.js +0 -1
- recce/data/_next/static/chunks/pages/_app-437c455677d62394.js +0 -1
- recce/data/_next/static/chunks/pages/_error-e7650df18ca04bde.js +0 -1
- recce/data/_next/static/chunks/webpack-7b49d5ba7e3a434d.js +0 -1
- recce/data/_next/static/css/17a96168e3a9db13.css +0 -1
- recce/data/_next/static/css/1b121dc4d36aeb4d.css +0 -3
- recce/data/_next/static/css/35c6679a098e1e34.css +0 -1
- recce/data/_next/static/css/951e2e0eea2d4a5b.css +0 -14
- recce/data/_next/static/media/montserrat-cyrillic-800-normal.22628180.woff2 +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-ext-800-normal.013b84f9.woff2 +0 -0
- recce/data/_next/static/media/montserrat-vietnamese-800-normal.c0035377.woff2 +0 -0
- recce/state.py +0 -785
- recce_nightly-1.9.0.20250623.dist-info/RECORD +0 -151
- tests/test_state.py +0 -134
- /recce/data/_next/static/{WrRUb3nV8BhAZG_R8kVma → 6LypcDXgyuSaiSCrsmUub}/_ssgManifest.js +0 -0
- /recce/data/_next/static/chunks/{polyfills-42372ed130431b0a.js → a6dad97d9634a72d.js} +0 -0
- /recce/data/_next/static/media/{montserrat-cyrillic-ext-800-normal.e6e0d8d0.woff → montserrat-cyrillic-ext-800-normal.a4fa76b5.woff} +0 -0
- /recce/data/_next/static/media/{reload-image.79aabb7d.svg → reload-image.7aa931c7.svg} +0 -0
- {recce_nightly-1.9.0.20250623.dist-info → recce_nightly-1.25.0.20251112a2066.dist-info}/WHEEL +0 -0
- {recce_nightly-1.9.0.20250623.dist-info → recce_nightly-1.25.0.20251112a2066.dist-info}/entry_points.txt +0 -0
- {recce_nightly-1.9.0.20250623.dist-info → recce_nightly-1.25.0.20251112a2066.dist-info}/licenses/LICENSE +0 -0
recce/cli.py
CHANGED
|
@@ -8,12 +8,28 @@ import uvicorn
|
|
|
8
8
|
from click import Abort
|
|
9
9
|
|
|
10
10
|
from recce import event
|
|
11
|
-
from recce.artifact import
|
|
11
|
+
from recce.artifact import (
|
|
12
|
+
delete_dbt_artifacts,
|
|
13
|
+
download_dbt_artifacts,
|
|
14
|
+
upload_artifacts_to_session,
|
|
15
|
+
upload_dbt_artifacts,
|
|
16
|
+
)
|
|
12
17
|
from recce.config import RECCE_CONFIG_FILE, RECCE_ERROR_LOG_FILE, RecceConfig
|
|
18
|
+
from recce.connect_to_cloud import (
|
|
19
|
+
generate_key_pair,
|
|
20
|
+
prepare_connection_url,
|
|
21
|
+
run_one_time_http_server,
|
|
22
|
+
)
|
|
13
23
|
from recce.exceptions import RecceConfigException
|
|
14
24
|
from recce.git import current_branch, current_default_branch
|
|
15
25
|
from recce.run import check_github_ci_env, cli_run
|
|
16
|
-
from recce.
|
|
26
|
+
from recce.server import RecceServerMode
|
|
27
|
+
from recce.state import (
|
|
28
|
+
CloudStateLoader,
|
|
29
|
+
FileStateLoader,
|
|
30
|
+
RecceCloudStateManager,
|
|
31
|
+
RecceShareStateManager,
|
|
32
|
+
)
|
|
17
33
|
from recce.summary import generate_markdown_summary
|
|
18
34
|
from recce.util.api_token import prepare_api_token, show_invalid_api_token_message
|
|
19
35
|
from recce.util.logger import CustomFormatter
|
|
@@ -34,9 +50,13 @@ def create_state_loader(review_mode, cloud_mode, state_file, cloud_options):
|
|
|
34
50
|
console = Console()
|
|
35
51
|
|
|
36
52
|
try:
|
|
37
|
-
|
|
38
|
-
review_mode=review_mode,
|
|
53
|
+
state_loader = (
|
|
54
|
+
CloudStateLoader(review_mode=review_mode, cloud_options=cloud_options)
|
|
55
|
+
if cloud_mode
|
|
56
|
+
else FileStateLoader(review_mode=review_mode, state_file=state_file)
|
|
39
57
|
)
|
|
58
|
+
state_loader.load()
|
|
59
|
+
return state_loader
|
|
40
60
|
except RecceCloudException as e:
|
|
41
61
|
console.print("[[red]Error[/red]] Failed to load recce state file")
|
|
42
62
|
console.print(f"Reason: {e.reason}")
|
|
@@ -47,6 +67,75 @@ def create_state_loader(review_mode, cloud_mode, state_file, cloud_options):
|
|
|
47
67
|
exit(1)
|
|
48
68
|
|
|
49
69
|
|
|
70
|
+
def patch_derived_args(args):
|
|
71
|
+
"""
|
|
72
|
+
Patch derived args based on other args.
|
|
73
|
+
"""
|
|
74
|
+
if args.get("session_id") or args.get("share_url"):
|
|
75
|
+
args["cloud"] = True
|
|
76
|
+
args["review"] = True
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def create_state_loader_by_args(state_file=None, **kwargs):
|
|
80
|
+
"""
|
|
81
|
+
Create a state loader based on CLI arguments.
|
|
82
|
+
|
|
83
|
+
This function handles the cloud options logic that is shared between
|
|
84
|
+
server and mcp-server commands.
|
|
85
|
+
|
|
86
|
+
Args:
|
|
87
|
+
state_file: Optional path to state file
|
|
88
|
+
**kwargs: CLI arguments including api_token, cloud, review, session_id, share_url, etc.
|
|
89
|
+
|
|
90
|
+
Returns:
|
|
91
|
+
state_loader: The created state loader instance
|
|
92
|
+
"""
|
|
93
|
+
from rich.console import Console
|
|
94
|
+
|
|
95
|
+
console = Console()
|
|
96
|
+
|
|
97
|
+
api_token = kwargs.get("api_token")
|
|
98
|
+
is_review = kwargs.get("review", False)
|
|
99
|
+
is_cloud = kwargs.get("cloud", False)
|
|
100
|
+
cloud_options = None
|
|
101
|
+
|
|
102
|
+
# Handle share_url and session_id
|
|
103
|
+
share_url = kwargs.get("share_url")
|
|
104
|
+
session_id = kwargs.get("session_id")
|
|
105
|
+
|
|
106
|
+
if share_url:
|
|
107
|
+
share_id = share_url.split("/")[-1]
|
|
108
|
+
if not share_id:
|
|
109
|
+
console.print("[[red]Error[/red]] Invalid share URL format.")
|
|
110
|
+
exit(1)
|
|
111
|
+
|
|
112
|
+
if is_cloud:
|
|
113
|
+
# Cloud mode
|
|
114
|
+
if share_url:
|
|
115
|
+
cloud_options = {
|
|
116
|
+
"host": kwargs.get("state_file_host"),
|
|
117
|
+
"api_token": api_token,
|
|
118
|
+
"share_id": share_id,
|
|
119
|
+
}
|
|
120
|
+
elif session_id:
|
|
121
|
+
cloud_options = {
|
|
122
|
+
"host": kwargs.get("state_file_host"),
|
|
123
|
+
"api_token": api_token,
|
|
124
|
+
"session_id": session_id,
|
|
125
|
+
}
|
|
126
|
+
else:
|
|
127
|
+
cloud_options = {
|
|
128
|
+
"host": kwargs.get("state_file_host"),
|
|
129
|
+
"github_token": kwargs.get("cloud_token"),
|
|
130
|
+
"password": kwargs.get("password"),
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
# Create state loader
|
|
134
|
+
state_loader = create_state_loader(is_review, is_cloud, state_file, cloud_options)
|
|
135
|
+
|
|
136
|
+
return state_loader
|
|
137
|
+
|
|
138
|
+
|
|
50
139
|
def handle_debug_flag(**kwargs):
|
|
51
140
|
if kwargs.get("debug"):
|
|
52
141
|
import logging
|
|
@@ -55,6 +144,14 @@ def handle_debug_flag(**kwargs):
|
|
|
55
144
|
ch.setFormatter(CustomFormatter())
|
|
56
145
|
logging.basicConfig(handlers=[ch], level=logging.DEBUG)
|
|
57
146
|
|
|
147
|
+
# Explicitly set uvicorn logger to DEBUG level
|
|
148
|
+
uvicorn_logger = logging.getLogger("uvicorn")
|
|
149
|
+
uvicorn_logger.setLevel(logging.DEBUG)
|
|
150
|
+
|
|
151
|
+
# Set all child loggers to DEBUG as well
|
|
152
|
+
for handler in uvicorn_logger.handlers:
|
|
153
|
+
handler.setLevel(logging.DEBUG)
|
|
154
|
+
|
|
58
155
|
|
|
59
156
|
def add_options(options):
|
|
60
157
|
def _add_options(func):
|
|
@@ -124,6 +221,15 @@ recce_cloud_options = [
|
|
|
124
221
|
),
|
|
125
222
|
]
|
|
126
223
|
|
|
224
|
+
recce_cloud_auth_options = [
|
|
225
|
+
click.option(
|
|
226
|
+
"--api-token",
|
|
227
|
+
help="The personal token generated by Recce Cloud.",
|
|
228
|
+
type=click.STRING,
|
|
229
|
+
envvar="RECCE_API_TOKEN",
|
|
230
|
+
)
|
|
231
|
+
]
|
|
232
|
+
|
|
127
233
|
recce_dbt_artifact_dir_options = [
|
|
128
234
|
click.option(
|
|
129
235
|
"--target-path",
|
|
@@ -139,6 +245,29 @@ recce_dbt_artifact_dir_options = [
|
|
|
139
245
|
),
|
|
140
246
|
]
|
|
141
247
|
|
|
248
|
+
recce_hidden_options = [
|
|
249
|
+
click.option(
|
|
250
|
+
"--mode",
|
|
251
|
+
envvar="RECCE_SERVER_MODE",
|
|
252
|
+
type=click.Choice(RecceServerMode.available_members(), case_sensitive=False),
|
|
253
|
+
hidden=True,
|
|
254
|
+
),
|
|
255
|
+
click.option(
|
|
256
|
+
"--share-url",
|
|
257
|
+
help="The share URL triggers this instance.",
|
|
258
|
+
type=click.STRING,
|
|
259
|
+
envvar="RECCE_SHARE_URL",
|
|
260
|
+
hidden=True,
|
|
261
|
+
),
|
|
262
|
+
click.option(
|
|
263
|
+
"--session-id",
|
|
264
|
+
help="The session ID triggers this instance.",
|
|
265
|
+
type=click.STRING,
|
|
266
|
+
envvar=["RECCE_SESSION_ID", "RECCE_SNAPSHOT_ID"], # Backward compatibility with RECCE_SNAPSHOT_ID
|
|
267
|
+
hidden=True,
|
|
268
|
+
),
|
|
269
|
+
]
|
|
270
|
+
|
|
142
271
|
|
|
143
272
|
def _execute_sql(context, sql_template, base=False):
|
|
144
273
|
try:
|
|
@@ -223,8 +352,9 @@ def debug(**kwargs):
|
|
|
223
352
|
|
|
224
353
|
return [True, manifest_is_ready, catalog_is_ready]
|
|
225
354
|
|
|
226
|
-
|
|
227
|
-
|
|
355
|
+
project_dir_path = Path(kwargs.get("project_dir") or "./")
|
|
356
|
+
target_path = project_dir_path.joinpath(Path(kwargs.get("target_path", "target")))
|
|
357
|
+
target_base_path = project_dir_path.joinpath(Path(kwargs.get("target_base_path", "target-base")))
|
|
228
358
|
|
|
229
359
|
curr_is_ready = check_artifacts("Development", target_path)
|
|
230
360
|
base_is_ready = check_artifacts("Base", target_base_path)
|
|
@@ -348,17 +478,23 @@ def diff(sql, primary_keys: List[str] = None, keep_shape: bool = False, keep_equ
|
|
|
348
478
|
@click.option("--host", default="localhost", show_default=True, help="The host to bind to.")
|
|
349
479
|
@click.option("--port", default=8000, show_default=True, help="The port to bind to.", type=int)
|
|
350
480
|
@click.option("--lifetime", default=0, show_default=True, help="The lifetime of the server in seconds.", type=int)
|
|
351
|
-
@click.option("--review", is_flag=True, help="Open the state file in the review mode.")
|
|
352
|
-
@click.option("--single-env", is_flag=True, help="Launch in single environment mode directly.")
|
|
353
481
|
@click.option(
|
|
354
|
-
"--
|
|
482
|
+
"--idle-timeout",
|
|
483
|
+
default=0,
|
|
484
|
+
show_default=True,
|
|
485
|
+
help="The idle timeout in seconds. If 0, idle timeout is disabled. Maximum value is capped by lifetime.",
|
|
486
|
+
type=int,
|
|
355
487
|
)
|
|
488
|
+
@click.option("--review", is_flag=True, help="Open the state file in the review mode.")
|
|
489
|
+
@click.option("--single-env", is_flag=True, help="Launch in single environment mode directly.")
|
|
356
490
|
@add_options(dbt_related_options)
|
|
357
491
|
@add_options(sqlmesh_related_options)
|
|
358
492
|
@add_options(recce_options)
|
|
359
493
|
@add_options(recce_dbt_artifact_dir_options)
|
|
360
494
|
@add_options(recce_cloud_options)
|
|
361
|
-
|
|
495
|
+
@add_options(recce_cloud_auth_options)
|
|
496
|
+
@add_options(recce_hidden_options)
|
|
497
|
+
def server(host, port, lifetime, idle_timeout=0, state_file=None, **kwargs):
|
|
362
498
|
"""
|
|
363
499
|
Launch the recce server
|
|
364
500
|
|
|
@@ -379,7 +515,8 @@ def server(host, port, lifetime, state_file=None, **kwargs):
|
|
|
379
515
|
recce server --review recce_state.json
|
|
380
516
|
|
|
381
517
|
\b
|
|
382
|
-
# Launch the server
|
|
518
|
+
# Launch the server using the state from the PR of your current branch. (Requires GitHub token)
|
|
519
|
+
export GITHUB_TOKEN=<your-github-token>
|
|
383
520
|
recce server --cloud
|
|
384
521
|
recce server --review --cloud
|
|
385
522
|
|
|
@@ -393,38 +530,57 @@ def server(host, port, lifetime, state_file=None, **kwargs):
|
|
|
393
530
|
RecceConfig(config_file=kwargs.get("config"))
|
|
394
531
|
|
|
395
532
|
handle_debug_flag(**kwargs)
|
|
533
|
+
patch_derived_args(kwargs)
|
|
534
|
+
|
|
535
|
+
server_mode = kwargs.get("mode") if kwargs.get("mode") else RecceServerMode.server
|
|
396
536
|
is_review = kwargs.get("review", False)
|
|
397
537
|
is_cloud = kwargs.get("cloud", False)
|
|
538
|
+
flag = {
|
|
539
|
+
"single_env_onboarding": False,
|
|
540
|
+
"show_relaunch_hint": False,
|
|
541
|
+
"preview": False,
|
|
542
|
+
"read_only": False,
|
|
543
|
+
}
|
|
398
544
|
console = Console()
|
|
399
|
-
cloud_options = None
|
|
400
|
-
flag = {"single_env_onboarding": False, "show_relaunch_hint": False}
|
|
401
|
-
if is_cloud:
|
|
402
|
-
cloud_options = {
|
|
403
|
-
"host": kwargs.get("state_file_host"),
|
|
404
|
-
"token": kwargs.get("cloud_token"),
|
|
405
|
-
"password": kwargs.get("password"),
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
# Check Single Environment Onboarding Mode if the review mode is False
|
|
409
|
-
if not Path(kwargs.get("target_base_path", "target-base")).is_dir() and not is_review:
|
|
410
|
-
# Mark as single env onboarding mode if user provides the target-path only
|
|
411
|
-
flag["single_env_onboarding"] = True
|
|
412
|
-
flag["show_relaunch_hint"] = True
|
|
413
|
-
# Use the target path as the base path
|
|
414
|
-
kwargs["target_base_path"] = kwargs.get("target_path")
|
|
415
545
|
|
|
416
|
-
|
|
546
|
+
# Prepare API token
|
|
417
547
|
try:
|
|
418
548
|
api_token = prepare_api_token(**kwargs)
|
|
549
|
+
kwargs["api_token"] = api_token
|
|
419
550
|
except RecceConfigException:
|
|
420
551
|
show_invalid_api_token_message()
|
|
421
552
|
exit(1)
|
|
422
|
-
auth_options
|
|
553
|
+
auth_options = {
|
|
554
|
+
"api_token": api_token,
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
# Check Single Environment Onboarding Mode if not in cloud mode and not in review mode
|
|
558
|
+
if not is_cloud and not is_review:
|
|
559
|
+
project_dir_path = Path(kwargs.get("project_dir") or "./")
|
|
560
|
+
target_base_path = project_dir_path.joinpath(Path(kwargs.get("target_base_path", "target-base")))
|
|
561
|
+
if not target_base_path.is_dir():
|
|
562
|
+
# Mark as single env onboarding mode if user provides the target-path only
|
|
563
|
+
flag["single_env_onboarding"] = True
|
|
564
|
+
flag["show_relaunch_hint"] = True
|
|
565
|
+
# Use the target path as the base path
|
|
566
|
+
kwargs["target_base_path"] = kwargs.get("target_path")
|
|
567
|
+
|
|
568
|
+
# Server mode:
|
|
569
|
+
#
|
|
570
|
+
# It's used to determine the features disabled in the Web UI. Only used in the cloud-managed recce instances.
|
|
571
|
+
#
|
|
572
|
+
# Read-Only: No run query, no checklist
|
|
573
|
+
# Preview (Metadata-Only): No run query
|
|
574
|
+
if server_mode == RecceServerMode.preview:
|
|
575
|
+
flag["preview"] = True
|
|
576
|
+
elif server_mode == RecceServerMode.read_only:
|
|
577
|
+
flag["read_only"] = True
|
|
423
578
|
|
|
424
579
|
# Onboarding State logic update here
|
|
425
|
-
update_onboarding_state(api_token, flag
|
|
580
|
+
update_onboarding_state(api_token, flag.get("single_env_onboarding"))
|
|
426
581
|
|
|
427
|
-
|
|
582
|
+
# Create state loader using shared function
|
|
583
|
+
state_loader = create_state_loader_by_args(state_file, **kwargs)
|
|
428
584
|
|
|
429
585
|
if not state_loader.verify():
|
|
430
586
|
error, hint = state_loader.error_and_hint
|
|
@@ -432,15 +588,21 @@ def server(host, port, lifetime, state_file=None, **kwargs):
|
|
|
432
588
|
console.print(f"{hint}")
|
|
433
589
|
exit(1)
|
|
434
590
|
|
|
435
|
-
|
|
591
|
+
try:
|
|
592
|
+
result, message = RecceContext.verify_required_artifacts(**kwargs)
|
|
593
|
+
except Exception as e:
|
|
594
|
+
result = False
|
|
595
|
+
error_type = type(e).__name__
|
|
596
|
+
error_message = str(e)
|
|
597
|
+
message = f"{error_type}: {error_message}"
|
|
436
598
|
if not result:
|
|
437
599
|
console.rule("Notice", style="orange3")
|
|
438
600
|
console.print(f"[[red]Error[/red]] {message}")
|
|
439
601
|
exit(1)
|
|
440
602
|
|
|
441
|
-
if state_loader.review_mode
|
|
603
|
+
if state_loader.review_mode:
|
|
442
604
|
console.rule("Recce Server : Review Mode")
|
|
443
|
-
elif flag
|
|
605
|
+
elif flag.get("single_env_onboarding"):
|
|
444
606
|
# Show warning message
|
|
445
607
|
console.rule("Notice", style="orange3")
|
|
446
608
|
console.print(
|
|
@@ -452,7 +614,7 @@ def server(host, port, lifetime, state_file=None, **kwargs):
|
|
|
452
614
|
|
|
453
615
|
single_env_flag = kwargs.get("single_env", False)
|
|
454
616
|
if not single_env_flag:
|
|
455
|
-
lanch_in_single_env = Confirm.ask("Continue
|
|
617
|
+
lanch_in_single_env = Confirm.ask("Continue to launch Recce?")
|
|
456
618
|
if not lanch_in_single_env:
|
|
457
619
|
exit(0)
|
|
458
620
|
|
|
@@ -460,16 +622,39 @@ def server(host, port, lifetime, state_file=None, **kwargs):
|
|
|
460
622
|
else:
|
|
461
623
|
console.rule("Recce Server")
|
|
462
624
|
|
|
625
|
+
# Validate idle_timeout: cap at lifetime if it exceeds lifetime
|
|
626
|
+
if idle_timeout > 0:
|
|
627
|
+
# If lifetime is set (> 0) and idle_timeout exceeds it, cap to lifetime
|
|
628
|
+
if lifetime > 0 and idle_timeout > lifetime:
|
|
629
|
+
effective_idle_timeout = lifetime
|
|
630
|
+
console.print(
|
|
631
|
+
f"[[yellow]Warning[/yellow]] idle_timeout ({idle_timeout}s) exceeds lifetime ({lifetime}s). "
|
|
632
|
+
f"Capping idle_timeout to {effective_idle_timeout}s."
|
|
633
|
+
)
|
|
634
|
+
else:
|
|
635
|
+
# Use idle_timeout as-is (either lifetime is 0, or idle_timeout <= lifetime)
|
|
636
|
+
effective_idle_timeout = idle_timeout
|
|
637
|
+
else:
|
|
638
|
+
# idle_timeout is 0 or negative, disable idle timeout
|
|
639
|
+
effective_idle_timeout = 0
|
|
640
|
+
|
|
463
641
|
state = AppState(
|
|
464
|
-
command=
|
|
642
|
+
command=server_mode,
|
|
465
643
|
state_loader=state_loader,
|
|
466
644
|
kwargs=kwargs,
|
|
467
645
|
flag=flag,
|
|
468
646
|
auth_options=auth_options,
|
|
469
647
|
lifetime=lifetime,
|
|
648
|
+
idle_timeout=effective_idle_timeout,
|
|
649
|
+
share_url=kwargs.get("share_url"),
|
|
650
|
+
organization_name=os.environ.get("RECCE_SESSION_ORGANIZATION_NAME"),
|
|
651
|
+
web_url=os.environ.get("RECCE_CLOUD_WEB_URL"),
|
|
470
652
|
)
|
|
471
653
|
app.state = state
|
|
472
654
|
|
|
655
|
+
if server_mode == RecceServerMode.read_only:
|
|
656
|
+
set_default_context(RecceContext.load(**kwargs, state_loader=state_loader))
|
|
657
|
+
|
|
473
658
|
uvicorn.run(app, host=host, port=port, lifespan="on")
|
|
474
659
|
|
|
475
660
|
|
|
@@ -488,6 +673,7 @@ DEFAULT_RECCE_STATE_FILE = "recce_state.json"
|
|
|
488
673
|
@click.option("--state-file", help="Path of the import state file.", type=click.Path())
|
|
489
674
|
@click.option("--summary", help="Path of the summary markdown file.", type=click.Path())
|
|
490
675
|
@click.option("--skip-query", is_flag=True, help="Skip running the queries for the checks.")
|
|
676
|
+
@click.option("--skip-check", is_flag=True, help="Skip running the checks.")
|
|
491
677
|
@click.option(
|
|
492
678
|
"--git-current-branch",
|
|
493
679
|
help="The git branch of the current environment.",
|
|
@@ -540,7 +726,7 @@ def run(output, **kwargs):
|
|
|
540
726
|
cloud_options = (
|
|
541
727
|
{
|
|
542
728
|
"host": kwargs.get("state_file_host"),
|
|
543
|
-
"
|
|
729
|
+
"github_token": kwargs.get("cloud_token"),
|
|
544
730
|
"password": kwargs.get("password"),
|
|
545
731
|
}
|
|
546
732
|
if cloud_mode
|
|
@@ -614,7 +800,7 @@ def summary(state_file, **kwargs):
|
|
|
614
800
|
cloud_options = (
|
|
615
801
|
{
|
|
616
802
|
"host": kwargs.get("state_file_host"),
|
|
617
|
-
"
|
|
803
|
+
"github_token": kwargs.get("cloud_token"),
|
|
618
804
|
"password": kwargs.get("password"),
|
|
619
805
|
}
|
|
620
806
|
if cloud_mode
|
|
@@ -642,6 +828,31 @@ def summary(state_file, **kwargs):
|
|
|
642
828
|
print(output)
|
|
643
829
|
|
|
644
830
|
|
|
831
|
+
@cli.command(cls=TrackCommand)
|
|
832
|
+
def connect_to_cloud():
|
|
833
|
+
"""
|
|
834
|
+
Connect OSS to Cloud
|
|
835
|
+
"""
|
|
836
|
+
import webbrowser
|
|
837
|
+
|
|
838
|
+
from rich.console import Console
|
|
839
|
+
|
|
840
|
+
console = Console()
|
|
841
|
+
|
|
842
|
+
# Prepare RSA keys for connecting to cloud
|
|
843
|
+
private_key, public_key = generate_key_pair()
|
|
844
|
+
|
|
845
|
+
connect_url, callback_port = prepare_connection_url(public_key)
|
|
846
|
+
console.rule("Connecting to Recce Cloud")
|
|
847
|
+
console.print("Attempting to automatically open the Recce Cloud authorization page in your default browser.")
|
|
848
|
+
console.print("If the browser does not open, please open the following URL:")
|
|
849
|
+
console.print(connect_url)
|
|
850
|
+
webbrowser.open(connect_url)
|
|
851
|
+
|
|
852
|
+
# Launch a callback HTTP server for fetching the api-token
|
|
853
|
+
run_one_time_http_server(private_key, port=callback_port)
|
|
854
|
+
|
|
855
|
+
|
|
645
856
|
@cli.group("cloud", short_help="Manage Recce Cloud state file.")
|
|
646
857
|
def cloud(**kwargs):
|
|
647
858
|
# Manage Recce Cloud.
|
|
@@ -678,14 +889,14 @@ def purge(**kwargs):
|
|
|
678
889
|
state_loader = None
|
|
679
890
|
cloud_options = {
|
|
680
891
|
"host": kwargs.get("state_file_host"),
|
|
681
|
-
"
|
|
892
|
+
"github_token": kwargs.get("cloud_token"),
|
|
682
893
|
"password": kwargs.get("password"),
|
|
683
894
|
}
|
|
684
895
|
force_to_purge = kwargs.get("force", False)
|
|
685
896
|
|
|
686
897
|
try:
|
|
687
898
|
console.rule("Check Recce State from Cloud")
|
|
688
|
-
state_loader =
|
|
899
|
+
state_loader = create_state_loader(
|
|
689
900
|
review_mode=False, cloud_mode=True, state_file=None, cloud_options=cloud_options
|
|
690
901
|
)
|
|
691
902
|
except Exception:
|
|
@@ -759,7 +970,7 @@ def upload(state_file, **kwargs):
|
|
|
759
970
|
handle_debug_flag(**kwargs)
|
|
760
971
|
cloud_options = {
|
|
761
972
|
"host": kwargs.get("state_file_host"),
|
|
762
|
-
"
|
|
973
|
+
"github_token": kwargs.get("cloud_token"),
|
|
763
974
|
"password": kwargs.get("password"),
|
|
764
975
|
}
|
|
765
976
|
|
|
@@ -828,7 +1039,7 @@ def download(**kwargs):
|
|
|
828
1039
|
filepath = kwargs.get("output")
|
|
829
1040
|
cloud_options = {
|
|
830
1041
|
"host": kwargs.get("state_file_host"),
|
|
831
|
-
"
|
|
1042
|
+
"github_token": kwargs.get("cloud_token"),
|
|
832
1043
|
"password": kwargs.get("password"),
|
|
833
1044
|
}
|
|
834
1045
|
|
|
@@ -1041,9 +1252,287 @@ def download_base_artifacts(**kwargs):
|
|
|
1041
1252
|
password = kwargs.get("password")
|
|
1042
1253
|
target_path = kwargs.get("target_path")
|
|
1043
1254
|
branch = kwargs.get("branch")
|
|
1255
|
+
# If recce can't infer default branch from "GITHUB_BASE_REF" and current_default_branch()
|
|
1256
|
+
if branch is None:
|
|
1257
|
+
console.print(
|
|
1258
|
+
"[[red]Error[/red]] Please provide your base branch name with '--branch' to download the base " "artifacts."
|
|
1259
|
+
)
|
|
1260
|
+
exit(1)
|
|
1261
|
+
|
|
1044
1262
|
return _download_artifacts(branch, cloud_token, console, kwargs, password, target_path)
|
|
1045
1263
|
|
|
1046
1264
|
|
|
1265
|
+
@cloud.command(cls=TrackCommand)
|
|
1266
|
+
@click.option("--cloud-token", help="The GitHub token used by Recce Cloud.", type=click.STRING, envvar="GITHUB_TOKEN")
|
|
1267
|
+
@click.option(
|
|
1268
|
+
"--branch",
|
|
1269
|
+
"-b",
|
|
1270
|
+
help="The branch to delete artifacts from.",
|
|
1271
|
+
type=click.STRING,
|
|
1272
|
+
envvar="GITHUB_HEAD_REF",
|
|
1273
|
+
default=current_branch(),
|
|
1274
|
+
show_default=True,
|
|
1275
|
+
)
|
|
1276
|
+
@click.option("--force", "-f", help="Bypasses the confirmation prompt. Delete the artifacts directly.", is_flag=True)
|
|
1277
|
+
@add_options(recce_options)
|
|
1278
|
+
def delete_artifacts(**kwargs):
|
|
1279
|
+
"""
|
|
1280
|
+
Delete the dbt artifacts from cloud
|
|
1281
|
+
|
|
1282
|
+
Delete the dbt artifacts (metadata.json, catalog.json) from Recce Cloud for the given branch.
|
|
1283
|
+
This will permanently remove the artifacts from the cloud storage.
|
|
1284
|
+
|
|
1285
|
+
By default, the artifacts are deleted from the current branch. You can specify the branch using the --branch option.
|
|
1286
|
+
"""
|
|
1287
|
+
from rich.console import Console
|
|
1288
|
+
|
|
1289
|
+
console = Console()
|
|
1290
|
+
cloud_token = kwargs.get("cloud_token")
|
|
1291
|
+
branch = kwargs.get("branch")
|
|
1292
|
+
force = kwargs.get("force", False)
|
|
1293
|
+
|
|
1294
|
+
if not force:
|
|
1295
|
+
if not click.confirm(f'Do you want to delete artifacts from branch "{branch}"?'):
|
|
1296
|
+
console.print("Deletion cancelled.")
|
|
1297
|
+
return 0
|
|
1298
|
+
|
|
1299
|
+
try:
|
|
1300
|
+
delete_dbt_artifacts(branch=branch, token=cloud_token, debug=kwargs.get("debug", False))
|
|
1301
|
+
console.print(f"[[green]Success[/green]] Artifacts deleted from branch: {branch}")
|
|
1302
|
+
return 0
|
|
1303
|
+
except click.exceptions.Abort:
|
|
1304
|
+
pass
|
|
1305
|
+
except RecceCloudException as e:
|
|
1306
|
+
console.print("[[red]Error[/red]] Failed to delete the dbt artifacts from cloud.")
|
|
1307
|
+
console.print(f"Reason: {e.reason}")
|
|
1308
|
+
exit(1)
|
|
1309
|
+
except Exception as e:
|
|
1310
|
+
console.print("[[red]Error[/red]] Failed to delete the dbt artifacts from cloud.")
|
|
1311
|
+
console.print(f"Reason: {e}")
|
|
1312
|
+
exit(1)
|
|
1313
|
+
|
|
1314
|
+
|
|
1315
|
+
@cloud.command(cls=TrackCommand, name="list-organizations")
|
|
1316
|
+
@click.option("--api-token", help="The Recce Cloud API token.", type=click.STRING, envvar="RECCE_API_TOKEN")
|
|
1317
|
+
@add_options(recce_options)
|
|
1318
|
+
def list_organizations(**kwargs):
|
|
1319
|
+
"""
|
|
1320
|
+
List organizations from Recce Cloud
|
|
1321
|
+
|
|
1322
|
+
Lists all organizations that the authenticated user has access to.
|
|
1323
|
+
"""
|
|
1324
|
+
from rich.console import Console
|
|
1325
|
+
from rich.table import Table
|
|
1326
|
+
|
|
1327
|
+
console = Console()
|
|
1328
|
+
handle_debug_flag(**kwargs)
|
|
1329
|
+
|
|
1330
|
+
try:
|
|
1331
|
+
api_token = prepare_api_token(**kwargs)
|
|
1332
|
+
except RecceConfigException:
|
|
1333
|
+
show_invalid_api_token_message()
|
|
1334
|
+
exit(1)
|
|
1335
|
+
|
|
1336
|
+
try:
|
|
1337
|
+
from recce.util.recce_cloud import RecceCloud
|
|
1338
|
+
|
|
1339
|
+
cloud = RecceCloud(api_token)
|
|
1340
|
+
organizations = cloud.list_organizations()
|
|
1341
|
+
|
|
1342
|
+
if not organizations:
|
|
1343
|
+
console.print("No organizations found.")
|
|
1344
|
+
return
|
|
1345
|
+
|
|
1346
|
+
table = Table(title="Organizations")
|
|
1347
|
+
table.add_column("ID", style="cyan")
|
|
1348
|
+
table.add_column("Name", style="green")
|
|
1349
|
+
table.add_column("Display Name", style="yellow")
|
|
1350
|
+
|
|
1351
|
+
for org in organizations:
|
|
1352
|
+
table.add_row(str(org.get("id", "")), org.get("name", ""), org.get("display_name", ""))
|
|
1353
|
+
|
|
1354
|
+
console.print(table)
|
|
1355
|
+
|
|
1356
|
+
except RecceCloudException as e:
|
|
1357
|
+
console.print(f"[[red]Error[/red]] {e}")
|
|
1358
|
+
exit(1)
|
|
1359
|
+
except Exception as e:
|
|
1360
|
+
console.print(f"[[red]Error[/red]] {e}")
|
|
1361
|
+
exit(1)
|
|
1362
|
+
|
|
1363
|
+
|
|
1364
|
+
@cloud.command(cls=TrackCommand, name="list-projects")
|
|
1365
|
+
@click.option(
|
|
1366
|
+
"--organization",
|
|
1367
|
+
"-o",
|
|
1368
|
+
help="Organization ID (can also be set via RECCE_ORGANIZATION_ID environment variable)",
|
|
1369
|
+
type=click.STRING,
|
|
1370
|
+
envvar="RECCE_ORGANIZATION_ID",
|
|
1371
|
+
)
|
|
1372
|
+
@click.option("--api-token", help="The Recce Cloud API token.", type=click.STRING, envvar="RECCE_API_TOKEN")
|
|
1373
|
+
@add_options(recce_options)
|
|
1374
|
+
def list_projects(**kwargs):
|
|
1375
|
+
"""
|
|
1376
|
+
List projects from Recce Cloud
|
|
1377
|
+
|
|
1378
|
+
Lists all projects in the specified organization that the authenticated user has access to.
|
|
1379
|
+
|
|
1380
|
+
Examples:
|
|
1381
|
+
|
|
1382
|
+
# Using environment variable
|
|
1383
|
+
export RECCE_ORGANIZATION_ID=8
|
|
1384
|
+
recce cloud list-projects
|
|
1385
|
+
|
|
1386
|
+
# Using command line argument
|
|
1387
|
+
recce cloud list-projects --organization 8
|
|
1388
|
+
|
|
1389
|
+
# Override environment variable
|
|
1390
|
+
export RECCE_ORGANIZATION_ID=8
|
|
1391
|
+
recce cloud list-projects --organization 10
|
|
1392
|
+
"""
|
|
1393
|
+
from rich.console import Console
|
|
1394
|
+
from rich.table import Table
|
|
1395
|
+
|
|
1396
|
+
console = Console()
|
|
1397
|
+
handle_debug_flag(**kwargs)
|
|
1398
|
+
|
|
1399
|
+
try:
|
|
1400
|
+
api_token = prepare_api_token(**kwargs)
|
|
1401
|
+
except RecceConfigException:
|
|
1402
|
+
show_invalid_api_token_message()
|
|
1403
|
+
exit(1)
|
|
1404
|
+
|
|
1405
|
+
organization = kwargs.get("organization")
|
|
1406
|
+
if not organization:
|
|
1407
|
+
console.print("[[red]Error[/red]] Organization ID is required. Please provide it via:")
|
|
1408
|
+
console.print(" --organization <id> or set RECCE_ORGANIZATION_ID environment variable")
|
|
1409
|
+
exit(1)
|
|
1410
|
+
|
|
1411
|
+
try:
|
|
1412
|
+
from recce.util.recce_cloud import RecceCloud
|
|
1413
|
+
|
|
1414
|
+
cloud = RecceCloud(api_token)
|
|
1415
|
+
projects = cloud.list_projects(organization)
|
|
1416
|
+
|
|
1417
|
+
if not projects:
|
|
1418
|
+
console.print(f"No projects found in organization {organization}.")
|
|
1419
|
+
return
|
|
1420
|
+
|
|
1421
|
+
table = Table(title=f"Projects in Organization {organization}")
|
|
1422
|
+
table.add_column("ID", style="cyan")
|
|
1423
|
+
table.add_column("Name", style="green")
|
|
1424
|
+
table.add_column("Display Name", style="yellow")
|
|
1425
|
+
|
|
1426
|
+
for project in projects:
|
|
1427
|
+
table.add_row(str(project.get("id", "")), project.get("name", ""), project.get("display_name", ""))
|
|
1428
|
+
|
|
1429
|
+
console.print(table)
|
|
1430
|
+
|
|
1431
|
+
except RecceCloudException as e:
|
|
1432
|
+
console.print(f"[[red]Error[/red]] {e}")
|
|
1433
|
+
exit(1)
|
|
1434
|
+
except Exception as e:
|
|
1435
|
+
console.print(f"[[red]Error[/red]] {e}")
|
|
1436
|
+
exit(1)
|
|
1437
|
+
|
|
1438
|
+
|
|
1439
|
+
@cloud.command(cls=TrackCommand, name="list-sessions")
|
|
1440
|
+
@click.option(
|
|
1441
|
+
"--organization",
|
|
1442
|
+
"-o",
|
|
1443
|
+
help="Organization ID (can also be set via RECCE_ORGANIZATION_ID environment variable)",
|
|
1444
|
+
type=click.STRING,
|
|
1445
|
+
envvar="RECCE_ORGANIZATION_ID",
|
|
1446
|
+
)
|
|
1447
|
+
@click.option(
|
|
1448
|
+
"--project",
|
|
1449
|
+
"-p",
|
|
1450
|
+
help="Project ID (can also be set via RECCE_PROJECT_ID environment variable)",
|
|
1451
|
+
type=click.STRING,
|
|
1452
|
+
envvar="RECCE_PROJECT_ID",
|
|
1453
|
+
)
|
|
1454
|
+
@click.option("--api-token", help="The Recce Cloud API token.", type=click.STRING, envvar="RECCE_API_TOKEN")
|
|
1455
|
+
@add_options(recce_options)
|
|
1456
|
+
def list_sessions(**kwargs):
|
|
1457
|
+
"""
|
|
1458
|
+
List sessions from Recce Cloud
|
|
1459
|
+
|
|
1460
|
+
Lists all sessions in the specified project that the authenticated user has access to.
|
|
1461
|
+
|
|
1462
|
+
Examples:
|
|
1463
|
+
|
|
1464
|
+
# Using environment variables
|
|
1465
|
+
export RECCE_ORGANIZATION_ID=8
|
|
1466
|
+
export RECCE_PROJECT_ID=7
|
|
1467
|
+
recce cloud list-sessions
|
|
1468
|
+
|
|
1469
|
+
# Using command line arguments
|
|
1470
|
+
recce cloud list-sessions --organization 8 --project 7
|
|
1471
|
+
|
|
1472
|
+
# Mixed usage (env + CLI override)
|
|
1473
|
+
export RECCE_ORGANIZATION_ID=8
|
|
1474
|
+
recce cloud list-sessions --project 7
|
|
1475
|
+
|
|
1476
|
+
# Override environment variables
|
|
1477
|
+
export RECCE_ORGANIZATION_ID=8
|
|
1478
|
+
export RECCE_PROJECT_ID=7
|
|
1479
|
+
recce cloud list-sessions --organization 10 --project 9
|
|
1480
|
+
"""
|
|
1481
|
+
from rich.console import Console
|
|
1482
|
+
from rich.table import Table
|
|
1483
|
+
|
|
1484
|
+
console = Console()
|
|
1485
|
+
handle_debug_flag(**kwargs)
|
|
1486
|
+
|
|
1487
|
+
try:
|
|
1488
|
+
api_token = prepare_api_token(**kwargs)
|
|
1489
|
+
except RecceConfigException:
|
|
1490
|
+
show_invalid_api_token_message()
|
|
1491
|
+
exit(1)
|
|
1492
|
+
|
|
1493
|
+
organization = kwargs.get("organization")
|
|
1494
|
+
project = kwargs.get("project")
|
|
1495
|
+
|
|
1496
|
+
# Validate required parameters
|
|
1497
|
+
if not organization:
|
|
1498
|
+
console.print("[[red]Error[/red]] Organization ID is required. Please provide it via:")
|
|
1499
|
+
console.print(" --organization <id> or set RECCE_ORGANIZATION_ID environment variable")
|
|
1500
|
+
exit(1)
|
|
1501
|
+
|
|
1502
|
+
if not project:
|
|
1503
|
+
console.print("[[red]Error[/red]] Project ID is required. Please provide it via:")
|
|
1504
|
+
console.print(" --project <id> or set RECCE_PROJECT_ID environment variable")
|
|
1505
|
+
exit(1)
|
|
1506
|
+
|
|
1507
|
+
try:
|
|
1508
|
+
from recce.util.recce_cloud import RecceCloud
|
|
1509
|
+
|
|
1510
|
+
cloud = RecceCloud(api_token)
|
|
1511
|
+
sessions = cloud.list_sessions(organization, project)
|
|
1512
|
+
|
|
1513
|
+
if not sessions:
|
|
1514
|
+
console.print(f"No sessions found in project {project}.")
|
|
1515
|
+
return
|
|
1516
|
+
|
|
1517
|
+
table = Table(title=f"Sessions in Project {project}")
|
|
1518
|
+
table.add_column("ID", style="cyan")
|
|
1519
|
+
table.add_column("Name", style="green")
|
|
1520
|
+
table.add_column("Is Base", style="yellow")
|
|
1521
|
+
|
|
1522
|
+
for session in sessions:
|
|
1523
|
+
is_base = "✓" if session.get("is_base", False) else ""
|
|
1524
|
+
table.add_row(session.get("id", ""), session.get("name", ""), is_base)
|
|
1525
|
+
|
|
1526
|
+
console.print(table)
|
|
1527
|
+
|
|
1528
|
+
except RecceCloudException as e:
|
|
1529
|
+
console.print(f"[[red]Error[/red]] {e}")
|
|
1530
|
+
exit(1)
|
|
1531
|
+
except Exception as e:
|
|
1532
|
+
console.print(f"[[red]Error[/red]] {e}")
|
|
1533
|
+
exit(1)
|
|
1534
|
+
|
|
1535
|
+
|
|
1047
1536
|
@cli.group("github", short_help="GitHub related commands", hidden=True)
|
|
1048
1537
|
def github(**kwargs):
|
|
1049
1538
|
pass
|
|
@@ -1073,7 +1562,10 @@ def artifact(**kwargs):
|
|
|
1073
1562
|
@cli.command(cls=TrackCommand)
|
|
1074
1563
|
@click.argument("state_file", type=click.Path(exists=True))
|
|
1075
1564
|
@click.option(
|
|
1076
|
-
"--api-token",
|
|
1565
|
+
"--api-token",
|
|
1566
|
+
help="The personal token generated by Recce Cloud.",
|
|
1567
|
+
type=click.STRING,
|
|
1568
|
+
envvar="RECCE_API_TOKEN",
|
|
1077
1569
|
)
|
|
1078
1570
|
def share(state_file, **kwargs):
|
|
1079
1571
|
"""
|
|
@@ -1131,49 +1623,189 @@ def share(state_file, **kwargs):
|
|
|
1131
1623
|
exit(1)
|
|
1132
1624
|
|
|
1133
1625
|
|
|
1626
|
+
snapshot_id_option = click.option(
|
|
1627
|
+
"--snapshot-id",
|
|
1628
|
+
help="The snapshot ID to upload artifacts to cloud.",
|
|
1629
|
+
type=click.STRING,
|
|
1630
|
+
envvar=["RECCE_SNAPSHOT_ID", "RECCE_SESSION_ID"],
|
|
1631
|
+
required=True,
|
|
1632
|
+
)
|
|
1633
|
+
|
|
1634
|
+
session_id_option = click.option(
|
|
1635
|
+
"--session-id",
|
|
1636
|
+
help="The session ID to upload artifacts to cloud.",
|
|
1637
|
+
type=click.STRING,
|
|
1638
|
+
envvar=["RECCE_SESSION_ID", "RECCE_SNAPSHOT_ID"],
|
|
1639
|
+
required=True,
|
|
1640
|
+
)
|
|
1641
|
+
|
|
1642
|
+
target_path_option = click.option(
|
|
1643
|
+
"--target-path",
|
|
1644
|
+
help="dbt artifacts directory for your artifacts.",
|
|
1645
|
+
type=click.STRING,
|
|
1646
|
+
default="target",
|
|
1647
|
+
show_default=True,
|
|
1648
|
+
)
|
|
1649
|
+
|
|
1650
|
+
|
|
1651
|
+
@cli.command(cls=TrackCommand, hidden=True)
|
|
1652
|
+
@add_options([session_id_option, target_path_option])
|
|
1653
|
+
@add_options(recce_cloud_auth_options)
|
|
1654
|
+
@add_options(recce_options)
|
|
1655
|
+
def upload_session(**kwargs):
|
|
1656
|
+
"""
|
|
1657
|
+
Upload target/manifest.json and target/catalog.json to the specific session ID
|
|
1658
|
+
|
|
1659
|
+
Upload the dbt artifacts (manifest.json, catalog.json) to Recce Cloud for the given session ID.
|
|
1660
|
+
This allows you to associate artifacts with a specific session for later use.
|
|
1661
|
+
|
|
1662
|
+
Examples:\n
|
|
1663
|
+
|
|
1664
|
+
\b
|
|
1665
|
+
# Upload artifacts to a session ID
|
|
1666
|
+
recce upload-session --session-id <session-id>
|
|
1667
|
+
|
|
1668
|
+
\b
|
|
1669
|
+
# Upload artifacts from custom target path to a session ID
|
|
1670
|
+
recce upload-session --session-id <session-id> --target-path my-target
|
|
1671
|
+
"""
|
|
1672
|
+
from rich.console import Console
|
|
1673
|
+
|
|
1674
|
+
console = Console()
|
|
1675
|
+
handle_debug_flag(**kwargs)
|
|
1676
|
+
|
|
1677
|
+
# Initialize Recce Config
|
|
1678
|
+
RecceConfig(config_file=kwargs.get("config"))
|
|
1679
|
+
|
|
1680
|
+
try:
|
|
1681
|
+
api_token = prepare_api_token(**kwargs)
|
|
1682
|
+
except RecceConfigException:
|
|
1683
|
+
show_invalid_api_token_message()
|
|
1684
|
+
exit(1)
|
|
1685
|
+
|
|
1686
|
+
session_id = kwargs.get("session_id")
|
|
1687
|
+
target_path = kwargs.get("target_path")
|
|
1688
|
+
|
|
1689
|
+
try:
|
|
1690
|
+
rc = upload_artifacts_to_session(
|
|
1691
|
+
target_path, session_id=session_id, token=api_token, debug=kwargs.get("debug", False)
|
|
1692
|
+
)
|
|
1693
|
+
console.rule("Uploaded Successfully")
|
|
1694
|
+
console.print(
|
|
1695
|
+
f'Uploaded dbt artifacts to Recce Cloud for session ID "{session_id}" from "{os.path.abspath(target_path)}"'
|
|
1696
|
+
)
|
|
1697
|
+
except Exception as e:
|
|
1698
|
+
console.rule("Failed to Upload Session", style="red")
|
|
1699
|
+
console.print(f"[[red]Error[/red]] Failed to upload the dbt artifacts to the session {session_id}.")
|
|
1700
|
+
console.print(f"Reason: {e}")
|
|
1701
|
+
rc = 1
|
|
1702
|
+
return rc
|
|
1703
|
+
|
|
1704
|
+
|
|
1705
|
+
# Backward compatibility for `recce snapshot` command
|
|
1706
|
+
@cli.command(
|
|
1707
|
+
cls=TrackCommand,
|
|
1708
|
+
hidden=True,
|
|
1709
|
+
deprecated=True,
|
|
1710
|
+
help="Upload target/manifest.json and target/catalog.json to the specific snapshot ID",
|
|
1711
|
+
)
|
|
1712
|
+
@add_options([snapshot_id_option, target_path_option])
|
|
1713
|
+
@add_options(recce_cloud_auth_options)
|
|
1714
|
+
@add_options(recce_options)
|
|
1715
|
+
def snapshot(**kwargs):
|
|
1716
|
+
kwargs["session_id"] = kwargs.get("snapshot_id")
|
|
1717
|
+
return upload_session(**kwargs)
|
|
1718
|
+
|
|
1719
|
+
|
|
1134
1720
|
@cli.command(hidden=True, cls=TrackCommand)
|
|
1135
1721
|
@click.argument("state_file", required=True)
|
|
1136
1722
|
@click.option("--host", default="localhost", show_default=True, help="The host to bind to.")
|
|
1137
1723
|
@click.option("--port", default=8000, show_default=True, help="The port to bind to.", type=int)
|
|
1138
1724
|
@click.option("--lifetime", default=0, show_default=True, help="The lifetime of the server in seconds.", type=int)
|
|
1139
1725
|
@click.option("--share-url", help="The share URL triggers this instance.", type=click.STRING, envvar="RECCE_SHARE_URL")
|
|
1140
|
-
|
|
1141
|
-
|
|
1726
|
+
@click.pass_context
|
|
1727
|
+
def read_only(ctx, state_file=None, **kwargs):
|
|
1728
|
+
# Invoke `recce server --mode read-only <state_file> ...
|
|
1729
|
+
kwargs["mode"] = RecceServerMode.read_only
|
|
1730
|
+
ctx.invoke(server, state_file=state_file, **kwargs)
|
|
1142
1731
|
|
|
1143
|
-
|
|
1732
|
+
|
|
1733
|
+
@cli.command(cls=TrackCommand)
|
|
1734
|
+
@add_options(dbt_related_options)
|
|
1735
|
+
@add_options(sqlmesh_related_options)
|
|
1736
|
+
@add_options(recce_options)
|
|
1737
|
+
@add_options(recce_dbt_artifact_dir_options)
|
|
1738
|
+
@add_options(recce_cloud_options)
|
|
1739
|
+
@add_options(recce_cloud_auth_options)
|
|
1740
|
+
@add_options(recce_hidden_options)
|
|
1741
|
+
def mcp_server(**kwargs):
|
|
1742
|
+
"""
|
|
1743
|
+
[Experiment] Start the Recce MCP (Model Context Protocol) server
|
|
1744
|
+
|
|
1745
|
+
The MCP server provides a stdio-based interface for AI assistants and tools
|
|
1746
|
+
to interact with Recce's data validation capabilities.
|
|
1747
|
+
|
|
1748
|
+
Available tools:
|
|
1749
|
+
- get_lineage_diff: Get lineage differences between environments
|
|
1750
|
+
- row_count_diff: Compare row counts between environments
|
|
1751
|
+
- query: Execute SQL queries with dbt templating
|
|
1752
|
+
- query_diff: Compare query results between environments
|
|
1753
|
+
- profile_diff: Generate statistical profiles and compare
|
|
1754
|
+
|
|
1755
|
+
Examples:\n
|
|
1756
|
+
|
|
1757
|
+
\b
|
|
1758
|
+
# Start the MCP server
|
|
1759
|
+
recce mcp-server
|
|
1760
|
+
|
|
1761
|
+
\b
|
|
1762
|
+
# Start with custom dbt configuration
|
|
1763
|
+
recce mcp-server --target prod --project-dir ./my_project
|
|
1764
|
+
"""
|
|
1765
|
+
from rich.console import Console
|
|
1144
1766
|
|
|
1145
1767
|
console = Console()
|
|
1768
|
+
try:
|
|
1769
|
+
# Import here to avoid import errors if mcp is not installed
|
|
1770
|
+
from recce.mcp_server import run_mcp_server
|
|
1771
|
+
except ImportError as e:
|
|
1772
|
+
console.print(f"[[red]Error[/red]] Failed to import MCP server: {e}")
|
|
1773
|
+
console.print(r"Please install the MCP package: pip install 'recce\[mcp]'")
|
|
1774
|
+
exit(1)
|
|
1775
|
+
|
|
1776
|
+
# Initialize Recce Config
|
|
1777
|
+
RecceConfig(config_file=kwargs.get("config"))
|
|
1778
|
+
|
|
1146
1779
|
handle_debug_flag(**kwargs)
|
|
1147
|
-
|
|
1148
|
-
is_cloud = False
|
|
1149
|
-
cloud_options = None
|
|
1150
|
-
flag = {
|
|
1151
|
-
"read_only": True,
|
|
1152
|
-
}
|
|
1153
|
-
state_loader = create_state_loader(is_review, is_cloud, state_file, cloud_options)
|
|
1780
|
+
patch_derived_args(kwargs)
|
|
1154
1781
|
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1782
|
+
# Prepare API token
|
|
1783
|
+
try:
|
|
1784
|
+
api_token = prepare_api_token(**kwargs)
|
|
1785
|
+
kwargs["api_token"] = api_token
|
|
1786
|
+
except RecceConfigException:
|
|
1787
|
+
show_invalid_api_token_message()
|
|
1159
1788
|
exit(1)
|
|
1160
1789
|
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1790
|
+
# Create state loader using shared function (if cloud mode is enabled)
|
|
1791
|
+
is_cloud = kwargs.get("cloud", False)
|
|
1792
|
+
if is_cloud:
|
|
1793
|
+
state_loader = create_state_loader_by_args(None, **kwargs)
|
|
1794
|
+
kwargs["state_loader"] = state_loader
|
|
1165
1795
|
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
kwargs=kwargs,
|
|
1170
|
-
flag=flag,
|
|
1171
|
-
lifetime=lifetime,
|
|
1172
|
-
share_url=kwargs.get("share_url"),
|
|
1173
|
-
)
|
|
1174
|
-
set_default_context(RecceContext.load(**kwargs, review=is_review, state_loader=state_loader))
|
|
1796
|
+
try:
|
|
1797
|
+
console.print("Starting Recce MCP Server...")
|
|
1798
|
+
console.print("Available tools: get_lineage_diff, row_count_diff, query, query_diff, profile_diff")
|
|
1175
1799
|
|
|
1176
|
-
|
|
1800
|
+
# Run the async server
|
|
1801
|
+
asyncio.run(run_mcp_server(**kwargs))
|
|
1802
|
+
except Exception as e:
|
|
1803
|
+
console.print(f"[[red]Error[/red]] Failed to start MCP server: {e}")
|
|
1804
|
+
if kwargs.get("debug"):
|
|
1805
|
+
import traceback
|
|
1806
|
+
|
|
1807
|
+
traceback.print_exc()
|
|
1808
|
+
exit(1)
|
|
1177
1809
|
|
|
1178
1810
|
|
|
1179
1811
|
if __name__ == "__main__":
|