tinybird 0.0.1.dev259__py3-none-any.whl → 0.0.1.dev260__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.dev259'
8
- __revision__ = '5b5805f'
7
+ __version__ = '0.0.1.dev260'
8
+ __revision__ = 'bd0c45e'
@@ -17,11 +17,11 @@ from tinybird.tb.modules.agent.animations import ThinkingAnimation
17
17
  from tinybird.tb.modules.agent.banner import display_banner
18
18
  from tinybird.tb.modules.agent.memory import clear_history, clear_messages, load_messages, save_messages
19
19
  from tinybird.tb.modules.agent.models import create_model, model_costs
20
- from tinybird.tb.modules.agent.prompts import agent_system_prompt, resources_prompt
20
+ from tinybird.tb.modules.agent.prompts import agent_system_prompt, load_custom_project_rules, resources_prompt
21
21
  from tinybird.tb.modules.agent.tools.analyze import analyze_file, analyze_url
22
22
  from tinybird.tb.modules.agent.tools.append import append_file, append_url
23
23
  from tinybird.tb.modules.agent.tools.build import build
24
- from tinybird.tb.modules.agent.tools.create_datafile import create_datafile
24
+ from tinybird.tb.modules.agent.tools.create_datafile import create_datafile, rename_datafile_or_fixture
25
25
  from tinybird.tb.modules.agent.tools.deploy import deploy
26
26
  from tinybird.tb.modules.agent.tools.deploy_check import deploy_check
27
27
  from tinybird.tb.modules.agent.tools.diff_resource import diff_resource
@@ -75,6 +75,12 @@ class TinybirdAgent:
75
75
  tools=[
76
76
  Tool(preview_datafile, docstring_format="google", require_parameter_descriptions=True, takes_ctx=False),
77
77
  Tool(create_datafile, docstring_format="google", require_parameter_descriptions=True, takes_ctx=True),
78
+ Tool(
79
+ rename_datafile_or_fixture,
80
+ docstring_format="google",
81
+ require_parameter_descriptions=True,
82
+ takes_ctx=True,
83
+ ),
78
84
  Tool(plan, docstring_format="google", require_parameter_descriptions=True, takes_ctx=True),
79
85
  Tool(build, docstring_format="google", require_parameter_descriptions=True, takes_ctx=True),
80
86
  Tool(deploy, docstring_format="google", require_parameter_descriptions=True, takes_ctx=True),
@@ -170,7 +176,7 @@ class TinybirdAgent:
170
176
  )
171
177
 
172
178
  def run(self, user_prompt: str, config: dict[str, Any]) -> None:
173
- user_prompt = f"{user_prompt}\n\n{resources_prompt(self.project)}"
179
+ user_prompt = f"{user_prompt}\n\n{load_custom_project_rules(self.project.folder)}"
174
180
  self.thinking_animation.start()
