tinybird 0.0.1.dev291__py3-none-any.whl → 0.0.1.dev292__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/context.py CHANGED
@@ -3,10 +3,11 @@ from typing import TYPE_CHECKING
3
3
 
4
4
  # Avoid circular import error
5
5
  if TYPE_CHECKING:
6
- from tinybird.user import User
6
+ from hfi.hfi_workspace_data import HfiWorkspaceData
7
+
7
8
 
8
9
  workspace_id: ContextVar[str] = ContextVar("workspace_id")
9
- workspace: ContextVar["User"] = ContextVar("workspace")
10
+ hfi_workspace_data: ContextVar["HfiWorkspaceData"] = ContextVar("hfi_workspace_data")
10
11
  table_id: ContextVar[str] = ContextVar("table_id")
11
12
  hfi_frequency: ContextVar[float] = ContextVar("hfi_frequency")
12
13
  hfi_frequency_gatherer: ContextVar[float] = ContextVar("hfi_frequency_gatherer")
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.dev291'
8
- __revision__ = '87da698'
7
+ __version__ = '0.0.1.dev292'
8
+ __revision__ = '78dba1d'
@@ -34,10 +34,12 @@ from tinybird.tb.modules.agent.mock_agent import MockAgent
34
34
  from tinybird.tb.modules.agent.models import create_model
35
35
  from tinybird.tb.modules.agent.prompts import (
36
36
  agent_system_prompt,
37
+ fixtures_prompt,
37
38
  load_custom_project_rules,
38
39
  resources_prompt,
39
40
  secrets_prompt,
40
41
  service_datasources_prompt,
42
+ vendor_files_prompt,
41
43
  )
42
44
  from tinybird.tb.modules.agent.testing_agent import TestingAgent
43
45
  from tinybird.tb.modules.agent.tools.analyze import analyze_file, analyze_url
@@ -322,6 +324,14 @@ class TinybirdAgent:
322
324
  def get_project_files(ctx: RunContext[TinybirdAgentContext]) -> str:
323
325
  return resources_prompt(self.project)
324
326
 
327
+ @self.agent.instructions
328
+ def get_vendor_files(ctx: RunContext[TinybirdAgentContext]) -> str:
329
+ return vendor_files_prompt(self.project)
330
+
331
+ @self.agent.instructions
332
+ def get_fixture_files(ctx: RunContext[TinybirdAgentContext]) -> str:
333
+ return fixtures_prompt(self.project)
334
+
325
335
  @self.agent.instructions
326
336
  def get_service_datasources(ctx: RunContext[TinybirdAgentContext]) -> str:
327
337
  return service_datasources_prompt()
@@ -12,6 +12,7 @@ from tinybird.tb.modules.agent.prompts import (
12
12
  resources_prompt,
13
13
  service_datasources_prompt,
14
14
  tone_and_style_instructions,
15
+ vendor_files_prompt,
15
16
  )
16
17
  from tinybird.tb.modules.agent.tools.diff_resource import diff_resource
17
18
  from tinybird.tb.modules.agent.tools.execute_query import execute_query
@@ -76,6 +77,10 @@ Once you finish the task, return a valid response for the task to complete.
76
77
  def get_project_files(ctx: RunContext[TinybirdAgentContext]) -> str:
77
78
  return resources_prompt(self.project)
78
79
 
80
+ @self.agent.instructions
81
+ def get_vendor_files(ctx: RunContext[TinybirdAgentContext]) -> str:
82
+ return vendor_files_prompt(self.project)
83
+
79
84
  @self.agent.instructions
80
85
  def get_service_datasources(ctx: RunContext[TinybirdAgentContext]) -> str:
81
86
  return service_datasources_prompt()
@@ -6,7 +6,7 @@ from pydantic_ai.usage import Usage
6
6
 
7
7
  from tinybird.tb.modules.agent.animations import ThinkingAnimation
8
8
  from tinybird.tb.modules.agent.models import create_model
