tinybird 0.0.1.dev270__py3-none-any.whl → 0.0.1.dev272__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.dev272'
8
+ __revision__ = '6fc56e0'
tinybird/tb/client.py CHANGED
@@ -300,13 +300,10 @@ class TinyB:
300
300
  response = self._req(f"/v0/connectors?{urlencode(params)}")
301
301
  return response["connectors"]
302
302
 
303
- def connections(self, connector: Optional[str] = None, skip_bigquery: Optional[bool] = False):
303
+ def connections(self, connector: Optional[str] = None):
304
304
  response = self._req("/v0/connectors")
305
305
  connectors = response["connectors"]
306
- bigquery_connection = None
307
- if not skip_bigquery:
308
- bigquery_connection = self.bigquery_connection() if connector == "bigquery" or connector is None else None
309
- connectors = [*connectors, bigquery_connection] if bigquery_connection else connectors
306
+
310
307
  if connector:
311
308
  return [
312
309
  {
@@ -328,24 +325,9 @@ class TinyB:
328
325
  **c["settings"],
329
326
  }
330
327
  for c in connectors
328
+ if c["service"] != "gcscheduler"
331
329
  ]
332
330
 
333
- def bigquery_connection(self):
334
- bigquery_resources = self.list_gcp_resources()
335
- if len(bigquery_resources) == 0:
336
- return None
337
-
338
- gcp_account_details: Dict[str, Any] = self.get_gcp_service_account_details()
339
- datasources = self.datasources()
340
- bigquery_datasources = [ds["name"] for ds in datasources if ds["type"] == "bigquery"]
341
- return {
342
- "id": gcp_account_details["account"].split("@")[0],
343
- "service": "bigquery",
344
- "name": "bigquery",
345
- "linkers": bigquery_datasources,
346
- "settings": gcp_account_details,
347
- }
348
-
349
331
  def get_datasource(self, ds_name: str, used_by: bool = False) -> Dict[str, Any]:
350
332
  params = {
351
333
  "attrs": "used_by" if used_by else "",
@@ -1037,10 +1019,9 @@ class TinyB:
1037
1019
  name_or_id: str,
1038
1020
  service: Optional[str] = None,
1039
1021
  key: Optional[str] = "name",
1040
- skip_bigquery: Optional[bool] = False,
1041
1022
  ) -> Optional[Dict[str, Any]]:
1042
1023
  return next(
1043
- (c for c in self.connections(connector=service, skip_bigquery=skip_bigquery) if c[key] == name_or_id),
1024
+ (c for c in self.connections(connector=service) if c[key] == name_or_id),
1044
1025
  None,
1045
1026
  )
1046
1027
 
@@ -121,7 +121,7 @@ def connection_ls(ctx: Context, service: Optional[DataConnectorType] = None) ->
121
121
  obj: Dict[str, Any] = ctx.ensure_object(dict)
122
122
  client: TinyB = obj["client"]
123
123
 
124
- connections = client.connections(connector=service, skip_bigquery=True)
124
+ connections = client.connections(connector=service)
125
125
  columns = []
126
126
  table = []
127
127
 
