tinybird 0.0.1.dev270__py3-none-any.whl → 0.0.1.dev271__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/forward/commands'
5
5
  __author__ = 'Tinybird'
6
6
  __author_email__ = 'support@tinybird.co'
7
- __version__ = '0.0.1.dev270'
8
- __revision__ = '77ee059'
7
+ __version__ = '0.0.1.dev271'
8
+ __revision__ = 'aeab6b9'
@@ -1,6 +1,6 @@
1
1
  import json
2
2
  import logging
3
- from datetime import datetime
3
+ from datetime import datetime, timedelta, timezone
4
4
  from pathlib import Path
5
5
  from typing import Any, Dict, Optional
6
6
 
@@ -405,4 +405,84 @@ def create_deployment_cmd(
405
405
  click.echo(FeedbackManager.success(message="Template downloaded successfully"))
406
406
  client = ctx.ensure_object(dict)["client"]
407
407
  config: Dict[str, Any] = ctx.ensure_object(dict)["config"]
408
- create_deployment(project, client, config, wait, auto, verbose, check, allow_destructive_operations)
408
+ is_web_analytics_starter_kit = bool(template and "web-analytics-starter-kit" in template)
409
+ create_deployment(
410
+ project,
411
+ client,
412
+ config,
413
+ wait,
414
+ auto,
415
+ verbose,
416
+ check,
417
+ allow_destructive_operations,
418
+ ingest_hint=not is_web_analytics_starter_kit,
419
+ )
420
+ show_web_analytics_starter_kit_hints(client, is_web_analytics_starter_kit)
421
+
422
+
423
+ def show_web_analytics_starter_kit_hints(client, is_web_analytics_starter_kit: bool) -> None:
424
+ try:
425
+ if not is_web_analytics_starter_kit:
426
+ return
427
+
428
+ from tinybird.tb.modules.cli import __unpatch_click_output
429
+
430
+ __unpatch_click_output()
431
+ tokens = client.tokens()
432
+ tracker_token = next((token for token in tokens if token["name"] == "tracker"), None)
433
+ if tracker_token:
434
+ click.echo(FeedbackManager.highlight(message="» Ingest data using the script below:"))
435
+ click.echo(
436
+ FeedbackManager.info(
437
+ message=f"""
438
+ <script
439
+ defer
440
+ src="https://unpkg.com/@tinybirdco/flock.js"
441
+ data-token="{tracker_token["token"]}"
442
+ data-host="{client.host}"
443
+ ></script>
444
+ """
445
+ )
446
+ )
447
+
448
+ try:
449
+ ttl = timedelta(days=365 * 10)
450
+ expiration_time = int((ttl + datetime.now(timezone.utc)).timestamp())
451
+ datasources = client.datasources()
452
+ pipes = client.pipes()
453
+
454
+ scopes = []
455
+ for res in pipes:
456
+ scope_data = {
457
+ "type": "PIPES:READ",
458
+ "resource": res["name"],
459
+ }
460
+
461
+ scopes.append(scope_data)
462
+
463
+ for res in datasources:
464
+ scope_data = {
465
+ "type": "DATASOURCES:READ",
466
+ "resource": res["name"],
467
+ }
468
+
469
+ scopes.append(scope_data)
470
+
471
+ response = client.create_jwt_token("web_analytics_starter_kit_jwt", expiration_time, scopes)
472
+ click.echo(FeedbackManager.highlight(message="» Open this URL in your browser to see the dashboard:\n"))
473
+ click.echo(
474
+ FeedbackManager.info(
475
+ message=f"https://analytics.tinybird.co?token={response['token']}&host={client.host}"
476
+ )
477
+ )
478
+ except Exception:
479
+ dashboard_token = next((token for token in tokens if token["name"] == "dashboard"), None)
480
+ if dashboard_token:
481
+ click.echo(FeedbackManager.highlight(message="» Open this URL in your browser to see the dashboard:\n"))
482
+ click.echo(
483
+ FeedbackManager.info(
484
+ message=f"https://analytics.tinybird.co?token={dashboard_token['token']}&host={client.host}"
485
+ )
486
+ )
487
+ except Exception:
488
+ pass
@@ -66,7 +66,7 @@ def api_post(
66
66
 
67
67
  # TODO(eclbg): This logic should be in the server, and there should be a dedicated endpoint for promoting a deployment
68
68
  # potato
69
- def promote_deployment(host: Optional[str], headers: dict, wait: bool) -> None:
69
+ def promote_deployment(host: Optional[str], headers: dict, wait: bool, ingest_hint: Optional[bool] = True) -> None:
70
70
  TINYBIRD_API_URL = f"{host}/v1/deployments"
71
71
  result = api_fetch(TINYBIRD_API_URL, headers)
72
72
 
@@ -123,7 +123,7 @@ def promote_deployment(host: Optional[str], headers: dict, wait: bool) -> None:
123
123
  break
124
124
 
125
125
  time.sleep(5)
126
- if last_deployment.get("id") == "0":
126
+ if last_deployment.get("id") == "0" and ingest_hint:
127
127
  # This is the first deployment, so we prompt the user to ingest data
128
128
  click.echo(
129
129
  FeedbackManager.info(
@@ -197,6 +197,7 @@ def create_deployment(
197
197
  verbose: bool = False,
198
198
  check: Optional[bool] = None,
199
199
  allow_destructive_operations: Optional[bool] = None,
200
+ ingest_hint: Optional[bool] = True,
200
201
  ) -> None:
201
202
  # TODO: This code is duplicated in build_server.py
202
203
  # Should be refactored to be shared
@@ -349,7 +350,7 @@ def create_deployment(
349
350
  click.echo(FeedbackManager.info(message="✓ Deployment is ready"))
350
351
 
351
352
  if auto:
352
- promote_deployment(client.host, HEADERS, wait=wait)
353
+ promote_deployment(client.host, HEADERS, wait=wait, ingest_hint=ingest_hint)
353
354
 
354
355
 
355
356
  def _build_data_movement_message(kind: str, source_mv_name: Optional[str]) -> str:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: tinybird
3
- Version: 0.0.1.dev270
3
+ Version: 0.0.1.dev271
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/forward/commands
6
6
  Author: Tinybird
@@ -17,7 +17,7 @@ tinybird/datafile/exceptions.py,sha256=8rw2umdZjtby85QbuRKFO5ETz_eRHwUY5l7eHsy1w
17
17
  tinybird/datafile/parse_connection.py,sha256=tRyn2Rpr1TeWet5BXmMoQgaotbGdYep1qiTak_OqC5E,1825
18
18
  tinybird/datafile/parse_datasource.py,sha256=ssW8QeFSgglVFi3sDZj_HgkJiTJ2069v2JgqnH3CkDE,1825
19
19
  tinybird/datafile/parse_pipe.py,sha256=xf4m0Tw44QWJzHzAm7Z7FwUoUUtr7noMYjU1NiWnX0k,3880
20
- tinybird/tb/__cli__.py,sha256=0CNLom7h-n1LVg5AImNZKydZhrXvMFV4o0p8IvRVHlk,247
20
+ tinybird/tb/__cli__.py,sha256=hE21EHSWlTInYkHEIdOVARPEKkTP_6FJafe-wwskyxc,247
21
21
  tinybird/tb/check_pypi.py,sha256=Gp0HkHHDFMSDL6nxKlOY51z7z1Uv-2LRexNTZSHHGmM,552
22
22
  tinybird/tb/cli.py,sha256=FdDFEIayjmsZEVsVSSvRiVYn_FHOVg_zWQzchnzfWho,1008
23
23
  tinybird/tb/client.py,sha256=OVNlCXI16kpD-Ph8BDhkyKbR68TdZcR_j4ng91Iiybg,54706
@@ -32,8 +32,8 @@ tinybird/tb/modules/connection.py,sha256=-MY56NUAai6EMC4-wpi7bT0_nz_SA8QzTmHkV7H
32
32
  tinybird/tb/modules/copy.py,sha256=dPZkcIDvxjJrlQUIvToO0vsEEEs4EYumbNV77-BzNoU,4404
33
33
  tinybird/tb/modules/create.py,sha256=pJxHXG69c9Z_21s-7VuJ3RZOF_nJU51LEwiAkvI3dZY,23251
34
34
  tinybird/tb/modules/datasource.py,sha256=pae-ENeHYIF1HHYRSOziFC-2FPLUFa0KS60YpdlKCS8,41725
35
- tinybird/tb/modules/deployment.py,sha256=EDEVOqFk5fp0fvvs2jV0mT5POFd-i_8uZIUREwzAbEk,13199
36
- tinybird/tb/modules/deployment_common.py,sha256=6Ws3YTtEyVl9Id7gyxXkEhe0GJpUJeibS-XGTtTA9DI,19076
35
+ tinybird/tb/modules/deployment.py,sha256=v0layOmG0IMnuXc3RT39mpGfa5M8yPlrL9F089fJFCo,15964
36
+ tinybird/tb/modules/deployment_common.py,sha256=gP2jYdRw8aehfKIHVQaS3DoS7sA43I-sQkLykcL83jE,19193
37
37
  tinybird/tb/modules/deprecations.py,sha256=rrszC1f_JJeJ8mUxGoCxckQTJFBCR8wREf4XXXN-PRc,4507
38
38
  tinybird/tb/modules/dev_server.py,sha256=57FCKuWpErwYUYgHspYDkLWEm9F4pbvVOtMrFXX1fVU,10129
39
39
  tinybird/tb/modules/endpoint.py,sha256=ksRj6mfDb9Xv63PhTkV_uKSosgysHElqagg3RTt21Do,11958
@@ -117,8 +117,8 @@ tinybird/tb_cli_modules/config.py,sha256=IsgdtFRnUrkY8-Zo32lmk6O7u3bHie1QCxLwgp4
117
117
  tinybird/tb_cli_modules/exceptions.py,sha256=pmucP4kTF4irIt7dXiG-FcnI-o3mvDusPmch1L8RCWk,3367
118
118
  tinybird/tb_cli_modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
119
119
  tinybird/tb_cli_modules/telemetry.py,sha256=Hh2Io8ZPROSunbOLuMvuIFU4TqwWPmQTqal4WS09K1A,10449
120
- tinybird-0.0.1.dev270.dist-info/METADATA,sha256=Qyq9d5eVbZ4ffQBnj4TDLyCARzfTBcYAJDjYDeY3ABY,1763
121
- tinybird-0.0.1.dev270.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
122
- tinybird-0.0.1.dev270.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
123
- tinybird-0.0.1.dev270.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
124
- tinybird-0.0.1.dev270.dist-info/RECORD,,
120
+ tinybird-0.0.1.dev271.dist-info/METADATA,sha256=CSddJZlg5oPjFuHA3lXFCB_D6GBoexmShKIi4qZY500,1763
121
+ tinybird-0.0.1.dev271.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
122
+ tinybird-0.0.1.dev271.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
123
+ tinybird-0.0.1.dev271.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
124
+ tinybird-0.0.1.dev271.dist-info/RECORD,,