tinybird 0.0.1.dev211__py3-none-any.whl → 0.0.1.dev213__py3-none-any.whl

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.

tinybird/sql.py CHANGED
@@ -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(
tinybird/tb/__cli__.py CHANGED
@@ -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'
@@ -1,249 +1,20 @@
1
- import json
2
- import os
3
- import re
4
1
  import subprocess
5
- import time
6
- from typing import Optional
7
2
 
8
- import boto3
9
3
  import click
10
4
  import requests
11
5
 
12
- import docker
13
6
  from docker.client import DockerClient
14
- from docker.models.containers import Container
15
7
  from tinybird.tb.modules.cli import cli
16
8
  from tinybird.tb.modules.common import coro
17
- from tinybird.tb.modules.exceptions import CLIException, CLILocalException
9
+ from tinybird.tb.modules.exceptions import CLIException
18
10
  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
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
+ )
247
18
 
248
19
 
249
20
  def stop_tinybird_local(docker_client: DockerClient) -> None:
@@ -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
@@ -4,7 +4,7 @@ tinybird/datatypes.py,sha256=r4WCvspmrXTJHiPjjyOTiZyZl31FO3Ynkwq4LQsYm6E,11059
4
4
  tinybird/feedback_manager.py,sha256=1INQFfRfuMCb9lfB8KNf4r6qC2khW568hoHjtk-wshI,69305
5
5
  tinybird/git_settings.py,sha256=Sw_8rGmribEFJ4Z_6idrVytxpFYk7ez8ei0qHULzs3E,3934
6
6
  tinybird/prompts.py,sha256=ZdpY7FyJh9vg7SfZkR0h5h-dy2VecbBMkli3nI7-eVo,38006
7
- tinybird/sql.py,sha256=C_B81wwv3BsqyXGhF5oTk9DcTUkrp7NwIFqSzd3Dmjc,47854
7
+ tinybird/sql.py,sha256=BufnOgclQokDyihtuXesOwHBsebN6wRXIxO5wKRkOwE,48299
8
8
  tinybird/sql_template.py,sha256=WjsTBjpQLVBHGZbY2dZuhZUurFR-rbJ_KRRy5vx4Y5E,99967
9
9
  tinybird/sql_template_fmt.py,sha256=KUHdj5rYCYm_rKKdXYSJAE9vIyXUQLB0YSZnUXHeBlY,10196
10
10
  tinybird/sql_toolset.py,sha256=M2rpLYkgV2W8NnYEYPC1tJdpy4uZHXVF64NBSKLQka4,19549
@@ -12,7 +12,7 @@ tinybird/syncasync.py,sha256=IPnOx6lMbf9SNddN1eBtssg8vCLHMt76SuZ6YNYm-Yk,27761
12
12
  tinybird/tornado_template.py,sha256=jjNVDMnkYFWXflmT8KU_Ssbo5vR8KQq3EJMk5vYgXRw,41959
13
13
  tinybird/ch_utils/constants.py,sha256=aYvg2C_WxYWsnqPdZB1ZFoIr8ZY-XjUXYyHKE9Ansj0,3890
14
14
  tinybird/ch_utils/engine.py,sha256=X4tE9OrfaUy6kO9cqVEzyI9cDcmOF3IAssRRzsTsfEQ,40781
15
- tinybird/tb/__cli__.py,sha256=dJnaXvzVEcL8O2Ju7bSj2suNdnw0CQh9c7dE9BwRK9g,247
15
+ tinybird/tb/__cli__.py,sha256=_Rr6Wm1SeYKD1LpPgtsU7XL8grX5YitBreg6jpN2MGU,247
16
16
  tinybird/tb/check_pypi.py,sha256=i3l2L8IajeB7sreikR7oPlYJki9MtS3c_M4crnmbByc,760
17
17
  tinybird/tb/cli.py,sha256=u3eGOhX0MHkuT6tiwaZ0_3twqLmqKXDAOxF7yV_Nn9Q,1075
18
18
  tinybird/tb/client.py,sha256=0zUAi9Lclo2JusQKlQnSnSP1XCiCK9I03XtLqmk8e04,56487
@@ -37,8 +37,8 @@ tinybird/tb/modules/infra.py,sha256=fve30Gj3mG9zbquGxS2e4ipcOYOxviWQCpNFfEzJN_Q,
37
37
  tinybird/tb/modules/job.py,sha256=AsUCRNzy7HG5oJ4fyk9NpIm5NtNJgBZSy8MtJdXBe5A,3167
