tinybird-cli 2.0.0.dev2__tar.gz → 2.1.0.dev1__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 (45) hide show
  1. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/PKG-INFO +18 -2
  2. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/__cli__.py +2 -2
  3. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/datafile.py +73 -4
  4. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/feedback_manager.py +3 -0
  5. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird_cli.egg-info/PKG-INFO +18 -2
  6. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/setup.cfg +0 -0
  7. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/ch_utils/constants.py +0 -0
  8. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/ch_utils/engine.py +0 -0
  9. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/check_pypi.py +0 -0
  10. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/client.py +0 -0
  11. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/config.py +0 -0
  12. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/connector_settings.py +0 -0
  13. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/connectors.py +0 -0
  14. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/context.py +0 -0
  15. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/datatypes.py +0 -0
  16. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/sql.py +0 -0
  17. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/sql_template.py +0 -0
  18. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/sql_template_fmt.py +0 -0
  19. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/sql_toolset.py +0 -0
  20. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/syncasync.py +0 -0
  21. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/tb_cli.py +0 -0
  22. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/tb_cli_modules/auth.py +0 -0
  23. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/tb_cli_modules/branch.py +0 -0
  24. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/tb_cli_modules/cicd.py +0 -0
  25. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/tb_cli_modules/cli.py +0 -0
  26. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/tb_cli_modules/common.py +0 -0
  27. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/tb_cli_modules/config.py +0 -0
  28. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/tb_cli_modules/connection.py +0 -0
  29. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/tb_cli_modules/datasource.py +0 -0
  30. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/tb_cli_modules/exceptions.py +0 -0
  31. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/tb_cli_modules/job.py +0 -0
  32. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/tb_cli_modules/pipe.py +0 -0
  33. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/tb_cli_modules/telemetry.py +0 -0
  34. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/tb_cli_modules/test.py +0 -0
  35. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/tb_cli_modules/tinyunit/tinyunit.py +0 -0
  36. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/tb_cli_modules/tinyunit/tinyunit_lib.py +0 -0
  37. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/tb_cli_modules/token.py +0 -0
  38. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/tb_cli_modules/workspace.py +0 -0
  39. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/tb_cli_modules/workspace_members.py +0 -0
  40. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird/tornado_template.py +0 -0
  41. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird_cli.egg-info/SOURCES.txt +0 -0
  42. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird_cli.egg-info/dependency_links.txt +0 -0
  43. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird_cli.egg-info/entry_points.txt +0 -0
  44. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/tinybird_cli.egg-info/requires.txt +0 -0
  45. {tinybird-cli-2.0.0.dev2 → tinybird-cli-2.1.0.dev1}/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: 2.0.0.dev2
3
+ Version: 2.1.0.dev1
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://docs.tinybird.co/cli.html
6
6
  Author: Tinybird
@@ -19,6 +19,22 @@ Changelog
19
19
 
20
20
  ---------
21
21
 
22
+ 2.1.0.dev1
23
+ ************
24
+
25
+ - `Added` `tb deploy` removes resources from datafiles deleted
26
+
27
+
28
+ 2.0.0
29
+ ************
30
+
31
+ Released new version 2.0.0 with all these changes:
32
+
33
+ - `Changed` All commands exit with 1 when there's an exception
34
+ - `Removed` Prefixes are not supported anymore ([context](https://www.tinybird.co/changelog/2023-10-09-versions), and [how to migrate](https://www.tinybird.co/docs/guides/staging-and-production-workspaces.html#migrating-from-prefixes))
35
+ - `Removed` `tb pipe create`
36
+
37
+
22
38
  2.0.0.dev2
23
39
  ************
24
40
 
@@ -28,7 +44,7 @@ Changelog
28
44
  2.0.0.dev1
29
45
  ************
30
46
 
31
- - `Removed` Prefixes are not supported anymore.
47
+ - `Removed` Prefixes are not supported anymore
32
48
 
33
49
 
34
50
  1.3.0
@@ -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__ = '2.0.0.dev2'
8
- __revision__ = '8973b45'
7
+ __version__ = '2.1.0.dev1'
8
+ __revision__ = '877be29'
@@ -52,7 +52,7 @@ from tinybird.tb_cli_modules.common import _get_tb_client, get_current_main_work
52
52
 
53
53
  from .tornado_template import UnClosedIfError
54
54
  from .sql import parse_table_structure, schema_to_sql_columns
55
- from .client import TinyB, DoesNotExistException
55
+ from .client import TinyB, DoesNotExistException, AuthException, CanNotBeDeletedException
56
56
  from .sql_template import render_sql_template, get_used_tables_in_template
57
57
  from tinybird.sql_template_fmt import format_sql_template
58
58
  from .feedback_manager import FeedbackManager
@@ -410,6 +410,9 @@ class CLIGitRelease:
410
410
  for filename in filenames
411
411
  }
412
412
 
413
+ def get_deleted_from_diffs(self, diffs: List[Diff]) -> List[str]:
414
+ return [diff.a_path for diff in diffs if diff.change_type == self.ChangeType.DELETED.value and diff.a_path]
415
+
413
416
  async def update_release(
414
417
  self, tb_client: TinyB, current_ws: Dict[str, Any], commit: Optional[str] = None
415
418
  ) -> Dict[str, Any]:
@@ -454,6 +457,7 @@ class Deployment:
454
457
  if not diffs:
455
458
  click.echo(FeedbackManager.info_git_release_no_diffs())
456
459
  changed = self.cli_git_release.get_changes_from_diffs(diffs, filenames)
460
+ deleted = self.cli_git_release.get_deleted_from_diffs(diffs)
457
461
 
458
462
  else:
459
463
  # only changes flow
@@ -462,7 +466,8 @@ class Deployment:
462
466
  if config
463
467
  else None
464
468
  )
