tinybird 0.0.1.dev166__py3-none-any.whl → 0.0.1.dev168__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.

@@ -146,10 +146,9 @@ class TableDetails:
146
146
  def is_replacing_engine(self) -> bool:
147
147
  if self.engine:
148
148
  engine_lower = self.engine.lower()
149
- is_aggregating = "aggregatingmergetree" in engine_lower
150
149
  is_replacing = "replacingmergetree" in engine_lower
151
150
  is_collapsing = "collapsingmergetree" in engine_lower
152
- return is_aggregating or is_replacing or is_collapsing
151
+ return is_replacing or is_collapsing
153
152
  return False
154
153
 
155
154
  def diff_ttl(self, new_ttl: str) -> bool:
@@ -169,6 +168,10 @@ class TableDetails:
169
168
  @property
170
169
  def sorting_key(self) -> Optional[str]:
171
170
  _sorting_key = self.details.get("sorting_key", None)
171
+ # TODO: This should use ENABLED_ENGINES to guess if the sorting key is required or not
172
+ # Also checking this and raising an error in a getter is a bit of an anti-pattern,
173
+ # a data source could have a "wrong" sorting key and we won't be able to even show it in the API.
174
+ # All these checks be performed only on creation time.
172
175
  if self.is_replacing_engine() and not _sorting_key:
173
176
  raise ValueError(f"SORTING_KEY must be defined for the {self.engine} engine")
174
177
  if self.is_mergetree_family():
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.dev166'
8
- __revision__ = 'dfe3726'
7
+ __version__ = '0.0.1.dev168'
8
+ __revision__ = 'd746fb3'
@@ -468,6 +468,19 @@ def create_deployment_cmd(
468
468
  template: Optional[str] = None,
469
469
  ) -> None:
470
470
  if template:
471
+ project = ctx.ensure_object(dict)["project"]
472
+ if project.get_project_files():
473
+ click.echo(
474
+ FeedbackManager.error(
475
+ message="You are trying to deploy a template from a folder that already contains data files. "
476
+ "Please remove the data files from the current folder or use a different folder and try again."
477
+ )
478
+ )
479
+ sys_exit(
480
+ "deployment_error",
481
+ "Deployment using a template is not allowed when the project already contains data files",
482
+ )
483
+
471
484
  click.echo(FeedbackManager.info(message="» Downloading template..."))
472
485
  try:
473
486
  download_github_template(template)
@@ -109,22 +109,84 @@ def get_local_tokens() -> Dict[str, str]:
109
109
  # ruff: noqa: ASYNC210
110
110
  return requests.get(f"{TB_LOCAL_ADDRESS}/tokens").json()
111
111
  except Exception:
112
+ # Check if tinybird-local is running using docker client (some clients use podman and won't have docker cmd)
112
113
  try:
