tinybird-cli 3.0.2.dev1__tar.gz → 3.0.2.dev3__tar.gz

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.
Files changed (47) hide show
  1. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/PKG-INFO +12 -2
  2. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/__cli__.py +2 -2
  3. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/git_settings.py +1 -0
  4. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/sql_template_fmt.py +48 -25
  5. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/tb_cli_modules/branch.py +14 -4
  6. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/tb_cli_modules/cli.py +16 -1
  7. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/tb_cli_modules/common.py +5 -3
  8. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird_cli.egg-info/PKG-INFO +12 -2
  9. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/setup.cfg +0 -0
  10. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/ch_utils/constants.py +0 -0
  11. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/ch_utils/engine.py +0 -0
  12. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/check_pypi.py +0 -0
  13. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/client.py +0 -0
  14. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/config.py +0 -0
  15. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/connector_settings.py +0 -0
  16. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/connectors.py +0 -0
  17. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/context.py +0 -0
  18. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/datafile.py +0 -0
  19. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/datatypes.py +0 -0
  20. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/feedback_manager.py +0 -0
  21. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/sql.py +0 -0
  22. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/sql_template.py +0 -0
  23. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/sql_toolset.py +0 -0
  24. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/syncasync.py +0 -0
  25. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/tb_cli.py +0 -0
  26. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/tb_cli_modules/auth.py +0 -0
  27. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/tb_cli_modules/cicd.py +0 -0
  28. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/tb_cli_modules/config.py +0 -0
  29. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/tb_cli_modules/connection.py +0 -0
  30. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/tb_cli_modules/datasource.py +0 -0
  31. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/tb_cli_modules/exceptions.py +0 -0
  32. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/tb_cli_modules/job.py +0 -0
  33. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/tb_cli_modules/pipe.py +0 -0
  34. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/tb_cli_modules/regions.py +0 -0
  35. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/tb_cli_modules/telemetry.py +0 -0
  36. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/tb_cli_modules/test.py +0 -0
  37. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/tb_cli_modules/tinyunit/tinyunit.py +0 -0
  38. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/tb_cli_modules/tinyunit/tinyunit_lib.py +0 -0
  39. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/tb_cli_modules/token.py +0 -0
  40. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/tb_cli_modules/workspace.py +0 -0
  41. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/tb_cli_modules/workspace_members.py +0 -0
  42. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird/tornado_template.py +0 -0
  43. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird_cli.egg-info/SOURCES.txt +0 -0
  44. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird_cli.egg-info/dependency_links.txt +0 -0
  45. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird_cli.egg-info/entry_points.txt +0 -0
  46. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird_cli.egg-info/requires.txt +0 -0
  47. {tinybird-cli-3.0.2.dev1 → tinybird-cli-3.0.2.dev3}/tinybird_cli.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tinybird-cli
3
- Version: 3.0.2.dev1
3
+ Version: 3.0.2.dev3
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://docs.tinybird.co/cli.html
6
6
  Author: Tinybird
@@ -19,6 +19,16 @@ Changelog
19
19
 
20
20
  ---------
21
21
 
22
+ 3.0.2.dev3
23
+ ************
24
+
25
+ - `Changed` `tb release promote` automatically deletes de oldest rollback Release if `export TB_FORCE_REMOVE_OLDEST_ROLLBACK=1`
26
+
27
+ 3.0.2.dev2
28
+ ************
29
+
30
+ - `Changed` Internal changes to allow parametrize fmt
31
+
22
32
  3.0.1
23
33
  ************
24
34
 
@@ -2486,4 +2496,4 @@ env=test tb push file.datasource
2486
2496
  *******************
2487
2497
  - Limited the amount of rows fetched when running ``tb sql`` to 100. Added ``--row-limit``.
2488
2498
  - Fixed warning when pipes use internal tables like ``datasources_ops_log``
2489
- - Raise an error when ``INSERT`` sql statement is used
2499
+ - Raise an error when ``INSERT`` sql statement is used.
@@ -4,5 +4,5 @@ __description__ = 'Tinybird Command Line Tool'
4
4
  __url__ = 'https://docs.tinybird.co/cli.html'
5
5
  __author__ = 'Tinybird'
6
6
  __author_email__ = 'support@tinybird.co'
