tinybird 0.0.1.dev57__py3-none-any.whl → 0.0.1.dev59__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/tb/__cli__.py CHANGED
@@ -4,5 +4,5 @@ __description__ = 'Tinybird Command Line Tool'
4
4
  __url__ = 'https://www.tinybird.co/docs/cli/introduction.html'
5
5
  __author__ = 'Tinybird'
6
6
  __author_email__ = 'support@tinybird.co'
7
- __version__ = '0.0.1.dev57'
8
- __revision__ = '0af16b9'
7
+ __version__ = '0.0.1.dev59'
8
+ __revision__ = 'ba88b07'
@@ -4,7 +4,7 @@ import sys
4
4
  import time
5
5
  from datetime import datetime
6
6
  from pathlib import Path
7
- from typing import Optional
7
+ from typing import Optional, Union
8
8
 
9
9
  import click
10
10
  import requests
@@ -153,12 +153,18 @@ def deployment_group() -> None:
153
153
  default=False,
154
154
  help="Auto-promote the deployment. Only works if --wait is enabled. Disabled by default.",
155
155
  )
156
+ @click.option(
157
+ "--check/--no-check",
158
+ is_flag=True,
159
+ default=False,
160
+ help="Validate the deployment before creating it. Disabled by default.",
161
+ )
156
162
  @click.pass_context
157
- def deployment_create(ctx: click.Context, wait: bool, auto: bool) -> None:
163
+ def deployment_create(ctx: click.Context, wait: bool, auto: bool, check: bool) -> None:
158
164
  """
159
165
  Validate and deploy the project server side.
160
166
  """
161
- create_deployment(ctx, wait, auto)
167
+ create_deployment(ctx, wait, auto, check)
162
168
 
163
169
 
164
170
  @deployment_group.command(name="ls")
@@ -246,15 +252,21 @@ def deployment_rollback(ctx: click.Context, wait: bool) -> None:
246
252
  default=False,
247
253
  help="Auto-promote the deployment. Only works if --wait is enabled. Disabled by default.",
248
254
  )
255
+ @click.option(
256
+ "--check",
257
+ is_flag=True,
258
+ default=False,
259
+ help="Validate the deployment before creating it. Disabled by default.",
260
+ )
249
261
  @click.pass_context
250
- def deploy(ctx: click.Context, wait: bool, auto: bool) -> None:
262
+ def deploy(ctx: click.Context, wait: bool, auto: bool, check: bool) -> None:
251
263
  """
252
264
  Deploy the project.
253
265
  """
254
- create_deployment(ctx, wait, auto)
266
+ create_deployment(ctx, wait, auto, check)
255
267
 
256
268
 
257
- def create_deployment(ctx: click.Context, wait: bool, auto: bool) -> None:
269
+ def create_deployment(ctx: click.Context, wait: bool, auto: bool, check: Optional[bool] = None) -> None:
258
270
  # TODO: This code is duplicated in build_server.py
259
271
  # Should be refactored to be shared
260
272
  MULTIPART_BOUNDARY_DATA_PROJECT = "data_project://"
@@ -281,11 +293,23 @@ def create_deployment(ctx: click.Context, wait: bool, auto: bool) -> None:
281
293
  deployment = None
282
294
  try:
283
295
  HEADERS = {"Authorization": f"Bearer {TINYBIRD_API_KEY}"}
284
-
285
- r = requests.post(TINYBIRD_API_URL, files=files, headers=HEADERS)
296
+ params = {}
297
+ if check:
298
+ click.echo(FeedbackManager.highlight(message="\n» Validating deployment...\n"))
299
+ params["check"] = "true"
300
+ r = requests.post(TINYBIRD_API_URL, files=files, headers=HEADERS, params=params)
286
301
  result = r.json()
287
302
  logging.debug(json.dumps(result, indent=2))
288
303
 
304
+ if check:
305
+ print_changes(result, project)
306
+ status = result.get("result")
307
+ if status == "success":
308
+ click.echo(FeedbackManager.success(message="\n✓ Deployment is valid"))
309
+ else:
310
+ click.echo(FeedbackManager.error(message="\n✗ Deployment is not valid"))
311
+ return
312
+
289
313
  deploy_result = result.get("result")
290
314
  if deploy_result == "success":
291
315
  click.echo(FeedbackManager.success(message="Deployment submitted successfully"))
@@ -308,6 +332,8 @@ def create_deployment(ctx: click.Context, wait: bool, auto: bool) -> None:
308
332
  click.echo(FeedbackManager.error(message=f"{deploy_error.get('error')}"))