465
- return changed
469
+ deleted = []
470
+ return changed, deleted
466
471
 
467
472
  def preparing_release(self):
468
473
  if not self.is_git_release:
@@ -504,6 +509,67 @@ class Deployment:
504
509
  )
505
510
  click.echo(FeedbackManager.success_git_release(release_commit=release["commit"]))
506
511
 
512
+ async def delete_resources(self, deleted: List[str], remote_pipes: List[Dict[str, Any]], dry_run: bool = False):
513
+ async def delete_pipe(resource_name_or_id: str, dry_run: bool = False):
514
+ if dry_run:
515
+ click.echo(
516
+ FeedbackManager.info_deleting_resource(dry_run="[DRY RUN] ", resource_name=resource_name_or_id)
517
+ )
518
+ else:
519
+ click.echo(FeedbackManager.info_deleting_resource(dry_run="", resource_name=resource_name_or_id))
520
+ try:
521
+ await self.tb_client.pipe_delete(resource_name_or_id)
522
+ except AuthException as e:
523
+ raise CLIGitReleaseException(str(e))
524
+ else:
525
+ click.echo(FeedbackManager.success_delete(name=resource_name_or_id))
526
+
527
+ async def delete_datasource(resource_name_or_id: str, dry_run: bool = False):
528
+ if dry_run:
529
+ click.echo(
530
+ FeedbackManager.info_deleting_resource(dry_run="[DRY RUN] ", resource_name=resource_name_or_id)
531
+ )
532
+ else:
533
+ click.echo(FeedbackManager.info_deleting_resource(dry_run="", resource_name=resource_name_or_id))
534
+ try:
535
+ await self.tb_client.datasource_delete(resource_name_or_id)
536
+ except CanNotBeDeletedException as e:
537
+ raise CLIGitReleaseException(str(e))
538
+ else:
539
+ click.echo(FeedbackManager.success_delete(name=resource_name_or_id))
540
+
541
+ resource_extension_processor = {".datasource": delete_datasource, ".pipe": delete_pipe}
542
+
543
+ # builds pipes deps the other way around from API to use with toposort
544
+ # i.e {'analytics_hits': ['analytics_pages', 'trend', 'analytics_sources', 'analytics_sessions']}
545
+ pipes_deps: Dict[str, List[str]] = {}
546
+ remote_pipes_type: Dict[str, str] = {}
547
+ for pipe in remote_pipes:
548
+ pipes_deps[pipe["name"]] = []
549
+ remote_pipes_type[pipe["name"]] = pipe["type"]
550
+ for node in pipe["nodes"]:
551
+ for dep in node["dependencies"]:
552
+ if dep in [pipe["name"] for pipe in remote_pipes]:
553
+ pipes_deps.setdefault(dep, []).append(pipe["name"])
554
+ deleted_resources: Dict[str, str] = {Path(resource).resolve().stem: resource for resource in deleted}
555
+
556
+ for group in toposort(pipes_deps):
557
+ # for each level keep materialized for the end
558
+ for pipe_name in sorted(group, key=lambda x: remote_pipes_type[x] == "materialized"):
559
+ if pipe_name in deleted_resources:
560
+ resource_path = deleted_resources.pop(pipe_name)
561
+ try:
562
+ await resource_extension_processor[Path(resource_path).suffix](pipe_name, dry_run)
563
+ except KeyError:
564
+ raise CLIGitReleaseException(FeedbackManager.error_file_extension(resource_path))
565
+
566
+ # Delete pending resources (datasources)
567
+ for name, path in deleted_resources.items():
568
+ try:
569
+ await resource_extension_processor[Path(path).suffix](name, dry_run)
570
+ except KeyError:
571
+ raise CLIGitReleaseException(FeedbackManager.error_file_extension(path))
572
+
507
573
 