7
- __version__ = '3.0.2.dev1'
8
- __revision__ = '0d49134'
7
+ __version__ = '3.0.2.dev3'
8
+ __revision__ = 'd9cea87'
@@ -99,6 +99,7 @@ DEFAULT_INIT_FILES = {
99
99
  "pipes/.gitkeep": "",
100
100
  "endpoints/.gitkeep": "",
101
101
  "deploy/.gitkeep": "",
102
+ "tests/.gitkeep": "",
102
103
  }
103
104
 
104
105
  GITHUB_CI_YML_PATH = ".github/workflows/tinybird_ci.yml"
@@ -4,7 +4,7 @@ from types import MethodType
4
4
  from typing import Any, Dict, List, Optional
5
5
 
6
6
  from sqlfmt import actions, api
7
- from sqlfmt.analyzer import Rule, group
7
+ from sqlfmt.analyzer import Analyzer, Rule, group
8
8
  from sqlfmt.comment import Comment
9
9
  from sqlfmt.dialect import ClickHouse
10
10
  from sqlfmt.jinjafmt import JinjaFormatter, JinjaTag
@@ -63,25 +63,6 @@ def from_nodes(
63
63
  return line
64
64
 
65
65
 
66
- def standardize_value(cls, token: Token) -> str:
67
- """
68
- Tinybird => Monkey patched to not lower keywords
69
- https://github.com/tconbeer/sqlfmt/blob/c11775b92d8a45f0e91d871b81a88a894d620bec/src/sqlfmt/node_manager.py#L215
70
- """
71
- if token.type in (
72
- TokenType.UNTERM_KEYWORD,
73
- TokenType.STATEMENT_START,
74
- TokenType.STATEMENT_END,
75
- TokenType.WORD_OPERATOR,
76
- TokenType.ON,
77
- TokenType.BOOLEAN_OPERATOR,
78
- TokenType.SET_OPERATOR,
79
- ):
80
- return " ".join(token.token.split())
81
- else:
82
- return token.token
83
-
84
-
85
66
  def _format_jinja_node(self, node: Node, max_length: int) -> bool:
86
67
  """
87
68
  Format a single jinja tag. No-ops for nodes that
@@ -127,10 +108,36 @@ def _format_jinja_node(self, node: Node, max_length: int) -> bool:
127
108
 
128
109
  # Some monkey patching
129
110
  Line.from_nodes = MethodType(from_nodes, Line)
130
- NodeManager.standardize_value = MethodType(standardize_value, NodeManager)
131
111
  JinjaFormatter._format_jinja_node = MethodType(_format_jinja_node, JinjaFormatter)
132
112
 
133
113
 
114
+ class TinybirdNodeManager(NodeManager):
115
+ def __init__(self, case_sensitive_names: bool, lower_keywords: bool) -> None:
116
+ super().__init__(case_sensitive_names)
117
+ self.lower_keywords = lower_keywords
118
+
119
+ def standardize_value(self, token: Token) -> str:
120
+ """
121
+ Tinybird => Patched to not lower keywords
122
+ https://github.com/tconbeer/sqlfmt/blob/c11775b92d8a45f0e91d871b81a88a894d620bec/src/sqlfmt/node_manager.py#L215
123
+ """
124
+ if self.lower_keywords:
125
+ return super().standardize_value(token)
126
+
127
+ if token.type in (
128
+ TokenType.UNTERM_KEYWORD,
129
+ TokenType.STATEMENT_START,
130
+ TokenType.STATEMENT_END,
131
+ TokenType.WORD_OPERATOR,
132
+ TokenType.ON,
133
+ TokenType.BOOLEAN_OPERATOR,
134
+ TokenType.SET_OPERATOR,
135
+ ):
136
+ return " ".join(token.token.split())
137
+ else:
138
+ return token.token
139
+
140
+
134
141
  class TinybirdDialect(ClickHouse):
135
142
  """
136
143
  This is an extension of the base rules.
@@ -142,8 +149,9 @@ class TinybirdDialect(ClickHouse):
142
149
  https://github.com/tconbeer/sqlfmt/blob/c11775b92d8a45f0e91d871b81a88a894d620bec/src/sqlfmt/dialect.py#L55
143
150
  """
144
151
 
145
- def __init__(self) -> None:
152
+ def __init__(self, lower_keywords: bool = False) -> None:
146
153
  super().__init__()
154
+ self.lower_keywords = lower_keywords
147
155
 
148
156
  override_rules = {
149
157
  "main": [],
@@ -171,14 +179,29 @@ class TinybirdDialect(ClickHouse):
171
179
  self.RULES[section].append(rule)
172
180
  break
173
181
 
182
+ def initialize_analyzer(self, line_length: int) -> Analyzer:
183
+ """
184
+ Creates and returns an analyzer that uses the Dialect's rules for lexing
185
+ Custom NodeManager for Tinybird
186
+ """
187
+ analyzer = Analyzer(
188
+ line_length=line_length,
189
+ rules=self.get_rules(),
190
+ node_manager=TinybirdNodeManager(self.case_sensitive_names, self.lower_keywords),
191
+ )
192
+ return analyzer
193
+
174
194
 
195
+ @dataclass
175
196
  class TBMode(Mode):
197
+ lower_keywords: bool = False
198
+
176
199
  def __post_init__(self) -> None:
177
200
  """
178
201
  Tinybird => Overriden to use `TinybirdDialect`
179
202
  https://github.com/tconbeer/sqlfmt/blob/c11775b92d8a45f0e91d871b81a88a894d620bec/src/sqlfmt/mode.py#L31
180
203
  """
181
- self.dialect = TinybirdDialect()
204
+ self.dialect = TinybirdDialect(self.lower_keywords)
182
205
 
183
206
 
184
207
  def _calc_str(self) -> str:
@@ -194,10 +217,10 @@ def _calc_str(self) -> str:
194
217
  Comment._calc_str = property(_calc_str)
195
218
 
196
219
 
197
- def format_sql_template(sql: str, line_length: Optional[int] = None) -> str:
220
+ def format_sql_template(sql: str, line_length: Optional[int] = None, lower_keywords: bool = False) -> str:
198
221
  try:
199
222
  # https://github.com/tconbeer/sqlfmt/blob/c11775b92d8a45f0e91d871b81a88a894d620bec/src/sqlfmt/mode.py#L16-L29
200
- config: Dict[str, Any] = {"line_length": line_length or 80}
223
+ config: Dict[str, Any] = {"line_length": line_length or 80, "lower_keywords": lower_keywords}
201
224
 
202
225
  mode = TBMode(**config)
203
226
  sql = sql.strip()
@@ -21,6 +21,7 @@ from tinybird.tb_cli_modules.common import (
21
21
  echo_safe_humanfriendly_tables_format_smart_table,
22
22
  get_current_main_workspace_temp,
23
23
  get_current_workspace_branches,
24
+ getenv_bool,
24
25
  print_branch_regression_tests_summary,
25
26
  print_current_branch,
26
27
  print_current_workspace,
@@ -148,12 +149,21 @@ async def release_create(semver: str) -> None:
148
149
  )
149
150
  @coro
150
151
  async def release_promote(semver: str) -> None:
152
+ """
153
+ The oldest rollback Release will be automatically removed if no usage, otherwise export TB_FORCE_REMOVE_OLDEST_ROLLBACK="1" to force deletion
154
+ """
151
155
  config = CLIConfig.get_project_config()
152
156
  _ = await try_update_config_with_remote(config, only_if_needed=True)
153
157
 
154
158
  client = config.get_client()
155
159
 
156
160
  try:
161
+ force_remove = getenv_bool("TB_FORCE_REMOVE_OLDEST_ROLLBACK", False)
162
+ click.echo(FeedbackManager.warning_remove_oldest_rollback(semver=semver))
163
+ try:
164
+ await remove_release(False, config, OLDEST_ROLLBACK, client, force=force_remove)
165
+ except Exception as e:
166
+ click.echo(FeedbackManager.error_remove_oldest_rollback(error=str(e), semver=semver))
157
167
  release = await client.release_promote(config["id"], semver)
158
168
  click.echo(FeedbackManager.success_release_promote(semver=semver))
159
169
  click.echo(FeedbackManager.success_git_release(release_commit=release["commit"]))
@@ -233,12 +243,12 @@ async def release_rm(semver: str, oldest_rollback: bool, force: bool, yes: bool,
233
243
  client = config.get_client()
234
244
  _ = await try_update_config_with_remote(config)
235
245
 
246
+ if oldest_rollback:
247
+ semver = OLDEST_ROLLBACK
248
+ await print_release_summary(config, semver, info=True, dry_run=dry_run)
236
249
  if dry_run or yes or click.confirm(FeedbackManager.warning_confirm_delete_release(semver=semver)):
237
250
  try:
238
- if oldest_rollback:
239
- semver = OLDEST_ROLLBACK
240
-
241
- await remove_release(dry_run, config, semver, client, force)
251
+ await remove_release(dry_run, config, semver, client, force, show_print=False)
242
252
  except Exception as e:
243
253
  raise CLIReleaseException(FeedbackManager.simple_error_exception(error=str(e)))
244
254
 
@@ -1427,7 +1427,22 @@ async def deploy(
1427
1427
  fork_downstream: bool,
1428
1428
  fork: bool,
1429
1429
  ) -> None:
1430
- """Deploy in tinybird pushing resources changed from previous release using git"""
1430
+ """Deploy in Tinybird pushing resources changed from previous Release using git.
1431
+
1432
+ Usage: tb --semver <semver> deploy
1433
+
1434
+ Semantic versioning logic is as follows:
1435
+
1436
+ --semver <semver> format is major.minor.patch-post where major, minor, patch and post are integer numbers
1437
+
1438
+ - bump post to deploy to the current live Release, rollback to previous post version is not available
1439
+
1440
+ - bump patch or minor to deploy a new Release and auto-promote it to live. Add TB_AUTO_PROMOTE=0 to create the Release in preview status
1441
+
1442
+ - bump major to deploy a new Release in preview status
1443
+
1444
+ When auto-promote the oldest rollback Release will be automatically removed if no usage, otherwise export TB_FORCE_REMOVE_OLDEST_ROLLBACK="1" to force deletion
1445
+ """
1431
1446
  try:
1432
1447
  ignore_sql_errors = FeatureFlags.ignore_sql_errors()
1433
1448
  context.disable_template_security_validation.set(True)
@@ -2029,10 +2029,11 @@ async def print_release_summary(config: CLIConfig, semver: str, info: bool = Fal
2029
2029
  else:
2030
2030
  columns = ["name", "id", "notes"]
2031
2031
  if not response:
2032
- click.echo(FeedbackManager.info_release_no_rollback(semver=semver))
2032
+ click.echo(FeedbackManager.info_release_no_rollback())
2033
2033
  return
2034
2034
 
2035
2035
  if len(response["datasources"]) or len(response["pipes"]):
2036
+ semver = response.get("semver", semver)
2036
2037
  if info:
2037
2038
  if dry_run:
2038
2039
  click.echo(FeedbackManager.info_release_rm_resources_dry_run(semver=semver))
@@ -2058,8 +2059,9 @@ async def print_release_summary(config: CLIConfig, semver: str, info: bool = Fal
2058
2059
  echo_safe_humanfriendly_tables_format_smart_table(rows, column_names=columns)
2059
2060
 
2060
2061
 
2061
- async def remove_release(dry_run: bool, config: CLIConfig, semver: str, client: TinyB, force: bool):
2062
- await print_release_summary(config, semver, info=True, dry_run=True)
2062
+ async def remove_release(dry_run: bool, config: CLIConfig, semver: str, client: TinyB, force: bool, show_print=True):
2063
+ if show_print:
2064
+ await print_release_summary(config, semver, info=True, dry_run=True)
2063
2065
  if not dry_run:
2064
2066
  response = await client.release_rm(
2065
2067
  config["id"], semver, confirmation=config["name"], dry_run=dry_run, force=force
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tinybird-cli
3
- Version: 3.0.2.dev1
3
+ Version: 3.0.2.dev3
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://docs.tinybird.co/cli.html
6
6
  Author: Tinybird
@@ -19,6 +19,16 @@ Changelog
19
19
 
20
20
  ---------
21
21
 
22
+ 3.0.2.dev3
23
+ ************
24
+
25
+ - `Changed` `tb release promote` automatically deletes de oldest rollback Release if `export TB_FORCE_REMOVE_OLDEST_ROLLBACK=1`
26
+
27
+ 3.0.2.dev2
28
+ ************
29
+
30
+ - `Changed` Internal changes to allow parametrize fmt
31
+
22
32
  3.0.1
23
33
  ************
24
34
 
@@ -2486,4 +2496,4 @@ env=test tb push file.datasource
2486
2496
  *******************
2487
2497
  - Limited the amount of rows fetched when running ``tb sql`` to 100. Added ``--row-limit``.
2488
2498
  - Fixed warning when pipes use internal tables like ``datasources_ops_log``
2489
- - Raise an error when ``INSERT`` sql statement is used
2499
+ - Raise an error when ``INSERT`` sql statement is used.