tinybird-cli 3.1.0.dev1__tar.gz → 3.1.0.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.1.0.dev1 → tinybird-cli-3.1.0.dev3}/PKG-INFO +11 -2
  2. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/__cli__.py +2 -2
  3. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/datafile.py +70 -9
  4. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/feedback_manager.py +2 -0
  5. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/tb_cli_modules/pipe.py +1 -1
  6. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird_cli.egg-info/PKG-INFO +11 -2
  7. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/setup.cfg +0 -0
  8. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/ch_utils/constants.py +0 -0
  9. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/ch_utils/engine.py +0 -0
  10. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/check_pypi.py +0 -0
  11. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/client.py +0 -0
  12. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/config.py +0 -0
  13. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/connector_settings.py +0 -0
  14. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/connectors.py +0 -0
  15. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/context.py +0 -0
  16. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/datatypes.py +0 -0
  17. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/git_settings.py +0 -0
  18. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/sql.py +0 -0
  19. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/sql_template.py +0 -0
  20. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/sql_template_fmt.py +0 -0
  21. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/sql_toolset.py +0 -0
  22. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/syncasync.py +0 -0
  23. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/tb_cli.py +0 -0
  24. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/tb_cli_modules/auth.py +0 -0
  25. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/tb_cli_modules/branch.py +0 -0
  26. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/tb_cli_modules/cicd.py +0 -0
  27. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/tb_cli_modules/cli.py +0 -0
  28. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/tb_cli_modules/common.py +0 -0
  29. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/tb_cli_modules/config.py +0 -0
  30. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/tb_cli_modules/connection.py +0 -0
  31. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/tb_cli_modules/datasource.py +0 -0
  32. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/tb_cli_modules/exceptions.py +0 -0
  33. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/tb_cli_modules/job.py +0 -0
  34. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/tb_cli_modules/regions.py +0 -0
  35. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/tb_cli_modules/telemetry.py +0 -0
  36. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/tb_cli_modules/test.py +0 -0
  37. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/tb_cli_modules/tinyunit/tinyunit.py +0 -0
  38. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/tb_cli_modules/tinyunit/tinyunit_lib.py +0 -0
  39. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/tb_cli_modules/token.py +0 -0
  40. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/tb_cli_modules/workspace.py +0 -0
  41. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/tb_cli_modules/workspace_members.py +0 -0
  42. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird/tornado_template.py +0 -0
  43. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird_cli.egg-info/SOURCES.txt +0 -0
  44. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird_cli.egg-info/dependency_links.txt +0 -0
  45. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird_cli.egg-info/entry_points.txt +0 -0
  46. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.dev3}/tinybird_cli.egg-info/requires.txt +0 -0
  47. {tinybird-cli-3.1.0.dev1 → tinybird-cli-3.1.0.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.1.0.dev1
3
+ Version: 3.1.0.dev3
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://docs.tinybird.co/cli.html
6
6
  Author: Tinybird
@@ -19,12 +19,21 @@ Changelog
19
19
 
20
20
  ---------
21
21
 
22
+ 3.1.0.dev3
23
+ ************
24
+
25
+ - `Changed` option `--node` in `tb pipe populate` to required as it is already mandatory to specify the node to populate. Now, it will provide an error message if the `--node` option is not provided.
26
+
27
+ 3.1.0.dev2
28
+ ************
29
+
30
+ - `Added` Ignore format changes on `tb deploy`. Only if `TB_DIFF_ON_DEPLOY` env variables is enabled
31
+
22
32
  3.1.0.dev1
23
33
  ************
24
34
 
25
35
  - `Added` `tb init --cicd` to generate CI/CD files not only when using `--git`. Combine with `--force` for overwrite
26
36
 
27
-
28
37
  3.0.2.dev3
29
38
  ************
30
39
 
@@ -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.1.0.dev1'
8
- __revision__ = '6ab3285'
7
+ __version__ = '3.1.0.dev3'
8
+ __revision__ = 'c07d4f3'
@@ -434,6 +434,21 @@ class Deployment:
434
434
  self.tb_client = tb_client
435
435
  self.dry_run = dry_run
436
436
 
437
+ def _filenames_from_changed_modified(self, changed: Dict[str, Optional[str]], filenames: List[str]) -> List[str]:
438
+ filenames_from_changed = []
439
+ for change, type in changed.items():
440
+ if (
441
+ self.cli_git_release
442
+ and type
443
+ and self.cli_git_release.ChangeType(type) == self.cli_git_release.ChangeType.MODIFIED
444
+ ):
445
+ filenames_from_changed += [
446
+ filename
447
+ for filename in filenames
448
+ if filename.endswith(f"{change}.pipe") or filename.endswith(f"{change}.datasource")
449
+ ]
450
+ return filenames_from_changed
451
+
437
452
  async def detect_changes(
438
453
  self, filenames: List[str], only_changes: bool = False, config: Optional[Dict[str, Any]] = None
439
454
  ):
@@ -462,6 +477,27 @@ class Deployment:
462
477
  changed = self.cli_git_release.get_changes_from_diffs(diffs, filenames)
463
478
  deleted = self.cli_git_release.get_deleted_from_diffs(diffs)
464
479
 
480
+ if getenv_bool("TB_DIFF_ON_DEPLOY", False):
481
+ filenames_to_diff = self._filenames_from_changed_modified(changed, filenames)
482
+
483
+ diff_command_output = await diff_command(
484
+ filenames_to_diff,
485
+ fmt=True,
486
+ client=self.tb_client,
487
+ with_print=False,
488
+ for_deploy=True,
489
+ clean_up=True,
490
+ )
491
+ found_ignored_by_format = None
492
+ for change, type in changed.items():
493
+ if type and self.cli_git_release.ChangeType(type) == self.cli_git_release.ChangeType.MODIFIED:
494
+ if change in diff_command_output and diff_command_output.get(change) is None:
495
+ if not found_ignored_by_format:
496
+ click.echo(FeedbackManager.info_detected_changes_only_format())
497
+ found_ignored_by_format = True
498
+ click.echo(FeedbackManager.info_ignored_only_format(resource=change))
499
+ changed[change] = None
500
+
465
501
  else:
466
502
  # only changes flow
467
503
  changed = (
@@ -4035,6 +4071,7 @@ async def format_datasource(
4035
4071
  client: Optional[TinyB] = None,
4036
4072
  replace_includes: bool = False,
4037
4073
  datafile: Optional[Datafile] = None,
4074
+ for_deploy_diff: bool = False,
4038
4075
  ) -> str:
4039
4076
  if datafile:
4040
4077
  doc = datafile
@@ -4061,6 +4098,8 @@ async def format_datasource(
4061
4098
  }
4062
4099
  )
4063
4100
  format_version(file_parts, doc)
4101
+ if for_deploy_diff:
4102
+ format_description(file_parts, doc)
4064
4103
  format_tokens(file_parts, doc)
4065
4104
  format_schema(file_parts, doc.nodes[0])
4066
4105
  await format_engine(file_parts, doc.nodes[0], only_ttl=True, client=client)
@@ -4126,10 +4165,12 @@ def format_tokens(file_parts: List[str], doc: Datafile) -> List[str]:
4126
4165
  return file_parts
4127
4166
 
4128
4167
 
4129
- def format_node_sql(file_parts: List[str], node: Dict[str, Any], line_length: Optional[int] = None) -> List[str]:
4168
+ def format_node_sql(
4169
+ file_parts: List[str], node: Dict[str, Any], line_length: Optional[int] = None, lower_keywords: bool = False
4170
+ ) -> List[str]:
4130
4171
  file_parts.append("SQL >")
4131
4172
  file_parts.append(DATAFILE_NEW_LINE)
4132
- file_parts.append(format_sql(node["sql"], DATAFILE_INDENT, line_length=line_length))
4173
+ file_parts.append(format_sql(node["sql"], DATAFILE_INDENT, line_length=line_length, lower_keywords=lower_keywords))
4133
4174
  file_parts.append(DATAFILE_NEW_LINE)
4134
4175
  file_parts.append(DATAFILE_NEW_LINE)
4135
4176
  return file_parts
@@ -4237,6 +4278,7 @@ async def format_node(
4237
4278
  includes: Dict[str, Any],
4238
4279
  line_length: Optional[int] = None,
4239
4280
  unroll_includes: bool = False,
4281
+ lower_keywords: bool = False,
4240
4282
  ) -> None:
4241
4283
  if not unroll_includes:
4242
4284
  format_pipe_include(file_parts, node, includes)
@@ -4251,7 +4293,7 @@ async def format_node(
4251
4293
 
4252
4294
  Doc = namedtuple("Doc", ["description"])
4253
4295
  format_description(file_parts, Doc(node.get("description", "")))
4254
- format_node_sql(file_parts, node, line_length=line_length)
4296
+ format_node_sql(file_parts, node, line_length=line_length, lower_keywords=lower_keywords)
4255
4297
  await format_node_type(file_parts, node)
4256
4298
 
4257
4299
 
@@ -4261,6 +4303,7 @@ async def format_pipe(
4261
4303
  unroll_includes: bool = False,
4262
4304
  replace_includes: bool = False,
4263
4305
  datafile: Optional[Datafile] = None,
4306
+ for_deploy_diff: bool = False,
4264
4307
  ) -> str:
4265
4308
  if datafile:
4266
4309
  doc = datafile
@@ -4301,7 +4344,14 @@ async def format_pipe(
4301
4344
  if unrolled_included_node:
4302
4345
  doc.nodes.remove(unrolled_included_node)
4303
4346
  for node in doc.nodes:
4304
- await format_node(file_parts, node, doc.includes, line_length=line_length, unroll_includes=unroll_includes)
4347
+ await format_node(
4348
+ file_parts,
4349
+ node,
4350
+ doc.includes,
4351
+ line_length=line_length,
4352
+ unroll_includes=unroll_includes,
4353
+ lower_keywords=True if for_deploy_diff else False,
4354
+ )
4305
4355
 
4306
4356
  if not unroll_includes:
4307
4357
  for k, _ in doc.includes.items():
@@ -4316,8 +4366,8 @@ async def format_pipe(
4316
4366
  return result
4317
4367
 
4318
4368
 
4319
- def format_sql(sql: str, DATAFILE_INDENT: str, line_length: Optional[int] = None) -> str:
4320
- sql = format_sql_template(sql.strip(), line_length=line_length)
4369
+ def format_sql(sql: str, DATAFILE_INDENT: str, line_length: Optional[int] = None, lower_keywords: bool = False) -> str:
4370
+ sql = format_sql_template(sql.strip(), line_length=line_length, lower_keywords=lower_keywords)
4321
4371
  return "\n".join([f"{DATAFILE_INDENT}{part}" for part in sql.split("\n") if len(part.strip())])
4322
4372
 
4323
4373
 
@@ -4478,6 +4528,7 @@ async def diff_command(
4478
4528
  verbose: Optional[bool] = None,
4479
4529
  clean_up: Optional[bool] = False,
4480
4530
  progress_bar: bool = False,
4531
+ for_deploy: bool = False,
4481
4532
  ):
4482
4533
  def is_shared_datasource(name):
4483
4534
  return "." in name
@@ -4529,7 +4580,9 @@ async def diff_command(
4529
4580
  suffix = ".datasource" if ".datasource" in file else ".pipe"
4530
4581
  target = target_dir + os.path.sep + rfilename + suffix
4531
4582
 
4532
- diff_lines = await diff_files(target, file, with_format=fmt, with_color=(not no_color), client=client)
4583
+ diff_lines = await diff_files(
4584
+ target, file, with_format=fmt, with_color=(not no_color), client=client, for_deploy=for_deploy
4585
+ )
4533
4586
  not_empty, diff_lines = peek(diff_lines)
4534
4587
  changed[rfilename] = not_empty
4535
4588
  if not_empty and with_print:
@@ -4561,6 +4614,7 @@ async def diff_files(
4561
4614
  with_format: bool = True,
4562
4615
  with_color: bool = False,
4563
4616
  client: Optional[TinyB] = None,
4617
+ for_deploy: bool = False,
4564
4618
  ):
4565
4619
  def file_lines(filename):
4566
4620
  with open(filename) as file:
@@ -4572,14 +4626,21 @@ async def diff_files(
4572
4626
  if is_file_a_datasource(filename):
4573
4627
  lines = (
4574
4628
  await format_datasource(
4575
- filename, unroll_includes=unroll_includes, for_diff=True, client=client, replace_includes=True
4629
+ filename,
4630
+ unroll_includes=unroll_includes,
4631
+ for_diff=True,
4632
+ client=client,
4633
+ replace_includes=True,
4634
+ for_deploy_diff=for_deploy,
4576
4635
  )
4577
4636
  if with_format
4578
4637
  else file_lines(filename)
4579
4638
  )
4580
4639
  elif (".pipe" in extensions) or (".incl" in extensions):
4581
4640
  lines = (
4582
- await format_pipe(filename, 100, unroll_includes=unroll_includes, replace_includes=True)
4641
+ await format_pipe(
4642
+ filename, 100, unroll_includes=unroll_includes, replace_includes=True, for_deploy_diff=for_deploy
4643
+ )
4583
4644
  if with_format
4584
4645
  else file_lines(filename)
4585
4646
  )
@@ -628,6 +628,8 @@ Ready? """
628
628
  info_processing_from_include = info_message("\t{include_filename} => {filename}")
629
629
  info_deps_for_resource = info_message("\t{resource} => '{dep}'")
630
630
  info_deleting_resource = info_message("** {dry_run}Deleting '{resource_name}'")
631
+ info_detected_changes_only_format = info_message("** Ignoring resources due to only format changes:")
632
+ info_ignored_only_format = info_message("\t{resource}")
631
633
 
632
634
  info_cicd_generation_cancelled_by_user = info_message("** CI/CD files generation cancelled by user.")
633
635
  info_skipping_sharing_datasources_branch = info_message(
@@ -211,7 +211,7 @@ async def pipe_ls(ctx: Context, match: str, format_: str):
211
211
 
212
212
  @pipe.command(name="populate")
213
213
  @click.argument("pipe_name")
214
- @click.option("--node", type=str, help="Name of the materialized node.")
214
+ @click.option("--node", type=str, help="Name of the materialized node.", required=True)
215
215
  @click.option(
216
216
  "--sql-condition",
217
217
  type=str,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tinybird-cli
3
- Version: 3.1.0.dev1
3
+ Version: 3.1.0.dev3
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://docs.tinybird.co/cli.html
6
6
  Author: Tinybird
@@ -19,12 +19,21 @@ Changelog
19
19
 
20
20
  ---------
21
21
 
22
+ 3.1.0.dev3
23
+ ************
24
+
25
+ - `Changed` option `--node` in `tb pipe populate` to required as it is already mandatory to specify the node to populate. Now, it will provide an error message if the `--node` option is not provided.
26
+
27
+ 3.1.0.dev2
28
+ ************
29
+
30
+ - `Added` Ignore format changes on `tb deploy`. Only if `TB_DIFF_ON_DEPLOY` env variables is enabled
31
+
22
32
  3.1.0.dev1
23
33
  ************
24
34
 
25
35
  - `Added` `tb init --cicd` to generate CI/CD files not only when using `--git`. Combine with `--force` for overwrite
26
36
 
27
-
28
37
  3.0.2.dev3
29
38
  ************
30
39