9
- from tinybird.tb.modules.agent.prompts import resources_prompt
9
+ from tinybird.tb.modules.agent.prompts import fixtures_prompt, resources_prompt
10
10
  from tinybird.tb.modules.agent.tools.mock import generate_mock_fixture
11
11
  from tinybird.tb.modules.agent.utils import TinybirdAgentContext
12
12
  from tinybird.tb.modules.project import Project
@@ -194,6 +194,10 @@ Today is {datetime.now().strftime("%Y-%m-%d")}
194
194
  def get_project_files(ctx: RunContext[TinybirdAgentContext]) -> str:
195
195
  return resources_prompt(self.project)
196
196
 
197
+ @self.agent.instructions
198
+ def get_fixture_files(ctx: RunContext[TinybirdAgentContext]) -> str:
199
+ return fixtures_prompt(self.project)
200
+
197
201
  def run(self, task: str, deps: TinybirdAgentContext, usage: Usage):
198
202
  result = self.agent.run_sync(
199
203
  task,
@@ -35,8 +35,10 @@ available_commands = [
35
35
  "`tb sink ls`: List all sinks",
36
36
  "`tb workspace current`: Show the current workspace",
37
37
  "`tb workspace clear --yes`: Delete all resources in the workspace (Only available in Tinybird Local)",
38
+ "`tb workspace ls`: List all workspaces",
38
39
  "`tb local start --skip-new-version`: Start Tinybird Local container in non-interactive mode",
39
40
  "`tb local restart --skip-new-version --yes`: Restart Tinybird Local container in non-interactive mode",
41
+ "`tb pull --only-vendored`: Pull only the vendored datasources from other workspaces",
40
42
  ]
41
43
 
42
44
  plan_instructions = """
@@ -166,7 +168,6 @@ SQL >
166
168
 
167
169
  def resources_prompt(project: Project) -> str:
168
170
  files = project.get_project_files()
169
- fixture_files = project.get_fixture_files()
170
171
 
171
172
  resources_content = "# Existing resources in the project:\n"
172
173
  if files:
@@ -184,7 +185,36 @@ def resources_prompt(project: Project) -> str:
184
185
  else:
185
186
  resources_content += "No resources found"
186
187
 
188
+ return resources_content
189
+
190
+
191
+ def vendor_files_prompt(project: Project) -> str:
192
+ files = project.get_vendored_files()
193
+ content = "# Datasources shared from other workspaces:\n"
194
+ if files:
195
+ resources: list[dict[str, Any]] = []
196
+ for filename in files:
197
+ file_path = Path(filename)
198
+ workspace_name = file_path.parent.parent.name
199
+ resource = {
200
+ "path": str(file_path.relative_to(project.folder)),
201
+ "type": get_resource_type(file_path),
202
+ "name": f"{workspace_name}.{file_path.stem}",
203
+ "content": file_path.read_text(),
204
+ "origin_workspace": workspace_name,
205
+ }
206
+ resources.append(resource)
207
+ content += format_as_xml(resources, root_tag="resources", item_tag="resource")
208
+ else:
209
+ content += "No datasources shared from other workspaces"
210
+
211
+ return content
212
+
213
+
214
+ def fixtures_prompt(project: Project) -> str:
215
+ fixture_files = project.get_fixture_files()
187
216
  fixture_content = "# Fixture files in the project:\n"
217
+
188
218
  if fixture_files:
189
219
  fixtures: list[dict[str, Any]] = []
190
220
  for filename in fixture_files:
@@ -199,7 +229,7 @@ def resources_prompt(project: Project) -> str:
199
229
  else:
200
230
  fixture_content += "No fixture files found"
201
231
 
202
- return resources_content + "\n" + fixture_content
232
+ return fixture_content
203
233
 
204
234
 
205
235
  def service_datasources_prompt() -> str:
@@ -954,6 +984,23 @@ After changes have been deployed and promoted, if you want to deploy other chang
954
984
  If after running a deployment, the error contains a recommended forward query, use it to update the .datasource file.
955
985
  </dev_notes>
956
986
 
987
+ ## Sharing datasources with other workspaces
988
+ To share a Data Source, in the .datasource file you want to share, add the destination workspace(s). For example:
989
+
990
+ ```
991
+ SHARED_WITH >
992
+ destination_workspace,
993
+ other_destination_workspace
994
+ ```
995
+
996
+ ## Working with shared datasources:
997
+
998
+ The following limitations apply to shared datasources:
999
+ - Shared datasources are read-only.
1000
+ - You can't share a shared datasource, only the original.
1001
+ - You can't check the quarantine of a shared datasource.
1002
+ - You can't create a Materialized View from a shared datasource.
1003
+
957
1004
  # Working with any type of pipe file:
958
1005
  {pipe_instructions}
959
1006
  {pipe_example}
@@ -3,6 +3,7 @@ import subprocess
3
3
  import click
4
4
  from pydantic_ai import RunContext
5
5
 
6
+ from tinybird.tb.modules.agent.prompts import available_commands
6
7
  from tinybird.tb.modules.agent.utils import (
7
8
  AgentRunCancelled,
8
9
  SubAgentRunCancelled,
@@ -20,6 +21,14 @@ def run_command(ctx: RunContext[TinybirdAgentContext], command: str):
20
21
  command (str): The command to run. Required. Examples: `tb --local sql "select 1"`, `tb --cloud datasource ls`, `tb --help`
21
22
  """
22
23
  try:
24
+ clean_commands = [cmd.split(":")[0].replace("`", "").split("[")[0] for cmd in available_commands]
25
+ available_commands_to_cloud = [f"tb --cloud {command.replace('tb ', '')}" for command in clean_commands]
26
+ available_commands_to_local = [f"tb --local {command.replace('tb ', '')}" for command in clean_commands]
27
+ all_commands = clean_commands + available_commands_to_cloud + available_commands_to_local
28
+
29
+ if not any(cmd.startswith(command) for cmd in all_commands):
30
+ raise SubAgentRunCancelled(f"Command {command} not found in the list of available commands")
31
+
23
32
  ctx.deps.thinking_animation.stop()
24
33
  force_confirmation = " deploy" in command.lower() or " truncate" in command.lower()
25
34
  confirmation = show_confirmation(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: tinybird
3
- Version: 0.0.1.dev291
3
+ Version: 0.0.1.dev292
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/forward/commands
6
6
  Author: Tinybird
@@ -1,5 +1,5 @@
1
1
  tinybird/connectors.py,sha256=7Gjms7b5MAaBFGi3xytsJurCylprONpFcYrzp4Fw2Rc,15241
2
- tinybird/context.py,sha256=FfqYfrGX_I7PKGTQo93utaKPDNVYWelg4Hsp3evX5wM,1291
2
+ tinybird/context.py,sha256=M2jhaNBDOFLlSU2ONDPwO7Coknh2z1PNY-TlNJAkEK0,1343
3
3
  tinybird/datatypes.py,sha256=r4WCvspmrXTJHiPjjyOTiZyZl31FO3Ynkwq4LQsYm6E,11059
4
4
  tinybird/feedback_manager.py,sha256=XY8d83pRlq-LH7xHMApkaEebfXEWLjDzrGe1prpcTHE,69778
5
5
  tinybird/git_settings.py,sha256=Sw_8rGmribEFJ4Z_6idrVytxpFYk7ez8ei0qHULzs3E,3934
@@ -18,7 +18,7 @@ tinybird/datafile/exceptions.py,sha256=8rw2umdZjtby85QbuRKFO5ETz_eRHwUY5l7eHsy1w
18
18
  tinybird/datafile/parse_connection.py,sha256=tRyn2Rpr1TeWet5BXmMoQgaotbGdYep1qiTak_OqC5E,1825
19
19
  tinybird/datafile/parse_datasource.py,sha256=ssW8QeFSgglVFi3sDZj_HgkJiTJ2069v2JgqnH3CkDE,1825
20
20
  tinybird/datafile/parse_pipe.py,sha256=xf4m0Tw44QWJzHzAm7Z7FwUoUUtr7noMYjU1NiWnX0k,3880
21
- tinybird/tb/__cli__.py,sha256=Etfq1IZSoQiHmnt8KFW5i_w4w_P9rnn-X56chF8OH3o,247
21
+ tinybird/tb/__cli__.py,sha256=-6WKEO5Hmmfh0zrBTi4mPaxkqDYeWDApz2022V9XsK8,247
22
22
  tinybird/tb/check_pypi.py,sha256=Gp0HkHHDFMSDL6nxKlOY51z7z1Uv-2LRexNTZSHHGmM,552
23
23
  tinybird/tb/cli.py,sha256=FdDFEIayjmsZEVsVSSvRiVYn_FHOVg_zWQzchnzfWho,1008
24
24
  tinybird/tb/client.py,sha256=IQRaInDjOwr9Fzaz3_xXc3aUGqh94tM2lew7IZbB9eM,53733
@@ -70,17 +70,17 @@ tinybird/tb/modules/watch.py,sha256=No0bK1M1_3CYuMaIgylxf7vYFJ72lTJe3brz6xQ-mJo,
70
70
  tinybird/tb/modules/workspace.py,sha256=tCP1zZMwBhLRGm22TGfpSd4cHvQLAS1o_azIXv_r6uw,11172
71
71
  tinybird/tb/modules/workspace_members.py,sha256=5JdkJgfuEwbq-t6vxkBhYwgsiTDxF790wsa6Xfif9nk,8608
72
72
  tinybird/tb/modules/agent/__init__.py,sha256=i3oe3vDIWWPaicdCM0zs7D7BJ1W0k7th93ooskHAV00,54
73
- tinybird/tb/modules/agent/agent.py,sha256=uVZ0yGOk4uRtF74mPHIYjawIDPSCweb5HCC7eLVuf2k,37339
73
+ tinybird/tb/modules/agent/agent.py,sha256=BodnCrX5cU8x6RYIwnBSLJ2nsHFTdqJCyB0capBKB0g,37708
74
74
  tinybird/tb/modules/agent/animations.py,sha256=4WOC5_2BracttmMCrV0H91tXfWcUzQHBUaIJc5FA7tE,3490
75
75
  tinybird/tb/modules/agent/banner.py,sha256=l6cO5Fi7lbVKp-GsBP8jf3IkjOWxg2jpAt9NBCy0WR8,4085
76
76
  tinybird/tb/modules/agent/command_agent.py,sha256=0Z08rQsir59zQAr-kkOvsKIFpIBsBSTGJJ1VgqqF5WA,3654
77
77
  tinybird/tb/modules/agent/compactor.py,sha256=BK5AxZFhrp3xWnsRnYaleiYoIWtVNc-_m650Hsopt8g,13841
78
- tinybird/tb/modules/agent/explore_agent.py,sha256=gyD5uV5TJwV24eeQiSwhkgfNPb4mtbeH7t2qSdoc18U,4100
78
+ tinybird/tb/modules/agent/explore_agent.py,sha256=QVMPmX6GDW8bh65_X4yXepvAgJmNRQh1S-YwmvGHkjw,4288
79
79
  tinybird/tb/modules/agent/file_agent.py,sha256=vE8VChVbG_-uyeBtp3I6QrXeNaPaVlVoNn4c9cGTAJA,2466
80
80
  tinybird/tb/modules/agent/memory.py,sha256=vBewB_64L_wHoT4tLT6UX2uxcHwSY880QZ26F9rPqXs,3793
81
- tinybird/tb/modules/agent/mock_agent.py,sha256=zbAZfAqdSLUtMr2VqO0erWpzjT2F1tTcuYjvHb-gvbA,8023
81
+ tinybird/tb/modules/agent/mock_agent.py,sha256=9_w5-MJDC3vp0U5SkM-ucqhxftfpeUM4FPLl5BAr1_0,8200
82
82
  tinybird/tb/modules/agent/models.py,sha256=eokO8XlY-kVJOsbqiVporGUAOCyKAXCO5xgTEK9SM6Y,2208
83
- tinybird/tb/modules/agent/prompts.py,sha256=a8ZnOZCTGRnxa_dlrTSmeaM9snOI3sMx0nwUdv7aVGI,44165
83
+ tinybird/tb/modules/agent/prompts.py,sha256=eua-QawthfG5X6Kz1dRzOZSjXU8tj0nr4k7onmvBZnk,45792
84
84
  tinybird/tb/modules/agent/testing_agent.py,sha256=AtwtJViH7805i7djyBgDb7SSUtDyJnw0TWJu6lBFsrg,2953
85
85
  tinybird/tb/modules/agent/utils.py,sha256=alvRNtpPPRZP0sNdOXbzX3uQZHqqeh1daIAg3aquq24,32015
86
86
  tinybird/tb/modules/agent/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -98,7 +98,7 @@ tinybird/tb/modules/agent/tools/get_openapi_definition.py,sha256=4TIMO2XzHBMhpt9
98
98
  tinybird/tb/modules/agent/tools/mock.py,sha256=Seo4WcYNLL1-SmPXutoaX94_pfOdIb47JXo8dHtUVhg,7106
99
99
  tinybird/tb/modules/agent/tools/plan.py,sha256=uAJEHZ-xXIq-EpURJYV7GUyY7IbIgactw9NWeCsIT9Y,2516
100
100
  tinybird/tb/modules/agent/tools/request_endpoint.py,sha256=bsLWrMn-ofJM3nn9vm8j_U8fdopVd3H5L0ii6ji-Kuw,4359
101
- tinybird/tb/modules/agent/tools/run_command.py,sha256=EOHkyK9nktlt5jVz9sQcSt4CN40LO490FjmAy3CuNmE,1793
101
+ tinybird/tb/modules/agent/tools/run_command.py,sha256=B0jyXQW7d0vSBi7abCTlhmEsf6nvwWcVEbRpGatLFBo,2464
102
102
  tinybird/tb/modules/agent/tools/secret.py,sha256=8AGTZgHLPg1bxCA2cPMnb-zNutWEwn4emHo7kLjJC5w,4323
103
103
  tinybird/tb/modules/agent/tools/test.py,sha256=4XuEWVHLOTSO51Z9xJ08dTjk0j3IWY_JlPtSBO5aaUs,10373
104
104
  tinybird/tb/modules/datafile/build.py,sha256=NFKBrusFLU0WJNCXePAFWiEDuTaXpwc0lHlOQWEJ43s,51117
@@ -121,8 +121,8 @@ tinybird/tb_cli_modules/config.py,sha256=IsgdtFRnUrkY8-Zo32lmk6O7u3bHie1QCxLwgp4
121
121
  tinybird/tb_cli_modules/exceptions.py,sha256=pmucP4kTF4irIt7dXiG-FcnI-o3mvDusPmch1L8RCWk,3367
122
122
  tinybird/tb_cli_modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
123
123
  tinybird/tb_cli_modules/telemetry.py,sha256=Hh2Io8ZPROSunbOLuMvuIFU4TqwWPmQTqal4WS09K1A,10449
124
- tinybird-0.0.1.dev291.dist-info/METADATA,sha256=WCSw6JMv71AZt3gonZC3XeWThiDtGWEynv8GH1jSKhE,1845
125
- tinybird-0.0.1.dev291.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
126
- tinybird-0.0.1.dev291.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
127
- tinybird-0.0.1.dev291.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
128
- tinybird-0.0.1.dev291.dist-info/RECORD,,
124
+ tinybird-0.0.1.dev292.dist-info/METADATA,sha256=d2RNeqvNyqjfXrpEIlGB9lV-Kh2KUu3bD8c99JGeGJQ,1845
125
+ tinybird-0.0.1.dev292.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
126
+ tinybird-0.0.1.dev292.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
127
+ tinybird-0.0.1.dev292.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
128
+ tinybird-0.0.1.dev292.dist-info/RECORD,,