309
333
  else:
310
334
  click.echo(FeedbackManager.error(message=f"Unknown build result {deploy_result}"))
335
+ except Exception as e:
336
+ click.echo(FeedbackManager.error_exception(error=e))
311
337
  finally:
312
338
  for fd in fds:
313
339
  fd.close()
@@ -343,3 +369,29 @@ def create_deployment(ctx: click.Context, wait: bool, auto: bool) -> None:
343
369
 
344
370
  if auto:
345
371
  promote_deployment(client.host, HEADERS, wait=wait)
372
+
373
+
374
+ def print_changes(result: dict, project: Project) -> None:
375
+ deployment = result.get("deployment", {})
376
+ columns = ["status", "name", "path"]
377
+ resources: list[list[Union[str, None]]] = []
378
+
379
+ for ds in deployment.get("new_datasource_names", []):
380
+ resources.append(["new", ds, project.get_resource_path(ds, "datasource")])
381
+
382
+ for p in deployment.get("new_pipe_names", []):
383
+ resources.append(["new", p, project.get_resource_path(p, "pipe")])
384
+
385
+ for ds in deployment.get("changed_datasource_names", []):
386
+ resources.append(["modified", ds, project.get_resource_path(ds, "datasource")])
387
+
388
+ for p in deployment.get("changed_pipe_names", []):
389
+ resources.append(["modified", p, project.get_resource_path(p, "pipe")])
390
+
391
+ for ds in deployment.get("deleted_datasource_names", []):
392
+ resources.append(["deleted", ds, project.get_resource_path(ds, "datasource")])
393
+
394
+ for p in deployment.get("deleted_pipe_names", []):
395
+ resources.append(["deleted", p, project.get_resource_path(p, "pipe")])
396
+
397
+ echo_safe_humanfriendly_tables_format_smart_table(resources, column_names=columns)
@@ -32,6 +32,12 @@ class Project:
32
32
  project_files.append(project_file)
33
33
  return project_files
34
34
 
35
+ def get_resource_path(self, resource_name: str, resource_type: str) -> Optional[str]:
36
+ full_path = next((p for p in self.get_project_files() if p.endswith(resource_name + f".{resource_type}")), "")
37
+ if not full_path:
38
+ return None
39
+ return Path(full_path).relative_to(self.path).as_posix()
40
+
35
41
  def get_vendor_files(self) -> List[str]:
36
42
  vendor_files: List[str] = []
37
43
  for project_file in glob.glob(f"{self.vendor_path}/**/*.datasource", recursive=True):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tinybird
3
- Version: 0.0.1.dev57
3
+ Version: 0.0.1.dev59
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/cli/introduction.html
6
6
  Author: Tinybird
@@ -15,7 +15,7 @@ tinybird/syncasync.py,sha256=IPnOx6lMbf9SNddN1eBtssg8vCLHMt76SuZ6YNYm-Yk,27761
15
15
  tinybird/tornado_template.py,sha256=FL85SMPq2dH4JqKovmSbaolGdEzwOO91NqOzqXo2Qr0,41863
16
16
  tinybird/ch_utils/constants.py,sha256=aYvg2C_WxYWsnqPdZB1ZFoIr8ZY-XjUXYyHKE9Ansj0,3890
17
17
  tinybird/ch_utils/engine.py,sha256=OXkBhlzGjZotjD0vaT-rFIbSGV4tpiHxE8qO_ip0SyQ,40454
18
- tinybird/tb/__cli__.py,sha256=VmPdPo--fZPs9pKsl45OvLsk2abvstvfh9n1sxUQmd4,251
18
+ tinybird/tb/__cli__.py,sha256=EDLw9kmNQZRJ7nm-Xm8E1sylwa5kbY0yIaPNaYsA3WA,251
19
19
  tinybird/tb/cli.py,sha256=FD1pfbzu9YHJHEG6Vtn_EwPLTYhwqw-I6AxXeTaRHU8,926
20
20
  tinybird/tb/modules/auth.py,sha256=EzRWFmwRkXNhUmRaruEVFLdkbUg8xMSix0cAWl5D4Jg,9029
21
21
  tinybird/tb/modules/build.py,sha256=92hGgYKg_MOPOjscj677mCGkv6E9H0s8XqD3oBaiaLc,8525