38
38
  tinybird/tb/modules/llm.py,sha256=KfsCYmKeW1VQz0iDZhGKCRkQv_Y3kTHh6JuxvofOguE,1076
39
39
  tinybird/tb/modules/llm_utils.py,sha256=nS9r4FAElJw8yXtmdYrx-rtI2zXR8qXfi1QqUDCfxvg,3469
40
- tinybird/tb/modules/local.py,sha256=9riA3PrCTUXWeDTWMhd14M2-9pFHI6fedpjY4m_lRpU,14359
41
- tinybird/tb/modules/local_common.py,sha256=msAZDNPPVenNyL9Dqfb0Z5uFC_1O809xdAi7j1iKmJA,17066
40
+ tinybird/tb/modules/local.py,sha256=mLSgMMP3H1MdanVLsFZieeqOANSnctPLey3pJ_L1ZBI,5807
41
+ tinybird/tb/modules/local_common.py,sha256=8CSEVygFi0fIISatYxCStcHizugXCA9WNTLO_zDKmXw,17195
42
42
  tinybird/tb/modules/login.py,sha256=qfY17J3FryTPl8A0ucQgxiyJ7jLy81qHdlHXgqohi0c,10170
43
43
  tinybird/tb/modules/logout.py,sha256=sniI4JNxpTrVeRCp0oGJuQ3yRerG4hH5uz6oBmjv724,1009
44
44
  tinybird/tb/modules/materialization.py,sha256=QJX5kCPhhm6IXBO1JsalVfbQdypCe_eOUDZ_WHJZWS8,5478
@@ -50,7 +50,7 @@ tinybird/tb/modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGM
50
50
  tinybird/tb/modules/secret.py,sha256=jw1DIDKmS1L1U-y7LRYo65sVSGuRcpIHGo5CNiKHjo4,4945
51
51
  tinybird/tb/modules/shell.py,sha256=Zd_4Ak_5tKVX-cw6B4ag36xZeEGHeh-jZpAsIXkoMoE,14116
52
52
  tinybird/tb/modules/table.py,sha256=4XrtjM-N0zfNtxVkbvLDQQazno1EPXnxTyo7llivfXk,11035
53
- tinybird/tb/modules/telemetry.py,sha256=X0p5AVkM8BNsK_Rhdcg4p2eIf6OHimHO_VLldBqHQ8o,11386
53
+ tinybird/tb/modules/telemetry.py,sha256=T9gtsQffWqG_4hRBaUJPzOfMkPwz7mH-R6Bn1XRYViA,11482
54
54
  tinybird/tb/modules/test.py,sha256=XakpYi0Q2gGKItpPdtRVLKzQldkvCPqzPhwwbUxyrmc,13292
55
55
  tinybird/tb/modules/token.py,sha256=2fmKwu10_M0pqs6YmJVeILR9ZQB0ejRAET86agASbKM,13488
56
56
  tinybird/tb/modules/watch.py,sha256=tkt2s8CLxBvB9Ty7YVgdh4wBTWIisZA5pstZTG7sZy8,8976
@@ -80,8 +80,8 @@ tinybird/tb_cli_modules/config.py,sha256=IsgdtFRnUrkY8-Zo32lmk6O7u3bHie1QCxLwgp4
80
80
  tinybird/tb_cli_modules/exceptions.py,sha256=pmucP4kTF4irIt7dXiG-FcnI-o3mvDusPmch1L8RCWk,3367
81
81
  tinybird/tb_cli_modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
82
82
  tinybird/tb_cli_modules/telemetry.py,sha256=Hh2Io8ZPROSunbOLuMvuIFU4TqwWPmQTqal4WS09K1A,10449
83
- tinybird-0.0.1.dev211.dist-info/METADATA,sha256=h5xeu9k1bFy0oL7O4fSN21kkx06osHCf0mpS8kzUXfw,1682
84
- tinybird-0.0.1.dev211.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
85
- tinybird-0.0.1.dev211.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
86
- tinybird-0.0.1.dev211.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
87
- tinybird-0.0.1.dev211.dist-info/RECORD,,
83
+ tinybird-0.0.1.dev213.dist-info/METADATA,sha256=XQKZmS6Dwt6M9bzsn5-JDiKBMA9DunE-kCMu2pAGkYI,1682
84
+ tinybird-0.0.1.dev213.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
85
+ tinybird-0.0.1.dev213.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
86
+ tinybird-0.0.1.dev213.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
87
+ tinybird-0.0.1.dev213.dist-info/RECORD,,