tinybird 0.0.1.dev63__py3-none-any.whl → 0.0.1.dev65__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/tb/__cli__.py CHANGED
@@ -4,5 +4,5 @@ __description__ = 'Tinybird Command Line Tool'
4
4
  __url__ = 'https://www.tinybird.co/docs/cli/introduction.html'
5
5
  __author__ = 'Tinybird'
6
6
  __author_email__ = 'support@tinybird.co'
7
- __version__ = '0.0.1.dev63'
8
- __revision__ = '4d0f19d'
7
+ __version__ = '0.0.1.dev65'
8
+ __revision__ = 'bb7c13c'
@@ -4,8 +4,9 @@ import logging
4
4
  import sys
5
5
  import threading
6
6
  import time
7
+ from functools import partial
7
8
  from pathlib import Path
8
- from typing import Optional
9
+ from typing import Callable, Optional
9
10
 
10
11
  import click
11
12
  import requests
@@ -31,9 +32,13 @@ def build(ctx: click.Context, watch: bool) -> None:
31
32
  project: Project = ctx.ensure_object(dict)["project"]
32
33
  tb_client: TinyB = ctx.ensure_object(dict)["client"]
33
34
  click.echo(FeedbackManager.highlight_building_project())
34
- process(project=project, tb_client=tb_client, watch=watch)
35
+ process(project=project, tb_client=tb_client, watch=False)
35
36
  if watch:
36
- run_watch(project=project, tb_client=tb_client)
37
+ run_watch(
38
+ project=project,
39
+ tb_client=tb_client,
40
+ process=partial(process, project=project, tb_client=tb_client, watch=True),
41
+ )
37
42
 
38
43
 
39
44
  @cli.command("dev", help="Build the project server side and watch for changes")
@@ -43,7 +48,7 @@ def dev(ctx: click.Context) -> None:
43
48
  tb_client: TinyB = ctx.ensure_object(dict)["client"]
44
49
  click.echo(FeedbackManager.highlight_building_project())
45
50
  process(project=project, tb_client=tb_client, watch=True)
46
- run_watch(project=project, tb_client=tb_client)
51
+ run_watch(project=project, tb_client=tb_client, process=partial(process, project=project, tb_client=tb_client))
47
52
 
48
53
 
49
54
  def build_project(project: Project, tb_client: TinyB, file_changed: Optional[str] = None) -> None:
