tinybird 0.0.1.dev211__tar.gz → 0.0.1.dev213__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.

Potentially problematic release.


This version of tinybird might be problematic. Click here for more details.

Files changed (111) hide show
  1. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/PKG-INFO +1 -1
  2. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/sql.py +11 -1
  3. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/__cli__.py +2 -2
  4. tinybird-0.0.1.dev213/tinybird/tb/modules/local.py +173 -0
  5. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/local_common.py +5 -1
  6. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/telemetry.py +2 -1
  7. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird.egg-info/PKG-INFO +1 -1
  8. tinybird-0.0.1.dev211/tinybird/tb/modules/local.py +0 -402
  9. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/setup.cfg +0 -0
  10. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/__cli__.py +0 -0
  11. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/ch_utils/constants.py +0 -0
  12. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/ch_utils/engine.py +0 -0
  13. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/check_pypi.py +0 -0
  14. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/client.py +0 -0
  15. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/config.py +0 -0
  16. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/connectors.py +0 -0
  17. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/context.py +0 -0
  18. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/datafile.py +0 -0
  19. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/datatypes.py +0 -0
  20. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/feedback_manager.py +0 -0
  21. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/git_settings.py +0 -0
  22. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/prompts.py +0 -0
  23. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/sql_template.py +0 -0
  24. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/sql_template_fmt.py +0 -0
  25. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/sql_toolset.py +0 -0
  26. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/syncasync.py +0 -0
  27. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/check_pypi.py +0 -0
  28. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/cli.py +0 -0
  29. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/client.py +0 -0
  30. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/config.py +0 -0
  31. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/build.py +0 -0
  32. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/cicd.py +0 -0
  33. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/cli.py +0 -0
  34. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/common.py +0 -0
  35. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/config.py +0 -0
  36. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/connection.py +0 -0
  37. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/copy.py +0 -0
  38. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/create.py +0 -0
  39. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/datafile/build.py +0 -0
  40. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/datafile/build_common.py +0 -0
  41. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/datafile/build_datasource.py +0 -0
  42. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/datafile/build_pipe.py +0 -0
  43. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/datafile/common.py +0 -0
  44. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/datafile/diff.py +0 -0
  45. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/datafile/exceptions.py +0 -0
  46. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/datafile/fixture.py +0 -0
  47. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/datafile/format_common.py +0 -0
  48. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/datafile/format_datasource.py +0 -0
  49. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/datafile/format_pipe.py +0 -0
  50. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/datafile/parse_datasource.py +0 -0
  51. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/datafile/parse_pipe.py +0 -0
  52. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/datafile/pipe_checker.py +0 -0
  53. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/datafile/playground.py +0 -0
  54. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/datafile/pull.py +0 -0
  55. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/datasource.py +0 -0
  56. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/deployment.py +0 -0
  57. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/deprecations.py +0 -0
  58. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/dev_server.py +0 -0
  59. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/endpoint.py +0 -0
  60. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/exceptions.py +0 -0
  61. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/feedback_manager.py +0 -0
  62. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/info.py +0 -0
  63. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/infra.py +0 -0
  64. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/job.py +0 -0
  65. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/llm.py +0 -0
  66. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/llm_utils.py +0 -0
  67. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/login.py +0 -0
  68. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/logout.py +0 -0
  69. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/materialization.py +0 -0
  70. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/mock.py +0 -0
  71. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/open.py +0 -0
  72. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/pipe.py +0 -0
  73. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/project.py +0 -0
  74. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/regions.py +0 -0
  75. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/secret.py +0 -0
  76. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/shell.py +0 -0
  77. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/table.py +0 -0
  78. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/test.py +0 -0
  79. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/tinyunit/tinyunit.py +0 -0
  80. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/tinyunit/tinyunit_lib.py +0 -0
  81. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/token.py +0 -0
  82. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/watch.py +0 -0
  83. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/workspace.py +0 -0
  84. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb/modules/workspace_members.py +0 -0
  85. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb_cli.py +0 -0
  86. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb_cli_modules/auth.py +0 -0
  87. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb_cli_modules/branch.py +0 -0
  88. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb_cli_modules/cicd.py +0 -0
  89. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb_cli_modules/cli.py +0 -0
  90. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb_cli_modules/common.py +0 -0
  91. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb_cli_modules/config.py +0 -0
  92. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb_cli_modules/connection.py +0 -0
  93. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb_cli_modules/datasource.py +0 -0
  94. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb_cli_modules/exceptions.py +0 -0
  95. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb_cli_modules/fmt.py +0 -0
  96. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb_cli_modules/job.py +0 -0
  97. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb_cli_modules/pipe.py +0 -0
  98. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb_cli_modules/regions.py +0 -0
  99. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb_cli_modules/tag.py +0 -0
  100. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb_cli_modules/telemetry.py +0 -0
  101. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb_cli_modules/test.py +0 -0
  102. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb_cli_modules/tinyunit/tinyunit.py +0 -0
  103. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb_cli_modules/tinyunit/tinyunit_lib.py +0 -0
  104. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb_cli_modules/workspace.py +0 -0
  105. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tb_cli_modules/workspace_members.py +0 -0
  106. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird/tornado_template.py +0 -0
  107. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird.egg-info/SOURCES.txt +0 -0
  108. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird.egg-info/dependency_links.txt +0 -0
  109. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird.egg-info/entry_points.txt +0 -0
  110. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird.egg-info/requires.txt +0 -0
  111. {tinybird-0.0.1.dev211 → tinybird-0.0.1.dev213}/tinybird.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: tinybird
