tinybird 0.0.1.dev90__py3-none-any.whl → 0.0.1.dev92__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.dev90'
8
- __revision__ = 'd11bb13'
7
+ __version__ = '0.0.1.dev92'
8
+ __revision__ = 'd99cccc'
tinybird/tb/cli.py CHANGED
@@ -8,6 +8,7 @@ import tinybird.tb.modules.auth
8
8
  import tinybird.tb.modules.build
9
9
  import tinybird.tb.modules.cli
10
10
  import tinybird.tb.modules.common
11
+ import tinybird.tb.modules.connection
11
12
  import tinybird.tb.modules.copy
12
13
  import tinybird.tb.modules.create
13
14
  import tinybird.tb.modules.datasource
@@ -412,7 +412,7 @@ async def create_ctx_client(ctx: Context, config: Dict[str, Any], cloud: bool, b
412
412
  return _get_tb_client(config.get("token", None), config["host"], staging=staging)
413
413
  build = command in commands_always_build or build
414
414
  if not build and command not in commands_always_local and command not in commands_always_build:
415
- click.echo(FeedbackManager.gray(message="Running against Tinybird Local\n"))
415
+ click.echo(FeedbackManager.gray(message="Running against Tinybird Local"))
416
416
  return await get_tinybird_local_client(config, build=build, staging=staging)
417
417
 
418
418
 
@@ -0,0 +1,125 @@
1
+ # This is a command file for our CLI. Please keep it clean.
2
+ #
3
+ # - If it makes sense and only when strictly necessary, you can create utility functions in this file.
4
+ # - But please, **do not** interleave utility functions and command definitions.
5
+
6
+ from typing import Any, Dict, List, Optional
7
+
8
+ import click
9
+ from click import Context
10
+
11
+ from tinybird.client import TinyB
12
+ from tinybird.tb.modules.cli import cli
13
+ from tinybird.tb.modules.common import (
14
+ DataConnectorType,
15
+ _get_setting_value,
16
+ coro,
17
+ echo_safe_humanfriendly_tables_format_smart_table,
18
+ )
19
+ from tinybird.tb.modules.feedback_manager import FeedbackManager
20
+
21
+ DATA_CONNECTOR_SETTINGS: Dict[DataConnectorType, List[str]] = {
22
+ DataConnectorType.KAFKA: [
23
+ "kafka_bootstrap_servers",
24
+ "kafka_sasl_plain_username",
25
+ "kafka_sasl_plain_password",
26
+ "cli_version",
27
+ "endpoint",
28
+ "kafka_security_protocol",
29
+ "kafka_sasl_mechanism",
30
+ "kafka_schema_registry_url",
31
+ "kafka_ssl_ca_pem",
32
+ ],
33
+ DataConnectorType.GCLOUD_SCHEDULER: ["gcscheduler_region"],
34
+ DataConnectorType.SNOWFLAKE: [
35
+ "account",
36
+ "username",
37
+ "password",
38
+ "role",
39
+ "warehouse",
40
+ "warehouse_size",
41
+ "stage",
42
+ "integration",
43
+ ],
44
+ DataConnectorType.BIGQUERY: ["account"],
45
+ DataConnectorType.GCLOUD_STORAGE: [
46
+ "gcs_private_key_id",
47
+ "gcs_client_x509_cert_url",
48
+ "gcs_project_id",
49
+ "gcs_client_id",
50
+ "gcs_client_email",
51
+ "gcs_private_key",
52
+ ],
53
+ DataConnectorType.GCLOUD_STORAGE_HMAC: [
54
+ "gcs_hmac_access_id",
55
+ "gcs_hmac_secret",
56
+ ],
57
+ DataConnectorType.GCLOUD_STORAGE_SA: ["account_email"],
58
+ DataConnectorType.AMAZON_S3: [
59
+ "s3_access_key_id",
60
+ "s3_secret_access_key",
61
+ "s3_region",
62
+ ],
63
+ DataConnectorType.AMAZON_S3_IAMROLE: [
64
+ "s3_iamrole_arn",
65
+ "s3_iamrole_region",
66
+ "s3_iamrole_external_id",
67
+ ],
68
+ DataConnectorType.AMAZON_DYNAMODB: [
69
+ "dynamodb_iamrole_arn",
70
+ "dynamodb_iamrole_region",
71
+ "dynamodb_iamrole_external_id",
72
+ ],
73
+ }
74
+
75
+ SENSITIVE_CONNECTOR_SETTINGS = {
76
+ DataConnectorType.KAFKA: ["kafka_sasl_plain_password"],
77
+ DataConnectorType.GCLOUD_SCHEDULER: [
78
+ "gcscheduler_target_url",
79
+ "gcscheduler_job_name",
80
+ "gcscheduler_region",
81
+ ],
82
+ DataConnectorType.GCLOUD_STORAGE_HMAC: ["gcs_hmac_secret"],
83
+ DataConnectorType.AMAZON_S3: ["s3_secret_access_key"],
84
+ DataConnectorType.AMAZON_S3_IAMROLE: ["s3_iamrole_arn"],
85
+ DataConnectorType.AMAZON_DYNAMODB: ["dynamodb_iamrole_arn"],
86
+ }
87
+
88
+
89
+ @cli.group()
90
+ @click.pass_context
91
+ def connection(ctx: Context) -> None:
92
+ """Connection commands."""
93
+
94
+
95
+ @connection.command(name="ls")
96
+ @click.option("--service", help="Filter by service")
97
+ @click.pass_context
98
+ @coro
99
+ async def connection_ls(ctx: Context, service: Optional[DataConnectorType] = None) -> None:
100
+ """List connections."""
101
+ obj: Dict[str, Any] = ctx.ensure_object(dict)
102
+ client: TinyB = obj["client"]
103
+
104
+ connections = await client.connections(connector=service, skip_bigquery=True)
105
+ columns = []
106
+ table = []
107
+
108
+ click.echo(FeedbackManager.info_connections())
109
+
110
+ if not service:
111
+ sensitive_settings = []
112
+ columns = ["service", "name", "id", "connected_datasources"]
113
+ else:
114
+ sensitive_settings = SENSITIVE_CONNECTOR_SETTINGS.get(service, [])
115
+ columns = ["service", "name", "id", "connected_datasources"]
116
+ if connector_settings := DATA_CONNECTOR_SETTINGS.get(service):
117
+ columns += connector_settings
118
+
119
+ for connection in connections:
120
+ row = [_get_setting_value(connection, setting, sensitive_settings) for setting in columns]
121
+ table.append(row)
122
+
123
+ column_names = [c.replace("kafka_", "") for c in columns]
124
+ echo_safe_humanfriendly_tables_format_smart_table(table, column_names=column_names)
125
+ click.echo("\n")
@@ -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, Union
7
+ from typing import Any, Dict, Optional, Union
8
8
 
9
9
  import click
10
10
  import requests
@@ -330,7 +330,7 @@ def create_deployment(
330
330
  }
331
331
  project: Project = ctx.ensure_object(dict)["project"]
332
332
  client = ctx.ensure_object(dict)["client"]
333
- config = ctx.ensure_object(dict)["config"]
333
+ config: Dict[str, Any] = ctx.ensure_object(dict)["config"]
334
334
  TINYBIRD_API_URL = f"{client.host}/v1/deploy"
335
335
  TINYBIRD_API_KEY = client.token
336
336
 
@@ -62,7 +62,7 @@ def playground(
62
62
  """Build the project in Tinybird Local."""
63
63
  project: Project = ctx.ensure_object(dict)["project"]
64
64
  tb_client: TinyB = ctx.ensure_object(dict)["client"]
65
- config: CLIConfig = ctx.ensure_object(dict)["config"]
65
+ config = CLIConfig.get_project_config()
66
66
  context.disable_template_security_validation.set(True)
67
67
 
68
68
  async def process(filenames: List[str], watch: bool = False):
@@ -5,6 +5,7 @@
5
5
 
6
6
  import difflib
7
7
  import glob
8
+ import os
8
9
  import sys
9
10
  import urllib.parse
10
11
  from pathlib import Path
@@ -75,8 +76,8 @@ async def test_create(ctx: click.Context, name_or_filename: str, prompt: str) ->
75
76
  """
76
77
  project: Project = ctx.ensure_object(dict)["project"]
77
78
  client: TinyB = ctx.ensure_object(dict)["client"]
78
- config: CLIConfig = ctx.ensure_object(dict)["config"]
79
- root_path = Path(project.folder)
79
+ config = CLIConfig.get_project_config()
80
+ root_path = project.path
80
81
  folder = project.folder
81
82
  try:
82
83
  if ".pipe" in name_or_filename:
@@ -85,20 +86,17 @@ async def test_create(ctx: click.Context, name_or_filename: str, prompt: str) ->
85
86
  raise CLIException(FeedbackManager.error(message=f"Pipe {name_or_filename} not found"))
86
87
  else:
87
88
  pipe_folders = ("endpoints", "copies", "materializations", "sinks", "pipes")
88
- try:
89
- pipe_path = next(
90
- root_path / folder / f"{name_or_filename}.pipe"
91
- for folder in pipe_folders
92
- if (root_path / folder / f"{name_or_filename}.pipe").exists()
93
- )
94
- except Exception:
89
+ pipe_path = next(
90
+ root_path / folder / f"{name_or_filename}.pipe"
91
+ for folder in pipe_folders
92
+ if os.path.exists(root_path / folder / f"{name_or_filename}.pipe")
93
+ )
94
+ if not pipe_path:
95
95
  raise CLIException(FeedbackManager.error(message=f"Pipe {name_or_filename} not found"))
96
96
 
97
97
  pipe_name = pipe_path.stem
98
98
  click.echo(FeedbackManager.highlight(message=f"\n» Creating tests for {pipe_name} endpoint..."))
99
- pipe_path = root_path / pipe_path
100
99
  pipe_content = pipe_path.read_text()
101
-
102
100
  pipe = await client._req(f"/v0/pipes/{pipe_name}")
103
101
  parameters = set([param["name"] for node in pipe["nodes"] for param in node["params"]])
104
102
 
@@ -112,7 +110,6 @@ async def test_create(ctx: click.Context, name_or_filename: str, prompt: str) ->
112
110
  raise CLIException(FeedbackManager.error(message="No user token found"))
113
111
 
114
112
  llm = LLM(user_token=user_token, host=config.get_client().host)
115
- click.echo(FeedbackManager.highlight(message=f"\n» Creating test for {pipe_name} endpoint..."))
116
113
  response_llm = llm.ask(system_prompt=system_prompt, prompt=prompt)
117
114
  response_xml = extract_xml(response_llm, "response")
118
115
  tests_content = parse_xml(response_xml, "test")
@@ -216,9 +213,12 @@ async def test_update(ctx: click.Context, pipe: str) -> None:
216
213
  async def run_tests(ctx: click.Context, name: Tuple[str, ...]) -> None:
217
214
  click.echo(FeedbackManager.highlight(message="\n» Running tests"))
218
215
  client: TinyB = ctx.ensure_object(dict)["client"]
216
+ project: Project = ctx.ensure_object(dict)["project"]
219
217
  paths = [Path(n) for n in name]
220
- endpoints = [f"./tests/{p.stem}.yaml" for p in paths]
221
- test_files: List[str] = endpoints if len(endpoints) > 0 else glob.glob("./tests/**/*.y*ml", recursive=True)
218
+ endpoints = [f"{project.path}/tests/{p.stem}.yaml" for p in paths]
219
+ test_files: List[str] = (
220
+ endpoints if len(endpoints) > 0 else glob.glob(f"{project.path}/tests/**/*.y*ml", recursive=True)
221
+ )
222
222
 
223
223
  async def run_test(test_file):
224
224
  test_file_path = Path(test_file)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: tinybird
3
- Version: 0.0.1.dev90
3
+ Version: 0.0.1.dev92
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/cli/introduction.html
6
6
  Author: Tinybird
@@ -15,18 +15,19 @@ tinybird/syncasync.py,sha256=IPnOx6lMbf9SNddN1eBtssg8vCLHMt76SuZ6YNYm-Yk,27761
15
15
  tinybird/tornado_template.py,sha256=jjNVDMnkYFWXflmT8KU_Ssbo5vR8KQq3EJMk5vYgXRw,41959
16
16
  tinybird/ch_utils/constants.py,sha256=aYvg2C_WxYWsnqPdZB1ZFoIr8ZY-XjUXYyHKE9Ansj0,3890
17
17
  tinybird/ch_utils/engine.py,sha256=BZuPM7MFS7vaEKK5tOMR2bwSAgJudPrJt27uVEwZmTY,40512
18
- tinybird/tb/__cli__.py,sha256=Xjw-O5fZcxgHniZqT8Lfpai9LjBf9MYDmOuWtnCwi2c,251
19
- tinybird/tb/cli.py,sha256=LOOJoNelfyqerVWrMasp2f-8roZzKdSoSa_sMViwHMg,1032
18
+ tinybird/tb/__cli__.py,sha256=JauWMFoQBsfMiTW1HIS8HciaaGZR3hE0PE8cWmZXvBU,251
19
+ tinybird/tb/cli.py,sha256=SSXALqjtPShcQbgvT1u7up2YL0ls36wXABX0hZwebdQ,1070
20
20
  tinybird/tb/modules/auth.py,sha256=L1IatO2arRSzys3t8px8xVt8uPWUL5EVD0sFzAV_uVU,9022
21
21
  tinybird/tb/modules/build.py,sha256=-lRGBxKtuipmyl3pmiGcfp67fH1Ed-COfHAZKdgLIWo,10483
22
22
  tinybird/tb/modules/cicd.py,sha256=T0lb9u_bDdTUVe8TwNNb1qQ5KnSPHMVjqPfKF4BBNBw,5347
23
- tinybird/tb/modules/cli.py,sha256=rE-0PtttuXvigKP1BkdgolP833pEhe-daK6l86bnaEw,16468
23
+ tinybird/tb/modules/cli.py,sha256=atBf86g3mgXi9L7wy3YtovvdFk8QXfjneUP08NvY_jk,16466
24
24
  tinybird/tb/modules/common.py,sha256=xWdxukkqTdK0YFHSUYxHx8_cJO165h2hdrE75aLHa7g,80383
25
25
  tinybird/tb/modules/config.py,sha256=BVZg-4f_R3vJTwCChXY2AXaH67SRk62xoP_IymquosI,11404
26
+ tinybird/tb/modules/connection.py,sha256=WKeDxbTpSsQ1PUmsT730g3S5RT2PtR5mPpVEanD1nbM,3933
26
27
  tinybird/tb/modules/copy.py,sha256=MAVqKip8_QhOYq99U_XuqSO6hCLJEh5sFtbhcXtI3SI,5802
27
28
  tinybird/tb/modules/create.py,sha256=KjotVfIQLfcPyQBykTHnPLn4ikrm6qqeMcbRE1d-6Jo,13280
28
29
  tinybird/tb/modules/datasource.py,sha256=dNCK9iCR2xPLfwqqwg2ixyE6NuoVEiJU2mBZBmOYrVY,16906
29
- tinybird/tb/modules/deployment.py,sha256=oSRnQnz2Wkvp1y0yt_tVa9g0aCYyFxNAsUyxoZTIcpY,17615
30
+ tinybird/tb/modules/deployment.py,sha256=Mfqx5Qq4HP8Ym0Vd_LnzFv8QkVyxI77-M0QkKmmZ_go,17642
30
31
  tinybird/tb/modules/endpoint.py,sha256=EhVoGAXsFz-83Fiwj1gI-I73iRRvL49d0W81un7hvPE,12080
31
32
  tinybird/tb/modules/exceptions.py,sha256=4A2sSjCEqKUMqpP3WI00zouCWW4uLaghXXLZBSw04mY,3363
32
33
  tinybird/tb/modules/feedback_manager.py,sha256=7nNiOx7OMebiheLED1r0d75SbuXCNxyBmF4e20rCBNc,69511
@@ -41,7 +42,7 @@ tinybird/tb/modules/logout.py,sha256=ULooy1cDBD02-r7voZmhV7udA0ML5tVuflJyShrh56Y
41
42
  tinybird/tb/modules/materialization.py,sha256=r8Q9HXcYEmfrEzP4WpiasCKDJdSkTPaAKJtZMoJKhi8,5749
42
43
  tinybird/tb/modules/mock.py,sha256=3q4i6CXKcS-zsgevbN_zpAP4AnB9_WIVxmVSJV3FNPQ,3881
43
44
  tinybird/tb/modules/pipe.py,sha256=gcLz0qHgwKDLsWFY3yFLO9a0ETAV1dFbI8YeLHi9460,2429
44
- tinybird/tb/modules/playground.py,sha256=CQaz2JqFDdReK2fJY1yZsSwiSY24_jeTb9PKw1WUigA,4848
45
+ tinybird/tb/modules/playground.py,sha256=bN0whphoSO6p1_u3b6OAUoc3ieG5Cl3qNXwt2HcUOp8,4834
45
46
  tinybird/tb/modules/project.py,sha256=ei0TIAuRksdV2g2FJqByuV4DPyivQGrZ42z_eQDNBgI,2963
46
47
  tinybird/tb/modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
47
48
  tinybird/tb/modules/secret.py,sha256=xxzfKxfFN7GORib1WslCaFDHt_dgnjmfOewyptPU_VM,2820
@@ -49,7 +50,7 @@ tinybird/tb/modules/shell.py,sha256=a98W4L4gfrmxEyybtu6S4ENXrBYtgNASB5e_evuXQvI,
49
50
  tinybird/tb/modules/table.py,sha256=4XrtjM-N0zfNtxVkbvLDQQazno1EPXnxTyo7llivfXk,11035
50
51
  tinybird/tb/modules/tag.py,sha256=anPmMUBc-TbFovlpFi8GPkKA18y7Y0GczMsMms5TZsU,3502
51
52
  tinybird/tb/modules/telemetry.py,sha256=Hh2Io8ZPROSunbOLuMvuIFU4TqwWPmQTqal4WS09K1A,10449
52
- tinybird/tb/modules/test.py,sha256=oa6_ApTCT526W8-hngpZwNyl2AbIpOztOsxf0iwlSwc,11547
53
+ tinybird/tb/modules/test.py,sha256=FUU-drY8mdjNoKsw16O5ZqvYvZqzycrZBEpSwbhGDUE,11456
53
54
  tinybird/tb/modules/token.py,sha256=OhqLFpCHVfYeBCxJ0n7n2qoho9E9eGcUfHgL7R1MUVQ,13485
54
55
  tinybird/tb/modules/watch.py,sha256=qMQhewRSso1AFSEFLuyeyGFA8Lxf9ccYJxmVdPU1BgM,8808
55
56
  tinybird/tb/modules/workspace.py,sha256=SYkEULv_Gg8FhnAnZspengzyT5N4w0wjsvWWZ3vy3Ho,7753
@@ -78,8 +79,8 @@ tinybird/tb_cli_modules/config.py,sha256=IsgdtFRnUrkY8-Zo32lmk6O7u3bHie1QCxLwgp4
78
79
  tinybird/tb_cli_modules/exceptions.py,sha256=pmucP4kTF4irIt7dXiG-FcnI-o3mvDusPmch1L8RCWk,3367
79
80
  tinybird/tb_cli_modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
80
81
  tinybird/tb_cli_modules/telemetry.py,sha256=Hh2Io8ZPROSunbOLuMvuIFU4TqwWPmQTqal4WS09K1A,10449
81
- tinybird-0.0.1.dev90.dist-info/METADATA,sha256=1J8tIFd9v-xKv7yNIMmNAR9ZEx63FSbKgxwM4jiHL-s,2585
82
- tinybird-0.0.1.dev90.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
83
- tinybird-0.0.1.dev90.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
84
- tinybird-0.0.1.dev90.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
85
- tinybird-0.0.1.dev90.dist-info/RECORD,,
82
+ tinybird-0.0.1.dev92.dist-info/METADATA,sha256=D4Zz8uPHhOGElZtKIwMnCE5o5021zYYpC7Ah-TaHVBc,2585
83
+ tinybird-0.0.1.dev92.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
84
+ tinybird-0.0.1.dev92.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
85
+ tinybird-0.0.1.dev92.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
86
+ tinybird-0.0.1.dev92.dist-info/RECORD,,