175
181
  result = self.agent.run_sync(
176
182
  user_prompt,
@@ -185,7 +191,7 @@ class TinybirdAgent:
185
191
  self._echo_usage(config, result)
186
192
 
187
193
  async def run_iter(self, user_prompt: str, config: dict[str, Any]) -> None:
188
- user_prompt = f"{user_prompt}\n\n"
194
+ user_prompt = f"{user_prompt}\n\n{load_custom_project_rules(self.project.folder)}"
189
195
  self.thinking_animation.start()
190
196
  deps = self._build_agent_deps(config)
191
197
 
@@ -568,9 +568,10 @@ You have access to the following tools:
568
568
  13. `request_endpoint` - Request an endpoint against Tinybird Cloud or Local.
569
569
  14. `diff_resource` - Diff the content of a resource in Tinybird Cloud vs Tinybird Local vs Project local file.
570
570
  15. `create_tests` - Create tests for an endpoint.
571
+ 16. `rename_datafile_or_fixture` - Rename a datafile or fixture.
571
572
 
572
573
  # When creating or updating datafiles:
573
- 1. Use `plan` tool to plan the creation or update of resources.
574
+ 1. Use `plan` tool to plan the creation, update or rename of resources.
574
575
  2. If the user confirms the plan, go from 3 to 7 steps until all the resources are created, updated or skipped.
575
576
  3. Use `preview_datafile` tool to preview the content of a datafile.
576
577
  4. Without asking, use the `create_datafile` tool to create the datafile, because it will ask for confirmation before creating the file.
@@ -674,3 +675,12 @@ GCS: {gcs_connection_example}
674
675
  # Info
675
676
  Today is {datetime.now().strftime("%Y-%m-%d")}
676
677
  """
678
+
679
+
680
+ def load_custom_project_rules(folder: str) -> str:
681
+ tinybird_rules = Path(folder).joinpath("TINYBIRD.md")
682
+
683
+ if not tinybird_rules.exists():
684
+ return ""
685
+
686
+ return f"# Custom Project Rulesd defined by the user\n\n{tinybird_rules.read_text()}"
@@ -122,3 +122,59 @@ def create_file(ctx: RunContext[TinybirdAgentContext], path: str, content: str):
122
122
  f.write(content)
123
123
 
124
124
  return "ok"
125
+
126
+
127
+ def rename_datafile_or_fixture(ctx: RunContext[TinybirdAgentContext], path: str, new_path: str):
128
+ """Renames a datafile or fixture.
129
+
130
+ Args:
131
+ path (str): The path to the file to rename. Required.
132
+ new_path (str): The new path to the file. Required.
133
+ """
134
+ try:
135
+ ctx.deps.thinking_animation.stop()
136
+ confirmation = show_confirmation(
137
+ title=f"Rename '{path}' to '{new_path}'?",
138
+ skip_confirmation=ctx.deps.dangerously_skip_permissions,
139
+ )
140
+
141
+ if confirmation == "review":
142
+ feedback = show_input(ctx.deps.workspace_name)
143
+ ctx.deps.thinking_animation.start()
144
+ return f"User did not confirm the proposed changes and gave the following feedback: {feedback}"
145
+
146
+ click.echo(FeedbackManager.highlight(message=f"» Renaming file {path} to {new_path}..."))
147
+ new_path_full = Path(ctx.deps.folder) / new_path.removeprefix("/")
148
+
149
+ if new_path_full.exists():
150
+ click.echo(FeedbackManager.error(message=f"Error: File {new_path} already exists"))
151
+ ctx.deps.thinking_animation.start()
152
+ return f"Error: File {new_path} already exists"
153
+
154
+ parent_path = new_path_full.parent
155
+ parent_path.mkdir(parents=True, exist_ok=True)
156
+ os.rename(Path(ctx.deps.folder) / path.removeprefix("/"), new_path_full)
157
+ is_datafile = (".connection", ".datasource", ".pipe")
158
+
159
+ if new_path_full.suffix in is_datafile:
160
+ ctx.deps.build_project(test=False, silent=True)
161
+
162
+ click.echo(FeedbackManager.success(message=f"✓ {new_path} created"))
163
+ ctx.deps.thinking_animation.start()
164
+ return f"Renamed file from {path} to {new_path}"
165
+ except AgentRunCancelled as e:
166
+ raise e
167
+ except FileNotFoundError:
168
+ ctx.deps.thinking_animation.start()
169
+ click.echo(FeedbackManager.error(message=f"Error: File {path} not found"))
170
+ return f"Error: File {path} not found (double check the file path)"
171
+ except CLIBuildException as e:
172
+ ctx.deps.thinking_animation.stop()
173
+ click.echo(FeedbackManager.error(message=e))
174
+ ctx.deps.thinking_animation.start()
175
+ return f"Error building project: {e}"
176
+ except Exception as e:
177
+ ctx.deps.thinking_animation.stop()
178
+ click.echo(FeedbackManager.error(message=e))
179
+ ctx.deps.thinking_animation.start()
180
+ return f"Error renaming {path} to {new_path}: {e}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: tinybird
3
- Version: 0.0.1.dev259
3
+ Version: 0.0.1.dev260
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=D0G5HjONd9vfaiba7rVUC32Pic_cEL9FIR6-Z3uB_2c,247
20
+ tinybird/tb/__cli__.py,sha256=GooE8LYwW5AvSc5ky2GJcqRgW4eIKUmmqimo2SYppqE,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=pJbdkWMXGAqKseNAvdsRRnl_c7I-DCMB0dWCQnG82nU,54146
@@ -69,18 +69,18 @@ tinybird/tb/modules/watch.py,sha256=No0bK1M1_3CYuMaIgylxf7vYFJ72lTJe3brz6xQ-mJo,
69
69
  tinybird/tb/modules/workspace.py,sha256=Q_8HcxMsNg8QG9aBlwcWS2umrDP5IkTIHqqz3sfmGuc,11341
70
70
  tinybird/tb/modules/workspace_members.py,sha256=5JdkJgfuEwbq-t6vxkBhYwgsiTDxF790wsa6Xfif9nk,8608
71
71
  tinybird/tb/modules/agent/__init__.py,sha256=i3oe3vDIWWPaicdCM0zs7D7BJ1W0k7th93ooskHAV00,54
72
- tinybird/tb/modules/agent/agent.py,sha256=1EGRxcIa3QTIO4EXrGAs8svBm4vlm3DiVCZEF5k7mFw,23773
72
+ tinybird/tb/modules/agent/agent.py,sha256=r8mreWX8CdvzKp_BSCvWJHGQ5xcKee2aPVeOcLbDeMo,24121
73
73
  tinybird/tb/modules/agent/animations.py,sha256=4WOC5_2BracttmMCrV0H91tXfWcUzQHBUaIJc5FA7tE,3490
74
74
  tinybird/tb/modules/agent/banner.py,sha256=7f97PeCPW-oW9mReQn3D0by8mnDhoc0VbfebEPRPI7c,3070
75
75
  tinybird/tb/modules/agent/memory.py,sha256=O6Kumn9AyKxcTkhI45yjAUZ3ZIAibLOcNWoiEuLYeqY,3245
76
76
  tinybird/tb/modules/agent/models.py,sha256=LW1D27gjcd_jwFmghEzteCgToDfodX2B6B5S8BYbysw,735
77
- tinybird/tb/modules/agent/prompts.py,sha256=-qks8FvYb8_WpchyjjWi9k8tQEYTjX9fEynuFrFLbzA,27727
77
+ tinybird/tb/modules/agent/prompts.py,sha256=pSjEeXzfN5_bFl0bF1mHcVva0A4mKBGXA7nBUUkVnGU,28057
78
78
  tinybird/tb/modules/agent/utils.py,sha256=tVymkZdDINcp5iLPrjEWEsoGmj4SjNbvgsXcYqsMrhU,26888
79
79
  tinybird/tb/modules/agent/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
80
80
  tinybird/tb/modules/agent/tools/analyze.py,sha256=fTKjMCq8ckvvqq8WqpE2aE_gO0XBM-eFPt75WTFC3ik,3565
81
81
  tinybird/tb/modules/agent/tools/append.py,sha256=b8nCO788MAk1ahITdNrrzMdUDhj-Y6KBwOCj4UmCQxg,5606
82
82
  tinybird/tb/modules/agent/tools/build.py,sha256=iSsdq42jpP8PC4SOUOLHYzuDrmqU3MDBYwhrT44tBFk,825
83
- tinybird/tb/modules/agent/tools/create_datafile.py,sha256=twsURhfIhQ5sjTwvsxR0rsERjfIcYxwDZpVNWG6MBPI,4423
83
+ tinybird/tb/modules/agent/tools/create_datafile.py,sha256=habaRw-PXGFMuyWgqwcm4Lg4ataYhkyebmPUoCl10p8,6860
84
84
  tinybird/tb/modules/agent/tools/deploy.py,sha256=2hKj6LMYiDea6ventsBjE6ArECGIryTdo3X-LYo5oZI,1248
85
85
  tinybird/tb/modules/agent/tools/deploy_check.py,sha256=2Wr9hQfKPlhqhumOv5TNl_xFctvdq_DHZ2dI2h_LggY,1048
86
86
  tinybird/tb/modules/agent/tools/diff_resource.py,sha256=_9xHcDzCTKk_E1wKQbuktVqV6U9sA0kqYaBxWvtliX0,2613
@@ -113,8 +113,8 @@ tinybird/tb_cli_modules/config.py,sha256=IsgdtFRnUrkY8-Zo32lmk6O7u3bHie1QCxLwgp4
113
113
  tinybird/tb_cli_modules/exceptions.py,sha256=pmucP4kTF4irIt7dXiG-FcnI-o3mvDusPmch1L8RCWk,3367
114
114
  tinybird/tb_cli_modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
115
115
  tinybird/tb_cli_modules/telemetry.py,sha256=Hh2Io8ZPROSunbOLuMvuIFU4TqwWPmQTqal4WS09K1A,10449
116
- tinybird-0.0.1.dev259.dist-info/METADATA,sha256=WTSSsjGRnfYv-YUjstmzMF58_YHbuYjg8OWOoghGaVg,1733
117
- tinybird-0.0.1.dev259.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
118
- tinybird-0.0.1.dev259.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
119
- tinybird-0.0.1.dev259.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
120
- tinybird-0.0.1.dev259.dist-info/RECORD,,
116
+ tinybird-0.0.1.dev260.dist-info/METADATA,sha256=BREz0wuoONs5NhcgFYDlZXBWfTF3MLyADgy3eF6X168,1733
117
+ tinybird-0.0.1.dev260.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
118
+ tinybird-0.0.1.dev260.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
119
+ tinybird-0.0.1.dev260.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
120
+ tinybird-0.0.1.dev260.dist-info/RECORD,,