508
574
  class Datafile:
509
575
  def __init__(self) -> None:
@@ -3407,7 +3473,7 @@ async def folder_push(
3407
3473
  workspace_lib_paths.append((x.name, x))
3408
3474
 
3409
3475
  datasources: List[Dict[str, Any]] = await tb_client.datasources()
3410
- pipes: List[Dict[str, Any]] = await tb_client.pipes()
3476
+ pipes: List[Dict[str, Any]] = await tb_client.pipes(dependencies=True)
3411
3477
 
3412
3478
  existing_resources: List[str] = [x["name"] for x in datasources] + [x["name"] for x in pipes]
3413
3479
  # replace workspace mapping names
@@ -3429,7 +3495,7 @@ async def folder_push(
3429
3495
  filenames = get_project_filenames(folder)
3430
3496
 
3431
3497
  # get the list of changes
3432
- changed = await deployment.detect_changes(filenames, only_changes, config)
3498
+ changed, deleted = await deployment.detect_changes(filenames, only_changes, config)
3433
3499
 
3434
3500
  deployment.preparing_release()
3435
3501
 
@@ -3668,9 +3734,12 @@ async def folder_push(
3668
3734
  if deployment.is_git_release:
3669
3735
  deployment.deploying_dry_run()
3670
3736
  await push_files(dry_run=True)
3737
+
3738
+ await deployment.delete_resources(deleted, pipes, dry_run=True)
3671
3739
  if not deployment.dry_run:
3672
3740
  deployment.deploying()
3673
3741
  await push_files(dry_run)
3742
+ await deployment.delete_resources(deleted, pipes)
3674
3743
  else:
3675
3744
  await push_files(dry_run)
3676
3745
 
@@ -436,6 +436,7 @@ Ready? """
436
436
  )
437
437
  warning_for_cicd_file = warning_message("** 🚨 Warning 🚨: {warning_message}")
438
438
  warning_unknown_response = warning_message("** Warning. Unknown response from server: {response}")
439
+ warning_resource_not_in_workspace = warning_message("** Warning: '{resource_name}' not found in workspace")
439
440
 
440
441
  info_materialize_push_datasource_exists = warning_message("** Data Source {name} already exists")
441
442
  info_materialize_push_datasource_override = prompt_message(
@@ -589,6 +590,7 @@ Ready? """
589
590
  info_detected_changes_from_includes = info_message("** Changes from includes:")
590
591
  info_processing_from_include = info_message("\t{include_filename} => {filename}")
591
592
  info_deps_for_resource = info_message("\t{resource} => '{dep}'")
593
+ info_deleting_resource = info_message("** {dry_run}Deleting '{resource_name}'")
592
594
 
593
595
  info_cicd_generation_cancelled_by_user = info_message("** CI/CD files generation cancelled by user.")
594
596
  info_skipping_sharing_datasources_environment = info_message(
@@ -697,6 +699,7 @@ Ready? """
697
699
  success_sink_job_finished = success_message("""** Data sinked to '{bucket_path}'""")
698
700
  success_print_pipe = success_message("** Pipe: {pipe}")
699
701
  success_create = success_message("** '{name}' created")
702
+ success_delete = success_message("** '{name}' deleted")
700
703
  success_progress_blocks = success_message("** \N{front-facing baby chick} done")
701
704
  success_now_using_config = success_message("** Now using {name} ({id})")
702
705
  success_connector_config = success_message(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tinybird-cli
3
- Version: 2.0.0.dev2
3
+ Version: 2.1.0.dev1
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://docs.tinybird.co/cli.html
6
6
  Author: Tinybird
@@ -19,6 +19,22 @@ Changelog
19
19
 
20
20
  ---------
21
21
 
22
+ 2.1.0.dev1
23
+ ************
24
+
25
+ - `Added` `tb deploy` removes resources from datafiles deleted
26
+
27
+
28
+ 2.0.0
29
+ ************
30
+
31
+ Released new version 2.0.0 with all these changes:
32
+
33
+ - `Changed` All commands exit with 1 when there's an exception
34
+ - `Removed` Prefixes are not supported anymore ([context](https://www.tinybird.co/changelog/2023-10-09-versions), and [how to migrate](https://www.tinybird.co/docs/guides/staging-and-production-workspaces.html#migrating-from-prefixes))
35
+ - `Removed` `tb pipe create`
36
+
37
+
22
38
  2.0.0.dev2
23
39
  ************
24
40
 
@@ -28,7 +44,7 @@ Changelog
28
44
  2.0.0.dev1
29
45
  ************
30
46
 
31
- - `Removed` Prefixes are not supported anymore.
47
+ - `Removed` Prefixes are not supported anymore
32
48
 
33
49
 
34
50
  1.3.0