tinybird 0.0.1.dev18__py3-none-any.whl → 0.0.1.dev20__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 tinybird might be problematic. Click here for more details.
- tinybird/client.py +24 -4
- tinybird/config.py +1 -1
- tinybird/feedback_manager.py +8 -30
- tinybird/tb/__cli__.py +8 -0
- tinybird/tb/modules/auth.py +1 -1
- tinybird/tb/modules/build.py +26 -80
- tinybird/tb/modules/cicd.py +1 -1
- tinybird/tb/modules/cli.py +11 -837
- tinybird/tb/modules/common.py +1 -55
- tinybird/tb/modules/connection.py +1 -1
- tinybird/tb/modules/create.py +18 -7
- tinybird/tb/modules/datafile/build.py +142 -971
- tinybird/tb/modules/datafile/build_common.py +1 -1
- tinybird/tb/modules/datafile/build_datasource.py +1 -1
- tinybird/tb/modules/datafile/build_pipe.py +1 -1
- tinybird/tb/modules/datafile/common.py +12 -11
- tinybird/tb/modules/datafile/diff.py +1 -1
- tinybird/tb/modules/datafile/fixture.py +1 -1
- tinybird/tb/modules/datafile/format_common.py +0 -7
- tinybird/tb/modules/datafile/format_datasource.py +0 -2
- tinybird/tb/modules/datafile/format_pipe.py +0 -2
- tinybird/tb/modules/datafile/parse_datasource.py +1 -1
- tinybird/tb/modules/datafile/parse_pipe.py +1 -1
- tinybird/tb/modules/datafile/pull.py +1 -1
- tinybird/tb/modules/datasource.py +4 -75
- tinybird/tb/modules/feedback_manager.py +1048 -0
- tinybird/tb/modules/fmt.py +1 -1
- tinybird/tb/modules/job.py +1 -1
- tinybird/tb/modules/llm.py +6 -4
- tinybird/tb/modules/local.py +26 -21
- tinybird/tb/modules/local_common.py +2 -1
- tinybird/tb/modules/login.py +18 -11
- tinybird/tb/modules/mock.py +18 -7
- tinybird/tb/modules/pipe.py +4 -126
- tinybird/tb/modules/{build_shell.py → shell.py} +66 -36
- tinybird/tb/modules/table.py +88 -5
- tinybird/tb/modules/tag.py +2 -2
- tinybird/tb/modules/test.py +45 -29
- tinybird/tb/modules/tinyunit/tinyunit.py +1 -1
- tinybird/tb/modules/token.py +2 -2
- tinybird/tb/modules/watch.py +72 -0
- tinybird/tb/modules/workspace.py +1 -1
- tinybird/tb/modules/workspace_members.py +1 -1
- {tinybird-0.0.1.dev18.dist-info → tinybird-0.0.1.dev20.dist-info}/METADATA +1 -1
- tinybird-0.0.1.dev20.dist-info/RECORD +76 -0
- tinybird-0.0.1.dev18.dist-info/RECORD +0 -73
- {tinybird-0.0.1.dev18.dist-info → tinybird-0.0.1.dev20.dist-info}/WHEEL +0 -0
- {tinybird-0.0.1.dev18.dist-info → tinybird-0.0.1.dev20.dist-info}/entry_points.txt +0 -0
- {tinybird-0.0.1.dev18.dist-info → tinybird-0.0.1.dev20.dist-info}/top_level.txt +0 -0
tinybird/tb/modules/fmt.py
CHANGED
|
@@ -7,13 +7,13 @@ import aiofiles
|
|
|
7
7
|
import click
|
|
8
8
|
from click import Context
|
|
9
9
|
|
|
10
|
-
from tinybird.feedback_manager import FeedbackManager
|
|
11
10
|
from tinybird.tb.modules.cli import cli
|
|
12
11
|
from tinybird.tb.modules.common import coro
|
|
13
12
|
from tinybird.tb.modules.datafile.common import is_file_a_datasource
|
|
14
13
|
from tinybird.tb.modules.datafile.diff import color_diff, peek
|
|
15
14
|
from tinybird.tb.modules.datafile.format_datasource import format_datasource
|
|
16
15
|
from tinybird.tb.modules.datafile.format_pipe import format_pipe
|
|
16
|
+
from tinybird.tb.modules.feedback_manager import FeedbackManager
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
@cli.command()
|
tinybird/tb/modules/job.py
CHANGED
|
@@ -7,10 +7,10 @@ import click
|
|
|
7
7
|
from click import Context
|
|
8
8
|
|
|
9
9
|
from tinybird.client import DoesNotExistException, TinyB
|
|
10
|
-
from tinybird.feedback_manager import FeedbackManager
|
|
11
10
|
from tinybird.tb.modules.cli import cli
|
|
12
11
|
from tinybird.tb.modules.common import coro, echo_safe_humanfriendly_tables_format_smart_table
|
|
13
12
|
from tinybird.tb.modules.exceptions import CLIException
|
|
13
|
+
from tinybird.tb.modules.feedback_manager import FeedbackManager
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
@cli.group()
|
tinybird/tb/modules/llm.py
CHANGED
|
@@ -37,7 +37,8 @@ class LLM:
|
|
|
37
37
|
self.client = client
|
|
38
38
|
user_token = CLIConfig.get_project_config().get_user_token()
|
|
39
39
|
user_client = deepcopy(client)
|
|
40
|
-
|
|
40
|
+
if user_token:
|
|
41
|
+
user_client.token = user_token
|
|
41
42
|
self.user_client = user_client
|
|
42
43
|
self.openai = OpenAI(api_key=api_key) if api_key else None
|
|
43
44
|
|
|
@@ -75,10 +76,11 @@ class LLM:
|
|
|
75
76
|
data=f'{{"schema": "{urllib.parse.quote(schema)}", "rows": {rows}, "context": "{prompt}"}}',
|
|
76
77
|
headers={"Content-Type": "application/json"},
|
|
77
78
|
)
|
|
78
|
-
|
|
79
|
+
result = response.get("result", "")
|
|
80
|
+
return result.replace("elementAt", "arrayElement")
|
|
79
81
|
|
|
80
82
|
async def create_test_commands(
|
|
81
|
-
self, pipe_content: str, pipe_params: set[str], context: str =
|
|
83
|
+
self, pipe_content: str, pipe_params: set[str], context: Optional[str] = None
|
|
82
84
|
) -> TestExpectations:
|
|
83
85
|
if not self.openai:
|
|
84
86
|
raise ValueError("OpenAI API key is not set")
|
|
@@ -86,7 +88,7 @@ class LLM:
|
|
|
86
88
|
completion = self.openai.beta.chat.completions.parse(
|
|
87
89
|
model="gpt-4o",
|
|
88
90
|
messages=[
|
|
89
|
-
{"role": "system", "content": create_test_calls_prompt.format(context=context)},
|
|
91
|
+
{"role": "system", "content": create_test_calls_prompt.format(context=context or "")},
|
|
90
92
|
{"role": "user", "content": f"Pipe content: {pipe_content}\nPipe params: {pipe_params}"},
|
|
91
93
|
],
|
|
92
94
|
temperature=0.2,
|
tinybird/tb/modules/local.py
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import os
|
|
2
|
+
import re
|
|
2
3
|
import time
|
|
3
4
|
|
|
4
5
|
import click
|
|
5
6
|
|
|
6
7
|
import docker
|
|
7
|
-
from tinybird.feedback_manager import FeedbackManager
|
|
8
8
|
from tinybird.tb.modules.cli import cli
|
|
9
9
|
from tinybird.tb.modules.common import coro
|
|
10
10
|
from tinybird.tb.modules.exceptions import CLIException
|
|
11
|
+
from tinybird.tb.modules.feedback_manager import FeedbackManager
|
|
11
12
|
from tinybird.tb.modules.local_common import TB_CONTAINER_NAME, TB_IMAGE_NAME, TB_LOCAL_PORT
|
|
12
13
|
|
|
13
14
|
|
|
@@ -28,9 +29,9 @@ def start_tinybird_local(
|
|
|
28
29
|
|
|
29
30
|
if (
|
|
30
31
|
pull_show_prompt
|
|
31
|
-
and click.prompt(FeedbackManager.
|
|
32
|
+
and click.prompt(FeedbackManager.warning(message="△ New version detected, download? [y/N]")).lower() == "y"
|
|
32
33
|
):
|
|
33
|
-
click.echo(FeedbackManager.info(message="
|
|
34
|
+
click.echo(FeedbackManager.info(message="* Downloading latest version of Tinybird Local..."))
|
|
34
35
|
pull_required = True
|
|
35
36
|
|
|
36
37
|
if pull_required:
|
|
@@ -57,7 +58,7 @@ def start_tinybird_local(
|
|
|
57
58
|
platform="linux/amd64",
|
|
58
59
|
)
|
|
59
60
|
|
|
60
|
-
click.echo(FeedbackManager.info(message="
|
|
61
|
+
click.echo(FeedbackManager.info(message="* Waiting for Tinybird Local to be ready..."))
|
|
61
62
|
for attempt in range(10):
|
|
62
63
|
try:
|
|
63
64
|
run = container.exec_run("tb --no-version-warning sql 'SELECT 1 AS healthcheck' --format json").output
|
|
@@ -68,16 +69,19 @@ def start_tinybird_local(
|
|
|
68
69
|
raise RuntimeError("Unexpected response from Tinybird")
|
|
69
70
|
except Exception:
|
|
70
71
|
if attempt == 9: # Last attempt
|
|
71
|
-
raise CLIException("Tinybird
|
|
72
|
+
raise CLIException("Tinybird Local not ready yet. Please try again in a few seconds.")
|
|
72
73
|
time.sleep(5) # Wait 5 seconds before retrying
|
|
73
74
|
|
|
74
|
-
|
|
75
|
+
# Remove tinybird-local dangling images to avoid running out of disk space
|
|
76
|
+
images = docker_client.images.list(name=re.sub(r":.*$", "", TB_IMAGE_NAME), all=True, filters={"dangling": True})
|
|
77
|
+
for image in images:
|
|
78
|
+
image.remove(force=True)
|
|
75
79
|
|
|
76
80
|
|
|
77
81
|
def get_docker_client():
|
|
78
82
|
"""Check if Docker is installed and running."""
|
|
79
83
|
try:
|
|
80
|
-
client = docker.from_env()
|
|
84
|
+
client = docker.from_env() # type: ignore
|
|
81
85
|
client.ping()
|
|
82
86
|
return client
|
|
83
87
|
except Exception:
|
|
@@ -105,9 +109,9 @@ def remove_tinybird_local(docker_client):
|
|
|
105
109
|
@cli.command()
|
|
106
110
|
def upgrade():
|
|
107
111
|
"""Upgrade Tinybird CLI to the latest version"""
|
|
108
|
-
click.echo(FeedbackManager.
|
|
112
|
+
click.echo(FeedbackManager.highlight(message="» Upgrading Tinybird CLI..."))
|
|
109
113
|
os.system(f"{os.getenv('HOME')}/.local/bin/uv tool upgrade tinybird")
|
|
110
|
-
click.echo(FeedbackManager.success(message="Tinybird CLI upgraded"))
|
|
114
|
+
click.echo(FeedbackManager.success(message="✓ Tinybird CLI upgraded"))
|
|
111
115
|
|
|
112
116
|
|
|
113
117
|
@cli.group()
|
|
@@ -119,39 +123,40 @@ def local(ctx):
|
|
|
119
123
|
@local.command()
|
|
120
124
|
@coro
|
|
121
125
|
async def stop() -> None:
|
|
122
|
-
"""Stop Tinybird
|
|
123
|
-
click.echo(FeedbackManager.
|
|
126
|
+
"""Stop Tinybird Local"""
|
|
127
|
+
click.echo(FeedbackManager.highlight(message="» Shutting down Tinybird Local..."))
|
|
124
128
|
docker_client = get_docker_client()
|
|
125
129
|
stop_tinybird_local(docker_client)
|
|
126
|
-
click.echo(FeedbackManager.success(message="Tinybird
|
|
130
|
+
click.echo(FeedbackManager.success(message="✓ Tinybird Local stopped"))
|
|
127
131
|
|
|
128
132
|
|
|
129
133
|
@local.command()
|
|
130
134
|
@coro
|
|
131
135
|
async def remove() -> None:
|
|
132
|
-
"""Remove Tinybird
|
|
133
|
-
click.echo(FeedbackManager.
|
|
136
|
+
"""Remove Tinybird Local"""
|
|
137
|
+
click.echo(FeedbackManager.highlight(message="» Removing Tinybird Local..."))
|
|
134
138
|
docker_client = get_docker_client()
|
|
135
139
|
remove_tinybird_local(docker_client)
|
|
136
|
-
click.echo(FeedbackManager.success(message="Tinybird
|
|
140
|
+
click.echo(FeedbackManager.success(message="✓ Tinybird Local removed"))
|
|
137
141
|
|
|
138
142
|
|
|
139
143
|
@local.command()
|
|
140
144
|
@coro
|
|
141
145
|
async def start() -> None:
|
|
142
|
-
"""Start Tinybird
|
|
143
|
-
click.echo(FeedbackManager.
|
|
146
|
+
"""Start Tinybird Local"""
|
|
147
|
+
click.echo(FeedbackManager.highlight(message="» Starting Tinybird Local..."))
|
|
144
148
|
docker_client = get_docker_client()
|
|
145
149
|
start_tinybird_local(docker_client)
|
|
146
|
-
click.echo(FeedbackManager.success(message="Tinybird
|
|
150
|
+
click.echo(FeedbackManager.success(message="✓ Tinybird Local is ready!"))
|
|
147
151
|
|
|
148
152
|
|
|
149
153
|
@local.command()
|
|
150
154
|
@coro
|
|
151
155
|
async def restart() -> None:
|
|
152
|
-
"""Restart Tinybird
|
|
153
|
-
click.echo(FeedbackManager.
|
|
156
|
+
"""Restart Tinybird Local"""
|
|
157
|
+
click.echo(FeedbackManager.highlight(message="» Restarting Tinybird Local..."))
|
|
154
158
|
docker_client = get_docker_client()
|
|
155
159
|
remove_tinybird_local(docker_client)
|
|
160
|
+
click.echo(FeedbackManager.info(message="✓ Tinybird Local stopped"))
|
|
156
161
|
start_tinybird_local(docker_client)
|
|
157
|
-
click.echo(FeedbackManager.success(message="Tinybird
|
|
162
|
+
click.echo(FeedbackManager.success(message="✓ Tinybird Local is ready!"))
|
|
@@ -8,7 +8,6 @@ from tinybird.client import TinyB
|
|
|
8
8
|
from tinybird.tb.modules.config import CLIConfig
|
|
9
9
|
from tinybird.tb.modules.exceptions import CLIException
|
|
10
10
|
|
|
11
|
-
# TODO: Use the official Tinybird image once it's available 'tinybirdco/tinybird-local:latest'
|
|
12
11
|
TB_IMAGE_NAME = "tinybirdco/tinybird-local:latest"
|
|
13
12
|
TB_CONTAINER_NAME = "tinybird-local"
|
|
14
13
|
TB_LOCAL_PORT = int(os.getenv("TB_LOCAL_PORT", 80))
|
|
@@ -40,6 +39,8 @@ async def get_tinybird_local_client(path: Optional[str] = None) -> TinyB:
|
|
|
40
39
|
await user_client.create_workspace(ws_name, template=None)
|
|
41
40
|
user_workspaces = await user_client.user_workspaces()
|
|
42
41
|
ws = next((ws for ws in user_workspaces["workspaces"] if ws["name"] == ws_name), None)
|
|
42
|
+
if not ws:
|
|
43
|
+
raise CLIException(f"Workspace {ws_name} not found after creation")
|
|
43
44
|
|
|
44
45
|
ws_token = ws["token"]
|
|
45
46
|
|
tinybird/tb/modules/login.py
CHANGED
|
@@ -9,8 +9,9 @@ from urllib.parse import urlencode
|
|
|
9
9
|
import click
|
|
10
10
|
import requests
|
|
11
11
|
|
|
12
|
-
from tinybird.feedback_manager import FeedbackManager
|
|
13
12
|
from tinybird.tb.modules.cli import CLIConfig, cli
|
|
13
|
+
from tinybird.tb.modules.common import coro
|
|
14
|
+
from tinybird.tb.modules.feedback_manager import FeedbackManager
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
class AuthHandler(http.server.SimpleHTTPRequestHandler):
|
|
@@ -74,7 +75,7 @@ class AuthHandler(http.server.SimpleHTTPRequestHandler):
|
|
|
74
75
|
|
|
75
76
|
if "token" in query_params:
|
|
76
77
|
token = query_params["token"][0]
|
|
77
|
-
self.server.auth_callback(token)
|
|
78
|
+
self.server.auth_callback(token) # type: ignore
|
|
78
79
|
self.send_response(200)
|
|
79
80
|
self.end_headers()
|
|
80
81
|
else:
|
|
@@ -115,11 +116,11 @@ def start_server(auth_callback):
|
|
|
115
116
|
"--workspace",
|
|
116
117
|
help="Set the workspace to authenticate to. If not set, the default workspace will be used.",
|
|
117
118
|
)
|
|
118
|
-
|
|
119
|
+
@coro
|
|
120
|
+
async def login(host: str, workspace: str):
|
|
119
121
|
"""Authenticate via browser."""
|
|
120
122
|
auth_event = threading.Event()
|
|
121
123
|
auth_code = [None] # Using a list to store the code, as it's mutable
|
|
122
|
-
config = CLIConfig.get_project_config()
|
|
123
124
|
host = host or "https://api.tinybird.co"
|
|
124
125
|
|
|
125
126
|
def auth_callback(code):
|
|
@@ -150,19 +151,25 @@ def login(host: str, workspace: str):
|
|
|
150
151
|
params = {}
|
|
151
152
|
if workspace:
|
|
152
153
|
params["workspace_id"] = workspace
|
|
153
|
-
response = requests.get(
|
|
154
|
+
response = requests.get( # noqa: ASYNC210
|
|
154
155
|
f"{host}/v0/user/tokens?{urlencode(params)}",
|
|
155
156
|
headers={"Authorization": f"Bearer {auth_code[0]}"},
|
|
156
157
|
)
|
|
158
|
+
|
|
157
159
|
data = response.json()
|
|
158
160
|
cli_config = CLIConfig.get_project_config()
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
cli_config.
|
|
162
|
-
cli_config.
|
|
163
|
-
|
|
164
|
-
|
|
161
|
+
cli_config.set_token(data.get("workspace_token", ""))
|
|
162
|
+
cli_config.set_token_for_host(data.get("workspace_token", ""), host)
|
|
163
|
+
cli_config.set_user_token(data.get("user_token", ""))
|
|
164
|
+
cli_config.set_host(host)
|
|
165
|
+
|
|
166
|
+
ws = await cli_config.get_client().workspace_info()
|
|
167
|
+
for k in ("id", "name", "user_email", "user_id", "scope"):
|
|
168
|
+
if k in ws:
|
|
169
|
+
cli_config[k] = ws[k]
|
|
170
|
+
|
|
165
171
|
cli_config.persist_to_file()
|
|
172
|
+
|
|
166
173
|
click.echo(FeedbackManager.success(message="✓ Authentication successful!"))
|
|
167
174
|
else:
|
|
168
175
|
click.echo(FeedbackManager.error(message="Authentication failed or timed out."))
|
tinybird/tb/modules/mock.py
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
import logging
|
|
1
2
|
import os
|
|
2
3
|
from pathlib import Path
|
|
3
4
|
|
|
4
5
|
import click
|
|
5
6
|
|
|
6
|
-
from tinybird.feedback_manager import FeedbackManager
|
|
7
7
|
from tinybird.tb.modules.cli import cli
|
|
8
|
-
from tinybird.tb.modules.common import CLIException, coro
|
|
8
|
+
from tinybird.tb.modules.common import CLIException, check_user_token, coro
|
|
9
9
|
from tinybird.tb.modules.config import CLIConfig
|
|
10
10
|
from tinybird.tb.modules.datafile.fixture import build_fixture_name, persist_fixture
|
|
11
|
+
from tinybird.tb.modules.feedback_manager import FeedbackManager
|
|
11
12
|
from tinybird.tb.modules.llm import LLM
|
|
12
13
|
from tinybird.tb.modules.local_common import get_tinybird_local_client
|
|
13
14
|
|
|
@@ -17,8 +18,9 @@ from tinybird.tb.modules.local_common import get_tinybird_local_client
|
|
|
17
18
|
@click.option("--rows", type=int, default=10, help="Number of events to send")
|
|
18
19
|
@click.option("--prompt", type=str, default="", help="Extra context to use for data generation")
|
|
19
20
|
@click.option("--folder", type=str, default=".", help="Folder where datafiles will be placed")
|
|
21
|
+
@click.pass_context
|
|
20
22
|
@coro
|
|
21
|
-
async def mock(datasource: str, rows: int, prompt: str, folder: str) -> None:
|
|
23
|
+
async def mock(ctx: click.Context, datasource: str, rows: int, prompt: str, folder: str) -> None:
|
|
22
24
|
"""Load sample data into a Data Source.
|
|
23
25
|
|
|
24
26
|
Args:
|
|
@@ -49,15 +51,24 @@ async def mock(datasource: str, rows: int, prompt: str, folder: str) -> None:
|
|
|
49
51
|
datasource_content = datasource_path.read_text()
|
|
50
52
|
config = CLIConfig.get_project_config()
|
|
51
53
|
user_client = config.get_client()
|
|
52
|
-
|
|
54
|
+
user_token = config.get_user_token()
|
|
55
|
+
|
|
56
|
+
try:
|
|
57
|
+
if not user_token:
|
|
58
|
+
raise CLIException("No user token found")
|
|
59
|
+
await check_user_token(ctx, token=user_token)
|
|
60
|
+
except Exception:
|
|
61
|
+
click.echo(FeedbackManager.error(message="This action requires authentication. Run 'tb login' first."))
|
|
62
|
+
return
|
|
63
|
+
|
|
53
64
|
llm = LLM(client=user_client)
|
|
54
65
|
tb_client = await get_tinybird_local_client(os.path.abspath(folder))
|
|
55
66
|
sql = await llm.generate_sql_sample_data(datasource_content, rows=rows, prompt=prompt)
|
|
56
|
-
if os.environ.get(
|
|
57
|
-
|
|
67
|
+
if os.environ.get("TB_DEBUG", "") != "":
|
|
68
|
+
logging.debug(sql)
|
|
58
69
|
result = await tb_client.query(f"{sql} FORMAT JSON")
|
|
59
70
|
data = result.get("data", [])[:rows]
|
|
60
|
-
fixture_name = build_fixture_name(datasource_path.absolute(), datasource_name, datasource_content)
|
|
71
|
+
fixture_name = build_fixture_name(datasource_path.absolute().as_posix(), datasource_name, datasource_content)
|
|
61
72
|
persist_fixture(fixture_name, data)
|
|
62
73
|
click.echo(FeedbackManager.success(message="✓ Done!"))
|
|
63
74
|
|
tinybird/tb/modules/pipe.py
CHANGED
|
@@ -13,10 +13,8 @@ import click
|
|
|
13
13
|
import humanfriendly
|
|
14
14
|
from click import Context
|
|
15
15
|
|
|
16
|
-
import tinybird.context as context
|
|
17
16
|
from tinybird.client import AuthNoTokenException, DoesNotExistException, TinyB
|
|
18
|
-
from tinybird.config import DEFAULT_API_HOST
|
|
19
|
-
from tinybird.feedback_manager import FeedbackManager
|
|
17
|
+
from tinybird.config import DEFAULT_API_HOST
|
|
20
18
|
from tinybird.tb.modules.cli import cli
|
|
21
19
|
from tinybird.tb.modules.common import (
|
|
22
20
|
coro,
|
|
@@ -24,12 +22,13 @@ from tinybird.tb.modules.common import (
|
|
|
24
22
|
echo_safe_humanfriendly_tables_format_smart_table,
|
|
25
23
|
wait_job,
|
|
26
24
|
)
|
|
27
|
-
from tinybird.tb.modules.datafile.build import
|
|
25
|
+
from tinybird.tb.modules.datafile.build import process_file
|
|
28
26
|
from tinybird.tb.modules.datafile.common import PipeNodeTypes, PipeTypes, get_name_version
|
|
29
27
|
from tinybird.tb.modules.exceptions import CLIPipeException
|
|
28
|
+
from tinybird.tb.modules.feedback_manager import FeedbackManager
|
|
30
29
|
|
|
31
30
|
|
|
32
|
-
@cli.group()
|
|
31
|
+
@cli.group(hidden=True)
|
|
33
32
|
@click.pass_context
|
|
34
33
|
def pipe(ctx):
|
|
35
34
|
"""Pipes commands"""
|
|
@@ -585,127 +584,6 @@ async def print_pipe(ctx: Context, pipe: str, query: str, format_: str):
|
|
|
585
584
|
click.echo(res)
|
|
586
585
|
|
|
587
586
|
|
|
588
|
-
@pipe.command(name="regression-test", short_help="Run regression tests using last requests")
|
|
589
|
-
@click.option(
|
|
590
|
-
"--debug",
|
|
591
|
-
is_flag=True,
|
|
592
|
-
default=False,
|
|
593
|
-
help="Prints internal representation, can be combined with any command to get more information.",
|
|
594
|
-
)
|
|
595
|
-
@click.option("--only-response-times", is_flag=True, default=False, help="Checks only response times")
|
|
596
|
-
@click.argument("filenames", type=click.Path(exists=True), nargs=-1, default=None)
|
|
597
|
-
@click.option("--workspace_map", nargs=2, type=str, multiple=True)
|
|
598
|
-
@click.option(
|
|
599
|
-
"--workspace",
|
|
600
|
-
nargs=2,
|
|
601
|
-
type=str,
|
|
602
|
-
multiple=True,
|
|
603
|
-
help="add a workspace path to the list of external workspaces, usage: --workspace name path/to/folder",
|
|
604
|
-
)
|
|
605
|
-
@click.option(
|
|
606
|
-
"--no-versions",
|
|
607
|
-
is_flag=True,
|
|
608
|
-
default=False,
|
|
609
|
-
help="when set, resource dependency versions are not used, it pushes the dependencies as-is",
|
|
610
|
-
)
|
|
611
|
-
@click.option(
|
|
612
|
-
"-l", "--limit", type=click.IntRange(0, 100), default=0, required=False, help="Number of requests to validate"
|
|
613
|
-
)
|
|
614
|
-
@click.option(
|
|
615
|
-
"--sample-by-params",
|
|
616
|
-
type=click.IntRange(1, 100),
|
|
617
|
-
default=1,
|
|
618
|
-
required=False,
|
|
619
|
-
help="When set, we will aggregate the pipe_stats_rt requests by extractURLParameterNames(assumeNotNull(url)) and for each combination we will take a sample of N requests",
|
|
620
|
-
)
|
|
621
|
-
@click.option(
|
|
622
|
-
"-m",
|
|
623
|
-
"--match",
|
|
624
|
-
multiple=True,
|
|
625
|
-
required=False,
|
|
626
|
-
help="Filter the checker requests by specific parameter. You can pass multiple parameters -m foo -m bar",
|
|
627
|
-
)
|
|
628
|
-
@click.option(
|
|
629
|
-
"-ff", "--failfast", is_flag=True, default=False, help="When set, the checker will exit as soon one test fails"
|
|
630
|
-
)
|
|
631
|
-
@click.option(
|
|
632
|
-
"--ignore-order", is_flag=True, default=False, help="When set, the checker will ignore the order of list properties"
|
|
633
|
-
)
|
|
634
|
-
@click.option(
|
|
635
|
-
"--validate-processed-bytes",
|
|
636
|
-
is_flag=True,
|
|
637
|
-
default=False,
|
|
638
|
-
help="When set, the checker will validate that the new version doesn't process more than 25% than the current version",
|
|
639
|
-
)
|
|
640
|
-
@click.option(
|
|
641
|
-
"--check-requests-from-main",
|
|
642
|
-
is_flag=True,
|
|
643
|
-
default=False,
|
|
644
|
-
help="When set, the checker will get Main Workspace requests",
|
|
645
|
-
hidden=True,
|
|
646
|
-
)
|
|
647
|
-
@click.option(
|
|
648
|
-
"--relative-change",
|
|
649
|
-
type=float,
|
|
650
|
-
default=0.01,
|
|
651
|
-
help="When set, the checker will validate the new version has less than this distance with the current version",
|
|
652
|
-
)
|
|
653
|
-
@click.pass_context
|
|
654
|
-
@coro
|
|
655
|
-
async def regression_test(
|
|
656
|
-
ctx: click.Context,
|
|
657
|
-
filenames: Optional[List[str]],
|
|
658
|
-
debug: bool,
|
|
659
|
-
only_response_times: bool,
|
|
660
|
-
workspace_map,
|
|
661
|
-
workspace: str,
|
|
662
|
-
no_versions: bool,
|
|
663
|
-
limit: int,
|
|
664
|
-
sample_by_params: int,
|
|
665
|
-
match: List[str],
|
|
666
|
-
failfast: bool,
|
|
667
|
-
ignore_order: bool,
|
|
668
|
-
validate_processed_bytes: bool,
|
|
669
|
-
check_requests_from_main: bool,
|
|
670
|
-
relative_change: float,
|
|
671
|
-
):
|
|
672
|
-
"""
|
|
673
|
-
Run regression tests on Tinybird
|
|
674
|
-
"""
|
|
675
|
-
|
|
676
|
-
ignore_sql_errors = FeatureFlags.ignore_sql_errors()
|
|
677
|
-
|
|
678
|
-
context.disable_template_security_validation.set(True)
|
|
679
|
-
await folder_push(
|
|
680
|
-
create_tb_client(ctx),
|
|
681
|
-
filenames,
|
|
682
|
-
dry_run=False,
|
|
683
|
-
check=True,
|
|
684
|
-
push_deps=False,
|
|
685
|
-
debug=debug,
|
|
686
|
-
force=False,
|
|
687
|
-
populate=False,
|
|
688
|
-
upload_fixtures=False,
|
|
689
|
-
wait=False,
|
|
690
|
-
ignore_sql_errors=ignore_sql_errors,
|
|
691
|
-
skip_confirmation=False,
|
|
692
|
-
only_response_times=only_response_times,
|
|
693
|
-
workspace_map=dict(workspace_map),
|
|
694
|
-
workspace_lib_paths=workspace,
|
|
695
|
-
no_versions=no_versions,
|
|
696
|
-
run_tests=True,
|
|
697
|
-
tests_to_run=limit,
|
|
698
|
-
tests_relative_change=relative_change,
|
|
699
|
-
tests_sample_by_params=sample_by_params,
|
|
700
|
-
tests_filter_by=match,
|
|
701
|
-
tests_failfast=failfast,
|
|
702
|
-
tests_ignore_order=ignore_order,
|
|
703
|
-
tests_validate_processed_bytes=validate_processed_bytes,
|
|
704
|
-
tests_check_requests_from_branch=check_requests_from_main,
|
|
705
|
-
)
|
|
706
|
-
return
|
|
707
|
-
|
|
708
|
-
|
|
709
587
|
@pipe_copy.command(name="run", short_help="Run an on-demand copy job")
|
|
710
588
|
@click.argument("pipe_name_or_id")
|
|
711
589
|
@click.option("--wait", is_flag=True, default=False, help="Wait for the copy job to finish")
|