tinybird 4.6.1.dev0__py3-none-any.whl → 4.6.2.dev0__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.
tinybird/sql_template.py CHANGED
@@ -7,7 +7,7 @@ from collections import deque
7
7
  from datetime import datetime
8
8
  from functools import lru_cache
9
9
  from json import loads
10
- from typing import Any, Callable, Dict, List, Optional, Tuple, Union
10
+ from typing import Any, Callable, Dict, List, Optional, Tuple, Union, cast
11
11
 
12
12
  from tornado import escape
13
13
  from tornado.util import ObjectDict, exec_in, unicode_type
@@ -1499,7 +1499,7 @@ def generate(self, **kwargs) -> Tuple[str, TemplateExecutionResults]:
1499
1499
  )
1500
1500
 
1501
1501
  exec_in(self.compiled, namespace)
1502
- execute = namespace["_tt_execute"]
1502
+ execute = cast(Callable[[], bytes], namespace["_tt_execute"])
1503
1503
  # Clear the traceback module's cache of source data now that
1504
1504
  # we've generated a new template (mainly for this module's
1505
1505
  # unittests, where different tests reuse the same name).
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__ = '4.6.1.dev0'
8
- __revision__ = '1d9f802'
7
+ __version__ = '4.6.2.dev0'
8
+ __revision__ = '41da03f'
@@ -105,7 +105,9 @@ def echo_safe_humanfriendly_tables_format_smart_table(data: Iterable[Any], colum
105
105
  try:
106
106
  click.echo(humanfriendly.tables.format_smart_table(data, column_names=column_names))
107
107
  except ValueError as exc:
108
- if str(exc) == "max() arg is an empty sequence":
108
+ # Python 3.11 wording: "max() arg is an empty sequence"
109
+ # Python 3.12 wording: "max() iterable argument is empty"
110
+ if str(exc) in ("max() arg is an empty sequence", "max() iterable argument is empty"):
109
111
  click.echo("------------")
110
112
  click.echo("Empty")
111
113
  click.echo("------------")
@@ -122,7 +124,9 @@ def echo_safe_humanfriendly_tables_format_pretty_table(data: Iterable[Any], colu
122
124
  try:
123
125
  click.echo(humanfriendly.tables.format_pretty_table(data, column_names=column_names))
124
126
  except ValueError as exc:
125
- if str(exc) == "max() arg is an empty sequence":
127
+ # Python 3.11 wording: "max() arg is an empty sequence"
128
+ # Python 3.12 wording: "max() iterable argument is empty"
129
+ if str(exc) in ("max() arg is an empty sequence", "max() iterable argument is empty"):
126
130
  click.echo("------------")
127
131
  click.echo("Empty")
128
132
  click.echo("------------")
@@ -139,7 +143,9 @@ def echo_safe_format_table(data: Iterable[Any], columns) -> None:
139
143
  try:
140
144
  click.echo(format_table(data, columns))
141
145
  except ValueError as exc:
142
- if str(exc) == "max() arg is an empty sequence":
146
+ # Python 3.11 wording: "max() arg is an empty sequence"
147
+ # Python 3.12 wording: "max() iterable argument is empty"
148
+ if str(exc) in ("max() arg is an empty sequence", "max() iterable argument is empty"):
143
149
  click.echo("------------")
144
150
  click.echo("Empty")
145
151
  click.echo("------------")
@@ -8,6 +8,8 @@ from tinybird.tb.modules.datafile.format_datasource import format_datasource
8
8
  from tinybird.tb.modules.datafile.format_pipe import format_pipe
9
9
  from tinybird.tb.modules.feedback_manager import FeedbackManager
10
10
 
11
+ PULL_EXISTING_FILE_MAX_DEPTH = 5
12
+
11
13
 
12
14
  def folder_pull(
13
15
  client: TinyB,
@@ -18,7 +20,7 @@ def folder_pull(
18
20
  progress_bar: bool = False,
19
21
  fmt: bool = False,
20
22
  ) -> list[str]:
21
- def get_file_folder(extension: str, resource_type: Optional[str]):
23
+ def get_file_folder(extension: str, resource_type: Optional[str]) -> Optional[str]:
22
24
  if extension == "datasource":
23
25
  return "datasources"
24
26
  if extension == "connection":
@@ -35,6 +37,24 @@ def folder_pull(
35
37
  return "pipes"
36
38
  return None
37
39
 
40
+ def find_existing_resource_file(dest_folder: Path, name: str) -> Optional[Path]:
41
+ if not dest_folder.exists():
42
+ return None
43
+
44
+ candidates = []
45
+ for candidate in dest_folder.rglob(name):
46
+ if not candidate.is_file():
47
+ continue
48
+
49
+ relative_parent = candidate.parent.relative_to(dest_folder)
50
+ if len(relative_parent.parts) <= PULL_EXISTING_FILE_MAX_DEPTH:
51
+ candidates.append(candidate)
52
+
53
+ if not candidates:
54
+ return None
55
+
56
+ return sorted(candidates, key=lambda path: (len(path.parent.relative_to(dest_folder).parts), str(path)))[0]
57
+
38
58
  def write_files(
39
59
  resources: list[dict[str, Any]],
40
60
  extension: str,
@@ -62,14 +82,17 @@ def folder_pull(
62
82
  file_folder = get_file_folder(extension, k.get("type"))
63
83
  f = Path(dest_folder) / file_folder if file_folder is not None else Path(dest_folder)
64
84
 
65
- if not f.exists():
66
- f.mkdir(parents=True)
67
-
68
- f = f / name
85
+ existing_file = find_existing_resource_file(Path(dest_folder), name)
86
+ if existing_file is not None:
87
+ f = existing_file
88
+ else:
89
+ if not f.exists():
90
+ f.mkdir(parents=True)
91
+ f = f / name
69
92
 
70
93
  if verbose:
71
94
  click.echo(FeedbackManager.info_writing_resource(resource=f))
72
- if not f.exists() or force:
95
+ if not f.exists() or force or existing_file is not None:
73
96
  with open(f, "w") as fd:
74
97
  if resource_to_write:
75
98
  fd.write(resource_to_write)
@@ -26,7 +26,9 @@ def print_table_formatted(res: dict, name: str):
26
26
  click.echo(FeedbackManager.success(message=stats_message))
27
27
  click.echo(FeedbackManager.gray(message=rows_message))
28
28
  except ValueError as exc:
29
- if str(exc) == "max() arg is an empty sequence":
29
+ # Python 3.11 wording: "max() arg is an empty sequence"
30
+ # Python 3.12 wording: "max() iterable argument is empty"
31
+ if str(exc) in ("max() arg is an empty sequence", "max() iterable argument is empty"):
30
32
  click.echo("------------")
31
33
  else:
32
34
  raise
@@ -112,7 +112,9 @@ def echo_safe_humanfriendly_tables_format_smart_table(data: Iterable[Any], colum
112
112
  try:
113
113
  click.echo(humanfriendly.tables.format_smart_table(data, column_names=column_names))
114
114
  except ValueError as exc:
115
- if str(exc) == "max() arg is an empty sequence":
115
+ # Python 3.11 wording: "max() arg is an empty sequence"
116
+ # Python 3.12 wording: "max() iterable argument is empty"
117
+ if str(exc) in ("max() arg is an empty sequence", "max() iterable argument is empty"):
116
118
  click.echo("------------")
117
119
  click.echo("Empty")
118
120
  click.echo("------------")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: tinybird
3
- Version: 4.6.1.dev0
3
+ Version: 4.6.2.dev0
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/forward/commands
6
6
  Author: Tinybird
@@ -27,7 +27,7 @@ Requires-Dist: requests<3,>=2.28.1
27
27
  Requires-Dist: shandy-sqlfmt==0.11.1
28
28
  Requires-Dist: shandy-sqlfmt[jinjafmt]==0.11.1
29
29
  Requires-Dist: toposort==1.10
30
- Requires-Dist: tornado~=6.0.0
30
+ Requires-Dist: tornado~=6.5.5
31
31
  Requires-Dist: urllib3<2,>=1.26.14
32
32
  Requires-Dist: watchdog==6.0.0
33
33
  Requires-Dist: wheel
@@ -52,6 +52,11 @@ The Tinybird command-line tool allows you to use all the Tinybird functionality
52
52
  Changelog
53
53
  ----------
54
54
 
55
+ 4.6.1
56
+ *******
57
+
58
+ - `Changed` `tb pull` to overwrite existing local files when pulling from a Tinybird workspace.
59
+
55
60
  4.6.0
56
61
  *******
57
62
 
@@ -5,7 +5,7 @@ tinybird/git_settings.py,sha256=mqWgeboOlOFsSo97qyv595UCR2R1QCAqT4GTawBNPBg,3935
5
5
  tinybird/prompts.py,sha256=F8ic_mGId50MDJmg5ec8i5BDavxz9SWtocLXqgO0IRY,45689
6
6
  tinybird/service_datasources.py,sha256=tt_8G6yJcr2ZbsaR99ulExe79pNS8h9dzdGm45vf16c,58710
7
7
  tinybird/sql.py,sha256=qdqxsq1WPiGTk-SmZWaxvZb936ISdo1ChZhnC_uXeUE,49351
8
- tinybird/sql_template.py,sha256=_J-QmHos4Sx9YS6tVsEyE68qrcFbj13VwCA1zB3Sz8Q,128634
8
+ tinybird/sql_template.py,sha256=nSzUdaQe18Da_8qlgLW7tsZl1pOa2kDaBa8TdrF6pJ4,128667
9
9
  tinybird/sql_template_fmt.py,sha256=Ma4qcs-2r8ZXQC4GUmrCqYz34DsnGF8k5lE2Jwnr314,10638
10
10
  tinybird/sql_toolset.py,sha256=xWY-EtixaZKUPuNY4WBz2fDwwNnmbgtdLsmI2wy67UA,27220
11
11
  tinybird/syncasync.py,sha256=rIPmCvygWSFqfnlVqhZH4N9gVVTvD6DEPsfoxGizYrI,27776
@@ -17,7 +17,7 @@ tinybird/datafile/exceptions.py,sha256=8rw2umdZjtby85QbuRKFO5ETz_eRHwUY5l7eHsy1w
17
17
  tinybird/datafile/parse_connection.py,sha256=GxmGp_XnWbDZPDbh_PBxitlIMqZRYfDwxMBw-JQBp1g,1890
18
18
  tinybird/datafile/parse_datasource.py,sha256=yd58HrUF4yNJXLn6OsvKGpZJpvrcjLGAeJG1lgBe_zk,1891
19
19
  tinybird/datafile/parse_pipe.py,sha256=-9bbgVuiWRyDYydrLVflDBt8GstZotMy6dklsrc6MUY,3859
20
- tinybird/tb/__cli__.py,sha256=QXbgUCqET_aryHwR2WxQwXVxJResA_P30lxlABqLiEA,245
20
+ tinybird/tb/__cli__.py,sha256=ghH8YiRtCEUACEVbZgch3RDH11g2M0Pxuf6s4Y3opmI,245
21
21
  tinybird/tb/check_pypi.py,sha256=Gp0HkHHDFMSDL6nxKlOY51z7z1Uv-2LRexNTZSHHGmM,552
22
22
  tinybird/tb/cli.py,sha256=IjiGfNIpxSxi1odK1kMj9s8lEhx3sAUgGA263XdmyR0,1119
23
23
  tinybird/tb/client.py,sha256=SEp4-XoRDXMEBj2_C1jfJKtZOkbiwNIYERPQN6uoolI,55646
@@ -27,7 +27,7 @@ tinybird/tb/modules/build.py,sha256=bGFoFppR_UbGUMDWFGDzfJ4nT3CGFwzCzl2o4OpwR2o,
27
27
  tinybird/tb/modules/build_common.py,sha256=o04aeaoyGTnwhR0cEXAgQzc7SJya97YECoEihsi4SyU,24979
28
28
  tinybird/tb/modules/cicd.py,sha256=IO4qqsoLRXcubALb7vx_QnRpg3zIIxfaVO9bGomlESY,8267
29
29
  tinybird/tb/modules/cli.py,sha256=n_B9EapB1eYOWOfRHN1Jefip6LcmYrkLDIz5GoGCJhA,41889
30
- tinybird/tb/modules/common.py,sha256=tiBjysOj5RW0aZRC2wIADoK6H-72yKx31UNc5MlwivM,94782
30
+ tinybird/tb/modules/common.py,sha256=5oyFPfrM4ct9-U3AmhtAKXTPUWw5eDoX55jxF3TK5H0,95286
31
31
  tinybird/tb/modules/config.py,sha256=Z47lMZxFeX68b62bTzgj9379zn-9eT4cPbrcMJ_xTGQ,11431
32
32
  tinybird/tb/modules/connection.py,sha256=HwHn0YgwqcKEYCLr2OqDzJzAUFd65Wv8MZiSUw_TLII,18452
33
33
  tinybird/tb/modules/connection_dynamodb.py,sha256=j1Z0tXrlTZJU1LJ0rEzv3ezo0pS4PJJKfVjUTGrH3nk,9473
@@ -63,7 +63,7 @@ tinybird/tb/modules/preview.py,sha256=712lVUgFE2a1qCmBGVrU_JyiaRyo5-S0dypcBxmKln
63
63
  tinybird/tb/modules/project.py,sha256=sb-561KV6RQiYrq4nHSULFNMOodq8Ywxwp6Dfogs0KY,9171
64
64
  tinybird/tb/modules/project_commands.py,sha256=t7h5JJWNA5eGth_Nrj0fak5B9eyVPGeDluF-41OBkhw,1877
65
65
  tinybird/tb/modules/py_project.py,sha256=DE3N-GPhcvVulELMINZQmw0zG6xZ1YeVkyJt1vn2E4I,7799
66
- tinybird/tb/modules/query_output.py,sha256=vdsjAsWt2YPfZ9hGEokCknYCnwuzMsnSVTDoLr47bBs,1346
66
+ tinybird/tb/modules/query_output.py,sha256=8Akg5_jzc6icM_-MvJXmP9Nn5v2s3xx6r1bMO4ap98c,1514
67
67
  tinybird/tb/modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
68
68
  tinybird/tb/modules/secret.py,sha256=iwwBDmlWSTm-9WKjg9G4gejJQHnOelBlB7XTg9zUr3g,3942
69
69
  tinybird/tb/modules/secret_common.py,sha256=8mEXOdNFrTuVWu7rgZ5-C8v-rB1EAdZQUHIyBIgwISI,1578
@@ -89,17 +89,17 @@ tinybird/tb/modules/datafile/format_datasource.py,sha256=rqA0Mr_3x5vaXe5vXWs7Fe2
89
89
  tinybird/tb/modules/datafile/format_pipe.py,sha256=9UuUsl5DjV4tJIRr6Whuv-AtIM9Gx7R3396AbKjHaJ4,7724
90
90
  tinybird/tb/modules/datafile/pipe_checker.py,sha256=dxsCQoA6ruxg1fvF6sMLFowpjaqws8lUQcM7XyhgZPE,24609
91
91
  tinybird/tb/modules/datafile/playground.py,sha256=TB4ebscUaNPqYzn0zBWqFBtK6TyzhcenHeTf62ac-2E,55269
92
- tinybird/tb/modules/datafile/pull.py,sha256=vzJ8_rixPRyuv3x_Ah8v5iHr1cM2LUGrSX54Opg4lGI,5073
92
+ tinybird/tb/modules/datafile/pull.py,sha256=WbFCv0rp-ThcCcfH6gqs9Be-NawJfEEkY-aU78O93hk,6004
93
93
  tinybird/tb/modules/tinyunit/tinyunit.py,sha256=GHdp_6uDcCO2C-Z5bXu4OJQGXMm9Y_yjrcLVYdWy65o,11238
94
94
  tinybird/tb/modules/tinyunit/tinyunit_lib.py,sha256=NHoXcCHPDcKWYLzgP3NViho3Ey-6RV-ynPDzySPrTPE,1817
95
95
  tinybird/tb_cli_modules/cicd.py,sha256=i2Mw8AbmEVNBcEPYdio7liy3PGqh1ezVFZ0OmJ9ww5o,13809
96
- tinybird/tb_cli_modules/common.py,sha256=WS8on_s8sGSq27YQdmMsfQ45MP9wyoJaRN_Cfrr6lUk,77275
96
+ tinybird/tb_cli_modules/common.py,sha256=_J0ovBGdMqdrYCMdkw4ub74pMLuMdkm1yAsu_OAFMwQ,77443
97
97
  tinybird/tb_cli_modules/config.py,sha256=0kFDmsDcjKon32rgFGMHHKSbv4j5dOrXtVOlyuAyEkk,11510
98
98
  tinybird/tb_cli_modules/exceptions.py,sha256=pmucP4kTF4irIt7dXiG-FcnI-o3mvDusPmch1L8RCWk,3367
99
99
  tinybird/tb_cli_modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
100
100
  tinybird/tb_cli_modules/telemetry.py,sha256=W098H6jmS4kpE7hN3tadaREBTf7oMocel-lkKWN0pU8,10466
101
- tinybird-4.6.1.dev0.dist-info/METADATA,sha256=yPtpFgNPvMixR2tfsd8kVlW17P2y1BA_k2HRSJ8_E-U,12572
102
- tinybird-4.6.1.dev0.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
103
- tinybird-4.6.1.dev0.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
104
- tinybird-4.6.1.dev0.dist-info/top_level.txt,sha256=ZIQJTPCzMqnfDzM_hEGZrJqDSEcKnIK_49T86DGWpyQ,78
105
- tinybird-4.6.1.dev0.dist-info/RECORD,,
101
+ tinybird-4.6.2.dev0.dist-info/METADATA,sha256=NUakUIjMH63SvEAurFVKJ1PsHBKbV9WbO-9KdACgETk,12684
102
+ tinybird-4.6.2.dev0.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
103
+ tinybird-4.6.2.dev0.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
104
+ tinybird-4.6.2.dev0.dist-info/top_level.txt,sha256=ZIQJTPCzMqnfDzM_hEGZrJqDSEcKnIK_49T86DGWpyQ,78
105
+ tinybird-4.6.2.dev0.dist-info/RECORD,,