recce-nightly 1.10.0.20250625__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 +5 -0
- recce/adapter/dbt_adapter/__init__.py +343 -245
- recce/apis/check_api.py +20 -14
- recce/apis/check_events_api.py +353 -0
- recce/apis/check_func.py +5 -5
- recce/apis/run_func.py +32 -3
- recce/artifact.py +76 -3
- recce/cli.py +705 -82
- recce/config.py +2 -2
- recce/connect_to_cloud.py +1 -1
- recce/core.py +3 -3
- recce/data/404/index.html +2 -0
- recce/data/404.html +2 -22
- 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.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/_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 +1 -1
- 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/index.html +2 -27
- recce/data/index.txt +32 -8
- 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/event/CONFIG.bak +1 -0
- 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 +725 -0
- recce/models/check.py +433 -15
- recce/models/types.py +61 -2
- recce/pull_request.py +1 -1
- recce/run.py +37 -17
- recce/server.py +216 -21
- 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 +25 -3
- recce/tasks/dataframe.py +63 -1
- recce/tasks/query.py +40 -3
- recce/tasks/rowcount.py +4 -1
- recce/tasks/schema.py +4 -1
- recce/tasks/utils.py +147 -0
- recce/tasks/valuediff.py +85 -57
- recce/util/api_token.py +11 -2
- recce/util/breaking.py +10 -1
- recce/util/cll.py +1 -2
- 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 +2 -2
- recce/util/lineage.py +19 -18
- recce/util/perf_tracking.py +85 -0
- recce/util/recce_cloud.py +254 -5
- recce/util/startup_perf.py +121 -0
- recce/yaml/__init__.py +2 -2
- {recce_nightly-1.10.0.20250625.dist-info → recce_nightly-1.30.0.20251221.dist-info}/METADATA +91 -71
- recce_nightly-1.30.0.20251221.dist-info/RECORD +183 -0
- {recce_nightly-1.10.0.20250625.dist-info → recce_nightly-1.30.0.20251221.dist-info}/WHEEL +1 -2
- recce/data/_next/static/abCX3x3UoIdRLEDWxx4xd/_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-607cd1af83c41f43.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-da6e046a8235dbfc.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/data/_next/static/media/reload-image.79aabb7d.svg +0 -4
- recce/state.py +0 -786
- recce_nightly-1.10.0.20250625.dist-info/RECORD +0 -154
- recce_nightly-1.10.0.20250625.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 -17
- tests/adapter/dbt_adapter/dbt_test_helper.py +0 -298
- tests/adapter/dbt_adapter/test_dbt_adapter.py +0 -25
- tests/adapter/dbt_adapter/test_dbt_cll.py +0 -384
- tests/adapter/dbt_adapter/test_selector.py +0 -202
- tests/tasks/__init__.py +0 -0
- tests/tasks/conftest.py +0 -4
- tests/tasks/test_histogram.py +0 -129
- tests/tasks/test_lineage.py +0 -55
- tests/tasks/test_preset_checks.py +0 -64
- tests/tasks/test_profile.py +0 -397
- tests/tasks/test_query.py +0 -151
- tests/tasks/test_row_count.py +0 -135
- tests/tasks/test_schema.py +0 -122
- tests/tasks/test_top_k.py +0 -77
- tests/tasks/test_valuediff.py +0 -85
- tests/test_cli.py +0 -133
- tests/test_config.py +0 -43
- tests/test_connect_to_cloud.py +0 -82
- tests/test_core.py +0 -29
- tests/test_dbt.py +0 -36
- tests/test_pull_request.py +0 -130
- tests/test_server.py +0 -104
- tests/test_state.py +0 -134
- tests/test_summary.py +0 -65
- /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/{abCX3x3UoIdRLEDWxx4xd → nX-Uz0AH6Tc6hIQUFGqaB}/_ssgManifest.js +0 -0
- {recce_nightly-1.10.0.20250625.dist-info → recce_nightly-1.30.0.20251221.dist-info}/entry_points.txt +0 -0
- {recce_nightly-1.10.0.20250625.dist-info → recce_nightly-1.30.0.20251221.dist-info}/licenses/LICENSE +0 -0
recce/cli.py
CHANGED
|
@@ -8,7 +8,12 @@ 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
|
|
13
18
|
from recce.connect_to_cloud import (
|
|
14
19
|
generate_key_pair,
|
|
@@ -18,7 +23,13 @@ from recce.connect_to_cloud import (
|
|
|
18
23
|
from recce.exceptions import RecceConfigException
|
|
19
24
|
from recce.git import current_branch, current_default_branch
|
|
20
25
|
from recce.run import check_github_ci_env, cli_run
|
|
21
|
-
from recce.
|
|
26
|
+
from recce.server import RecceServerMode
|
|
27
|
+
from recce.state import (
|
|
28
|
+
CloudStateLoader,
|
|
29
|
+
FileStateLoader,
|
|
30
|
+
RecceCloudStateManager,
|
|
31
|
+
RecceShareStateManager,
|
|
32
|
+
)
|
|
22
33
|
from recce.summary import generate_markdown_summary
|
|
23
34
|
from recce.util.api_token import prepare_api_token, show_invalid_api_token_message
|
|
24
35
|
from recce.util.logger import CustomFormatter
|
|
@@ -26,6 +37,7 @@ from recce.util.onboarding_state import update_onboarding_state
|
|
|
26
37
|
from recce.util.recce_cloud import (
|
|
27
38
|
RecceCloudException,
|
|
28
39
|
)
|
|
40
|
+
from recce.util.startup_perf import track_timing
|
|
29
41
|
|
|
30
42
|
from .core import RecceContext, set_default_context
|
|
31
43
|
from .event.track import TrackCommand
|
|
@@ -39,9 +51,13 @@ def create_state_loader(review_mode, cloud_mode, state_file, cloud_options):
|
|
|
39
51
|
console = Console()
|
|
40
52
|
|
|
41
53
|
try:
|
|
42
|
-
|
|
43
|
-
review_mode=review_mode,
|
|
54
|
+
state_loader = (
|
|
55
|
+
CloudStateLoader(review_mode=review_mode, cloud_options=cloud_options)
|
|
56
|
+
if cloud_mode
|
|
57
|
+
else FileStateLoader(review_mode=review_mode, state_file=state_file)
|
|
44
58
|
)
|
|
59
|
+
state_loader.load()
|
|
60
|
+
return state_loader
|
|
45
61
|
except RecceCloudException as e:
|
|
46
62
|
console.print("[[red]Error[/red]] Failed to load recce state file")
|
|
47
63
|
console.print(f"Reason: {e.reason}")
|
|
@@ -52,6 +68,76 @@ def create_state_loader(review_mode, cloud_mode, state_file, cloud_options):
|
|
|
52
68
|
exit(1)
|
|
53
69
|
|
|
54
70
|
|
|
71
|
+
def patch_derived_args(args):
|
|
72
|
+
"""
|
|
73
|
+
Patch derived args based on other args.
|
|
74
|
+
"""
|
|
75
|
+
if args.get("session_id") or args.get("share_url"):
|
|
76
|
+
args["cloud"] = True
|
|
77
|
+
args["review"] = True
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
@track_timing("state_loader_init")
|
|
81
|
+
def create_state_loader_by_args(state_file=None, **kwargs):
|
|
82
|
+
"""
|
|
83
|
+
Create a state loader based on CLI arguments.
|
|
84
|
+
|
|
85
|
+
This function handles the cloud options logic that is shared between
|
|
86
|
+
server and mcp-server commands.
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
state_file: Optional path to state file
|
|
90
|
+
**kwargs: CLI arguments including api_token, cloud, review, session_id, share_url, etc.
|
|
91
|
+
|
|
92
|
+
Returns:
|
|
93
|
+
state_loader: The created state loader instance
|
|
94
|
+
"""
|
|
95
|
+
from rich.console import Console
|
|
96
|
+
|
|
97
|
+
console = Console()
|
|
98
|
+
|
|
99
|
+
api_token = kwargs.get("api_token")
|
|
100
|
+
is_review = kwargs.get("review", False)
|
|
101
|
+
is_cloud = kwargs.get("cloud", False)
|
|
102
|
+
cloud_options = None
|
|
103
|
+
|
|
104
|
+
# Handle share_url and session_id
|
|
105
|
+
share_url = kwargs.get("share_url")
|
|
106
|
+
session_id = kwargs.get("session_id")
|
|
107
|
+
|
|
108
|
+
if share_url:
|
|
109
|
+
share_id = share_url.split("/")[-1]
|
|
110
|
+
if not share_id:
|
|
111
|
+
console.print("[[red]Error[/red]] Invalid share URL format.")
|
|
112
|
+
exit(1)
|
|
113
|
+
|
|
114
|
+
if is_cloud:
|
|
115
|
+
# Cloud mode
|
|
116
|
+
if share_url:
|
|
117
|
+
cloud_options = {
|
|
118
|
+
"host": kwargs.get("state_file_host"),
|
|
119
|
+
"api_token": api_token,
|
|
120
|
+
"share_id": share_id,
|
|
121
|
+
}
|
|
122
|
+
elif session_id:
|
|
123
|
+
cloud_options = {
|
|
124
|
+
"host": kwargs.get("state_file_host"),
|
|
125
|
+
"api_token": api_token,
|
|
126
|
+
"session_id": session_id,
|
|
127
|
+
}
|
|
128
|
+
else:
|
|
129
|
+
cloud_options = {
|
|
130
|
+
"host": kwargs.get("state_file_host"),
|
|
131
|
+
"github_token": kwargs.get("cloud_token"),
|
|
132
|
+
"password": kwargs.get("password"),
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
# Create state loader
|
|
136
|
+
state_loader = create_state_loader(is_review, is_cloud, state_file, cloud_options)
|
|
137
|
+
|
|
138
|
+
return state_loader
|
|
139
|
+
|
|
140
|
+
|
|
55
141
|
def handle_debug_flag(**kwargs):
|
|
56
142
|
if kwargs.get("debug"):
|
|
57
143
|
import logging
|
|
@@ -60,6 +146,14 @@ def handle_debug_flag(**kwargs):
|
|
|
60
146
|
ch.setFormatter(CustomFormatter())
|
|
61
147
|
logging.basicConfig(handlers=[ch], level=logging.DEBUG)
|
|
62
148
|
|
|
149
|
+
# Explicitly set uvicorn logger to DEBUG level
|
|
150
|
+
uvicorn_logger = logging.getLogger("uvicorn")
|
|
151
|
+
uvicorn_logger.setLevel(logging.DEBUG)
|
|
152
|
+
|
|
153
|
+
# Set all child loggers to DEBUG as well
|
|
154
|
+
for handler in uvicorn_logger.handlers:
|
|
155
|
+
handler.setLevel(logging.DEBUG)
|
|
156
|
+
|
|
63
157
|
|
|
64
158
|
def add_options(options):
|
|
65
159
|
def _add_options(func):
|
|
@@ -129,6 +223,15 @@ recce_cloud_options = [
|
|
|
129
223
|
),
|
|
130
224
|
]
|
|
131
225
|
|
|
226
|
+
recce_cloud_auth_options = [
|
|
227
|
+
click.option(
|
|
228
|
+
"--api-token",
|
|
229
|
+
help="The personal token generated by Recce Cloud.",
|
|
230
|
+
type=click.STRING,
|
|
231
|
+
envvar="RECCE_API_TOKEN",
|
|
232
|
+
)
|
|
233
|
+
]
|
|
234
|
+
|
|
132
235
|
recce_dbt_artifact_dir_options = [
|
|
133
236
|
click.option(
|
|
134
237
|
"--target-path",
|
|
@@ -144,6 +247,29 @@ recce_dbt_artifact_dir_options = [
|
|
|
144
247
|
),
|
|
145
248
|
]
|
|
146
249
|
|
|
250
|
+
recce_hidden_options = [
|
|
251
|
+
click.option(
|
|
252
|
+
"--mode",
|
|
253
|
+
envvar="RECCE_SERVER_MODE",
|
|
254
|
+
type=click.Choice(RecceServerMode.available_members(), case_sensitive=False),
|
|
255
|
+
hidden=True,
|
|
256
|
+
),
|
|
257
|
+
click.option(
|
|
258
|
+
"--share-url",
|
|
259
|
+
help="The share URL triggers this instance.",
|
|
260
|
+
type=click.STRING,
|
|
261
|
+
envvar="RECCE_SHARE_URL",
|
|
262
|
+
hidden=True,
|
|
263
|
+
),
|
|
264
|
+
click.option(
|
|
265
|
+
"--session-id",
|
|
266
|
+
help="The session ID triggers this instance.",
|
|
267
|
+
type=click.STRING,
|
|
268
|
+
envvar=["RECCE_SESSION_ID", "RECCE_SNAPSHOT_ID"], # Backward compatibility with RECCE_SNAPSHOT_ID
|
|
269
|
+
hidden=True,
|
|
270
|
+
),
|
|
271
|
+
]
|
|
272
|
+
|
|
147
273
|
|
|
148
274
|
def _execute_sql(context, sql_template, base=False):
|
|
149
275
|
try:
|
|
@@ -228,8 +354,9 @@ def debug(**kwargs):
|
|
|
228
354
|
|
|
229
355
|
return [True, manifest_is_ready, catalog_is_ready]
|
|
230
356
|
|
|
231
|
-
|
|
232
|
-
|
|
357
|
+
project_dir_path = Path(kwargs.get("project_dir") or "./")
|
|
358
|
+
target_path = project_dir_path.joinpath(Path(kwargs.get("target_path", "target")))
|
|
359
|
+
target_base_path = project_dir_path.joinpath(Path(kwargs.get("target_base_path", "target-base")))
|
|
233
360
|
|
|
234
361
|
curr_is_ready = check_artifacts("Development", target_path)
|
|
235
362
|
base_is_ready = check_artifacts("Base", target_base_path)
|
|
@@ -353,17 +480,23 @@ def diff(sql, primary_keys: List[str] = None, keep_shape: bool = False, keep_equ
|
|
|
353
480
|
@click.option("--host", default="localhost", show_default=True, help="The host to bind to.")
|
|
354
481
|
@click.option("--port", default=8000, show_default=True, help="The port to bind to.", type=int)
|
|
355
482
|
@click.option("--lifetime", default=0, show_default=True, help="The lifetime of the server in seconds.", type=int)
|
|
356
|
-
@click.option("--review", is_flag=True, help="Open the state file in the review mode.")
|
|
357
|
-
@click.option("--single-env", is_flag=True, help="Launch in single environment mode directly.")
|
|
358
483
|
@click.option(
|
|
359
|
-
"--
|
|
484
|
+
"--idle-timeout",
|
|
485
|
+
default=0,
|
|
486
|
+
show_default=True,
|
|
487
|
+
help="The idle timeout in seconds. If 0, idle timeout is disabled. Maximum value is capped by lifetime.",
|
|
488
|
+
type=int,
|
|
360
489
|
)
|
|
490
|
+
@click.option("--review", is_flag=True, help="Open the state file in the review mode.")
|
|
491
|
+
@click.option("--single-env", is_flag=True, help="Launch in single environment mode directly.")
|
|
361
492
|
@add_options(dbt_related_options)
|
|
362
493
|
@add_options(sqlmesh_related_options)
|
|
363
494
|
@add_options(recce_options)
|
|
364
495
|
@add_options(recce_dbt_artifact_dir_options)
|
|
365
496
|
@add_options(recce_cloud_options)
|
|
366
|
-
|
|
497
|
+
@add_options(recce_cloud_auth_options)
|
|
498
|
+
@add_options(recce_hidden_options)
|
|
499
|
+
def server(host, port, lifetime, idle_timeout=0, state_file=None, **kwargs):
|
|
367
500
|
"""
|
|
368
501
|
Launch the recce server
|
|
369
502
|
|
|
@@ -384,7 +517,8 @@ def server(host, port, lifetime, state_file=None, **kwargs):
|
|
|
384
517
|
recce server --review recce_state.json
|
|
385
518
|
|
|
386
519
|
\b
|
|
387
|
-
# Launch the server
|
|
520
|
+
# Launch the server using the state from the PR of your current branch. (Requires GitHub token)
|
|
521
|
+
export GITHUB_TOKEN=<your-github-token>
|
|
388
522
|
recce server --cloud
|
|
389
523
|
recce server --review --cloud
|
|
390
524
|
|
|
@@ -397,39 +531,70 @@ def server(host, port, lifetime, state_file=None, **kwargs):
|
|
|
397
531
|
|
|
398
532
|
RecceConfig(config_file=kwargs.get("config"))
|
|
399
533
|
|
|
534
|
+
# Initialize startup performance tracking
|
|
535
|
+
from recce.util.startup_perf import StartupPerfTracker, set_startup_tracker
|
|
536
|
+
|
|
537
|
+
startup_tracker = StartupPerfTracker()
|
|
538
|
+
set_startup_tracker(startup_tracker)
|
|
539
|
+
|
|
400
540
|
handle_debug_flag(**kwargs)
|
|
541
|
+
patch_derived_args(kwargs)
|
|
542
|
+
|
|
543
|
+
server_mode = kwargs.get("mode") if kwargs.get("mode") else RecceServerMode.server
|
|
401
544
|
is_review = kwargs.get("review", False)
|
|
402
545
|
is_cloud = kwargs.get("cloud", False)
|
|
546
|
+
startup_tracker.set_cloud_mode(is_cloud)
|
|
547
|
+
flag = {
|
|
548
|
+
"single_env_onboarding": False,
|
|
549
|
+
"show_relaunch_hint": False,
|
|
550
|
+
"preview": False,
|
|
551
|
+
"read_only": False,
|
|
552
|
+
}
|
|
403
553
|
console = Console()
|
|
404
|
-
cloud_options = None
|
|
405
|
-
flag = {"single_env_onboarding": False, "show_relaunch_hint": False}
|
|
406
|
-
if is_cloud:
|
|
407
|
-
cloud_options = {
|
|
408
|
-
"host": kwargs.get("state_file_host"),
|
|
409
|
-
"token": kwargs.get("cloud_token"),
|
|
410
|
-
"password": kwargs.get("password"),
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
# Check Single Environment Onboarding Mode if the review mode is False
|
|
414
|
-
if not Path(kwargs.get("target_base_path", "target-base")).is_dir() and not is_review:
|
|
415
|
-
# Mark as single env onboarding mode if user provides the target-path only
|
|
416
|
-
flag["single_env_onboarding"] = True
|
|
417
|
-
flag["show_relaunch_hint"] = True
|
|
418
|
-
# Use the target path as the base path
|
|
419
|
-
kwargs["target_base_path"] = kwargs.get("target_path")
|
|
420
554
|
|
|
421
|
-
|
|
555
|
+
# Prepare API token
|
|
422
556
|
try:
|
|
423
557
|
api_token = prepare_api_token(**kwargs)
|
|
558
|
+
kwargs["api_token"] = api_token
|
|
424
559
|
except RecceConfigException:
|
|
425
560
|
show_invalid_api_token_message()
|
|
426
561
|
exit(1)
|
|
427
|
-
auth_options
|
|
562
|
+
auth_options = {
|
|
563
|
+
"api_token": api_token,
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
# Check Single Environment Onboarding Mode if not in cloud mode and not in review mode
|
|
567
|
+
if not is_cloud and not is_review:
|
|
568
|
+
project_dir_path = Path(kwargs.get("project_dir") or "./")
|
|
569
|
+
target_base_path = project_dir_path.joinpath(Path(kwargs.get("target_base_path", "target-base")))
|
|
570
|
+
if not target_base_path.is_dir():
|
|
571
|
+
# Mark as single env onboarding mode if user provides the target-path only
|
|
572
|
+
flag["single_env_onboarding"] = True
|
|
573
|
+
flag["show_relaunch_hint"] = True
|
|
574
|
+
# Use the target path as the base path
|
|
575
|
+
kwargs["target_base_path"] = kwargs.get("target_path")
|
|
576
|
+
|
|
577
|
+
# Server mode:
|
|
578
|
+
#
|
|
579
|
+
# It's used to determine the features disabled in the Web UI. Only used in the cloud-managed recce instances.
|
|
580
|
+
#
|
|
581
|
+
# Read-Only: No run query, no checklist
|
|
582
|
+
# Preview (Metadata-Only): No run query
|
|
583
|
+
if server_mode == RecceServerMode.preview:
|
|
584
|
+
flag["preview"] = True
|
|
585
|
+
elif server_mode == RecceServerMode.read_only:
|
|
586
|
+
flag["read_only"] = True
|
|
428
587
|
|
|
429
588
|
# Onboarding State logic update here
|
|
430
|
-
update_onboarding_state(api_token, flag
|
|
589
|
+
update_onboarding_state(api_token, flag.get("single_env_onboarding"))
|
|
431
590
|
|
|
432
|
-
|
|
591
|
+
# Create state loader using shared function
|
|
592
|
+
from recce.util.startup_perf import get_startup_tracker
|
|
593
|
+
|
|
594
|
+
state_loader = create_state_loader_by_args(state_file, **kwargs)
|
|
595
|
+
|
|
596
|
+
if (tracker := get_startup_tracker()) and hasattr(state_loader, "catalog"):
|
|
597
|
+
tracker.set_catalog_type(state_loader.catalog)
|
|
433
598
|
|
|
434
599
|
if not state_loader.verify():
|
|
435
600
|
error, hint = state_loader.error_and_hint
|
|
@@ -449,9 +614,9 @@ def server(host, port, lifetime, state_file=None, **kwargs):
|
|
|
449
614
|
console.print(f"[[red]Error[/red]] {message}")
|
|
450
615
|
exit(1)
|
|
451
616
|
|
|
452
|
-
if state_loader.review_mode
|
|
617
|
+
if state_loader.review_mode:
|
|
453
618
|
console.rule("Recce Server : Review Mode")
|
|
454
|
-
elif flag
|
|
619
|
+
elif flag.get("single_env_onboarding"):
|
|
455
620
|
# Show warning message
|
|
456
621
|
console.rule("Notice", style="orange3")
|
|
457
622
|
console.print(
|
|
@@ -471,16 +636,39 @@ def server(host, port, lifetime, state_file=None, **kwargs):
|
|
|
471
636
|
else:
|
|
472
637
|
console.rule("Recce Server")
|
|
473
638
|
|
|
639
|
+
# Validate idle_timeout: cap at lifetime if it exceeds lifetime
|
|
640
|
+
if idle_timeout > 0:
|
|
641
|
+
# If lifetime is set (> 0) and idle_timeout exceeds it, cap to lifetime
|
|
642
|
+
if lifetime > 0 and idle_timeout > lifetime:
|
|
643
|
+
effective_idle_timeout = lifetime
|
|
644
|
+
console.print(
|
|
645
|
+
f"[[yellow]Warning[/yellow]] idle_timeout ({idle_timeout}s) exceeds lifetime ({lifetime}s). "
|
|
646
|
+
f"Capping idle_timeout to {effective_idle_timeout}s."
|
|
647
|
+
)
|
|
648
|
+
else:
|
|
649
|
+
# Use idle_timeout as-is (either lifetime is 0, or idle_timeout <= lifetime)
|
|
650
|
+
effective_idle_timeout = idle_timeout
|
|
651
|
+
else:
|
|
652
|
+
# idle_timeout is 0 or negative, disable idle timeout
|
|
653
|
+
effective_idle_timeout = 0
|
|
654
|
+
|
|
474
655
|
state = AppState(
|
|
475
|
-
command=
|
|
656
|
+
command=server_mode,
|
|
476
657
|
state_loader=state_loader,
|
|
477
658
|
kwargs=kwargs,
|
|
478
659
|
flag=flag,
|
|
479
660
|
auth_options=auth_options,
|
|
480
661
|
lifetime=lifetime,
|
|
662
|
+
idle_timeout=effective_idle_timeout,
|
|
663
|
+
share_url=kwargs.get("share_url"),
|
|
664
|
+
organization_name=os.environ.get("RECCE_SESSION_ORGANIZATION_NAME"),
|
|
665
|
+
web_url=os.environ.get("RECCE_CLOUD_WEB_URL"),
|
|
481
666
|
)
|
|
482
667
|
app.state = state
|
|
483
668
|
|
|
669
|
+
if server_mode == RecceServerMode.read_only:
|
|
670
|
+
set_default_context(RecceContext.load(**kwargs, state_loader=state_loader))
|
|
671
|
+
|
|
484
672
|
uvicorn.run(app, host=host, port=port, lifespan="on")
|
|
485
673
|
|
|
486
674
|
|
|
@@ -499,6 +687,7 @@ DEFAULT_RECCE_STATE_FILE = "recce_state.json"
|
|
|
499
687
|
@click.option("--state-file", help="Path of the import state file.", type=click.Path())
|
|
500
688
|
@click.option("--summary", help="Path of the summary markdown file.", type=click.Path())
|
|
501
689
|
@click.option("--skip-query", is_flag=True, help="Skip running the queries for the checks.")
|
|
690
|
+
@click.option("--skip-check", is_flag=True, help="Skip running the checks.")
|
|
502
691
|
@click.option(
|
|
503
692
|
"--git-current-branch",
|
|
504
693
|
help="The git branch of the current environment.",
|
|
@@ -516,6 +705,8 @@ DEFAULT_RECCE_STATE_FILE = "recce_state.json"
|
|
|
516
705
|
@add_options(recce_options)
|
|
517
706
|
@add_options(recce_dbt_artifact_dir_options)
|
|
518
707
|
@add_options(recce_cloud_options)
|
|
708
|
+
@add_options(recce_cloud_auth_options)
|
|
709
|
+
@add_options(recce_hidden_options)
|
|
519
710
|
def run(output, **kwargs):
|
|
520
711
|
"""
|
|
521
712
|
Run recce and output the state file
|
|
@@ -546,21 +737,22 @@ def run(output, **kwargs):
|
|
|
546
737
|
# Initialize Recce Config
|
|
547
738
|
RecceConfig(config_file=kwargs.get("config"))
|
|
548
739
|
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
{
|
|
553
|
-
"host": kwargs.get("state_file_host"),
|
|
554
|
-
"token": kwargs.get("cloud_token"),
|
|
555
|
-
"password": kwargs.get("password"),
|
|
556
|
-
}
|
|
557
|
-
if cloud_mode
|
|
558
|
-
else None
|
|
559
|
-
)
|
|
740
|
+
patch_derived_args(kwargs)
|
|
741
|
+
# Remove share_url from kwargs to avoid affecting state loader creation
|
|
742
|
+
kwargs.pop("share_url", None)
|
|
560
743
|
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
744
|
+
state_file = kwargs.pop("state_file", None)
|
|
745
|
+
|
|
746
|
+
# Prepare API token
|
|
747
|
+
try:
|
|
748
|
+
api_token = prepare_api_token(**kwargs)
|
|
749
|
+
kwargs["api_token"] = api_token
|
|
750
|
+
except RecceConfigException:
|
|
751
|
+
show_invalid_api_token_message()
|
|
752
|
+
exit(1)
|
|
753
|
+
|
|
754
|
+
# Create state loader using shared function
|
|
755
|
+
state_loader = create_state_loader_by_args(state_file, **kwargs)
|
|
564
756
|
|
|
565
757
|
if not state_loader.verify():
|
|
566
758
|
error, hint = state_loader.error_and_hint
|
|
@@ -625,7 +817,7 @@ def summary(state_file, **kwargs):
|
|
|
625
817
|
cloud_options = (
|
|
626
818
|
{
|
|
627
819
|
"host": kwargs.get("state_file_host"),
|
|
628
|
-
"
|
|
820
|
+
"github_token": kwargs.get("cloud_token"),
|
|
629
821
|
"password": kwargs.get("password"),
|
|
630
822
|
}
|
|
631
823
|
if cloud_mode
|
|
@@ -714,14 +906,14 @@ def purge(**kwargs):
|
|
|
714
906
|
state_loader = None
|
|
715
907
|
cloud_options = {
|
|
716
908
|
"host": kwargs.get("state_file_host"),
|
|
717
|
-
"
|
|
909
|
+
"github_token": kwargs.get("cloud_token"),
|
|
718
910
|
"password": kwargs.get("password"),
|
|
719
911
|
}
|
|
720
912
|
force_to_purge = kwargs.get("force", False)
|
|
721
913
|
|
|
722
914
|
try:
|
|
723
915
|
console.rule("Check Recce State from Cloud")
|
|
724
|
-
state_loader =
|
|
916
|
+
state_loader = create_state_loader(
|
|
725
917
|
review_mode=False, cloud_mode=True, state_file=None, cloud_options=cloud_options
|
|
726
918
|
)
|
|
727
919
|
except Exception:
|
|
@@ -795,7 +987,7 @@ def upload(state_file, **kwargs):
|
|
|
795
987
|
handle_debug_flag(**kwargs)
|
|
796
988
|
cloud_options = {
|
|
797
989
|
"host": kwargs.get("state_file_host"),
|
|
798
|
-
"
|
|
990
|
+
"github_token": kwargs.get("cloud_token"),
|
|
799
991
|
"password": kwargs.get("password"),
|
|
800
992
|
}
|
|
801
993
|
|
|
@@ -864,7 +1056,7 @@ def download(**kwargs):
|
|
|
864
1056
|
filepath = kwargs.get("output")
|
|
865
1057
|
cloud_options = {
|
|
866
1058
|
"host": kwargs.get("state_file_host"),
|
|
867
|
-
"
|
|
1059
|
+
"github_token": kwargs.get("cloud_token"),
|
|
868
1060
|
"password": kwargs.get("password"),
|
|
869
1061
|
}
|
|
870
1062
|
|
|
@@ -1077,9 +1269,287 @@ def download_base_artifacts(**kwargs):
|
|
|
1077
1269
|
password = kwargs.get("password")
|
|
1078
1270
|
target_path = kwargs.get("target_path")
|
|
1079
1271
|
branch = kwargs.get("branch")
|
|
1272
|
+
# If recce can't infer default branch from "GITHUB_BASE_REF" and current_default_branch()
|
|
1273
|
+
if branch is None:
|
|
1274
|
+
console.print(
|
|
1275
|
+
"[[red]Error[/red]] Please provide your base branch name with '--branch' to download the base " "artifacts."
|
|
1276
|
+
)
|
|
1277
|
+
exit(1)
|
|
1278
|
+
|
|
1080
1279
|
return _download_artifacts(branch, cloud_token, console, kwargs, password, target_path)
|
|
1081
1280
|
|
|
1082
1281
|
|
|
1282
|
+
@cloud.command(cls=TrackCommand)
|
|
1283
|
+
@click.option("--cloud-token", help="The GitHub token used by Recce Cloud.", type=click.STRING, envvar="GITHUB_TOKEN")
|
|
1284
|
+
@click.option(
|
|
1285
|
+
"--branch",
|
|
1286
|
+
"-b",
|
|
1287
|
+
help="The branch to delete artifacts from.",
|
|
1288
|
+
type=click.STRING,
|
|
1289
|
+
envvar="GITHUB_HEAD_REF",
|
|
1290
|
+
default=current_branch(),
|
|
1291
|
+
show_default=True,
|
|
1292
|
+
)
|
|
1293
|
+
@click.option("--force", "-f", help="Bypasses the confirmation prompt. Delete the artifacts directly.", is_flag=True)
|
|
1294
|
+
@add_options(recce_options)
|
|
1295
|
+
def delete_artifacts(**kwargs):
|
|
1296
|
+
"""
|
|
1297
|
+
Delete the dbt artifacts from cloud
|
|
1298
|
+
|
|
1299
|
+
Delete the dbt artifacts (metadata.json, catalog.json) from Recce Cloud for the given branch.
|
|
1300
|
+
This will permanently remove the artifacts from the cloud storage.
|
|
1301
|
+
|
|
1302
|
+
By default, the artifacts are deleted from the current branch. You can specify the branch using the --branch option.
|
|
1303
|
+
"""
|
|
1304
|
+
from rich.console import Console
|
|
1305
|
+
|
|
1306
|
+
console = Console()
|
|
1307
|
+
cloud_token = kwargs.get("cloud_token")
|
|
1308
|
+
branch = kwargs.get("branch")
|
|
1309
|
+
force = kwargs.get("force", False)
|
|
1310
|
+
|
|
1311
|
+
if not force:
|
|
1312
|
+
if not click.confirm(f'Do you want to delete artifacts from branch "{branch}"?'):
|
|
1313
|
+
console.print("Deletion cancelled.")
|
|
1314
|
+
return 0
|
|
1315
|
+
|
|
1316
|
+
try:
|
|
1317
|
+
delete_dbt_artifacts(branch=branch, token=cloud_token, debug=kwargs.get("debug", False))
|
|
1318
|
+
console.print(f"[[green]Success[/green]] Artifacts deleted from branch: {branch}")
|
|
1319
|
+
return 0
|
|
1320
|
+
except click.exceptions.Abort:
|
|
1321
|
+
pass
|
|
1322
|
+
except RecceCloudException as e:
|
|
1323
|
+
console.print("[[red]Error[/red]] Failed to delete the dbt artifacts from cloud.")
|
|
1324
|
+
console.print(f"Reason: {e.reason}")
|
|
1325
|
+
exit(1)
|
|
1326
|
+
except Exception as e:
|
|
1327
|
+
console.print("[[red]Error[/red]] Failed to delete the dbt artifacts from cloud.")
|
|
1328
|
+
console.print(f"Reason: {e}")
|
|
1329
|
+
exit(1)
|
|
1330
|
+
|
|
1331
|
+
|
|
1332
|
+
@cloud.command(cls=TrackCommand, name="list-organizations")
|
|
1333
|
+
@click.option("--api-token", help="The Recce Cloud API token.", type=click.STRING, envvar="RECCE_API_TOKEN")
|
|
1334
|
+
@add_options(recce_options)
|
|
1335
|
+
def list_organizations(**kwargs):
|
|
1336
|
+
"""
|
|
1337
|
+
List organizations from Recce Cloud
|
|
1338
|
+
|
|
1339
|
+
Lists all organizations that the authenticated user has access to.
|
|
1340
|
+
"""
|
|
1341
|
+
from rich.console import Console
|
|
1342
|
+
from rich.table import Table
|
|
1343
|
+
|
|
1344
|
+
console = Console()
|
|
1345
|
+
handle_debug_flag(**kwargs)
|
|
1346
|
+
|
|
1347
|
+
try:
|
|
1348
|
+
api_token = prepare_api_token(**kwargs)
|
|
1349
|
+
except RecceConfigException:
|
|
1350
|
+
show_invalid_api_token_message()
|
|
1351
|
+
exit(1)
|
|
1352
|
+
|
|
1353
|
+
try:
|
|
1354
|
+
from recce.util.recce_cloud import RecceCloud
|
|
1355
|
+
|
|
1356
|
+
cloud = RecceCloud(api_token)
|
|
1357
|
+
organizations = cloud.list_organizations()
|
|
1358
|
+
|
|
1359
|
+
if not organizations:
|
|
1360
|
+
console.print("No organizations found.")
|
|
1361
|
+
return
|
|
1362
|
+
|
|
1363
|
+
table = Table(title="Organizations")
|
|
1364
|
+
table.add_column("ID", style="cyan")
|
|
1365
|
+
table.add_column("Name", style="green")
|
|
1366
|
+
table.add_column("Display Name", style="yellow")
|
|
1367
|
+
|
|
1368
|
+
for org in organizations:
|
|
1369
|
+
table.add_row(str(org.get("id", "")), org.get("name", ""), org.get("display_name", ""))
|
|
1370
|
+
|
|
1371
|
+
console.print(table)
|
|
1372
|
+
|
|
1373
|
+
except RecceCloudException as e:
|
|
1374
|
+
console.print(f"[[red]Error[/red]] {e}")
|
|
1375
|
+
exit(1)
|
|
1376
|
+
except Exception as e:
|
|
1377
|
+
console.print(f"[[red]Error[/red]] {e}")
|
|
1378
|
+
exit(1)
|
|
1379
|
+
|
|
1380
|
+
|
|
1381
|
+
@cloud.command(cls=TrackCommand, name="list-projects")
|
|
1382
|
+
@click.option(
|
|
1383
|
+
"--organization",
|
|
1384
|
+
"-o",
|
|
1385
|
+
help="Organization ID (can also be set via RECCE_ORGANIZATION_ID environment variable)",
|
|
1386
|
+
type=click.STRING,
|
|
1387
|
+
envvar="RECCE_ORGANIZATION_ID",
|
|
1388
|
+
)
|
|
1389
|
+
@click.option("--api-token", help="The Recce Cloud API token.", type=click.STRING, envvar="RECCE_API_TOKEN")
|
|
1390
|
+
@add_options(recce_options)
|
|
1391
|
+
def list_projects(**kwargs):
|
|
1392
|
+
"""
|
|
1393
|
+
List projects from Recce Cloud
|
|
1394
|
+
|
|
1395
|
+
Lists all projects in the specified organization that the authenticated user has access to.
|
|
1396
|
+
|
|
1397
|
+
Examples:
|
|
1398
|
+
|
|
1399
|
+
# Using environment variable
|
|
1400
|
+
export RECCE_ORGANIZATION_ID=8
|
|
1401
|
+
recce cloud list-projects
|
|
1402
|
+
|
|
1403
|
+
# Using command line argument
|
|
1404
|
+
recce cloud list-projects --organization 8
|
|
1405
|
+
|
|
1406
|
+
# Override environment variable
|
|
1407
|
+
export RECCE_ORGANIZATION_ID=8
|
|
1408
|
+
recce cloud list-projects --organization 10
|
|
1409
|
+
"""
|
|
1410
|
+
from rich.console import Console
|
|
1411
|
+
from rich.table import Table
|
|
1412
|
+
|
|
1413
|
+
console = Console()
|
|
1414
|
+
handle_debug_flag(**kwargs)
|
|
1415
|
+
|
|
1416
|
+
try:
|
|
1417
|
+
api_token = prepare_api_token(**kwargs)
|
|
1418
|
+
except RecceConfigException:
|
|
1419
|
+
show_invalid_api_token_message()
|
|
1420
|
+
exit(1)
|
|
1421
|
+
|
|
1422
|
+
organization = kwargs.get("organization")
|
|
1423
|
+
if not organization:
|
|
1424
|
+
console.print("[[red]Error[/red]] Organization ID is required. Please provide it via:")
|
|
1425
|
+
console.print(" --organization <id> or set RECCE_ORGANIZATION_ID environment variable")
|
|
1426
|
+
exit(1)
|
|
1427
|
+
|
|
1428
|
+
try:
|
|
1429
|
+
from recce.util.recce_cloud import RecceCloud
|
|
1430
|
+
|
|
1431
|
+
cloud = RecceCloud(api_token)
|
|
1432
|
+
projects = cloud.list_projects(organization)
|
|
1433
|
+
|
|
1434
|
+
if not projects:
|
|
1435
|
+
console.print(f"No projects found in organization {organization}.")
|
|
1436
|
+
return
|
|
1437
|
+
|
|
1438
|
+
table = Table(title=f"Projects in Organization {organization}")
|
|
1439
|
+
table.add_column("ID", style="cyan")
|
|
1440
|
+
table.add_column("Name", style="green")
|
|
1441
|
+
table.add_column("Display Name", style="yellow")
|
|
1442
|
+
|
|
1443
|
+
for project in projects:
|
|
1444
|
+
table.add_row(str(project.get("id", "")), project.get("name", ""), project.get("display_name", ""))
|
|
1445
|
+
|
|
1446
|
+
console.print(table)
|
|
1447
|
+
|
|
1448
|
+
except RecceCloudException as e:
|
|
1449
|
+
console.print(f"[[red]Error[/red]] {e}")
|
|
1450
|
+
exit(1)
|
|
1451
|
+
except Exception as e:
|
|
1452
|
+
console.print(f"[[red]Error[/red]] {e}")
|
|
1453
|
+
exit(1)
|
|
1454
|
+
|
|
1455
|
+
|
|
1456
|
+
@cloud.command(cls=TrackCommand, name="list-sessions")
|
|
1457
|
+
@click.option(
|
|
1458
|
+
"--organization",
|
|
1459
|
+
"-o",
|
|
1460
|
+
help="Organization ID (can also be set via RECCE_ORGANIZATION_ID environment variable)",
|
|
1461
|
+
type=click.STRING,
|
|
1462
|
+
envvar="RECCE_ORGANIZATION_ID",
|
|
1463
|
+
)
|
|
1464
|
+
@click.option(
|
|
1465
|
+
"--project",
|
|
1466
|
+
"-p",
|
|
1467
|
+
help="Project ID (can also be set via RECCE_PROJECT_ID environment variable)",
|
|
1468
|
+
type=click.STRING,
|
|
1469
|
+
envvar="RECCE_PROJECT_ID",
|
|
1470
|
+
)
|
|
1471
|
+
@click.option("--api-token", help="The Recce Cloud API token.", type=click.STRING, envvar="RECCE_API_TOKEN")
|
|
1472
|
+
@add_options(recce_options)
|
|
1473
|
+
def list_sessions(**kwargs):
|
|
1474
|
+
"""
|
|
1475
|
+
List sessions from Recce Cloud
|
|
1476
|
+
|
|
1477
|
+
Lists all sessions in the specified project that the authenticated user has access to.
|
|
1478
|
+
|
|
1479
|
+
Examples:
|
|
1480
|
+
|
|
1481
|
+
# Using environment variables
|
|
1482
|
+
export RECCE_ORGANIZATION_ID=8
|
|
1483
|
+
export RECCE_PROJECT_ID=7
|
|
1484
|
+
recce cloud list-sessions
|
|
1485
|
+
|
|
1486
|
+
# Using command line arguments
|
|
1487
|
+
recce cloud list-sessions --organization 8 --project 7
|
|
1488
|
+
|
|
1489
|
+
# Mixed usage (env + CLI override)
|
|
1490
|
+
export RECCE_ORGANIZATION_ID=8
|
|
1491
|
+
recce cloud list-sessions --project 7
|
|
1492
|
+
|
|
1493
|
+
# Override environment variables
|
|
1494
|
+
export RECCE_ORGANIZATION_ID=8
|
|
1495
|
+
export RECCE_PROJECT_ID=7
|
|
1496
|
+
recce cloud list-sessions --organization 10 --project 9
|
|
1497
|
+
"""
|
|
1498
|
+
from rich.console import Console
|
|
1499
|
+
from rich.table import Table
|
|
1500
|
+
|
|
1501
|
+
console = Console()
|
|
1502
|
+
handle_debug_flag(**kwargs)
|
|
1503
|
+
|
|
1504
|
+
try:
|
|
1505
|
+
api_token = prepare_api_token(**kwargs)
|
|
1506
|
+
except RecceConfigException:
|
|
1507
|
+
show_invalid_api_token_message()
|
|
1508
|
+
exit(1)
|
|
1509
|
+
|
|
1510
|
+
organization = kwargs.get("organization")
|
|
1511
|
+
project = kwargs.get("project")
|
|
1512
|
+
|
|
1513
|
+
# Validate required parameters
|
|
1514
|
+
if not organization:
|
|
1515
|
+
console.print("[[red]Error[/red]] Organization ID is required. Please provide it via:")
|
|
1516
|
+
console.print(" --organization <id> or set RECCE_ORGANIZATION_ID environment variable")
|
|
1517
|
+
exit(1)
|
|
1518
|
+
|
|
1519
|
+
if not project:
|
|
1520
|
+
console.print("[[red]Error[/red]] Project ID is required. Please provide it via:")
|
|
1521
|
+
console.print(" --project <id> or set RECCE_PROJECT_ID environment variable")
|
|
1522
|
+
exit(1)
|
|
1523
|
+
|
|
1524
|
+
try:
|
|
1525
|
+
from recce.util.recce_cloud import RecceCloud
|
|
1526
|
+
|
|
1527
|
+
cloud = RecceCloud(api_token)
|
|
1528
|
+
sessions = cloud.list_sessions(organization, project)
|
|
1529
|
+
|
|
1530
|
+
if not sessions:
|
|
1531
|
+
console.print(f"No sessions found in project {project}.")
|
|
1532
|
+
return
|
|
1533
|
+
|
|
1534
|
+
table = Table(title=f"Sessions in Project {project}")
|
|
1535
|
+
table.add_column("ID", style="cyan")
|
|
1536
|
+
table.add_column("Name", style="green")
|
|
1537
|
+
table.add_column("Is Base", style="yellow")
|
|
1538
|
+
|
|
1539
|
+
for session in sessions:
|
|
1540
|
+
is_base = "✓" if session.get("is_base", False) else ""
|
|
1541
|
+
table.add_row(session.get("id", ""), session.get("name", ""), is_base)
|
|
1542
|
+
|
|
1543
|
+
console.print(table)
|
|
1544
|
+
|
|
1545
|
+
except RecceCloudException as e:
|
|
1546
|
+
console.print(f"[[red]Error[/red]] {e}")
|
|
1547
|
+
exit(1)
|
|
1548
|
+
except Exception as e:
|
|
1549
|
+
console.print(f"[[red]Error[/red]] {e}")
|
|
1550
|
+
exit(1)
|
|
1551
|
+
|
|
1552
|
+
|
|
1083
1553
|
@cli.group("github", short_help="GitHub related commands", hidden=True)
|
|
1084
1554
|
def github(**kwargs):
|
|
1085
1555
|
pass
|
|
@@ -1109,7 +1579,10 @@ def artifact(**kwargs):
|
|
|
1109
1579
|
@cli.command(cls=TrackCommand)
|
|
1110
1580
|
@click.argument("state_file", type=click.Path(exists=True))
|
|
1111
1581
|
@click.option(
|
|
1112
|
-
"--api-token",
|
|
1582
|
+
"--api-token",
|
|
1583
|
+
help="The personal token generated by Recce Cloud.",
|
|
1584
|
+
type=click.STRING,
|
|
1585
|
+
envvar="RECCE_API_TOKEN",
|
|
1113
1586
|
)
|
|
1114
1587
|
def share(state_file, **kwargs):
|
|
1115
1588
|
"""
|
|
@@ -1167,49 +1640,199 @@ def share(state_file, **kwargs):
|
|
|
1167
1640
|
exit(1)
|
|
1168
1641
|
|
|
1169
1642
|
|
|
1643
|
+
snapshot_id_option = click.option(
|
|
1644
|
+
"--snapshot-id",
|
|
1645
|
+
help="The snapshot ID to upload artifacts to cloud.",
|
|
1646
|
+
type=click.STRING,
|
|
1647
|
+
envvar=["RECCE_SNAPSHOT_ID", "RECCE_SESSION_ID"],
|
|
1648
|
+
required=True,
|
|
1649
|
+
)
|
|
1650
|
+
|
|
1651
|
+
session_id_option = click.option(
|
|
1652
|
+
"--session-id",
|
|
1653
|
+
help="The session ID to upload artifacts to cloud.",
|
|
1654
|
+
type=click.STRING,
|
|
1655
|
+
envvar=["RECCE_SESSION_ID", "RECCE_SNAPSHOT_ID"],
|
|
1656
|
+
required=True,
|
|
1657
|
+
)
|
|
1658
|
+
|
|
1659
|
+
target_path_option = click.option(
|
|
1660
|
+
"--target-path",
|
|
1661
|
+
help="dbt artifacts directory for your artifacts.",
|
|
1662
|
+
type=click.STRING,
|
|
1663
|
+
default="target",
|
|
1664
|
+
show_default=True,
|
|
1665
|
+
)
|
|
1666
|
+
|
|
1667
|
+
|
|
1668
|
+
@cli.command(cls=TrackCommand, hidden=True)
|
|
1669
|
+
@add_options([session_id_option, target_path_option])
|
|
1670
|
+
@add_options(recce_cloud_auth_options)
|
|
1671
|
+
@add_options(recce_options)
|
|
1672
|
+
def upload_session(**kwargs):
|
|
1673
|
+
"""
|
|
1674
|
+
Upload target/manifest.json and target/catalog.json to the specific session ID
|
|
1675
|
+
|
|
1676
|
+
Upload the dbt artifacts (manifest.json, catalog.json) to Recce Cloud for the given session ID.
|
|
1677
|
+
This allows you to associate artifacts with a specific session for later use.
|
|
1678
|
+
|
|
1679
|
+
Examples:\n
|
|
1680
|
+
|
|
1681
|
+
\b
|
|
1682
|
+
# Upload artifacts to a session ID
|
|
1683
|
+
recce upload-session --session-id <session-id>
|
|
1684
|
+
|
|
1685
|
+
\b
|
|
1686
|
+
# Upload artifacts from custom target path to a session ID
|
|
1687
|
+
recce upload-session --session-id <session-id> --target-path my-target
|
|
1688
|
+
"""
|
|
1689
|
+
from rich.console import Console
|
|
1690
|
+
|
|
1691
|
+
console = Console()
|
|
1692
|
+
handle_debug_flag(**kwargs)
|
|
1693
|
+
|
|
1694
|
+
# Initialize Recce Config
|
|
1695
|
+
RecceConfig(config_file=kwargs.get("config"))
|
|
1696
|
+
|
|
1697
|
+
try:
|
|
1698
|
+
api_token = prepare_api_token(**kwargs)
|
|
1699
|
+
except RecceConfigException:
|
|
1700
|
+
show_invalid_api_token_message()
|
|
1701
|
+
exit(1)
|
|
1702
|
+
|
|
1703
|
+
session_id = kwargs.get("session_id")
|
|
1704
|
+
target_path = kwargs.get("target_path")
|
|
1705
|
+
|
|
1706
|
+
try:
|
|
1707
|
+
rc = upload_artifacts_to_session(
|
|
1708
|
+
target_path, session_id=session_id, token=api_token, debug=kwargs.get("debug", False)
|
|
1709
|
+
)
|
|
1710
|
+
console.rule("Uploaded Successfully")
|
|
1711
|
+
console.print(
|
|
1712
|
+
f'Uploaded dbt artifacts to Recce Cloud for session ID "{session_id}" from "{os.path.abspath(target_path)}"'
|
|
1713
|
+
)
|
|
1714
|
+
except Exception as e:
|
|
1715
|
+
console.rule("Failed to Upload Session", style="red")
|
|
1716
|
+
console.print(f"[[red]Error[/red]] Failed to upload the dbt artifacts to the session {session_id}.")
|
|
1717
|
+
console.print(f"Reason: {e}")
|
|
1718
|
+
rc = 1
|
|
1719
|
+
return rc
|
|
1720
|
+
|
|
1721
|
+
|
|
1722
|
+
# Backward compatibility for `recce snapshot` command
|
|
1723
|
+
@cli.command(
|
|
1724
|
+
cls=TrackCommand,
|
|
1725
|
+
hidden=True,
|
|
1726
|
+
deprecated=True,
|
|
1727
|
+
help="Upload target/manifest.json and target/catalog.json to the specific snapshot ID",
|
|
1728
|
+
)
|
|
1729
|
+
@add_options([snapshot_id_option, target_path_option])
|
|
1730
|
+
@add_options(recce_cloud_auth_options)
|
|
1731
|
+
@add_options(recce_options)
|
|
1732
|
+
def snapshot(**kwargs):
|
|
1733
|
+
kwargs["session_id"] = kwargs.get("snapshot_id")
|
|
1734
|
+
return upload_session(**kwargs)
|
|
1735
|
+
|
|
1736
|
+
|
|
1170
1737
|
@cli.command(hidden=True, cls=TrackCommand)
|
|
1171
1738
|
@click.argument("state_file", required=True)
|
|
1172
1739
|
@click.option("--host", default="localhost", show_default=True, help="The host to bind to.")
|
|
1173
1740
|
@click.option("--port", default=8000, show_default=True, help="The port to bind to.", type=int)
|
|
1174
1741
|
@click.option("--lifetime", default=0, show_default=True, help="The lifetime of the server in seconds.", type=int)
|
|
1175
1742
|
@click.option("--share-url", help="The share URL triggers this instance.", type=click.STRING, envvar="RECCE_SHARE_URL")
|
|
1176
|
-
|
|
1177
|
-
|
|
1743
|
+
@click.pass_context
|
|
1744
|
+
def read_only(ctx, state_file=None, **kwargs):
|
|
1745
|
+
# Invoke `recce server --mode read-only <state_file> ...
|
|
1746
|
+
kwargs["mode"] = RecceServerMode.read_only
|
|
1747
|
+
ctx.invoke(server, state_file=state_file, **kwargs)
|
|
1178
1748
|
|
|
1179
|
-
|
|
1749
|
+
|
|
1750
|
+
@cli.command(cls=TrackCommand)
|
|
1751
|
+
@click.option("--sse", is_flag=True, default=False, help="Start in HTTP/SSE mode instead of stdio mode")
|
|
1752
|
+
@click.option("--host", default="localhost", help="Host to bind to in SSE mode (default: localhost)")
|
|
1753
|
+
@click.option("--port", default=8000, type=int, help="Port to bind to in SSE mode (default: 8000)")
|
|
1754
|
+
@add_options(dbt_related_options)
|
|
1755
|
+
@add_options(sqlmesh_related_options)
|
|
1756
|
+
@add_options(recce_options)
|
|
1757
|
+
@add_options(recce_dbt_artifact_dir_options)
|
|
1758
|
+
@add_options(recce_cloud_options)
|
|
1759
|
+
@add_options(recce_cloud_auth_options)
|
|
1760
|
+
@add_options(recce_hidden_options)
|
|
1761
|
+
def mcp_server(sse, host, port, **kwargs):
|
|
1762
|
+
"""
|
|
1763
|
+
Start the Recce MCP (Model Context Protocol) server
|
|
1764
|
+
|
|
1765
|
+
The MCP server provides an interface for AI assistants and tools to interact
|
|
1766
|
+
with Recce's data validation capabilities. By default, it uses stdio for
|
|
1767
|
+
communication. Use --sse to enable HTTP/Server-Sent Events mode instead.
|
|
1768
|
+
|
|
1769
|
+
Examples:\n
|
|
1770
|
+
|
|
1771
|
+
\b
|
|
1772
|
+
# Start the MCP server in stdio mode (default)
|
|
1773
|
+
recce mcp-server
|
|
1774
|
+
|
|
1775
|
+
\b
|
|
1776
|
+
# Start in HTTP/SSE mode on default port 8000
|
|
1777
|
+
recce mcp-server --sse
|
|
1778
|
+
|
|
1779
|
+
\b
|
|
1780
|
+
# Start in HTTP/SSE mode with custom host and port
|
|
1781
|
+
recce mcp-server --sse --host 0.0.0.0 --port 9000
|
|
1782
|
+
|
|
1783
|
+
SSE Connection URL (when using --sse): http://<host>:<port>/sse
|
|
1784
|
+
"""
|
|
1785
|
+
from rich.console import Console
|
|
1180
1786
|
|
|
1181
1787
|
console = Console()
|
|
1788
|
+
try:
|
|
1789
|
+
# Import here to avoid import errors if mcp is not installed
|
|
1790
|
+
from recce.mcp_server import run_mcp_server
|
|
1791
|
+
except ImportError as e:
|
|
1792
|
+
console.print(f"[[red]Error[/red]] Failed to import MCP server: {e}")
|
|
1793
|
+
console.print(r"Please install the MCP package: pip install 'recce\[mcp]'")
|
|
1794
|
+
exit(1)
|
|
1795
|
+
|
|
1796
|
+
# Initialize Recce Config
|
|
1797
|
+
RecceConfig(config_file=kwargs.get("config"))
|
|
1798
|
+
|
|
1182
1799
|
handle_debug_flag(**kwargs)
|
|
1183
|
-
|
|
1184
|
-
is_cloud = False
|
|
1185
|
-
cloud_options = None
|
|
1186
|
-
flag = {
|
|
1187
|
-
"read_only": True,
|
|
1188
|
-
}
|
|
1189
|
-
state_loader = create_state_loader(is_review, is_cloud, state_file, cloud_options)
|
|
1800
|
+
patch_derived_args(kwargs)
|
|
1190
1801
|
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1802
|
+
# Prepare API token
|
|
1803
|
+
try:
|
|
1804
|
+
api_token = prepare_api_token(**kwargs)
|
|
1805
|
+
kwargs["api_token"] = api_token
|
|
1806
|
+
except RecceConfigException:
|
|
1807
|
+
show_invalid_api_token_message()
|
|
1195
1808
|
exit(1)
|
|
1196
1809
|
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1810
|
+
# Create state loader using shared function (if cloud mode is enabled)
|
|
1811
|
+
is_cloud = kwargs.get("cloud", False)
|
|
1812
|
+
if is_cloud:
|
|
1813
|
+
state_loader = create_state_loader_by_args(None, **kwargs)
|
|
1814
|
+
kwargs["state_loader"] = state_loader
|
|
1201
1815
|
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
share_url=kwargs.get("share_url"),
|
|
1209
|
-
)
|
|
1210
|
-
set_default_context(RecceContext.load(**kwargs, review=is_review, state_loader=state_loader))
|
|
1816
|
+
try:
|
|
1817
|
+
if sse:
|
|
1818
|
+
console.print(f"Starting Recce MCP Server in HTTP/SSE mode on {host}:{port}...")
|
|
1819
|
+
console.print(f"SSE endpoint: http://{host}:{port}/sse")
|
|
1820
|
+
else:
|
|
1821
|
+
console.print("Starting Recce MCP Server in stdio mode...")
|
|
1211
1822
|
|
|
1212
|
-
|
|
1823
|
+
# Run the server (stdio or SSE based on --sse flag)
|
|
1824
|
+
asyncio.run(run_mcp_server(sse=sse, host=host, port=port, **kwargs))
|
|
1825
|
+
except (asyncio.CancelledError, KeyboardInterrupt):
|
|
1826
|
+
# Graceful shutdown (e.g., Ctrl+C)
|
|
1827
|
+
console.print("[yellow]MCP Server interrupted[/yellow]")
|
|
1828
|
+
exit(0)
|
|
1829
|
+
except Exception as e:
|
|
1830
|
+
console.print(f"[[red]Error[/red]] Failed to start MCP server: {e}")
|
|
1831
|
+
if kwargs.get("debug"):
|
|
1832
|
+
import traceback
|
|
1833
|
+
|
|
1834
|
+
traceback.print_exc()
|
|
1835
|
+
exit(1)
|
|
1213
1836
|
|
|
1214
1837
|
|
|
1215
1838
|
if __name__ == "__main__":
|