tinybird 0.0.1.dev237__py3-none-any.whl → 0.0.1.dev239__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/sql_template.py CHANGED
@@ -1388,6 +1388,7 @@ _namespace = {
1388
1388
  "close": None,
1389
1389
  "print": None,
1390
1390
  "input": None,
1391
+ "id": None,
1391
1392
  }
1392
1393
 
1393
1394
 
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.dev237'
8
- __revision__ = '7aa96d2'
7
+ __version__ = '0.0.1.dev239'
8
+ __revision__ = '960f37b'
tinybird/tb/cli.py CHANGED
@@ -1,3 +1,4 @@
1
+ import tinybird.tb.modules.agent
1
2
  import tinybird.tb.modules.build
2
3
  import tinybird.tb.modules.cli
3
4
  import tinybird.tb.modules.common
tinybird/tb/client.py CHANGED
@@ -1394,3 +1394,7 @@ class TinyB:
1394
1394
 
1395
1395
  def delete_tag(self, name: str):
1396
1396
  self._req(f"/v0/tags/{name}", method="DELETE")
1397
+
1398
+ def explore_data(self, prompt: str) -> str:
1399
+ params = urlencode({"prompt": prompt, "host": self.host, "origin": "cli"})
1400
+ return self._req(f"/v1/agents/explore?{params}")
@@ -0,0 +1,80 @@
1
+ import os
2
+ import sys
3
+ from typing import Any, Dict, Optional
4
+
5
+ import click
6
+ from prompt_toolkit import PromptSession
7
+ from prompt_toolkit.history import FileHistory
8
+ from prompt_toolkit.styles import Style
9
+
10
+ from tinybird.tb.client import TinyB
11
+ from tinybird.tb.modules.common import _get_tb_client
12
+ from tinybird.tb.modules.feedback_manager import FeedbackManager
13
+
14
+
15
+ def agent_banner():
16
+ # Define gradient colors (teal/turquoise range)
17
+ colors = [
18
+ "\033[38;2;0;128;128m", # Teal
19
+ "\033[38;2;0;150;136m", # Teal-ish
20
+ "\033[38;2;20;160;145m", # Turquoise blend
21
+ "\033[38;2;40;170;155m", # Light turquoise
22
+ "\033[38;2;60;180;165m", # Lighter turquoise
23
+ "\033[38;2;80;190;175m", # Very light turquoise
24
+ ]
25
+ reset = "\033[0m"
26
+
27
+ # The Tinybird Code ASCII art banner
28
+ banner = [
29
+ " ████████╗██╗███╗ ██╗██╗ ██╗██████╗ ██╗██████╗ ██████╗ ██████╗ ██████╗ ██████╗ ███████╗",
30
+ " ╚══██╔══╝██║████╗ ██║╚██╗ ██╔╝██╔══██╗██║██╔══██╗██╔══██╗ ██╔════╝██╔═══██╗██╔══██╗██╔════╝",
31
+ " ██║ ██║██╔██╗ ██║ ╚████╔╝ ██████╔╝██║██████╔╝██║ ██║ ██║ ██║ ██║██║ ██║█████╗ ",
32
+ " ██║ ██║██║╚██╗██║ ╚██╔╝ ██╔══██╗██║██╔══██╗██║ ██║ ██║ ██║ ██║██║ ██║██╔══╝ ",
33
+ " ██║ ██║██║ ╚████║ ██║ ██████╔╝██║██║ ██║██████╔╝ ╚██████╗╚██████╔╝██████╔╝███████╗",
34
+ " ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═╝ ╚═════╝ ╚═╝╚═╝ ╚═╝╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝",
35
+ ]
36
+
37
+ # Print each line with a smooth horizontal gradient
38
+ for line in banner:
39
+ colored_line = ""
40
+ for j, char in enumerate(line):
41
+ # Skip coloring spaces
42
+ if char == " ":
43
+ colored_line += char
44
+ continue
45
+
46
+ # Calculate color index for a smooth gradient
47
+ color_index = min(int(j * len(colors) / len(line)), len(colors) - 1)
48
+ colored_line += f"{colors[color_index]}{char}"
49
+
50
+ click.echo(colored_line + reset)
51
+
52
+
53
+ def explore_data(client: TinyB, prompt: str):
54
+ click.echo(FeedbackManager.highlight(message="\nExploring data...\n"))
55
+ result = client.explore_data(prompt)
56
+ click.echo(result)
57
+
58
+
59
+ def run_agent_shell(config: Dict[str, Any]):
60
+ style = Style.from_dict({"prompt": "fg:#34D399 bold"})
61
+ history: Optional[FileHistory] = None
62
+ try:
63
+ history_file = os.path.expanduser("~/.tb_agent_history")
64
+ history = FileHistory(history_file)
65
+ except Exception:
66
+ pass
67
+ workspace_name = config.get("name", "No workspace found")
68
+ session: PromptSession = PromptSession(history=history)
69
+ user_input = session.prompt([("class:prompt", f"\ntb ({workspace_name}) » ")], style=style)
70
+ if user_input == "exit":
71
+ sys.exit(0)
72
+ else:
73
+ client = _get_tb_client(config.get("token", None), config["host"])
74
+ explore_data(client, user_input)
75
+ return run_agent_shell(config)
76
+
77
+
78
+ def run_agent(config: Dict[str, Any]):
79
+ agent_banner()
80
+ run_agent_shell(config)
@@ -22,6 +22,7 @@ from tinybird.tb.client import (
22
22
  AuthException,
23
23
  AuthNoTokenException,
24
24
  )
