tinybird-cli 5.2.1.dev0__tar.gz → 5.2.1.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 (46) hide show
  1. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/PKG-INFO +16 -1
  2. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/__cli__.py +2 -2
  3. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/datafile.py +36 -6
  4. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/datatypes.py +27 -0
  5. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/feedback_manager.py +15 -0
  6. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/tb_cli_modules/branch.py +11 -2
  7. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird_cli.egg-info/PKG-INFO +16 -1
  8. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/setup.cfg +0 -0
  9. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/ch_utils/constants.py +0 -0
  10. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/ch_utils/engine.py +0 -0
  11. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/check_pypi.py +0 -0
  12. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/client.py +0 -0
  13. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/config.py +0 -0
  14. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/connectors.py +0 -0
  15. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/context.py +0 -0
  16. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/git_settings.py +0 -0
  17. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/sql.py +0 -0
  18. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/sql_template.py +0 -0
  19. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/sql_template_fmt.py +0 -0
  20. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/sql_toolset.py +0 -0
  21. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/syncasync.py +0 -0
  22. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/tb_cli.py +0 -0
  23. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/tb_cli_modules/auth.py +0 -0
  24. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/tb_cli_modules/cicd.py +0 -0
  25. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/tb_cli_modules/cli.py +0 -0
  26. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/tb_cli_modules/common.py +0 -0
  27. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/tb_cli_modules/config.py +0 -0
  28. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/tb_cli_modules/connection.py +0 -0
  29. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/tb_cli_modules/datasource.py +0 -0
  30. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/tb_cli_modules/exceptions.py +0 -0
  31. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/tb_cli_modules/job.py +0 -0
  32. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/tb_cli_modules/pipe.py +0 -0
  33. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/tb_cli_modules/regions.py +0 -0
  34. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/tb_cli_modules/telemetry.py +0 -0
  35. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/tb_cli_modules/test.py +0 -0
  36. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/tb_cli_modules/tinyunit/tinyunit.py +0 -0
  37. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/tb_cli_modules/tinyunit/tinyunit_lib.py +0 -0
  38. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/tb_cli_modules/token.py +0 -0
  39. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/tb_cli_modules/workspace.py +0 -0
  40. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/tb_cli_modules/workspace_members.py +0 -0
  41. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird/tornado_template.py +0 -0
  42. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird_cli.egg-info/SOURCES.txt +0 -0
  43. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird_cli.egg-info/dependency_links.txt +0 -0
  44. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird_cli.egg-info/entry_points.txt +0 -0
  45. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.dev3}/tinybird_cli.egg-info/requires.txt +0 -0
  46. {tinybird-cli-5.2.1.dev0 → tinybird-cli-5.2.1.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: 5.2.1.dev0
3
+ Version: 5.2.1.dev3
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/cli/introduction.html
6
6
  Author: Tinybird
@@ -18,6 +18,21 @@ The Tinybird command-line tool allows you to use all the Tinybird functionality
18
18
  Changelog
19
19
  ----------
20
20
 
21
+ 5.2.1.dev3
22
+ ************
23
+
24
+ - `Added` `tb branch ls --sort` option to list branches sorted by branch name.
25
+
26
+ 5.2.1.dev2
27
+ ************
28
+
29
+ - `Added` `tb push` prevents pushing pipes that have nodes with the same name as the pipe.
30
+
31
+ 5.2.1.dev1
32
+ ************
33
+
34
+ - `Fixed` error messages when using `tb push` with already taken names for other resources.
35
+
21
36
  5.2.0
22
37
  ******
23
38
 
@@ -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__ = '5.2.1.dev0'
8
- __revision__ = '83349b1'
7
+ __version__ = '5.2.1.dev3'
8
+ __revision__ = 'ca0c2bb'
@@ -814,7 +814,6 @@ def parse_pipe(
814
814
  )
815
815
  except ModuleNotFoundError:
816
816
  pass
817
-
818
817
  return doc
819
818
 
820
819
 
@@ -2627,6 +2626,10 @@ async def new_pipe(
2627
2626
  copy_node = next((node for node in p["nodes"] if node.get("params", {}).get("type", None) == "copy"), None)
2628
2627
  sink_node = next((node for node in p["nodes"] if node.get("params", {}).get("type", None) == "sink"), None)
2629
2628
 
2629
+ for node in p["nodes"]:
2630
+ if node["params"]["name"] == p["name"]:
2631
+ raise click.ClickException(FeedbackManager.error_pipe_node_same_name(name=p["name"]))
2632
+
2630
2633
  if pipe_exists:
2631
2634
  if force or run_tests:
2632
2635
  # TODO: this should create a different node and rename it to the final one on success
@@ -3817,6 +3820,18 @@ def get_project_filenames(folder: str, with_vendor=False) -> List[str]:
3817
3820
  return filenames
3818
3821
 
3819
3822
 
3823
+ async def name_matches_existing_resource(resource: str, name: str, tb_client: TinyB):
3824
+ if resource == "datasources":
3825
+ current_pipes: List[Dict[str, Any]] = await tb_client.pipes()
3826
+ if name in [x["name"] for x in current_pipes]:
3827
+ return True
3828
+ else:
3829
+ current_datasources: List[Dict[str, Any]] = await tb_client.datasources()
3830
+ if name in [x["name"] for x in current_datasources]:
3831
+ return True
3832
+ return False
3833
+
3834
+
3820
3835
  def is_new(
3821
3836
  name: str,
3822
3837
  changed: Dict[str, str],
@@ -4018,6 +4033,7 @@ async def folder_push(
4018
4033
  fork: Optional[bool] = False,
4019
4034
  ):
4020
4035
  if name in to_run:
4036
+ resource = to_run[name]["resource"]
4021
4037
  if not dry_run:
4022
4038
  if should_push_file(name, remote_resource_names, latest_datasource_versions, force, run_tests):
4023
4039
  if name not in resource_versions:
@@ -4089,11 +4105,19 @@ async def folder_push(
4089
4105
  )
4090
4106
  )
4091
4107
  else:
4092
- click.echo(
4093
- FeedbackManager.warning_name_already_exists(
4094
- name=name if to_run[name]["version"] is None else f'{name}__v{to_run[name]["version"]}'
4108
+ if await name_matches_existing_resource(resource, name, tb_client):
4109
+ if resource == "pipes":
4110
+ click.echo(FeedbackManager.error_pipe_cannot_be_pushed(name=name))
4111
+ else:
4112
+ click.echo(FeedbackManager.error_datasource_cannot_be_pushed(name=name))
4113
+ else:
4114
+ click.echo(
4115
+ FeedbackManager.warning_name_already_exists(
4116
+ name=name
4117
+ if to_run[name]["version"] is None
4118
+ else f'{name}__v{to_run[name]["version"]}'
4119
+ )
4095
4120
  )
4096
- )
4097
4121
  else:
4098
4122
  if should_push_file(name, remote_resource_names, latest_datasource_versions, force, run_tests):
4099
4123
  if name not in resource_versions:
@@ -4110,7 +4134,13 @@ async def folder_push(
4110
4134
  )
4111
4135
  )
4112
4136
  else:
4113
- click.echo(FeedbackManager.warning_dry_name_already_exists(name=name))
4137
+ if await name_matches_existing_resource(resource, name, tb_client):
4138
+ if resource == "pipes":
4139
+ click.echo(FeedbackManager.warning_pipe_cannot_be_pushed(name=name))
4140
+ else:
4141
+ click.echo(FeedbackManager.warning_datasource_cannot_be_pushed(name=name))
4142
+ else:
4143
+ click.echo(FeedbackManager.warning_dry_name_already_exists(name=name))
4114
4144
 
4115
4145
  async def push_files(
4116
4146
  dependency_graph: GraphDependencies,
@@ -30,6 +30,28 @@ float64_max = 2**52 # 51 bits is the fractional part of float 64 ieee754
30
30
  datetime64_type_pattern = r"^DateTime64(\([1-9](, ?'.+')?\))?$"
31
31
  datetime_type_pattern = r"^DateTime(\(('.+')?)?\)?$"
32
32
 
33
+ # List from https://github.com/tinybirdco/ClickHousePrivate/blob/153473d9c1c871974688a1d72dcff7a13fc2076c/src/DataTypes/Serializations/SerializationBool.cpp#L216
34
+ bool_allowed_values = {
35
+ "true",
36
+ "false",
37
+ "True",
38
+ "False",
39
+ "T",
40
+ "F",
41
+ "Y",
42
+ "N",
43
+ "Yes",
44
+ "No",
45
+ "On",
46
+ "Off",
47
+ "Enable",
48
+ "Disable",
49
+ "Enabled",
50
+ "Disabled",
51
+ "1",
52
+ "0",
53
+ }
54
+
33
55
 
34
56
  def is_type_datetime64(type_to_check):
35
57
  """
@@ -143,6 +165,10 @@ def float64_test(x):
143
165
  return "_" not in x and type_test(x, float) and -float64_max < float(x) < float64_max
144
166
 
145
167
 
168
+ def bool_test(x):
169
+ return x in bool_allowed_values
170
+
171
+
146
172
  def test_numeric_testers(fn, n):
147
173
  """
148
174
  >>> test_numeric_testers(int32_test, (2**31)-1)
@@ -266,6 +292,7 @@ testers = {
266
292
  "UInt256": uint256_test,
267
293
  "Float32": float_test,
268
294
  "Float64": float_test,
295
+ "Bool": bool_test,
269
296
  "Array(Int32)": array_test(int),
270
297
  "Array(Float32)": array_test(float),
271
298
  "Array(String)": array_test(str),
@@ -69,6 +69,15 @@ class FeedbackManager:
69
69
  "{number} files need to be formatted, run the commands below to fix them."
70
70
  )
71
71
  error_pipe_already_exists = error_message("{pipe} already exists")
72
+ error_pipe_node_same_name = error_message(
73
+ "Error in node '{name}'. The Pipe is already using that name. Nodes can't have the same exact name as the Pipe they belong to."
74
+ )
75
+ error_pipe_cannot_be_pushed = error_message(
76
+ "Failed pushing pipe. Top level object names must be unique. {name} cannot have same name as an existing datasource."
77
+ )
78
+ error_datasource_cannot_be_pushed = error_message(
79
+ "Failed pushing datasource. Top level object names must be unique. {name} cannot have same name as an existing pipe."
80
+ )
72
81
  error_datasource_already_exists = error_message("{datasource} already exists")
73
82
  error_datasource_already_exists_and_alter_failed = error_message(
74
83
  "{datasource} already exists and the migration can't be executed to match the new definition: {alter_error_message}"
@@ -500,6 +509,12 @@ Ready? """
500
509
  )
501
510
  warning_name_already_exists = warning_message("** Warning: {name} already exists, skipping")
502
511
  warning_dry_name_already_exists = warning_message("** [DRY RUN] {name} already exists, skipping")
512
+ warning_datasource_cannot_be_pushed = warning_message(
513
+ "** [DRY RUN] Failed pushing datasource. Top level object names must be unique. {name} cannot have same name as an existing pipe."
514
+ )
515
+ warning_pipe_cannot_be_pushed = warning_message(
516
+ "** [DRY RUN] Failed pushing pipe. Top level object names must be unique. {name} cannot have same name as an existing datasource."
517
+ )
503
518
  warning_fixture_not_found = warning_message("** Warning: No fixture found for the datasource {datasource_name}")
504
519
  warning_update_version = warning_message(
505
520
  '** UPDATE AVAILABLE: please run "pip install tinybird-cli=={latest_version}" to update or `export TB_VERSION_WARNING=0` to skip the check.'
@@ -273,8 +273,9 @@ def branch() -> None:
273
273
 
274
274
 
275
275
  @branch.command(name="ls")
276
+ @click.option("--sort/--no-sort", default=False, help="Sort the table rows by name")
276
277
  @coro
277
- async def branch_ls() -> None:
278
+ async def branch_ls(sort: bool) -> None:
278
279
  """List all the branches available using the workspace token"""
279
280
 
280
281
  config = CLIConfig.get_project_config()
@@ -298,10 +299,18 @@ async def branch_ls() -> None:
298
299
  for branch in response["environments"]:
299
300
  table.append((branch["name"], branch["id"], config["id"] == branch["id"]))
300
301
 
302
+ current_branch = [row for row in table if row[2]]
303
+ other_branches = [row for row in table if not row[2]]
304
+
305
+ if sort:
306
+ other_branches.sort(key=lambda x: x[0])
307
+
308
+ sorted_table = current_branch + other_branches
309
+
301
310
  await print_current_workspace(config)
302
311
 
303
312
  click.echo(FeedbackManager.info_branches())
304
- echo_safe_humanfriendly_tables_format_smart_table(table, column_names=columns)
313
+ echo_safe_humanfriendly_tables_format_smart_table(sorted_table, column_names=columns)
305
314
 
306
315
 
307
316
  @branch.command(name="use")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tinybird-cli
3
- Version: 5.2.1.dev0
3
+ Version: 5.2.1.dev3
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/cli/introduction.html
6
6
  Author: Tinybird
@@ -18,6 +18,21 @@ The Tinybird command-line tool allows you to use all the Tinybird functionality
18
18
  Changelog
19
19
  ----------
20
20
 
21
+ 5.2.1.dev3
22
+ ************
23
+
24
+ - `Added` `tb branch ls --sort` option to list branches sorted by branch name.
25
+
26
+ 5.2.1.dev2
27
+ ************
28
+
29
+ - `Added` `tb push` prevents pushing pipes that have nodes with the same name as the pipe.
30
+
31
+ 5.2.1.dev1
32
+ ************
33
+
34
+ - `Fixed` error messages when using `tb push` with already taken names for other resources.
35
+
21
36
  5.2.0
22
37
  ******
23
38