@@ -26,7 +26,7 @@ tinybird/tb/modules/config.py,sha256=mie3oMVTf5YOUFEiLs88P16U4LkJafJjSpjwyAkFHog
26
26
  tinybird/tb/modules/copy.py,sha256=Aq6wh_wjRiyLQtEOKF9pKLPgJhSvbGTFWIw_LJB0t0U,5801
27
27
  tinybird/tb/modules/create.py,sha256=We8hffR9x5xSrdCmEk0tfqc_0ddys61gw_J136ZpA3E,14097
28
28
  tinybird/tb/modules/datasource.py,sha256=TQ4wSag3CCw34d54FEXPJFGLQNYyNqv2nQbU6QT9uAE,14725
29
- tinybird/tb/modules/deployment.py,sha256=LtAvjNuoUZFEB8gi3DKYGwPCAjiIh-OskDONW6lZdRI,12111
29
+ tinybird/tb/modules/deployment.py,sha256=sbKyjt1PPk43VLDb1DffMs2TLSlpiPbVAMGcW4q8tr0,14244
30
30
  tinybird/tb/modules/endpoint.py,sha256=9arqN1JQCMb0Nd3-EJ7lukOYkGHHCpQmiiZpp5FqPhc,9432
31
31
  tinybird/tb/modules/exceptions.py,sha256=4A2sSjCEqKUMqpP3WI00zouCWW4uLaghXXLZBSw04mY,3363
32
32
  tinybird/tb/modules/feedback_manager.py,sha256=mrw5tdYycfvg6WLXlM0KIjfJardm_aNpnJkUg2vH0cA,68463
@@ -40,7 +40,7 @@ tinybird/tb/modules/login.py,sha256=EGxwVRmMX1Y7ZeCRyA8fqaCWpYYk7NvnZ3x_1g0NlYA,
40
40
  tinybird/tb/modules/materialization.py,sha256=HQKRTH6lkcYiDQJihbFqF_in58ezXG4ggZ_7Ywp_nUM,5738
41
41
  tinybird/tb/modules/mock.py,sha256=m4RnskeN_EjR25mC9lT0L61Vrn5ldtNS-ghyVjB5RG8,5112
42
42
  tinybird/tb/modules/pipe.py,sha256=pH2KwgH6Xbvl3kT8vMelpKvT6bcyB4EKFDvGfOsxXbg,2418
43
- tinybird/tb/modules/project.py,sha256=rucAh_6K1EsW2dxjmqHPJ7bt6IliOWR0dNtEYG454fw,2620
43
+ tinybird/tb/modules/project.py,sha256=RkejMzY6OLWlJMckziZiZFJLnjFxSeQjagklXAYCzoQ,2945
44
44
  tinybird/tb/modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
45
45
  tinybird/tb/modules/shell.py,sha256=LShGXwP_kzYAOUiTcvHMmcDugVr0crIfdNb5En6cfxo,14604
46
46
  tinybird/tb/modules/table.py,sha256=4XrtjM-N0zfNtxVkbvLDQQazno1EPXnxTyo7llivfXk,11035
@@ -74,8 +74,8 @@ tinybird/tb_cli_modules/config.py,sha256=6u6B5QCdiQLbJkCkwtnKGs9H3nP-KXXhC75mF7B
74
74
  tinybird/tb_cli_modules/exceptions.py,sha256=pmucP4kTF4irIt7dXiG-FcnI-o3mvDusPmch1L8RCWk,3367
75
75
  tinybird/tb_cli_modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
76
76
  tinybird/tb_cli_modules/telemetry.py,sha256=iEGnMuCuNhvF6ln__j6X9MSTwL_0Hm-GgFHHHvhfknk,10466
77
- tinybird-0.0.1.dev57.dist-info/METADATA,sha256=5UWJlzMHZ_XOENz6CDy-Bhy0m2rYvC9cVkv8n7wqyF0,2482
78
- tinybird-0.0.1.dev57.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
79
- tinybird-0.0.1.dev57.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
80
- tinybird-0.0.1.dev57.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
81
- tinybird-0.0.1.dev57.dist-info/RECORD,,
77
+ tinybird-0.0.1.dev59.dist-info/METADATA,sha256=628jqWml58nuSpGAv4N7de6Zci_gidHbC0nidwIIUiI,2482
78
+ tinybird-0.0.1.dev59.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
79
+ tinybird-0.0.1.dev59.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
80
+ tinybird-0.0.1.dev59.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
81
+ tinybird-0.0.1.dev59.dist-info/RECORD,,