25
+ from tinybird.tb.modules.agent import run_agent
25
26
  from tinybird.tb.modules.common import (
26
27
  CatchAuthExceptions,
27
28
  CLIException,
@@ -46,6 +47,8 @@ DEFAULT_PATTERNS: List[Tuple[str, Union[str, Callable[[str], str]]]] = [
46
47
  ]
47
48
  VERSION = f"{__cli__.__version__} (rev {__cli__.__revision__})"
48
49
 
50
+ agent_mode_flag = os.environ.get("TB_AGENT_MODE", "false") == "true"
51
+
49
52
 
50
53
  @click.group(
51
54
  cls=CatchAuthExceptions,
@@ -53,6 +56,7 @@ VERSION = f"{__cli__.__version__} (rev {__cli__.__revision__})"
53
56
  "help_option_names": ["-h", "--help"],
54
57
  "max_content_width": shutil.get_terminal_size().columns - 10,
55
58
  },
59
+ invoke_without_command=agent_mode_flag,
56
60
  )
57
61
  @click.option(
58
62
  "--debug/--no-debug",
@@ -93,6 +97,7 @@ def cli(
93
97
  """
94
98
  Use `OBFUSCATE_REGEX_PATTERN` and `OBFUSCATE_PATTERN_SEPARATOR` environment variables to define a regex pattern and a separator (in case of a single string with multiple regex) to obfuscate secrets in the CLI output.
95
99
  """
100
+
96
101
  # We need to unpatch for our tests not to break
97
102
  if output != "human":
98
103
  __hide_click_output()
@@ -188,6 +193,11 @@ def cli(
188
193
  ctx.ensure_object(dict)["env"] = get_target_env(cloud)
189
194
  ctx.ensure_object(dict)["output"] = output
190
195
 
196
+ is_agent_mode = agent_mode_flag and ctx.invoked_subcommand is None
197
+
198
+ if is_agent_mode:
199
+ run_agent(config)
200
+
191
201
 
192
202
  @cli.command(hidden=True)
193
203
  @click.option("-f", "--force", is_flag=True, default=False, help="Override existing files")
@@ -365,7 +375,7 @@ def create_ctx_client(ctx: Context, config: Dict[str, Any], cloud: bool, staging
365
375
  "init",
366
376
  ]
367
377
  command = ctx.invoked_subcommand
368
- if command in commands_without_ctx_client:
378
+ if not command or command in commands_without_ctx_client:
369
379
  return None
370
380
 
371
381
  commands_always_cloud = ["pull", "infra"]
@@ -1,4 +1,5 @@
1
1
  import subprocess
2
+ from pathlib import Path
2
3
 
3
4
  import click
4
5
  import requests
@@ -148,6 +149,11 @@ def remove() -> None:
148
149
  )
149
150
  def start(use_aws_creds: bool, volumes_path: str) -> None:
150
151
  """Start Tinybird Local"""
152
+ if volumes_path is not None:
153
+ absolute_path = Path(volumes_path).absolute()
154
+ absolute_path.mkdir(parents=True, exist_ok=True)
155
+ volumes_path = str(absolute_path)
156
+
151
157
  click.echo(FeedbackManager.highlight(message="» Starting Tinybird Local..."))
152
158
  docker_client = get_docker_client()
153
159
  start_tinybird_local(docker_client, use_aws_creds, volumes_path)
@@ -168,6 +174,11 @@ def start(use_aws_creds: bool, volumes_path: str) -> None:
168
174
  )
169
175
  def restart(use_aws_creds: bool, volumes_path: str) -> None:
170
176
  """Restart Tinybird Local"""
177
+ if volumes_path is not None:
178
+ absolute_path = Path(volumes_path).absolute()
179
+ absolute_path.mkdir(parents=True, exist_ok=True)
180
+ volumes_path = str(absolute_path)
181
+
171
182
  click.echo(FeedbackManager.highlight(message="» Restarting Tinybird Local..."))
172
183
  docker_client = get_docker_client()
173
184
  remove_tinybird_local(docker_client, volumes_path is not None)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: tinybird
3
- Version: 0.0.1.dev237
3
+ Version: 0.0.1.dev239
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/forward/commands
6
6
  Author: Tinybird
@@ -5,7 +5,7 @@ tinybird/feedback_manager.py,sha256=1INQFfRfuMCb9lfB8KNf4r6qC2khW568hoHjtk-wshI,
5
5
  tinybird/git_settings.py,sha256=Sw_8rGmribEFJ4Z_6idrVytxpFYk7ez8ei0qHULzs3E,3934
6
6
  tinybird/prompts.py,sha256=dg8Q8Q29X69j-PPP8KGooMz7-M3FNXEYqC0Fj0LcUbw,45316
7
7
  tinybird/sql.py,sha256=BufnOgclQokDyihtuXesOwHBsebN6wRXIxO5wKRkOwE,48299
8
- tinybird/sql_template.py,sha256=WjsTBjpQLVBHGZbY2dZuhZUurFR-rbJ_KRRy5vx4Y5E,99967
8
+ tinybird/sql_template.py,sha256=LChDztXUUrNO4Qukv2RMsdjQ-vhmepWiHVoX6yr140E,99983
9
9
  tinybird/sql_template_fmt.py,sha256=KUHdj5rYCYm_rKKdXYSJAE9vIyXUQLB0YSZnUXHeBlY,10196
10
10
  tinybird/sql_toolset.py,sha256=M2rpLYkgV2W8NnYEYPC1tJdpy4uZHXVF64NBSKLQka4,19549
11
11
  tinybird/syncasync.py,sha256=IPnOx6lMbf9SNddN1eBtssg8vCLHMt76SuZ6YNYm-Yk,27761
@@ -17,14 +17,15 @@ 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=vmMQxvQ7ux44Mfpu0EDdpMaLEOM4WmWMZ3dbG8YeI5s,247
20
+ tinybird/tb/__cli__.py,sha256=8mfKuN5jmJ9hrzhAZqnZA9ASZ0QXkYRjiGxO_zKzPhM,247
21
21
  tinybird/tb/check_pypi.py,sha256=Gp0HkHHDFMSDL6nxKlOY51z7z1Uv-2LRexNTZSHHGmM,552
22
- tinybird/tb/cli.py,sha256=_5hIbxDFdLjMq0GiXpdoMIz7TdTpQ0DHfAS9MKdlST4,975
23
- tinybird/tb/client.py,sha256=cHJky5SF-z_epBajNovo_gaIRdMsU5KXx7vtVl4sdgE,53957
22
+ tinybird/tb/cli.py,sha256=FdDFEIayjmsZEVsVSSvRiVYn_FHOVg_zWQzchnzfWho,1008
23
+ tinybird/tb/client.py,sha256=pJbdkWMXGAqKseNAvdsRRnl_c7I-DCMB0dWCQnG82nU,54146
24
24
  tinybird/tb/config.py,sha256=mhMTGnMB5KcxGoh3dewIr2Jjsa6pHE183gCPAQWyp6o,3973
25
+ tinybird/tb/modules/agent.py,sha256=RE_QlGSq6MByEaOBUbr1dSr3X2bi09-QvzoxpxQtyPs,3900
25
26
  tinybird/tb/modules/build.py,sha256=MxGQY-KII4lYut-yOWGBIHFpg-m_cfHgpE7lwOzZCeQ,19871
26
27
  tinybird/tb/modules/cicd.py,sha256=0KLKccha9IP749QvlXBmzdWv1On3mFwMY4DUcJlBxiE,7326
27
- tinybird/tb/modules/cli.py,sha256=E91z3aw4Yziu93AxCjJyBfWnvh3tZk1zxkzRG1s5EhY,16036
28
+ tinybird/tb/modules/cli.py,sha256=SgXaNjyX1ba3Uvmjpc-ViG1NLbscw394mH1vBj-A2JI,16335
28
29
  tinybird/tb/modules/common.py,sha256=jTTaDDHrZREt--032XhP6GkbfFwC79YJ5aH1Sl7bmbo,81925
29
30
  tinybird/tb/modules/config.py,sha256=gK7rgaWTDd4ZKCrNEg_Uemr26EQjqWt6TjyQKujxOws,11462
30
31
  tinybird/tb/modules/connection.py,sha256=-MY56NUAai6EMC4-wpi7bT0_nz_SA8QzTmHkV7HB1IQ,17810
@@ -42,7 +43,7 @@ tinybird/tb/modules/infra.py,sha256=JE9oLIyF4bi_JBoe-BgZ5HhKp_lQgSihuSV1KIS02Qs,
42
43
  tinybird/tb/modules/job.py,sha256=wBsnu8UPTOha2rkLvucgmw4xYv73ubmui3eeSIF68ZM,3107
43
44
  tinybird/tb/modules/llm.py,sha256=QbHRcMLgFmLKEh4zVb2ctR_5tIGUGdFJrAiRCDtMxDw,1572
44
45
  tinybird/tb/modules/llm_utils.py,sha256=nS9r4FAElJw8yXtmdYrx-rtI2zXR8qXfi1QqUDCfxvg,3469
45
- tinybird/tb/modules/local.py,sha256=HTLUFb8xqR8_PEFkvZV1UB-uk2L66_DAh6eflce6_FE,6446
46
+ tinybird/tb/modules/local.py,sha256=tpiw_F_qOIp42h3kTBwTm5GQDyuVLF0QNF1jmB0zR94,6845
46
47
  tinybird/tb/modules/local_common.py,sha256=_WODjW3oPshgsZ1jDFFx2nr0zrLi3Gxz5dlahWPobM8,17464
47
48
  tinybird/tb/modules/login.py,sha256=glqj5RWH26AseEoBl8XfrSDEjQTdko17i_pVWOIMoGc,12497
48
49
  tinybird/tb/modules/logout.py,sha256=sniI4JNxpTrVeRCp0oGJuQ3yRerG4hH5uz6oBmjv724,1009
@@ -82,8 +83,8 @@ tinybird/tb_cli_modules/config.py,sha256=IsgdtFRnUrkY8-Zo32lmk6O7u3bHie1QCxLwgp4
82
83
  tinybird/tb_cli_modules/exceptions.py,sha256=pmucP4kTF4irIt7dXiG-FcnI-o3mvDusPmch1L8RCWk,3367
83
84
  tinybird/tb_cli_modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
84
85
  tinybird/tb_cli_modules/telemetry.py,sha256=Hh2Io8ZPROSunbOLuMvuIFU4TqwWPmQTqal4WS09K1A,10449
85
- tinybird-0.0.1.dev237.dist-info/METADATA,sha256=Wx48Mkja_8CCOe1o8FJFVlz9M36gjsZHPKZK86YVQDo,1682
86
- tinybird-0.0.1.dev237.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
87
- tinybird-0.0.1.dev237.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
88
- tinybird-0.0.1.dev237.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
89
- tinybird-0.0.1.dev237.dist-info/RECORD,,
86
+ tinybird-0.0.1.dev239.dist-info/METADATA,sha256=NtL4GLVWnmL5-eQn2I6DCzgQqGODeBofbbGVyPXOt90,1682
87
+ tinybird-0.0.1.dev239.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
88
+ tinybird-0.0.1.dev239.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
89
+ tinybird-0.0.1.dev239.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
90
+ tinybird-0.0.1.dev239.dist-info/RECORD,,