tinybird 0.0.1.dev294__py3-none-any.whl → 0.0.1.dev296__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/ch_utils/constants.py +4 -0
- tinybird/tb/__cli__.py +2 -2
- tinybird/tb/modules/build.py +5 -3
- tinybird/tb/modules/build_common.py +51 -7
- tinybird/tb/modules/local_common.py +2 -1
- tinybird/tb/modules/test_common.py +7 -1
- tinybird/tb/modules/watch.py +5 -3
- {tinybird-0.0.1.dev294.dist-info → tinybird-0.0.1.dev296.dist-info}/METADATA +1 -1
- {tinybird-0.0.1.dev294.dist-info → tinybird-0.0.1.dev296.dist-info}/RECORD +12 -12
- {tinybird-0.0.1.dev294.dist-info → tinybird-0.0.1.dev296.dist-info}/WHEEL +0 -0
- {tinybird-0.0.1.dev294.dist-info → tinybird-0.0.1.dev296.dist-info}/entry_points.txt +0 -0
- {tinybird-0.0.1.dev294.dist-info → tinybird-0.0.1.dev296.dist-info}/top_level.txt +0 -0
tinybird/ch_utils/constants.py
CHANGED
tinybird/tb/__cli__.py
CHANGED
|
@@ -4,5 +4,5 @@ __description__ = 'Tinybird Command Line Tool'
|
|
|
4
4
|
__url__ = 'https://www.tinybird.co/docs/forward/commands'
|
|
5
5
|
__author__ = 'Tinybird'
|
|
6
6
|
__author_email__ = 'support@tinybird.co'
|
|
7
|
-
__version__ = '0.0.1.
|
|
8
|
-
__revision__ = '
|
|
7
|
+
__version__ = '0.0.1.dev296'
|
|
8
|
+
__revision__ = 'b2373b7'
|
tinybird/tb/modules/build.py
CHANGED
|
@@ -53,6 +53,7 @@ def build(ctx: click.Context, watch: bool) -> None:
|
|
|
53
53
|
run_watch(
|
|
54
54
|
project=project,
|
|
55
55
|
tb_client=tb_client,
|
|
56
|
+
config=config,
|
|
56
57
|
process=partial(process, project=project, tb_client=tb_client, watch=True, config=config),
|
|
57
58
|
)
|
|
58
59
|
|
|
@@ -81,16 +82,17 @@ def dev(ctx: click.Context, data_origin: str, ui: bool) -> None:
|
|
|
81
82
|
run_watch(
|
|
82
83
|
project=project,
|
|
83
84
|
tb_client=tb_client,
|
|
84
|
-
|
|
85
|
+
config=config,
|
|
86
|
+
process=partial(process, project=project, tb_client=tb_client, build_status=build_status, config=config),
|
|
85
87
|
)
|
|
86
88
|
|
|
87
89
|
|
|
88
|
-
def run_watch(project: Project, tb_client: TinyB, process: Callable) -> None:
|
|
90
|
+
def run_watch(project: Project, tb_client: TinyB, process: Callable, config: dict[str, Any]) -> None:
|
|
89
91
|
shell = Shell(project=project, tb_client=tb_client, playground=False)
|
|
90
92
|
click.echo(FeedbackManager.gray(message="\nWatching for changes..."))
|
|
91
93
|
watcher_thread = threading.Thread(
|
|
92
94
|
target=watch_project,
|
|
93
|
-
args=(shell, process, project),
|
|
95
|
+
args=(shell, process, project, config),
|
|
94
96
|
daemon=True,
|
|
95
97
|
)
|
|
96
98
|
watcher_thread.start()
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import json
|
|
2
2
|
import logging
|
|
3
|
+
import re
|
|
3
4
|
import time
|
|
4
5
|
from copy import deepcopy
|
|
5
6
|
from pathlib import Path
|
|
@@ -31,11 +32,14 @@ def process(
|
|
|
31
32
|
build_status: Optional[BuildStatus] = None,
|
|
32
33
|
exit_on_error: bool = True,
|
|
33
34
|
load_fixtures: bool = True,
|
|
35
|
+
project_with_vendors: Optional[Project] = None,
|
|
34
36
|
) -> Optional[str]:
|
|
35
37
|
time_start = time.time()
|
|
36
38
|
|
|
37
39
|
# Build vendored workspaces before build
|
|
38
|
-
|
|
40
|
+
if not project_with_vendors:
|
|
41
|
+
build_vendored_workspaces(project=project, tb_client=tb_client, config=config)
|
|
42
|
+
|
|
39
43
|
# Ensure SHARED_WITH workspaces exist before build
|
|
40
44
|
build_shared_with_workspaces(project=project, tb_client=tb_client, config=config)
|
|
41
45
|
|
|
@@ -63,7 +67,13 @@ def process(
|
|
|
63
67
|
build_status.error = None
|
|
64
68
|
else:
|
|
65
69
|
try:
|
|
66
|
-
build_result = build_project(
|
|
70
|
+
build_result = build_project(
|
|
71
|
+
project,
|
|
72
|
+
tb_client,
|
|
73
|
+
silent,
|
|
74
|
+
load_fixtures,
|
|
75
|
+
project_with_vendors=project_with_vendors,
|
|
76
|
+
)
|
|
67
77
|
if build_status:
|
|
68
78
|
build_status.building = False
|
|
69
79
|
build_status.error = None
|
|
@@ -192,7 +202,11 @@ def show_data(tb_client: TinyB, filename: str, diff: Optional[str] = None):
|
|
|
192
202
|
|
|
193
203
|
|
|
194
204
|
def build_project(
|
|
195
|
-
project: Project,
|
|
205
|
+
project: Project,
|
|
206
|
+
tb_client: TinyB,
|
|
207
|
+
silent: bool = False,
|
|
208
|
+
load_fixtures: bool = True,
|
|
209
|
+
project_with_vendors: Optional[Project] = None,
|
|
196
210
|
) -> Optional[bool]:
|
|
197
211
|
MULTIPART_BOUNDARY_DATA_PROJECT = "data_project://"
|
|
198
212
|
DATAFILE_TYPE_TO_CONTENT_TYPE = {
|
|
@@ -204,6 +218,7 @@ def build_project(
|
|
|
204
218
|
logging.debug(TINYBIRD_API_URL)
|
|
205
219
|
TINYBIRD_API_KEY = tb_client.token
|
|
206
220
|
error: Optional[str] = None
|
|
221
|
+
|
|
207
222
|
try:
|
|
208
223
|
files = [
|
|
209
224
|
("context://", ("cli-version", "1.0.0", "text/plain")),
|
|
@@ -218,9 +233,15 @@ def build_project(
|
|
|
218
233
|
relative_path = Path(file_path).relative_to(project_path).as_posix()
|
|
219
234
|
with open(file_path, "rb") as fd:
|
|
220
235
|
content_type = DATAFILE_TYPE_TO_CONTENT_TYPE.get(Path(file_path).suffix, "application/unknown")
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
236
|
+
content = fd.read().decode("utf-8")
|
|
237
|
+
if project_with_vendors:
|
|
238
|
+
# Replace 'SHARED_WITH' and everything that comes after, including new lines, with 'SHARED_WITH Tinybird_Local_Test_'
|
|
239
|
+
content = replace_shared_with(
|
|
240
|
+
content,
|
|
241
|
+
[project_with_vendors.workspace_name],
|
|
242
|
+
)
|
|
243
|
+
|
|
244
|
+
files.append((MULTIPART_BOUNDARY_DATA_PROJECT, (relative_path, content, content_type)))
|
|
224
245
|
HEADERS = {"Authorization": f"Bearer {TINYBIRD_API_KEY}"}
|
|
225
246
|
|
|
226
247
|
r = requests.post(TINYBIRD_API_URL, files=files, headers=HEADERS)
|
|
@@ -408,7 +429,8 @@ def build_vendored_workspaces(project: Project, tb_client: TinyB, config: dict[s
|
|
|
408
429
|
vendor_client = deepcopy(tb_client)
|
|
409
430
|
vendor_client.token = ws_token
|
|
410
431
|
vendor_project = Project(folder=str(ws_dir), workspace_name=workspace_name, max_depth=project.max_depth)
|
|
411
|
-
|
|
432
|
+
workspace_info = tb_client.workspace_info(version="v1")
|
|
433
|
+
project.workspace_name = workspace_info.get("name", "")
|
|
412
434
|
# Do not exit on error to allow main project to continue
|
|
413
435
|
process(
|
|
414
436
|
project=vendor_project,
|
|
@@ -418,6 +440,7 @@ def build_vendored_workspaces(project: Project, tb_client: TinyB, config: dict[s
|
|
|
418
440
|
exit_on_error=True,
|
|
419
441
|
load_fixtures=True,
|
|
420
442
|
config=config,
|
|
443
|
+
project_with_vendors=project,
|
|
421
444
|
)
|
|
422
445
|
except Exception as e:
|
|
423
446
|
# Never break the main build due to vendored build errors
|
|
@@ -459,3 +482,24 @@ def build_shared_with_workspaces(project: Project, tb_client: TinyB, config: dic
|
|
|
459
482
|
find_workspace_or_create(user_client, ws_name)
|
|
460
483
|
except Exception as e:
|
|
461
484
|
click.echo(FeedbackManager.error_exception(error=e))
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
def replace_shared_with(text: str, new_workspaces: list[str]) -> str:
|
|
488
|
+
replacement = ", ".join(new_workspaces)
|
|
489
|
+
|
|
490
|
+
# 1) Formato multilinea:
|
|
491
|
+
# SHARED_WITH >
|
|
492
|
+
# workspace1, workspace2
|
|
493
|
+
#
|
|
494
|
+
# Solo sustituimos la LÍNEA de workspaces (grupo 3), no usamos DOTALL.
|
|
495
|
+
pat_multiline = re.compile(r"(?m)^(SHARED_WITH\s*>\s*)\n([ \t]*)([^\n]*)$")
|
|
496
|
+
if pat_multiline.search(text):
|
|
497
|
+
return pat_multiline.sub(lambda m: f"{m.group(1)}\n{m.group(2)}{replacement}", text)
|
|
498
|
+
|
|
499
|
+
# 2) Formato inline:
|
|
500
|
+
# SHARED_WITH workspace1, workspace2
|
|
501
|
+
pat_inline = re.compile(r"(?m)^(SHARED_WITH\s+)([^\n]*)$")
|
|
502
|
+
if pat_inline.search(text):
|
|
503
|
+
return pat_inline.sub(lambda m: f"{m.group(1)}{replacement}", text)
|
|
504
|
+
|
|
505
|
+
return text
|
|
@@ -63,7 +63,8 @@ def get_tinybird_local_config(config_obj: Dict[str, Any], test: bool = False, si
|
|
|
63
63
|
).json()
|
|
64
64
|
local_workspaces = user_workspaces.get("workspaces", [])
|
|
65
65
|
for ws in local_workspaces:
|
|
66
|
-
|
|
66
|
+
is_test_workspace = ws["name"].startswith("Tinybird_Local_Test_")
|
|
67
|
+
if is_test_workspace:
|
|
67
68
|
requests.delete(
|
|
68
69
|
f"{TB_LOCAL_ADDRESS}/v1/workspaces/{ws['id']}?token={user_token}&hard_delete_confirmation=yes"
|
|
69
70
|
)
|
|
@@ -64,7 +64,13 @@ def create_test(
|
|
|
64
64
|
try:
|
|
65
65
|
click.echo(FeedbackManager.highlight(message="\n» Building test environment"))
|
|
66
66
|
build_error = build_project(
|
|
67
|
-
project=project,
|
|
67
|
+
project=project,
|
|
68
|
+
tb_client=client,
|
|
69
|
+
watch=False,
|
|
70
|
+
silent=True,
|
|
71
|
+
exit_on_error=False,
|
|
72
|
+
config=config,
|
|
73
|
+
load_fixtures=True,
|
|
68
74
|
)
|
|
69
75
|
if build_error:
|
|
70
76
|
raise Exception(build_error)
|
tinybird/tb/modules/watch.py
CHANGED
|
@@ -33,9 +33,10 @@ class WatchProjectHandler(PatternMatchingEventHandler):
|
|
|
33
33
|
".env.local",
|
|
34
34
|
]
|
|
35
35
|
|
|
36
|
-
def __init__(self, shell: Shell, project: Project, process: Callable):
|
|
36
|
+
def __init__(self, shell: Shell, project: Project, config: dict[str, Any], process: Callable):
|
|
37
37
|
self.shell = shell
|
|
38
38
|
self.project = project
|
|
39
|
+
self.config = config
|
|
39
40
|
self.process = process
|
|
40
41
|
self.datafiles = project.get_project_datafiles()
|
|
41
42
|
patterns = [f"**/*{ext}" for ext in self.valid_extensions]
|
|
@@ -58,7 +59,7 @@ class WatchProjectHandler(PatternMatchingEventHandler):
|
|
|
58
59
|
|
|
59
60
|
def _process(self, path: Optional[str] = None) -> None:
|
|
60
61
|
click.echo(FeedbackManager.highlight(message="» Rebuilding project..."))
|
|
61
|
-
self.process(watch=True, file_changed=path, diff=self.diff(path))
|
|
62
|
+
self.process(watch=True, file_changed=path, diff=self.diff(path), config=self.config)
|
|
62
63
|
self.shell.reprint_prompt()
|
|
63
64
|
|
|
64
65
|
def diff(self, path: Optional[str] = None) -> Optional[str]:
|
|
@@ -137,8 +138,9 @@ def watch_project(
|
|
|
137
138
|
shell: Shell,
|
|
138
139
|
process: Callable[[bool, Optional[str], Optional[str]], None],
|
|
139
140
|
project: Project,
|
|
141
|
+
config: dict[str, Any],
|
|
140
142
|
) -> None:
|
|
141
|
-
event_handler = WatchProjectHandler(shell=shell, project=project, process=process)
|
|
143
|
+
event_handler = WatchProjectHandler(shell=shell, project=project, process=process, config=config)
|
|
142
144
|
observer = Observer()
|
|
143
145
|
observer.schedule(event_handler, path=str(project.path), recursive=True)
|
|
144
146
|
observer.start()
|
|
@@ -11,20 +11,20 @@ tinybird/sql_template_fmt.py,sha256=KUHdj5rYCYm_rKKdXYSJAE9vIyXUQLB0YSZnUXHeBlY,
|
|
|
11
11
|
tinybird/sql_toolset.py,sha256=Y2_fQrbk5GSNoRncAmRS_snpV61XQbiOy4uYkeF6pr4,19767
|
|
12
12
|
tinybird/syncasync.py,sha256=IPnOx6lMbf9SNddN1eBtssg8vCLHMt76SuZ6YNYm-Yk,27761
|
|
13
13
|
tinybird/tornado_template.py,sha256=jjNVDMnkYFWXflmT8KU_Ssbo5vR8KQq3EJMk5vYgXRw,41959
|
|
14
|
-
tinybird/ch_utils/constants.py,sha256=
|
|
14
|
+
tinybird/ch_utils/constants.py,sha256=yTNizMzgYNBzUc2EV3moBfdrDIggOe9hiuAgWF7sv2c,4333
|
|
15
15
|
tinybird/ch_utils/engine.py,sha256=4X1B-iuhdW_mxKnX_m3iCsxgP9RPVgR75g7yH1vsJ6A,40851
|
|
16
16
|
tinybird/datafile/common.py,sha256=hr9Qv4Xot21l2dW6xKPa5_JUu8pnGuDNnVpDf8pgthc,105659
|
|
17
17
|
tinybird/datafile/exceptions.py,sha256=8rw2umdZjtby85QbuRKFO5ETz_eRHwUY5l7eHsy1wnI,556
|
|
18
18
|
tinybird/datafile/parse_connection.py,sha256=tRyn2Rpr1TeWet5BXmMoQgaotbGdYep1qiTak_OqC5E,1825
|
|
19
19
|
tinybird/datafile/parse_datasource.py,sha256=ssW8QeFSgglVFi3sDZj_HgkJiTJ2069v2JgqnH3CkDE,1825
|
|
20
20
|
tinybird/datafile/parse_pipe.py,sha256=8e9LMecSQVWHC4AXf8cdxoQ1nxUR4fTObYxTctO_EXQ,3816
|
|
21
|
-
tinybird/tb/__cli__.py,sha256=
|
|
21
|
+
tinybird/tb/__cli__.py,sha256=P2Ti-wEFHoOSwUBJ94hsFL-3YXmkiScFvoAVUOKFdZw,247
|
|
22
22
|
tinybird/tb/check_pypi.py,sha256=Gp0HkHHDFMSDL6nxKlOY51z7z1Uv-2LRexNTZSHHGmM,552
|
|
23
23
|
tinybird/tb/cli.py,sha256=FdDFEIayjmsZEVsVSSvRiVYn_FHOVg_zWQzchnzfWho,1008
|
|
24
24
|
tinybird/tb/client.py,sha256=IQRaInDjOwr9Fzaz3_xXc3aUGqh94tM2lew7IZbB9eM,53733
|
|
25
25
|
tinybird/tb/config.py,sha256=mhMTGnMB5KcxGoh3dewIr2Jjsa6pHE183gCPAQWyp6o,3973
|
|
26
|
-
tinybird/tb/modules/build.py,sha256
|
|
27
|
-
tinybird/tb/modules/build_common.py,sha256=
|
|
26
|
+
tinybird/tb/modules/build.py,sha256=vyhQyyDGLUHrJGdKoRy0gCc62vzZrRjtyzdXAJttYE4,7925
|
|
27
|
+
tinybird/tb/modules/build_common.py,sha256=w6UUXfr73EKjTCBqKgZxciMoL8HVwpg37gL4GXYKycw,20201
|
|
28
28
|
tinybird/tb/modules/cicd.py,sha256=0KLKccha9IP749QvlXBmzdWv1On3mFwMY4DUcJlBxiE,7326
|
|
29
29
|
tinybird/tb/modules/cli.py,sha256=-hkwg2ZIWPtldkLkgdY7RYWacOJtkMx58eqqYzMoMfw,17793
|
|
30
30
|
tinybird/tb/modules/common.py,sha256=zY0PFDQVWjhu2MivBtUmcXtAlv7imgO-RG_PUK37XvI,83659
|
|
@@ -46,7 +46,7 @@ tinybird/tb/modules/job.py,sha256=wBsnu8UPTOha2rkLvucgmw4xYv73ubmui3eeSIF68ZM,31
|
|
|
46
46
|
tinybird/tb/modules/llm.py,sha256=fPBBCmM3KlCksLlgJkg4joDn6y3H5QjDzE-Pm4YNf7E,1782
|
|
47
47
|
tinybird/tb/modules/llm_utils.py,sha256=nS9r4FAElJw8yXtmdYrx-rtI2zXR8qXfi1QqUDCfxvg,3469
|
|
48
48
|
tinybird/tb/modules/local.py,sha256=kW3IHwJPvhBsa1eMh_xzow9Az3yYpHthkzsLSHeP5HE,6512
|
|
49
|
-
tinybird/tb/modules/local_common.py,sha256=
|
|
49
|
+
tinybird/tb/modules/local_common.py,sha256=vHgFIH7cLNX6085iCls_grj_Dud_yRegr9Zia5Fgtgw,18528
|
|
50
50
|
tinybird/tb/modules/login.py,sha256=zerXZqIv15pbFk5XRt746xGcVnp01YmL_403byBf4jQ,1245
|
|
51
51
|
tinybird/tb/modules/login_common.py,sha256=CKXD_BjivhGUmBtNbLTJwzQDr6885C72XPZjo0GLLvI,12010
|
|
52
52
|
tinybird/tb/modules/logout.py,sha256=sniI4JNxpTrVeRCp0oGJuQ3yRerG4hH5uz6oBmjv724,1009
|
|
@@ -64,9 +64,9 @@ tinybird/tb/modules/sink.py,sha256=dK2s__my0ePIUYrqBzhPSgdWN9rbpvP1G4dT7DJzz80,3
|
|
|
64
64
|
tinybird/tb/modules/table.py,sha256=4XrtjM-N0zfNtxVkbvLDQQazno1EPXnxTyo7llivfXk,11035
|
|
65
65
|
tinybird/tb/modules/telemetry.py,sha256=T9gtsQffWqG_4hRBaUJPzOfMkPwz7mH-R6Bn1XRYViA,11482
|
|
66
66
|
tinybird/tb/modules/test.py,sha256=gi7fH6zavFp1jDs3SoRWdf9uBiKjp1hdOPAEleg7H-Y,2145
|
|
67
|
-
tinybird/tb/modules/test_common.py,sha256=
|
|
67
|
+
tinybird/tb/modules/test_common.py,sha256=501Fo6oDI-ZzJv8bqcLz7-6ulS8-FGViwi1tHq_A5h0,14766
|
|
68
68
|
tinybird/tb/modules/token.py,sha256=ZhW_o7XCr90wJRhMN6816vyo_TVfnzPXyIhrhzQ7oZ0,13807
|
|
69
|
-
tinybird/tb/modules/watch.py,sha256=
|
|
69
|
+
tinybird/tb/modules/watch.py,sha256=R0wERRyL-PrwxKOLSk-T-EvkIczHpeoGirrl3JZxXa8,8935
|
|
70
70
|
tinybird/tb/modules/workspace.py,sha256=tCP1zZMwBhLRGm22TGfpSd4cHvQLAS1o_azIXv_r6uw,11172
|
|
71
71
|
tinybird/tb/modules/workspace_members.py,sha256=5JdkJgfuEwbq-t6vxkBhYwgsiTDxF790wsa6Xfif9nk,8608
|
|
72
72
|
tinybird/tb/modules/agent/__init__.py,sha256=i3oe3vDIWWPaicdCM0zs7D7BJ1W0k7th93ooskHAV00,54
|
|
@@ -121,8 +121,8 @@ tinybird/tb_cli_modules/config.py,sha256=IsgdtFRnUrkY8-Zo32lmk6O7u3bHie1QCxLwgp4
|
|
|
121
121
|
tinybird/tb_cli_modules/exceptions.py,sha256=pmucP4kTF4irIt7dXiG-FcnI-o3mvDusPmch1L8RCWk,3367
|
|
122
122
|
tinybird/tb_cli_modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
|
|
123
123
|
tinybird/tb_cli_modules/telemetry.py,sha256=Hh2Io8ZPROSunbOLuMvuIFU4TqwWPmQTqal4WS09K1A,10449
|
|
124
|
-
tinybird-0.0.1.
|
|
125
|
-
tinybird-0.0.1.
|
|
126
|
-
tinybird-0.0.1.
|
|
127
|
-
tinybird-0.0.1.
|
|
128
|
-
tinybird-0.0.1.
|
|
124
|
+
tinybird-0.0.1.dev296.dist-info/METADATA,sha256=QzTIE7fRrhXS5qTEMjtIHQHsbVBXOcPk8BwDp7NFZzA,1845
|
|
125
|
+
tinybird-0.0.1.dev296.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
126
|
+
tinybird-0.0.1.dev296.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
|
|
127
|
+
tinybird-0.0.1.dev296.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
|
|
128
|
+
tinybird-0.0.1.dev296.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|