@@ -55,7 +60,7 @@ def build_project(project: Project, tb_client: TinyB, file_changed: Optional[str
55
60
  TINYBIRD_API_URL = tb_client.host + "/v1/build"
56
61
  logging.debug(TINYBIRD_API_URL)
57
62
  TINYBIRD_API_KEY = tb_client.token
58
- error = False
63
+ error: Optional[str] = None
59
64
  try:
60
65
  files = [
61
66
  ("context://", ("cli-version", "1.0.0", "text/plain")),
@@ -129,22 +134,19 @@ def build_project(project: Project, tb_client: TinyB, file_changed: Optional[str
129
134
 
130
135
  elif build_result == "failed":
131
136
  build_errors = result.get("errors")
132
- error = True
133
137
  for build_error in build_errors:
134
138
  filename_bit = f"{build_error.get('filename', '')}"
135
139
  error_msg = ((filename_bit + "\n\n") if filename_bit else "") + build_error.get("error")
136
- click.echo(FeedbackManager.error(message=error_msg))
140
+ error = error_msg
137
141
  else:
138
- error = True
139
- click.echo(FeedbackManager.error(message=f"Unknown build result. Error: {result.get('error')}"))
140
-
142
+ error = f"Unknown build result. Error: {result.get('error')}"
141
143
  except Exception as e:
142
- click.echo(FeedbackManager.error_exception(error="Error: " + str(e)))
144
+ error = str(e)
143
145
  finally:
144
146
  for fd in fds:
145
147
  fd.close()
146
148
  if error:
147
- raise click.ClickException(FeedbackManager.error(message="Error: Build failed"))
149
+ raise click.ClickException(error)
148
150
 
149
151
 
150
152
  def append_fixture(
@@ -212,10 +214,10 @@ def process(
212
214
  try:
213
215
  build_project(project, tb_client, file_changed)
214
216
  except click.ClickException as e:
215
- click.echo(e)
217
+ click.echo(FeedbackManager.error(message=e))
216
218
  build_failed = True
217
219
  try:
218
- if file_changed:
220
+ if file_changed and not build_failed:
219
221
  asyncio.run(folder_build(project, tb_client, filenames=[file_changed]))
220
222
  show_data(tb_client, file_changed, diff)
221
223
  except Exception:
@@ -224,7 +226,7 @@ def process(
224
226
  time_end = time.time()
225
227
  elapsed_time = time_end - time_start
226
228
 
227
- rebuild_str = "Rebuild" if watch else "Build"
229
+ rebuild_str = "Rebuild" if watch and file_changed else "Build"
228
230
  if build_failed:
229
231
  click.echo(FeedbackManager.error(message=f"\n✗ {rebuild_str} failed"))
230
232
  if not watch:
@@ -233,7 +235,9 @@ def process(
233
235
  click.echo(FeedbackManager.success(message=f"\n✓ {rebuild_str} completed in {elapsed_time:.1f}s"))
234
236
 
235
237
 
236
- def run_watch(project: Project, tb_client: TinyB) -> None:
238
+ def run_watch(
239
+ project: Project, tb_client: TinyB, process: Callable[[bool, Optional[str], Optional[str]], None]
240
+ ) -> None:
237
241
  shell = Shell(project=project, tb_client=tb_client)
238
242
  click.echo(FeedbackManager.gray(message="\nWatching for changes..."))
239
243
  watcher_thread = threading.Thread(
@@ -269,7 +269,7 @@ async def endpoint_stats(ctx: click.Context, pipes: Tuple[str, ...], format_: st
269
269
  echo_safe_humanfriendly_tables_format_smart_table(table_human_readable, column_names=columns)
270
270
 
271
271
 
272
- def build_endpoint_snippet(tb_client: TinyB, pipe_name: str, token: Optional[str], language: str) -> Optional[str]:
272
+ def build_endpoint_snippet(tb_client: TinyB, pipe_name: str, token: str, language: str) -> Optional[str]:
273
273
  endpoint_url = build_endpoint_url(tb_client, pipe_name, token)
274
274
  if language == "http":
275
275
  return endpoint_url
@@ -282,9 +282,9 @@ def build_endpoint_snippet(tb_client: TinyB, pipe_name: str, token: Optional[str
282
282
  elif language == "javascript":
283
283
  snippet = build_javascript_snippet(endpoint_url, token)
284
284
  elif language == "rust":
285
- snippet = build_rust_snippet(endpoint_url, token)
285
+ snippet = build_rust_snippet(endpoint_url)
286
286
  elif language == "go":
287
- snippet = build_go_snippet(endpoint_url, token)
287
+ snippet = build_go_snippet(endpoint_url)
288
288
 
289
289
  if not snippet:
290
290
  raise CLIPipeException(FeedbackManager.error(message=f"Language {language} not supported"))
@@ -51,7 +51,7 @@ async def mock(ctx: click.Context, datasource: str, rows: int, prompt: str, skip
51
51
  if datasource_path.suffix == ".datasource":
52
52
  datasource_name = datasource_path.stem
53
53
  else:
54
- datasource_from_glob = glob.glob(f"**/*/{datasource}.datasource")
54
+ datasource_from_glob = glob.glob(f"{folder}/**/{datasource}.datasource")
55
55
  if datasource_from_glob:
56
56
  datasource_path = Path(datasource_from_glob[0])
57
57
 
@@ -249,11 +249,11 @@ class Shell:
249
249
  if cmd in ["exit", "quit"]:
250
250
  sys.exit(0)
251
251
  elif cmd == "build":
252
- self.handle_build(arg)
252
+ self.handle_build()
253
253
  elif cmd == "auth":
254
- self.handle_auth(arg)
254
+ self.handle_auth()
255
255
  elif cmd == "workspace":
256
- self.handle_workspace(arg)
256
+ self.handle_workspace()
257
257
  elif cmd == "mock":
258
258
  self.handle_mock(arg)
259
259
  elif cmd == "tb":
@@ -262,27 +262,30 @@ class Shell:
262
262
  # Check if it looks like a SQL query or run as a tb command
263
263
  self.default(line)
264
264
 
265
- def handle_build(self, arg):
266
- click.echo(FeedbackManager.error(message=f"'tb {arg}' command is not available in watch mode"))
265
+ def handle_build(self):
266
+ click.echo(FeedbackManager.error(message="'tb build' command is not available in watch mode"))
267
267
 
268
- def handle_auth(self, arg):
269
- click.echo(FeedbackManager.error(message=f"'tb {arg}' command is not available in watch mode"))
268
+ def handle_auth(self):
269
+ click.echo(FeedbackManager.error(message="'tb auth' command is not available in watch mode"))
270
270
 
271
- def handle_workspace(self, arg):
272
- click.echo(FeedbackManager.error(message=f"'tb {arg}' command is not available in watch mode"))
271
+ def handle_workspace(self):
272
+ click.echo(FeedbackManager.error(message="'tb workspace' command is not available in watch mode"))
273
273
 
274
274
  def handle_mock(self, arg):
275
+ arg = arg.strip().lower()
276
+ if "mock" in arg:
277
+ arg = arg.replace("mock", "")
275
278
  subprocess.run(f"tb --build mock {arg} --skip", shell=True, text=True)
276
279
 
277
280
  def handle_tb(self, arg):
278
281
  click.echo("")
279
282
  arg = arg.strip().lower()
280
283
  if arg.startswith("build"):
281
- self.handle_build(arg)
284
+ self.handle_build()
282
285
  elif arg.startswith("auth"):
283
- self.handle_auth(arg)
286
+ self.handle_auth()
284
287
  elif arg.startswith("workspace"):
285
- self.handle_workspace(arg)
288
+ self.handle_workspace()
286
289
  elif arg.startswith("mock"):
287
290
  self.handle_mock(arg)
288
291
  else:
@@ -18,12 +18,7 @@ from tinybird.tb.modules.shell import Shell
18
18
 
19
19
 
20
20
  class WatchProjectHandler(PatternMatchingEventHandler):
21
- def __init__(
22
- self,
23
- shell: Shell,
24
- project: Project,
25
- process: Callable[[bool, Optional[str], Optional[str]], None],
26
- ):
21
+ def __init__(self, shell: Shell, project: Project, process: Callable):
27
22
  self.shell = shell
28
23
  self.project = project
29
24
  self.process = process
@@ -51,7 +46,7 @@ class WatchProjectHandler(PatternMatchingEventHandler):
51
46
 
52
47
  def _process(self, path: Optional[str] = None) -> None:
53
48
  click.echo(FeedbackManager.highlight(message="» Rebuilding project..."))
54
- self.process(True, path, self.diff(path))
49
+ self.process(watch=True, file_changed=path, diff=self.diff(path))
55
50
  self.shell.reprint_prompt()
56
51
 
57
52
  def diff(self, path: Optional[str] = None) -> Optional[str]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tinybird
3
- Version: 0.0.1.dev63
3
+ Version: 0.0.1.dev65
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/cli/introduction.html
6
6
  Author: Tinybird
@@ -15,10 +15,10 @@ tinybird/syncasync.py,sha256=IPnOx6lMbf9SNddN1eBtssg8vCLHMt76SuZ6YNYm-Yk,27761
15
15
  tinybird/tornado_template.py,sha256=FL85SMPq2dH4JqKovmSbaolGdEzwOO91NqOzqXo2Qr0,41863
16
16
  tinybird/ch_utils/constants.py,sha256=aYvg2C_WxYWsnqPdZB1ZFoIr8ZY-XjUXYyHKE9Ansj0,3890
17
17
  tinybird/ch_utils/engine.py,sha256=OXkBhlzGjZotjD0vaT-rFIbSGV4tpiHxE8qO_ip0SyQ,40454
18
- tinybird/tb/__cli__.py,sha256=QktikNnLUbi0rxQxIzziq0Aaqu14iBSAtYvvVy79A8M,251
18
+ tinybird/tb/__cli__.py,sha256=fD49yxghhJjtdVUmPoEWjIta0RRP1hCf3gR6vBT8PB4,251
19
19
  tinybird/tb/cli.py,sha256=FD1pfbzu9YHJHEG6Vtn_EwPLTYhwqw-I6AxXeTaRHU8,926
20
20
  tinybird/tb/modules/auth.py,sha256=EzRWFmwRkXNhUmRaruEVFLdkbUg8xMSix0cAWl5D4Jg,9029
21
- tinybird/tb/modules/build.py,sha256=zo7qexonQ5vDNHZ1u7AK_jdo62hMfG5vWnoQBe_2oyw,9042
21
+ tinybird/tb/modules/build.py,sha256=UN1d7EZ93VOlPCrtsay-KLgZnzxn2NCBDY3wvrUSP1Q,9198
22
22
  tinybird/tb/modules/cicd.py,sha256=xxXwy-QekJcG14kkJeGNl7LkHduhZXfvBZE8WrU6-t4,5351
23
23
  tinybird/tb/modules/cli.py,sha256=oE1hMCQUxfp1m2r9k6y5LlNgvJCNJhwxfilJbUHp7dY,15914
24
24
  tinybird/tb/modules/common.py,sha256=TWcGJUgzJCQvzI1oMKbNdx-KTRmMGvB25BawHpsaV8Q,70610
@@ -27,7 +27,7 @@ tinybird/tb/modules/copy.py,sha256=Aq6wh_wjRiyLQtEOKF9pKLPgJhSvbGTFWIw_LJB0t0U,5
27
27
  tinybird/tb/modules/create.py,sha256=Q7ZY4oUmEtAYpUbBLjjyiUZ6IKlkU81qJJrmdgjduOk,13914
28
28
  tinybird/tb/modules/datasource.py,sha256=TQ4wSag3CCw34d54FEXPJFGLQNYyNqv2nQbU6QT9uAE,14725
29
29
  tinybird/tb/modules/deployment.py,sha256=E3YdQgFmX7rPlgPUw9yAB0jyl7m1MQcqiQF7uHs8wK4,14272
30
- tinybird/tb/modules/endpoint.py,sha256=M2ZerljZHLJHvDfH30r4Yma3-JGExg2PlRunb2l4r-A,11931
30
+ tinybird/tb/modules/endpoint.py,sha256=7pOF4eLZ41vA5H6bKMCFZnOyKQKfdyytgwTO2Fcxtso,11907
31
31
  tinybird/tb/modules/exceptions.py,sha256=4A2sSjCEqKUMqpP3WI00zouCWW4uLaghXXLZBSw04mY,3363
32
32
  tinybird/tb/modules/feedback_manager.py,sha256=mrw5tdYycfvg6WLXlM0KIjfJardm_aNpnJkUg2vH0cA,68463
33
33
  tinybird/tb/modules/fmt.py,sha256=poh6_cwVGSf-sBu6LKWuO2TANL_J8Sgm25sPpwxa3Aw,3558
@@ -38,17 +38,17 @@ tinybird/tb/modules/local.py,sha256=_PIa-1M-72bv9rhLwqaNthJM1ZhvcjWXFChZAfEPXRs,
38
38
  tinybird/tb/modules/local_common.py,sha256=W1fEnB1vBQ4YC5U1PdA0w0g3cTV78bQ5R-lRxdDj5-Y,2868
39
39
  tinybird/tb/modules/login.py,sha256=EGxwVRmMX1Y7ZeCRyA8fqaCWpYYk7NvnZ3x_1g0NlYA,6063
40
40
  tinybird/tb/modules/materialization.py,sha256=HQKRTH6lkcYiDQJihbFqF_in58ezXG4ggZ_7Ywp_nUM,5738
41
- tinybird/tb/modules/mock.py,sha256=7v7ccTrjSRcwgVLs_NfOpAxqdY2L16cUJ3mgm4lf11w,5085
41
+ tinybird/tb/modules/mock.py,sha256=6_hY9a7jdFDwrHnOmOpn1mGchDl9MBIqcNTn8Gm9-Eg,5092
42
42
  tinybird/tb/modules/pipe.py,sha256=pH2KwgH6Xbvl3kT8vMelpKvT6bcyB4EKFDvGfOsxXbg,2418
43
43
  tinybird/tb/modules/project.py,sha256=RkejMzY6OLWlJMckziZiZFJLnjFxSeQjagklXAYCzoQ,2945
44
44
  tinybird/tb/modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
45
- tinybird/tb/modules/shell.py,sha256=LgH5K9mXO0YQ8m0WLw4r9DV7FrnSuFqT0JiAJYjaUsI,14511
45
+ tinybird/tb/modules/shell.py,sha256=B9PLdsSIMN9nsSPecQrlBKNwE5ZUTWoyj_U6KOIxfts,14580
46
46
  tinybird/tb/modules/table.py,sha256=4XrtjM-N0zfNtxVkbvLDQQazno1EPXnxTyo7llivfXk,11035
47
47
  tinybird/tb/modules/tag.py,sha256=anPmMUBc-TbFovlpFi8GPkKA18y7Y0GczMsMms5TZsU,3502
48
48
  tinybird/tb/modules/telemetry.py,sha256=iEGnMuCuNhvF6ln__j6X9MSTwL_0Hm-GgFHHHvhfknk,10466
49
49
  tinybird/tb/modules/test.py,sha256=xqu-oPscTVDmH4Q9F6ShQOdOP-aNT0HU-WAQCPzclRc,12871
50
50
  tinybird/tb/modules/token.py,sha256=A2I5wTUUmo0KfTI1BH6M6pqCQOd5dE4w2-Xaa1yM5PE,12810
51
- tinybird/tb/modules/watch.py,sha256=uvLQYejOzcUzupGlRrs4jIgqnmZ1sq_DJxQ0EAG9_58,4591
51
+ tinybird/tb/modules/watch.py,sha256=SfqFfgVML6D73172y0WRPfTpGdUzeJNqrZvVTh8RoM8,4532
52
52
  tinybird/tb/modules/workspace.py,sha256=sfT9QkoeFlN7ndUXxyImp4a7EFEHjY9MlGlldOViz0Y,6404
53
53
  tinybird/tb/modules/workspace_members.py,sha256=Ai6iCOzXX1zQ8q9iXIFSFHsBJlT-8Q28DaG5Ie-UweY,8726
54
54
  tinybird/tb/modules/datafile/build.py,sha256=seGFSvmgyRrAM1-icsKBkuog3WccfGUYFTPT-xoA5W8,50940
@@ -74,8 +74,8 @@ tinybird/tb_cli_modules/config.py,sha256=6u6B5QCdiQLbJkCkwtnKGs9H3nP-KXXhC75mF7B
74
74
  tinybird/tb_cli_modules/exceptions.py,sha256=pmucP4kTF4irIt7dXiG-FcnI-o3mvDusPmch1L8RCWk,3367
75
75
  tinybird/tb_cli_modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
76
76
  tinybird/tb_cli_modules/telemetry.py,sha256=iEGnMuCuNhvF6ln__j6X9MSTwL_0Hm-GgFHHHvhfknk,10466
77
- tinybird-0.0.1.dev63.dist-info/METADATA,sha256=geQOxg7QCmumWpO-8_OTWSWhE4XICYuUorRLujiLBQQ,2482
78
- tinybird-0.0.1.dev63.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
79
- tinybird-0.0.1.dev63.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
80
- tinybird-0.0.1.dev63.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
81
- tinybird-0.0.1.dev63.dist-info/RECORD,,
77
+ tinybird-0.0.1.dev65.dist-info/METADATA,sha256=XOsZaJhbk6z2jxLEATAMBLOo4EtGmXnij7ZjGPYabNY,2482
78
+ tinybird-0.0.1.dev65.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
79
+ tinybird-0.0.1.dev65.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
80
+ tinybird-0.0.1.dev65.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
81
+ tinybird-0.0.1.dev65.dist-info/RECORD,,