@@ -89,7 +89,7 @@ def folder_pull(
89
89
  try:
90
90
  datasources = client.datasources()
91
91
  pipes = client.pipes()
92
- connections = client.connections(skip_bigquery=True)
92
+ connections = client.connections()
93
93
 
94
94
  write_files(
95
95
  resources=datasources,
@@ -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.dev272
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/forward/commands
6
6
  Author: Tinybird
@@ -17,10 +17,10 @@ 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=s5oRxeoOkXoJmiNFK4NqIPzdBDisEOHAWlbA-u4cJlg,247
21
21
  tinybird/tb/check_pypi.py,sha256=Gp0HkHHDFMSDL6nxKlOY51z7z1Uv-2LRexNTZSHHGmM,552
22
22
  tinybird/tb/cli.py,sha256=FdDFEIayjmsZEVsVSSvRiVYn_FHOVg_zWQzchnzfWho,1008
23
- tinybird/tb/client.py,sha256=OVNlCXI16kpD-Ph8BDhkyKbR68TdZcR_j4ng91Iiybg,54706
23
+ tinybird/tb/client.py,sha256=IQRaInDjOwr9Fzaz3_xXc3aUGqh94tM2lew7IZbB9eM,53733
24
24
  tinybird/tb/config.py,sha256=mhMTGnMB5KcxGoh3dewIr2Jjsa6pHE183gCPAQWyp6o,3973
25
25
  tinybird/tb/modules/build.py,sha256=efD-vamK1NPaDo9R86Hn8be2DYoW0Hh5bZiH7knK5dk,7790
26
26
  tinybird/tb/modules/build_common.py,sha256=dthlaDn_CuwZnedQcUi7iIdDoHWfSbbbGQwiDgNcmC0,13062
@@ -28,12 +28,12 @@ tinybird/tb/modules/cicd.py,sha256=0KLKccha9IP749QvlXBmzdWv1On3mFwMY4DUcJlBxiE,7
28
28
  tinybird/tb/modules/cli.py,sha256=OC4jqGciUAgPQLgmo4ztjiQTOiGzqX3yILfxjbZ-CIs,16686
29
29
  tinybird/tb/modules/common.py,sha256=tj6DR2yOqMMQ0PILwFGXmMogxdrbQCgj36HdSM611rs,82657
30
30
  tinybird/tb/modules/config.py,sha256=gK7rgaWTDd4ZKCrNEg_Uemr26EQjqWt6TjyQKujxOws,11462
31
- tinybird/tb/modules/connection.py,sha256=-MY56NUAai6EMC4-wpi7bT0_nz_SA8QzTmHkV7HB1IQ,17810
31
+ tinybird/tb/modules/connection.py,sha256=axp8Fny1_4PSLJGN4UF6WygyRbQtM3Lbt6thxHKTxzw,17790
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
@@ -108,7 +108,7 @@ tinybird/tb/modules/datafile/format_datasource.py,sha256=X5N65vDpprFKaWaxkSwFnHa
108
108
  tinybird/tb/modules/datafile/format_pipe.py,sha256=_64RGD8XI-gpQBMzhymUAVGMhpQK6zar_irDrJFQrHY,7378
109
109
  tinybird/tb/modules/datafile/pipe_checker.py,sha256=dxsCQoA6ruxg1fvF6sMLFowpjaqws8lUQcM7XyhgZPE,24609
110
110
  tinybird/tb/modules/datafile/playground.py,sha256=47q4XcvDhclHWYv7oFNEqmF1T5NXd9GPWkrT6Av2VhY,56343
111
- tinybird/tb/modules/datafile/pull.py,sha256=oVQaMJktX9Es8E5tiO2SBONlbM-mRAY4f72OpASDPWg,4329
111
+ tinybird/tb/modules/datafile/pull.py,sha256=BB-JSAPDRL8WotaSo73PHBDdAKBx4ZM-YeZCVcXdRTQ,4311
112
112
  tinybird/tb/modules/tinyunit/tinyunit.py,sha256=sJeBnKDHcUNn8t0sdsKB_M2w8IdzeeQ1PzJuleeQ2-E,11695
113
113
  tinybird/tb/modules/tinyunit/tinyunit_lib.py,sha256=hGh1ZaXC1af7rKnX7222urkj0QJMhMWclqMy59dOqwE,1922
114
114
  tinybird/tb_cli_modules/cicd.py,sha256=0lMkb6CVOFZl5HOwgY8mK4T4mgI7O8335UngLXtCc-c,13851
@@ -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.dev272.dist-info/METADATA,sha256=Ait5uLqtYO9yjOWIF4F7i4ULQE8rxaqqsyrjfYpxyyc,1763
121
+ tinybird-0.0.1.dev272.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
122
+ tinybird-0.0.1.dev272.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
123
+ tinybird-0.0.1.dev272.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
124
+ tinybird-0.0.1.dev272.dist-info/RECORD,,