3
- Version: 0.0.1.dev211
3
+ Version: 0.0.1.dev213
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/forward/commands
6
6
  Author: Tinybird
@@ -67,8 +67,18 @@ class TableIndex:
67
67
  if index_supported_types:
68
68
  for supported_type in INDEX_SUPPORTED_TYPES.get(index_supported_types, []):
69
69
  # Convert supported type to regex pattern
70
- # Replace * with \d+ to match any number
71
70
  pattern = supported_type.replace("*", r"\d+")
71
+
72
+ # Special handling for complex types that can have parameters
73
+ if supported_type == "Array":
74
+ pattern = r"Array\(.*\)"
75
+ elif supported_type == "Map":
76
+ pattern = r"Map\(.*\)"
77
+ elif supported_type == "LowCardinality":
78
+ pattern = r"LowCardinality\(.*\)"
79
+ elif supported_type == "Nullable":
80
+ pattern = r"Nullable\(.*\)"
81
+
72
82
  if re.match(f"^{pattern}$", col_type):
73
83
  return
74
84
  raise ValueError(
@@ -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__ = '0.0.1.dev211'
8
- __revision__ = 'b26a42d'
7
+ __version__ = '0.0.1.dev213'
8
+ __revision__ = '36a1e58'
@@ -0,0 +1,173 @@
1
+ import subprocess
2
+
3
+ import click
4
+ import requests
5
+
6
+ from docker.client import DockerClient
7
+ from tinybird.tb.modules.cli import cli
8
+ from tinybird.tb.modules.common import coro
9
+ from tinybird.tb.modules.exceptions import CLIException
10
+ from tinybird.tb.modules.feedback_manager import FeedbackManager
11
+ from tinybird.tb.modules.local_common import (
12
+ TB_CONTAINER_NAME,
13
+ TB_LOCAL_ADDRESS,
14
+ get_docker_client,
15
+ get_existing_container_with_matching_env,
16
+ start_tinybird_local,
17
+ )
18
+
19
+
20
+ def stop_tinybird_local(docker_client: DockerClient) -> None:
21
+ """Stop the Tinybird container."""
22
+ try:
23
+ container = docker_client.containers.get(TB_CONTAINER_NAME)
24
+ container.stop()
25
+ except Exception:
26
+ pass
27
+
28
+
29
+ def remove_tinybird_local(docker_client: DockerClient) -> None:
30
+ """Remove the Tinybird container."""
31
+ try:
32
+ container = docker_client.containers.get(TB_CONTAINER_NAME)
33
+ if click.confirm(
34
+ FeedbackManager.warning(
35
+ message="△ This step will remove all your data inside Tinybird Local. Are you sure? [y/N]:"
36
+ ),
37
+ show_default=False,
38
+ prompt_suffix="",
39
+ ):
40
+ container.remove(force=True)
41
+ except Exception:
42
+ pass
43
+
44
+
45
+ def update_cli() -> None:
46
+ click.echo(FeedbackManager.highlight(message="» Updating Tinybird CLI..."))
47
+
48
+ try:
49
+ process = subprocess.Popen(
50
+ ["uv", "tool", "upgrade", "tinybird"],
51
+ stdout=subprocess.PIPE,
52
+ stderr=subprocess.PIPE,
53
+ text=True,
54
+ )
55
+ except FileNotFoundError:
56
+ raise CLIException(
57
+ FeedbackManager.error(
58
+ message="Cannot find required tool: uv. Reinstall using: curl https://tinybird.co | sh"
59
+ )
60
+ )
61
+
62
+ stdout, stderr = process.communicate()
63
+ if "Nothing to upgrade" not in stdout + stderr:
64
+ for line in stdout.split("\n") + stderr.split("\n"):
65
+ if "Updated tinybird" in line:
66
+ click.echo(FeedbackManager.info(message=f"» {line}"))
67
+ click.echo(FeedbackManager.success(message="✓ Tinybird CLI updated"))
68
+ else:
69
+ click.echo(FeedbackManager.info(message="✓ Tinybird CLI is already up-to-date"))
70
+
71
+
72
+ @cli.command()
73
+ def update() -> None:
74
+ """Update Tinybird CLI to the latest version."""
75
+ update_cli()
76
+
77
+
78
+ @cli.command(name="upgrade", hidden=True)
79
+ def upgrade() -> None:
80
+ """Update Tinybird CLI to the latest version."""
81
+ update_cli()
82
+
83
+
84
+ @cli.group()
85
+ @click.pass_context
86
+ def local(ctx: click.Context) -> None:
87
+ """Manage the local Tinybird instance."""
88
+
89
+
90
+ @local.command()
91
+ @coro
92
+ async def stop() -> None:
93
+ """Stop Tinybird Local"""
94
+ click.echo(FeedbackManager.highlight(message="» Shutting down Tinybird Local..."))
95
+ docker_client = get_docker_client()
96
+ stop_tinybird_local(docker_client)
97
+ click.echo(FeedbackManager.success(message="✓ Tinybird Local stopped."))
98
+
99
+
100
+ @local.command()
101
+ @coro
102
+ async def status() -> None:
103
+ """Check status of Tinybird Local"""
104
+ docker_client = get_docker_client()
105
+ container = get_existing_container_with_matching_env(docker_client, TB_CONTAINER_NAME, {})
106
+
107
+ if container:
108
+ status = container.status
109
+ health = container.attrs.get("State", {}).get("Health", {}).get("Status")
110
+
111
+ if status == "running" and health == "healthy":
112
+ click.echo(FeedbackManager.success(message="✓ Tinybird Local is ready!"))
113
+ elif status == "restarting" or (status == "running" and health == "starting"):
114
+ click.echo(FeedbackManager.highlight(message="* Tinybird Local is starting..."))
115
+ elif status == "removing":
116
+ click.echo(FeedbackManager.highlight(message="* Tinybird Local is stopping..."))
117
+ else:
118
+ click.echo(
119
+ FeedbackManager.info(message="✗ Tinybird Local is not running. Run 'tb local start' to start it")
120
+ )
121
+ else:
122
+ click.echo(FeedbackManager.info(message="✗ Tinybird Local is not running. Run 'tb local start' to start it"))
123
+
124
+
125
+ @local.command()
126
+ @coro
127
+ async def remove() -> None:
128
+ """Remove Tinybird Local"""
129
+ click.echo(FeedbackManager.highlight(message="» Removing Tinybird Local..."))
130
+ docker_client = get_docker_client()
131
+ remove_tinybird_local(docker_client)
132
+ click.echo(FeedbackManager.success(message="✓ Tinybird Local removed"))
133
+
134
+
135
+ @local.command()
136
+ @coro
137
+ @click.option(
138
+ "--use-aws-creds",
139
+ default=False,
140
+ is_flag=True,
141
+ help="Use local AWS credentials from your environment and pass them to the Tinybird docker container",
142
+ )
143
+ async def start(use_aws_creds: bool) -> None:
144
+ """Start Tinybird Local"""
145
+ click.echo(FeedbackManager.highlight(message="» Starting Tinybird Local..."))
146
+ docker_client = get_docker_client()
147
+ start_tinybird_local(docker_client, use_aws_creds)
148
+ click.echo(FeedbackManager.success(message="✓ Tinybird Local is ready!"))
149
+
150
+
151
+ @local.command()
152
+ @coro
153
+ @click.option(
154
+ "--use-aws-creds",
155
+ default=False,
156
+ is_flag=True,
157
+ help="Use local AWS credentials from your environment and pass them to the Tinybird docker container",
158
+ )
159
+ async def restart(use_aws_creds: bool) -> None:
160
+ """Restart Tinybird Local"""
161
+ click.echo(FeedbackManager.highlight(message="» Restarting Tinybird Local..."))
162
+ docker_client = get_docker_client()
163
+ remove_tinybird_local(docker_client)
164
+ click.echo(FeedbackManager.info(message="✓ Tinybird Local stopped"))
165
+ start_tinybird_local(docker_client, use_aws_creds)
166
+ click.echo(FeedbackManager.success(message="✓ Tinybird Local is ready!"))
167
+
168
+
169
+ @local.command()
170
+ def version() -> None:
171
+ """Show Tinybird Local version"""
172
+ response = requests.get(f"{TB_LOCAL_ADDRESS}/version")
173
+ click.echo(FeedbackManager.success(message=f"✓ Tinybird Local version: {response.text}"))
@@ -384,11 +384,15 @@ def get_docker_client() -> DockerClient:
384
384
  raise e
385
385
  return client
386
386
  except Exception:
387
+ docker_location_message = ""
388
+ if docker_host:
389
+ docker_location_message = f"Trying to connect to Docker-compatible runtime at {docker_host}"
390
+
387
391
  raise CLILocalException(
388
392
  FeedbackManager.error(
389
393
  message=(
390
394
  f"No container runtime is running. Make sure a Docker-compatible runtime is installed and running. "
391
- f"Trying to connect to Docker-compatible runtime at {docker_host}\n\n"
395
+ f"{docker_location_message}\n\n"
392
396
  "If you're using a custom location, please provide it using the DOCKER_HOST environment variable."
393
397
  )
394
398
  )
@@ -117,7 +117,8 @@ class TelemetryHelper:
117
117
  self.log("Not sending events in local development mode")
118
118
  return
119
119
 
120
- event_data["fingerprint_id"] = hashlib.sha256(platform.node().encode()).hexdigest()
120
+ fingerprint_string = f"{platform.node()}-{platform.platform()}-{platform.version()}"
121
+ event_data["fingerprint_id"] = hashlib.sha256(fingerprint_string.encode()).hexdigest()
121
122
  event_data["cwd"] = os.getcwd()
122
123
 
123
124
  config = get_config(host="", token=None)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: tinybird
3
- Version: 0.0.1.dev211
3
+ Version: 0.0.1.dev213
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/forward/commands
6
6
  Author: Tinybird
@@ -1,402 +0,0 @@
1
- import json
2
- import os
3
- import re
4
- import subprocess
5
- import time
6
- from typing import Optional
7
-
8
- import boto3
9
- import click
10
- import requests
11
-
12
- import docker
13
- from docker.client import DockerClient
14
- from docker.models.containers import Container
15
- from tinybird.tb.modules.cli import cli
16
- from tinybird.tb.modules.common import coro
17
- from tinybird.tb.modules.exceptions import CLIException, CLILocalException
18
- from tinybird.tb.modules.feedback_manager import FeedbackManager
19
- from tinybird.tb.modules.local_common import TB_CONTAINER_NAME, TB_IMAGE_NAME, TB_LOCAL_ADDRESS, TB_LOCAL_PORT
20
- from tinybird.tb.modules.telemetry import add_telemetry_event
21
-
22
-
23
- def start_tinybird_local(
24
- docker_client: DockerClient,
25
- use_aws_creds: bool,
26
- ) -> None:
27
- """Start the Tinybird container."""
28
- pull_show_prompt = False
29
- pull_required = False
30
- try:
31
- local_image = docker_client.images.get(TB_IMAGE_NAME)
32
- local_image_id = local_image.attrs["RepoDigests"][0].split("@")[1]
33
- remote_image = docker_client.images.get_registry_data(TB_IMAGE_NAME)
34
- pull_show_prompt = local_image_id != remote_image.id
35
- except Exception:
36
- pull_show_prompt = False
37
- pull_required = True
38
-
39
- if pull_show_prompt and click.confirm(
40
- FeedbackManager.warning(message="△ New version detected, download? [y/N]:"),
41
- show_default=False,
42
- prompt_suffix="",
43
- ):
44
- click.echo(FeedbackManager.info(message="* Downloading latest version of Tinybird Local..."))
45
- pull_required = True
46
-
47
- if pull_required:
48
- docker_client.images.pull(TB_IMAGE_NAME, platform="linux/amd64")
49
-
50
- environment = get_use_aws_creds() if use_aws_creds else {}
51
-
52
- container = get_existing_container_with_matching_env(docker_client, TB_CONTAINER_NAME, environment)
53
-
54
- if container and not pull_required:
55
- # Container `start` is idempotent. It's safe to call it even if the container is already running.
56
- container.start()
57
- else:
58
- if container:
59
- container.remove(force=True)
60
-
61
- container = docker_client.containers.run(
62
- TB_IMAGE_NAME,
63
- name=TB_CONTAINER_NAME,
64
- detach=True,
65
- ports={"7181/tcp": TB_LOCAL_PORT},
66
- remove=False,
67
- platform="linux/amd64",
68
- environment=environment,
69
- )
70
-
71
- click.echo(FeedbackManager.info(message="* Waiting for Tinybird Local to be ready..."))
72
- while True:
73
- container.reload() # Refresh container attributes
74
- health = container.attrs.get("State", {}).get("Health", {}).get("Status")
75
- if health == "healthy":
76
- break
77
- if health == "unhealthy":
78
- raise CLILocalException(
79
- FeedbackManager.error(
80
- message="Tinybird Local is unhealthy. Try running `tb local restart` in a few seconds."
81
- )
82
- )
83
-
84
- time.sleep(5)
85
-
86
- # Remove tinybird-local dangling images to avoid running out of disk space
87
- images = docker_client.images.list(name=re.sub(r":.*$", "", TB_IMAGE_NAME), all=True, filters={"dangling": True})
88
- for image in images:
89
- image.remove(force=True)
90
-
91
-
92
- def get_existing_container_with_matching_env(
93
- docker_client: DockerClient, container_name: str, required_env: dict[str, str]
94
- ) -> Optional[Container]:
95
- """
96
- Checks if a container with the given name exists and has matching environment variables.
97
- If it exists but environment doesn't match, it returns None.
98
-
99
- Args:
100
- docker_client: The Docker client instance
101
- container_name: The name of the container to check
102
- required_env: Dictionary of environment variables that must be present
103
-
104
- Returns:
105
- The container if it exists with matching environment, None otherwise
106
- """
107
- container = None
108
- containers = docker_client.containers.list(all=True, filters={"name": container_name})
109
- if containers:
110
- container = containers[0]
111
-
112
- if container and required_env:
113
- container_info = container.attrs
114
- container_env = container_info.get("Config", {}).get("Env", [])
115
- env_missing = False
116
- for key, value in required_env.items():
117
- env_var = f"{key}={value}"
118
- if env_var not in container_env:
119
- env_missing = True
120
- break
121
-
122
- if env_missing:
123
- container.remove(force=True)
124
- container = None
125
-
126
- return container
127
-
128
-
129
- def get_docker_client() -> DockerClient:
130
- """Check if Docker is installed and running."""
131
- try:
132
- docker_host = os.getenv("DOCKER_HOST")
133
- if not docker_host:
134
- # Try to get docker host from docker context
135
- try:
136
- try:
137
- output = subprocess.check_output(["docker", "context", "inspect"], text=True)
138
- except Exception as e:
139
- add_telemetry_event(
140
- "docker_error",
141
- error=f"docker_context_inspect_error: {str(e)}",
142
- )
143
- raise e
144
- try:
145
- context = json.loads(output)
146
- except Exception as e:
147
- add_telemetry_event(
148
- "docker_error",
149
- error=f"docker_context_inspect_parse_output_error: {str(e)}",
150
- data={
151
- "docker_context_inspect_output": output,
152
- },
153
- )
154
- raise e
155
- if context and len(context) > 0:
156
- try:
157
- docker_host = context[0].get("Endpoints", {}).get("docker", {}).get("Host")
158
- if docker_host:
159
- os.environ["DOCKER_HOST"] = docker_host
160
- except Exception as e:
161
- add_telemetry_event(
162
- "docker_error",
163
- error=f"docker_context_parse_host_error: {str(e)}",
164
- data={
165
- "context": json.dumps(context),
166
- },
167
- )
168
- raise e
169
- except Exception:
170
- pass
171
- try:
172
- client = docker.from_env() # type: ignore
173
- except Exception as e:
174
- add_telemetry_event(
175
- "docker_error",
176
- error=f"docker_get_client_from_env_error: {str(e)}",
177
- )
178
- raise e
179
- try:
180
- client.ping()
181
- except Exception as e:
182
- client_dict_non_sensitive = {k: v for k, v in client.api.__dict__.items() if "auth" not in k}
183
- add_telemetry_event(
184
- "docker_error",
185
- error=f"docker_ping_error: {str(e)}",
186
- data={
187
- "client": repr(client_dict_non_sensitive),
188
- },
189
- )
190
- raise e
191
- return client
192
- except Exception:
193
- docker_location_message = ""
194
- if docker_host:
195
- docker_location_message = f"Trying to connect to Docker-compatible runtime at {docker_host}"
196
-
197
- raise CLILocalException(
198
- FeedbackManager.error(
199
- message=(
200
- f"No container runtime is running. Make sure a Docker-compatible runtime is installed and running. "
201
- f"{docker_location_message}\n\n"
202
- "If you're using a custom location, please provide it using the DOCKER_HOST environment variable."
203
- )
204
- )
205
- )
206
-
207
-
208
- def get_use_aws_creds() -> dict[str, str]:
209
- credentials: dict[str, str] = {}
210
- try:
211
- # Get the boto3 session and credentials
212
- session = boto3.Session()
213
- creds = session.get_credentials()
214
-
215
- if creds:
216
- # Create environment variables for the container based on boto credentials
217
- credentials["AWS_ACCESS_KEY_ID"] = creds.access_key
218
- credentials["AWS_SECRET_ACCESS_KEY"] = creds.secret_key
219
-
220
- # Add session token if it exists (for temporary credentials)
221
- if creds.token:
222
- credentials["AWS_SESSION_TOKEN"] = creds.token
223
-
224
- # Add region if available
225
- if session.region_name:
226
- credentials["AWS_DEFAULT_REGION"] = session.region_name
227
-
228
- click.echo(
229
- FeedbackManager.success(
230
- message=f"✓ AWS credentials found and will be passed to Tinybird Local (region: {session.region_name or 'not set'})"
231
- )
232
- )
233
- else:
234
- click.echo(
235
- FeedbackManager.warning(
236
- message="△ No AWS credentials found. S3 operations will not work in Tinybird Local."
237
- )
238
- )
239
- except Exception as e:
240
- click.echo(
241
- FeedbackManager.warning(
242
- message=f"△ Error retrieving AWS credentials: {str(e)}. S3 operations will not work in Tinybird Local."
243
- )
244
- )
245
-
246
- return credentials
247
-
248
-
249
- def stop_tinybird_local(docker_client: DockerClient) -> None:
250
- """Stop the Tinybird container."""
251
- try:
252
- container = docker_client.containers.get(TB_CONTAINER_NAME)
253
- container.stop()
254
- except Exception:
255
- pass
256
-
257
-
258
- def remove_tinybird_local(docker_client: DockerClient) -> None:
259
- """Remove the Tinybird container."""
260
- try:
261
- container = docker_client.containers.get(TB_CONTAINER_NAME)
262
- if click.confirm(
263
- FeedbackManager.warning(
264
- message="△ This step will remove all your data inside Tinybird Local. Are you sure? [y/N]:"
265
- ),
266
- show_default=False,
267
- prompt_suffix="",
268
- ):
269
- container.remove(force=True)
270
- except Exception:
271
- pass
272
-
273
-
274
- def update_cli() -> None:
275
- click.echo(FeedbackManager.highlight(message="» Updating Tinybird CLI..."))
276
-
277
- try:
278
- process = subprocess.Popen(
279
- ["uv", "tool", "upgrade", "tinybird"],
280
- stdout=subprocess.PIPE,
281
- stderr=subprocess.PIPE,
282
- text=True,
283
- )
284
- except FileNotFoundError:
285
- raise CLIException(
286
- FeedbackManager.error(
287
- message="Cannot find required tool: uv. Reinstall using: curl https://tinybird.co | sh"
288
- )
289
- )
290
-
291
- stdout, stderr = process.communicate()
292
- if "Nothing to upgrade" not in stdout + stderr:
293
- for line in stdout.split("\n") + stderr.split("\n"):
294
- if "Updated tinybird" in line:
295
- click.echo(FeedbackManager.info(message=f"» {line}"))
296
- click.echo(FeedbackManager.success(message="✓ Tinybird CLI updated"))
297
- else:
298
- click.echo(FeedbackManager.info(message="✓ Tinybird CLI is already up-to-date"))
299
-
300
-
301
- @cli.command()
302
- def update() -> None:
303
- """Update Tinybird CLI to the latest version."""
304
- update_cli()
305
-
306
-
307
- @cli.command(name="upgrade", hidden=True)
308
- def upgrade() -> None:
309
- """Update Tinybird CLI to the latest version."""
310
- update_cli()
311
-
312
-
313
- @cli.group()
314
- @click.pass_context
315
- def local(ctx: click.Context) -> None:
316
- """Manage the local Tinybird instance."""
317
-
318
-
319
- @local.command()
320
- @coro
321
- async def stop() -> None:
322
- """Stop Tinybird Local"""
323
- click.echo(FeedbackManager.highlight(message="» Shutting down Tinybird Local..."))
324
- docker_client = get_docker_client()
325
- stop_tinybird_local(docker_client)
326
- click.echo(FeedbackManager.success(message="✓ Tinybird Local stopped."))
327
-
328
-
329
- @local.command()
330
- @coro
331
- async def status() -> None:
332
- """Check status of Tinybird Local"""
333
- docker_client = get_docker_client()
334
- container = get_existing_container_with_matching_env(docker_client, TB_CONTAINER_NAME, {})
335
-
336
- if container:
337
- status = container.status
338
- health = container.attrs.get("State", {}).get("Health", {}).get("Status")
339
-
340
- if status == "running" and health == "healthy":
341
- click.echo(FeedbackManager.success(message="✓ Tinybird Local is ready!"))
342
- elif status == "restarting" or (status == "running" and health == "starting"):
343
- click.echo(FeedbackManager.highlight(message="* Tinybird Local is starting..."))
344
- elif status == "removing":
345
- click.echo(FeedbackManager.highlight(message="* Tinybird Local is stopping..."))
346
- else:
347
- click.echo(
348
- FeedbackManager.info(message="✗ Tinybird Local is not running. Run 'tb local start' to start it")
349
- )
350
- else:
351
- click.echo(FeedbackManager.info(message="✗ Tinybird Local is not running. Run 'tb local start' to start it"))
352
-
353
-
354
- @local.command()
355
- @coro
356
- async def remove() -> None:
357
- """Remove Tinybird Local"""
358
- click.echo(FeedbackManager.highlight(message="» Removing Tinybird Local..."))
359
- docker_client = get_docker_client()
360
- remove_tinybird_local(docker_client)
361
- click.echo(FeedbackManager.success(message="✓ Tinybird Local removed"))
362
-
363
-
364
- @local.command()
365
- @coro
366
- @click.option(
367
- "--use-aws-creds",
368
- default=False,
369
- is_flag=True,
370
- help="Use local AWS credentials from your environment and pass them to the Tinybird docker container",
371
- )
372
- async def start(use_aws_creds: bool) -> None:
373
- """Start Tinybird Local"""
374
- click.echo(FeedbackManager.highlight(message="» Starting Tinybird Local..."))
375
- docker_client = get_docker_client()
376
- start_tinybird_local(docker_client, use_aws_creds)
377
- click.echo(FeedbackManager.success(message="✓ Tinybird Local is ready!"))
378
-
379
-
380
- @local.command()
381
- @coro
382
- @click.option(
383
- "--use-aws-creds",
384
- default=False,
385
- is_flag=True,
386
- help="Use local AWS credentials from your environment and pass them to the Tinybird docker container",
387
- )
388
- async def restart(use_aws_creds: bool) -> None:
389
- """Restart Tinybird Local"""
390
- click.echo(FeedbackManager.highlight(message="» Restarting Tinybird Local..."))
391
- docker_client = get_docker_client()
392
- remove_tinybird_local(docker_client)
393
- click.echo(FeedbackManager.info(message="✓ Tinybird Local stopped"))
394
- start_tinybird_local(docker_client, use_aws_creds)
395
- click.echo(FeedbackManager.success(message="✓ Tinybird Local is ready!"))
396
-
397
-
398
- @local.command()
399
- def version() -> None:
400
- """Show Tinybird Local version"""
401
- response = requests.get(f"{TB_LOCAL_ADDRESS}/version")
402
- click.echo(FeedbackManager.success(message=f"✓ Tinybird Local version: {response.text}"))