113
- # Check if tinybird-local is running with docker, in case it's a config issue
114
- output = subprocess.check_output(["docker", "ps"], text=True)
115
- header_row = next((line for line in output.splitlines() if "CONTAINER ID" in line), "")
116
- tb_local_row = next(
117
- (line for line in output.splitlines() if TB_CONTAINER_NAME in line),
118
- f"{TB_CONTAINER_NAME} not found in output",
114
+ docker_client = get_docker_client()
115
+ container = get_existing_container_with_matching_env(docker_client, TB_CONTAINER_NAME, {})
116
+
117
+ output = {}
118
+ if container:
119
+ output = container.attrs
120
+ add_telemetry_event(
121
+ "docker_debug",
122
+ data={
123
+ "container_attrs": output,
124
+ },
119
125
  )
126
+
127
+ if container and container.status == "running":
128
+ if container.health == "healthy":
129
+ raise CLILocalException(
130
+ FeedbackManager.error(
131
+ message=(
132
+ "Looks like Tinybird Local is running but we are not able to connect to it.\n\n"
133
+ "If you've run it manually using different host or port, please set the environment variables "
134
+ "TB_LOCAL_HOST and TB_LOCAL_PORT to match the ones you're using.\n"
135
+ "If you're not sure about this, please run `tb local restart` and try again."
136
+ )
137
+ )
138
+ )
139
+ raise CLILocalException(
140
+ FeedbackManager.error(
141
+ message=(
142
+ "Tinybird Local is running but it's unhealthy. Please check if it's running and try again.\n"
143
+ "If the problem persists, please run `tb local restart` and try again."
144
+ )
145
+ )
146
+ )
147
+ except CLILocalException as e:
148
+ raise e
149
+ except Exception:
150
+ pass
151
+
152
+ # Check if tinybird-local is running with docker
153
+ try:
154
+ output_str = subprocess.check_output(
155
+ ["docker", "ps", "--filter", f"name={TB_CONTAINER_NAME}", "--format", "json"], text=True
156
+ )
157
+ output = {}
158
+ if output_str:
159
+ output = json.loads(output_str)
120
160
  add_telemetry_event(
121
161
  "docker_debug",
122
162
  data={
123
- "docker_ps_output": header_row + tb_local_row,
163
+ "docker_ps_output": output,
124
164
  },
125
165
  )
166
+
167
+ if output.get("State", "") == "running":
168
+ if "(healthy)" in output.get("Status", ""):
169
+ raise CLILocalException(
170
+ FeedbackManager.error(
171
+ message=(
172
+ "Looks like Tinybird Local is running but we are not able to connect to it.\n\n"
173
+ "If you've run it manually using different host or port, please set the environment variables "
174
+ "TB_LOCAL_HOST and TB_LOCAL_PORT to match the ones you're using.\n"
175
+ "If you're not sure about this, please run `tb local restart` and try again."
176
+ )
177
+ )
178
+ )
179
+ raise CLILocalException(
180
+ FeedbackManager.error(
181
+ message="Tinybird Local is running but it's unhealthy. Please check if it's running and try again.\n"
182
+ "If the problem persists, please run `tb local restart` and try again."
183
+ )
184
+ )
185
+ except CLILocalException as e:
186
+ raise e
126
187
  except Exception:
127
188
  pass
189
+
128
190
  is_ci = (
129
191
  os.getenv("GITHUB_ACTIONS")
130
192
  or os.getenv("TRAVIS")
@@ -146,6 +208,7 @@ def get_local_tokens() -> Dict[str, str]:
146
208
  start_tinybird_local(docker_client, False)
147
209
  click.echo(FeedbackManager.success(message="✓ Tinybird Local is ready!"))
148
210
  return get_local_tokens()
211
+
149
212
  raise CLILocalException(
150
213
  FeedbackManager.error(message="Tinybird local is not running. Please run `tb local start` first.")
151
214
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: tinybird
3
- Version: 0.0.1.dev166
3
+ Version: 0.0.1.dev168
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/forward/commands
6
6
  Author: Tinybird
@@ -11,8 +11,8 @@ tinybird/sql_toolset.py,sha256=KORVbNAUTfW1qo3U9oe7Z59xQ0QMsFhB0ji3HzY2JVo,15324
11
11
  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
- tinybird/ch_utils/engine.py,sha256=BZuPM7MFS7vaEKK5tOMR2bwSAgJudPrJt27uVEwZmTY,40512
15
- tinybird/tb/__cli__.py,sha256=Bncibdl66_JHCDwjy6-b6gYfCvP97569anD3Ydq_nmo,247
14
+ tinybird/ch_utils/engine.py,sha256=X4tE9OrfaUy6kO9cqVEzyI9cDcmOF3IAssRRzsTsfEQ,40781
15
+ tinybird/tb/__cli__.py,sha256=XPx4-MwELLknnQYjPb6p_n3szbXZ7pyW7d3_yhPjhGc,247
16
16
  tinybird/tb/check_pypi.py,sha256=rW4QmDRbtgKdUUwJCnBkVjmTjZSZGN-XgZhx7vMkC0w,1009
17
17
  tinybird/tb/cli.py,sha256=u3eGOhX0MHkuT6tiwaZ0_3twqLmqKXDAOxF7yV_Nn9Q,1075
18
18
  tinybird/tb/client.py,sha256=CSBl_JRuioPyY0H8Ac96dJ9wQXDXfrvK2lwqlOxKGoY,55715
@@ -26,7 +26,7 @@ tinybird/tb/modules/connection.py,sha256=7oOR7x4PhBcm1ETFFCH2YJ_3oeGXjAbmx1cnZX9
26
26
  tinybird/tb/modules/copy.py,sha256=2Mm4FWKehOG7CoOhiF1m9UZJgJn0W1_cMolqju8ONYg,5805
27
27
  tinybird/tb/modules/create.py,sha256=OHUvuHuvP0iecPPGI4eVOHOgR20qy7a_Sw7sbJKuG8g,17411
28
28
  tinybird/tb/modules/datasource.py,sha256=V314rkpdVxVMjsp5qcSCTqDlmp4Vu--qM07BoWh-aqs,17783
29
- tinybird/tb/modules/deployment.py,sha256=BAvZy8ghdIwK_eH8J6eJ0W69U2TPtvRmtIThYc2cvOQ,26255
29
+ tinybird/tb/modules/deployment.py,sha256=rChSiCSB4t7528Ojf-E3KAvLJfvYARqZ-W6M8WZnOE0,26854
30
30
  tinybird/tb/modules/deprecations.py,sha256=rrszC1f_JJeJ8mUxGoCxckQTJFBCR8wREf4XXXN-PRc,4507
31
31
  tinybird/tb/modules/dev_server.py,sha256=57FCKuWpErwYUYgHspYDkLWEm9F4pbvVOtMrFXX1fVU,10129
32
32
  tinybird/tb/modules/endpoint.py,sha256=XySDt3pk66vxOZ0egUfz4bY8bEk3BjOXkv-L0OIJ3sc,12083
@@ -38,7 +38,7 @@ tinybird/tb/modules/job.py,sha256=n4dSSBgnA8NqD7srGahf2xRj6wxkmX9Vl0J-QJ_a2w0,29
38
38
  tinybird/tb/modules/llm.py,sha256=KfsCYmKeW1VQz0iDZhGKCRkQv_Y3kTHh6JuxvofOguE,1076
39
39
  tinybird/tb/modules/llm_utils.py,sha256=nS9r4FAElJw8yXtmdYrx-rtI2zXR8qXfi1QqUDCfxvg,3469
40
40
  tinybird/tb/modules/local.py,sha256=SUaGWH9TLDFFF9uCw4y7UW4NsKgnXG8uxTcxz1dbkCM,14230
41
- tinybird/tb/modules/local_common.py,sha256=4GHb7h26iTT02vF_eExsLQM26BGgHF_qTpmDKmxK6nY,14216
41
+ tinybird/tb/modules/local_common.py,sha256=msAZDNPPVenNyL9Dqfb0Z5uFC_1O809xdAi7j1iKmJA,17066
42
42
  tinybird/tb/modules/login.py,sha256=fmXPSdvJnKPv03chptGuu3_Fm6LhP6kUsUKhrmT8rJc,8269
43
43
  tinybird/tb/modules/logout.py,sha256=ULooy1cDBD02-r7voZmhV7udA0ML5tVuflJyShrh56Y,1022
44
44
  tinybird/tb/modules/materialization.py,sha256=QJX5kCPhhm6IXBO1JsalVfbQdypCe_eOUDZ_WHJZWS8,5478
@@ -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.dev166.dist-info/METADATA,sha256=BAITivfECM2Is3v12uYS8vUupGPgcXdLunIaqiQ3WEQ,1607
84
- tinybird-0.0.1.dev166.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
85
- tinybird-0.0.1.dev166.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
86
- tinybird-0.0.1.dev166.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
87
- tinybird-0.0.1.dev166.dist-info/RECORD,,
83
+ tinybird-0.0.1.dev168.dist-info/METADATA,sha256=7U21tZLoTw5A0sAI75vDGVKAbv05tNj0GHruwEm3Q0Y,1607
84
+ tinybird-0.0.1.dev168.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
85
+ tinybird-0.0.1.dev168.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
86
+ tinybird-0.0.1.dev168.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
87
+ tinybird-0.0.1.dev168.dist-info/RECORD,,