tinybird 0.0.1.dev245__tar.gz → 0.0.1.dev246__tar.gz
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-0.0.1.dev245 → tinybird-0.0.1.dev246}/PKG-INFO +1 -1
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/__cli__.py +2 -2
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/agent/agent.py +63 -20
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/agent/prompts.py +14 -14
- tinybird-0.0.1.dev246/tinybird/tb/modules/agent/tools/build.py +19 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/agent/tools/create_datafile.py +3 -3
- tinybird-0.0.1.dev246/tinybird/tb/modules/agent/tools/deploy.py +45 -0
- tinybird-0.0.1.dev246/tinybird/tb/modules/agent/tools/deploy_check.py +19 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/agent/utils.py +5 -2
- tinybird-0.0.1.dev246/tinybird/tb/modules/deployment.py +360 -0
- tinybird-0.0.1.dev245/tinybird/tb/modules/deployment.py → tinybird-0.0.1.dev246/tinybird/tb/modules/deployment_common.py +5 -324
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/feedback_manager.py +7 -6
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird.egg-info/PKG-INFO +1 -1
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird.egg-info/SOURCES.txt +4 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/setup.cfg +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/__cli__.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/ch_utils/constants.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/ch_utils/engine.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/check_pypi.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/client.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/config.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/connectors.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/context.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/datafile/common.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/datafile/exceptions.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/datafile/parse_connection.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/datafile/parse_datasource.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/datafile/parse_pipe.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/datatypes.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/feedback_manager.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/git_settings.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/prompts.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/sql.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/sql_template.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/sql_template_fmt.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/sql_toolset.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/syncasync.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/check_pypi.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/cli.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/client.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/config.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/agent/__init__.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/agent/animations.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/agent/banner.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/agent/memory.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/agent/models.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/agent/tools/__init__.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/agent/tools/explore.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/agent/tools/plan.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/agent/tools/preview_datafile.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/build.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/build_common.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/cicd.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/cli.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/common.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/config.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/connection.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/copy.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/create.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/datafile/build.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/datafile/build_common.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/datafile/build_datasource.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/datafile/build_pipe.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/datafile/diff.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/datafile/fixture.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/datafile/format_common.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/datafile/format_datasource.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/datafile/format_pipe.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/datafile/pipe_checker.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/datafile/playground.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/datafile/pull.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/datasource.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/deprecations.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/dev_server.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/endpoint.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/exceptions.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/info.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/infra.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/job.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/llm.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/llm_utils.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/local.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/local_common.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/login.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/logout.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/materialization.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/mock.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/open.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/pipe.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/project.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/regions.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/secret.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/secret_common.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/shell.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/sink.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/table.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/telemetry.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/test.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/tinyunit/tinyunit.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/tinyunit/tinyunit_lib.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/token.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/watch.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/workspace.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/workspace_members.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb_cli.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb_cli_modules/auth.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb_cli_modules/branch.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb_cli_modules/cicd.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb_cli_modules/cli.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb_cli_modules/common.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb_cli_modules/config.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb_cli_modules/connection.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb_cli_modules/datasource.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb_cli_modules/exceptions.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb_cli_modules/fmt.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb_cli_modules/job.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb_cli_modules/pipe.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb_cli_modules/regions.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb_cli_modules/tag.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb_cli_modules/telemetry.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb_cli_modules/test.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb_cli_modules/tinyunit/tinyunit.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb_cli_modules/tinyunit/tinyunit_lib.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb_cli_modules/workspace.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb_cli_modules/workspace_members.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tornado_template.py +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird.egg-info/dependency_links.txt +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird.egg-info/entry_points.txt +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird.egg-info/requires.txt +0 -0
- {tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird.egg-info/top_level.txt +0 -0
|
@@ -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.
|
|
8
|
-
__revision__ = '
|
|
7
|
+
__version__ = '0.0.1.dev246'
|
|
8
|
+
__revision__ = '5c11131'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import subprocess
|
|
1
2
|
import sys
|
|
2
|
-
import uuid
|
|
3
3
|
from datetime import datetime
|
|
4
4
|
from functools import partial
|
|
5
5
|
from typing import Any
|
|
@@ -35,12 +35,17 @@ from tinybird.tb.modules.agent.prompts import (
|
|
|
35
35
|
resources_prompt,
|
|
36
36
|
sql_instructions,
|
|
37
37
|
)
|
|
38
|
+
from tinybird.tb.modules.agent.tools.build import build
|
|
38
39
|
from tinybird.tb.modules.agent.tools.create_datafile import create_datafile
|
|
40
|
+
from tinybird.tb.modules.agent.tools.deploy import deploy
|
|
41
|
+
from tinybird.tb.modules.agent.tools.deploy_check import deploy_check
|
|
39
42
|
from tinybird.tb.modules.agent.tools.explore import explore_data
|
|
40
43
|
from tinybird.tb.modules.agent.tools.plan import plan
|
|
41
44
|
from tinybird.tb.modules.agent.tools.preview_datafile import preview_datafile
|
|
42
45
|
from tinybird.tb.modules.agent.utils import TinybirdAgentContext
|
|
43
46
|
from tinybird.tb.modules.build_common import process as build_process
|
|
47
|
+
from tinybird.tb.modules.common import _get_tb_client
|
|
48
|
+
from tinybird.tb.modules.deployment_common import create_deployment
|
|
44
49
|
from tinybird.tb.modules.exceptions import CLIBuildException
|
|
45
50
|
from tinybird.tb.modules.feedback_manager import FeedbackManager
|
|
46
51
|
from tinybird.tb.modules.local_common import get_tinybird_local_client
|
|
@@ -86,7 +91,9 @@ You have access to the following tools:
|
|
|
86
91
|
2. `preview_datafile` - Preview the content of a datafile (datasource, endpoint, materialized, sink, copy, connection).
|
|
87
92
|
3. `create_datafile` - Create a file in the project folder. Confirmation will be asked by the tool before creating the file.
|
|
88
93
|
4. `plan` - Plan the creation or update of resources.
|
|
89
|
-
|
|
94
|
+
5. `build` - Build the project.
|
|
95
|
+
6. `deploy` - Deploy the project to Tinybird Cloud.
|
|
96
|
+
7. `deploy_check` - Check if the project can be deployed to Tinybird Cloud before deploying it.
|
|
90
97
|
|
|
91
98
|
# When creating or updating datafiles:
|
|
92
99
|
1. Use `plan` tool to plan the creation or update of resources.
|
|
@@ -140,6 +147,9 @@ Today is {datetime.now().strftime("%Y-%m-%d")}
|
|
|
140
147
|
Tool(preview_datafile, docstring_format="google", require_parameter_descriptions=True, takes_ctx=False),
|
|
141
148
|
Tool(create_datafile, docstring_format="google", require_parameter_descriptions=True, takes_ctx=True),
|
|
142
149
|
Tool(plan, docstring_format="google", require_parameter_descriptions=True, takes_ctx=True),
|
|
150
|
+
Tool(build, docstring_format="google", require_parameter_descriptions=True, takes_ctx=True),
|
|
151
|
+
Tool(deploy, docstring_format="google", require_parameter_descriptions=True, takes_ctx=True),
|
|
152
|
+
Tool(deploy_check, docstring_format="google", require_parameter_descriptions=True, takes_ctx=True),
|
|
143
153
|
],
|
|
144
154
|
)
|
|
145
155
|
|
|
@@ -147,22 +157,25 @@ Today is {datetime.now().strftime("%Y-%m-%d")}
|
|
|
147
157
|
"""Keep only the last 5 messages to manage token usage."""
|
|
148
158
|
return self.messages[-5:] if len(self.messages) > 5 else self.messages
|
|
149
159
|
|
|
150
|
-
def run(self, user_prompt: str, project: Project) -> None:
|
|
160
|
+
def run(self, user_prompt: str, config: dict[str, Any], project: Project) -> None:
|
|
151
161
|
user_prompt = f"{user_prompt}\n\n# Existing resources in the project:\n{resources_prompt(project)}"
|
|
152
162
|
client = TinyB(token=self.token, host=self.host)
|
|
153
163
|
folder = self.project.folder
|
|
164
|
+
|
|
154
165
|
thinking_animation = ThinkingAnimation(message="Chirping", delay=0.15)
|
|
155
166
|
thinking_animation.start()
|
|
156
|
-
|
|
157
167
|
result = self.agent.run_sync(
|
|
158
168
|
user_prompt,
|
|
159
169
|
deps=TinybirdAgentContext(
|
|
160
170
|
# context does not support the whole client, so we need to pass only the functions we need
|
|
161
171
|
explore_data=client.explore_data,
|
|
162
|
-
build_project=partial(build_project,
|
|
172
|
+
build_project=partial(build_project, project=project, config=config),
|
|
173
|
+
deploy_project=partial(deploy_project, project=project, config=config),
|
|
174
|
+
deploy_check_project=partial(deploy_check_project, project=project, config=config),
|
|
163
175
|
get_project_files=project.get_project_files,
|
|
164
176
|
folder=folder,
|
|
165
177
|
thinking_animation=thinking_animation,
|
|
178
|
+
workspace_name=self.project.workspace_name,
|
|
166
179
|
),
|
|
167
180
|
message_history=self.messages,
|
|
168
181
|
)
|
|
@@ -182,9 +195,11 @@ def run_agent(config: dict[str, Any], project: Project):
|
|
|
182
195
|
host = config["host"]
|
|
183
196
|
agent = TinybirdAgent(token, host, project)
|
|
184
197
|
click.echo()
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
198
|
+
if config.get("token"):
|
|
199
|
+
click.echo(FeedbackManager.info(message="Describe what you want to create and I'll help you build it"))
|
|
200
|
+
click.echo(FeedbackManager.info(message="Run /help for more commands"))
|
|
201
|
+
else:
|
|
202
|
+
click.echo(FeedbackManager.info(message="Run /login to authenticate"))
|
|
188
203
|
click.echo()
|
|
189
204
|
|
|
190
205
|
except Exception as e:
|
|
@@ -207,25 +222,29 @@ def run_agent(config: dict[str, Any], project: Project):
|
|
|
207
222
|
),
|
|
208
223
|
)
|
|
209
224
|
|
|
210
|
-
if user_input.lower() in ["exit", "quit"]:
|
|
225
|
+
if user_input.lower() in ["/exit", "/quit"]:
|
|
211
226
|
click.echo(FeedbackManager.info(message="Goodbye!"))
|
|
212
227
|
break
|
|
213
|
-
elif user_input.lower() == "clear":
|
|
228
|
+
elif user_input.lower() == "/clear":
|
|
214
229
|
clear_history()
|
|
215
230
|
continue
|
|
216
|
-
elif user_input.lower() == "
|
|
231
|
+
elif user_input.lower() == "/login":
|
|
232
|
+
click.echo()
|
|
233
|
+
subprocess.run(["tb", "login"], check=True)
|
|
234
|
+
click.echo()
|
|
235
|
+
continue
|
|
236
|
+
elif user_input.lower() == "/help":
|
|
217
237
|
click.echo()
|
|
218
|
-
click.echo(FeedbackManager.info(message="Tinybird Code Help:"))
|
|
219
238
|
click.echo("• Describe what you want to create: 'Create a user analytics system'")
|
|
220
239
|
click.echo("• Ask for specific resources: 'Create a pipe to aggregate daily clicks'")
|
|
221
|
-
click.echo("•
|
|
222
|
-
click.echo("• Type 'exit' or 'quit' to leave")
|
|
240
|
+
click.echo("• Connect to external services: 'Set up a Kafka connection for events'")
|
|
241
|
+
click.echo("• Type '/exit' or '/quit' to leave")
|
|
223
242
|
click.echo()
|
|
224
243
|
continue
|
|
225
244
|
elif user_input.strip() == "":
|
|
226
245
|
continue
|
|
227
246
|
else:
|
|
228
|
-
agent.run(user_input, project)
|
|
247
|
+
agent.run(user_input, config, project)
|
|
229
248
|
|
|
230
249
|
except KeyboardInterrupt:
|
|
231
250
|
click.echo(FeedbackManager.info(message="Goodbye!"))
|
|
@@ -239,10 +258,34 @@ def run_agent(config: dict[str, Any], project: Project):
|
|
|
239
258
|
sys.exit(1)
|
|
240
259
|
|
|
241
260
|
|
|
242
|
-
def build_project(
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
261
|
+
def build_project(config: dict[str, Any], project: Project, silent: bool = True, test: bool = True) -> None:
|
|
262
|
+
local_client = get_tinybird_local_client(config, test=test, silent=silent)
|
|
263
|
+
build_error = build_process(
|
|
264
|
+
project=project, tb_client=local_client, watch=False, silent=silent, exit_on_error=False
|
|
265
|
+
)
|
|
247
266
|
if build_error:
|
|
248
267
|
raise CLIBuildException(build_error)
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
def deploy_project(config: dict[str, Any], project: Project) -> None:
|
|
271
|
+
client = _get_tb_client(config["token"], config["host"])
|
|
272
|
+
create_deployment(
|
|
273
|
+
project=project,
|
|
274
|
+
client=client,
|
|
275
|
+
config=config,
|
|
276
|
+
wait=True,
|
|
277
|
+
auto=True,
|
|
278
|
+
allow_destructive_operations=False,
|
|
279
|
+
)
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
def deploy_check_project(config: dict[str, Any], project: Project) -> None:
|
|
283
|
+
client = _get_tb_client(config["token"], config["host"])
|
|
284
|
+
create_deployment(
|
|
285
|
+
project=project,
|
|
286
|
+
client=client,
|
|
287
|
+
config=config,
|
|
288
|
+
check=True,
|
|
289
|
+
wait=True,
|
|
290
|
+
auto=True,
|
|
291
|
+
)
|
|
@@ -5,23 +5,23 @@ from tinybird.tb.modules.project import Project
|
|
|
5
5
|
plan_instructions = """
|
|
6
6
|
When asked to create a plan, you MUST respond with this EXACT format and NOTHING ELSE:
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
1.
|
|
12
|
-
2.
|
|
13
|
-
3.
|
|
14
|
-
4.
|
|
15
|
-
5.
|
|
16
|
-
6.
|
|
17
|
-
7.
|
|
8
|
+
Plan description: [One sentence describing what will be built]
|
|
9
|
+
|
|
10
|
+
Steps:
|
|
11
|
+
1. Connection: [name] - [description] - Depends on: none
|
|
12
|
+
2. Datasource: [name] - [description] - Depends on: [connection_name (optional)]
|
|
13
|
+
3. Endpoint: [name] - [description] - Depends on: [resources]
|
|
14
|
+
4. Materialized pipe: [name] - [description] - Depends on: [resources]
|
|
15
|
+
5. Materialized datasource: [name] - [description] - Depends on: [resources]
|
|
16
|
+
6. Sink: [name] - [description] - Depends on: [resources]
|
|
17
|
+
7. Copy: [name] - [description] - Depends on: [resources]
|
|
18
|
+
8. Build project
|
|
18
19
|
|
|
19
20
|
You can skip steps where resources will not be created or updated.
|
|
21
|
+
Always add BUILD_PROJECT step at the end of the plan.
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
RESOURCE_DEPENDENCIES:
|
|
24
|
-
[resource_name]: [resource_name]
|
|
23
|
+
Resource dependencies:
|
|
24
|
+
[resource_name]: [resources]
|
|
25
25
|
"""
|
|
26
26
|
|
|
27
27
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import click
|
|
2
|
+
from pydantic_ai import RunContext
|
|
3
|
+
|
|
4
|
+
from tinybird.tb.modules.agent.utils import TinybirdAgentContext
|
|
5
|
+
from tinybird.tb.modules.feedback_manager import FeedbackManager
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def build(ctx: RunContext[TinybirdAgentContext]) -> str:
|
|
9
|
+
"""Build the project"""
|
|
10
|
+
try:
|
|
11
|
+
ctx.deps.thinking_animation.stop()
|
|
12
|
+
ctx.deps.build_project(test=False, silent=False)
|
|
13
|
+
ctx.deps.thinking_animation.start()
|
|
14
|
+
return "Project built successfully"
|
|
15
|
+
except Exception as e:
|
|
16
|
+
ctx.deps.thinking_animation.stop()
|
|
17
|
+
click.echo(FeedbackManager.error(message=e))
|
|
18
|
+
ctx.deps.thinking_animation.start()
|
|
19
|
+
return f"Error building project: {e}"
|
{tinybird-0.0.1.dev245 → tinybird-0.0.1.dev246}/tinybird/tb/modules/agent/tools/create_datafile.py
RENAMED
|
@@ -44,17 +44,17 @@ def create_datafile(ctx: RunContext[TinybirdAgentContext], resource: Datafile) -
|
|
|
44
44
|
path = Path(ctx.deps.folder) / resource.pathname
|
|
45
45
|
exists = str(path) in ctx.deps.get_project_files()
|
|
46
46
|
confirmation = get_resource_confirmation(resource, exists)
|
|
47
|
-
ctx.deps.thinking_animation.start()
|
|
48
47
|
|
|
49
48
|
if not confirmation:
|
|
49
|
+
ctx.deps.thinking_animation.start()
|
|
50
50
|
return f"Resource {resource.pathname} was not created. User cancelled creation."
|
|
51
51
|
|
|
52
52
|
folder_path = path.parent
|
|
53
53
|
folder_path.mkdir(parents=True, exist_ok=True)
|
|
54
54
|
path.touch(exist_ok=True)
|
|
55
|
-
|
|
56
55
|
path.write_text(resource.content)
|
|
57
|
-
ctx.deps.build_project()
|
|
56
|
+
ctx.deps.build_project(test=True, silent=True)
|
|
57
|
+
ctx.deps.thinking_animation.start()
|
|
58
58
|
return f"Created {resource.pathname}"
|
|
59
59
|
|
|
60
60
|
except CLIBuildException as e:
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import click
|
|
2
|
+
from pydantic_ai import RunContext
|
|
3
|
+
|
|
4
|
+
from tinybird.tb.modules.agent.utils import TinybirdAgentContext, show_options
|
|
5
|
+
from tinybird.tb.modules.feedback_manager import FeedbackManager
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def get_deploy_confirmation() -> bool:
|
|
9
|
+
"""Get user confirmation for deploying the project"""
|
|
10
|
+
while True:
|
|
11
|
+
result = show_options(
|
|
12
|
+
options=["Yes, deploy the project", "No, and tell Tinybird Code what to do"],
|
|
13
|
+
title="Do you want to deploy the project?",
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
if result is None: # Cancelled
|
|
17
|
+
return False
|
|
18
|
+
|
|
19
|
+
if result.startswith("Yes"):
|
|
20
|
+
return True
|
|
21
|
+
elif result.startswith("No"):
|
|
22
|
+
return False
|
|
23
|
+
|
|
24
|
+
return False
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def deploy(ctx: RunContext[TinybirdAgentContext]) -> str:
|
|
28
|
+
"""Deploy the project"""
|
|
29
|
+
try:
|
|
30
|
+
ctx.deps.thinking_animation.stop()
|
|
31
|
+
confirmation = get_deploy_confirmation()
|
|
32
|
+
ctx.deps.thinking_animation.start()
|
|
33
|
+
|
|
34
|
+
if not confirmation:
|
|
35
|
+
return "User cancelled deployment."
|
|
36
|
+
|
|
37
|
+
ctx.deps.thinking_animation.stop()
|
|
38
|
+
ctx.deps.deploy_project()
|
|
39
|
+
ctx.deps.thinking_animation.start()
|
|
40
|
+
return "Project deployed successfully"
|
|
41
|
+
except Exception as e:
|
|
42
|
+
ctx.deps.thinking_animation.stop()
|
|
43
|
+
click.echo(FeedbackManager.error(message=e))
|
|
44
|
+
ctx.deps.thinking_animation.start()
|
|
45
|
+
return f"Error depoying project: {e}"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import click
|
|
2
|
+
from pydantic_ai import RunContext
|
|
3
|
+
|
|
4
|
+
from tinybird.tb.modules.agent.utils import TinybirdAgentContext
|
|
5
|
+
from tinybird.tb.modules.feedback_manager import FeedbackManager
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def deploy_check(ctx: RunContext[TinybirdAgentContext]) -> str:
|
|
9
|
+
"""Check that project can be deployed"""
|
|
10
|
+
try:
|
|
11
|
+
ctx.deps.thinking_animation.stop()
|
|
12
|
+
ctx.deps.deploy_check_project()
|
|
13
|
+
ctx.deps.thinking_animation.start()
|
|
14
|
+
return "Project can be deployed"
|
|
15
|
+
except Exception as e:
|
|
16
|
+
ctx.deps.thinking_animation.stop()
|
|
17
|
+
click.echo(FeedbackManager.error(message=e))
|
|
18
|
+
ctx.deps.thinking_animation.start()
|
|
19
|
+
return f"Project cannot be deployed: {e}"
|
|
@@ -18,11 +18,14 @@ from pydantic import BaseModel, Field
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
class TinybirdAgentContext(BaseModel):
|
|
21
|
-
explore_data: Callable[[str], str]
|
|
22
21
|
folder: str
|
|
23
|
-
|
|
22
|
+
workspace_name: str
|
|
24
23
|
thinking_animation: Any
|
|
25
24
|
get_project_files: Callable[[], List[str]]
|
|
25
|
+
explore_data: Callable[[str], str]
|
|
26
|
+
build_project: Callable[..., None]
|
|
27
|
+
deploy_project: Callable[[], None]
|
|
28
|
+
deploy_check_project: Callable[[], None]
|
|
26
29
|
|
|
27
30
|
|
|
28
31
|
default_style = Style.from_dict(
|