tinybird 0.0.1.dev27__py3-none-any.whl → 0.0.1.dev28__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/prompts.py +47 -44
- tinybird/tb/__cli__.py +2 -2
- tinybird/tb/modules/create.py +75 -69
- tinybird/tb/modules/deploy.py +96 -2
- tinybird/tb/modules/mock.py +1 -0
- {tinybird-0.0.1.dev27.dist-info → tinybird-0.0.1.dev28.dist-info}/METADATA +1 -1
- {tinybird-0.0.1.dev27.dist-info → tinybird-0.0.1.dev28.dist-info}/RECORD +10 -10
- {tinybird-0.0.1.dev27.dist-info → tinybird-0.0.1.dev28.dist-info}/WHEEL +0 -0
- {tinybird-0.0.1.dev27.dist-info → tinybird-0.0.1.dev28.dist-info}/entry_points.txt +0 -0
- {tinybird-0.0.1.dev27.dist-info → tinybird-0.0.1.dev28.dist-info}/top_level.txt +0 -0
tinybird/prompts.py
CHANGED
|
@@ -627,10 +627,27 @@ You are a Tinybird expert. You will be given a prompt to generate Tinybird resou
|
|
|
627
627
|
<existing_resources>
|
|
628
628
|
{existing_resources}
|
|
629
629
|
</existing_resources>
|
|
630
|
-
<
|
|
630
|
+
<datasource_file_instructions>
|
|
631
631
|
- The datasource names must be unique.
|
|
632
|
+
- No indentation is allowed for property names: DESCRIPTION, SCHEMA, ENGINE, ENGINE_PARTITION_KEY, ENGINE_SORTING_KEY, etc.
|
|
633
|
+
</datasource_file_instructions>
|
|
634
|
+
<pipe_file_instructions>
|
|
632
635
|
- The pipe names must be unique.
|
|
633
|
-
-
|
|
636
|
+
- Nodes do NOT use the same name as the Pipe they belong to. So if the pipe name is "my_pipe", the nodes must be named different like "my_pipe_node_1", "my_pipe_node_2", etc.
|
|
637
|
+
- Nodes can't have the same exact name as the Pipe they belong to.
|
|
638
|
+
- Avoid more than one node per pipe unless it is really necessary or requested by the user.
|
|
639
|
+
- No indentation is allowed for property names: DESCRIPTION, NODE, SQL, TYPE, etc.
|
|
640
|
+
- Endpoints can export Prometehus format, Node sql must have name two columns:
|
|
641
|
+
- name (String): The name of the metric
|
|
642
|
+
- value (Number): The numeric value for the metric.
|
|
643
|
+
- and then some optional columns:
|
|
644
|
+
- help (String): A description of the metric.
|
|
645
|
+
- timestamp (Number): A Unix timestamp for the metric.
|
|
646
|
+
- type (String): Defines the metric type (counter, gauge, histogram, summary, untyped, or empty).
|
|
647
|
+
- labels (Map(String, String)): A set of key-value pairs providing metric dimensions.
|
|
648
|
+
- Use prometheus format when you are asked to monitor something
|
|
649
|
+
</pipe_file_instructions>
|
|
650
|
+
<sql_instructions>
|
|
634
651
|
- The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).
|
|
635
652
|
- SQL queries with parameters must start with "%" character and a newline on top of every query to be able to use the parameters. Examples:
|
|
636
653
|
<invalid_query_with_parameters_no_%_on_top>
|
|
@@ -658,45 +675,24 @@ You are a Tinybird expert. You will be given a prompt to generate Tinybird resou
|
|
|
658
675
|
AND {{{{DateTime(end_date)}}}}
|
|
659
676
|
{{%end%}}
|
|
660
677
|
</valid_condition_without_now>
|
|
661
|
-
- Nodes can't have the same exact name as the Pipe they belong to.
|
|
662
|
-
- Endpoints can export Prometehus format, Node sql must have name two columns:
|
|
663
|
-
name (String): The name of the metric
|
|
664
|
-
value (Number): The numeric value for the metric.
|
|
665
|
-
and then some optional columns:
|
|
666
|
-
help (String): A description of the metric.
|
|
667
|
-
timestamp (Number): A Unix timestamp for the metric.
|
|
668
|
-
type (String): Defines the metric type (counter, gauge, histogram, summary, untyped, or empty).
|
|
669
|
-
labels (Map(String, String)): A set of key-value pairs providing metric dimensions.
|
|
670
|
-
- Use prometheus format when you are asked to monitor something
|
|
671
|
-
- Nodes do NOT use the same name as the Pipe they belong to. So if the pipe name is "my_pipe", the nodes must be named "my_pipe_node_1", "my_pipe_node_2", etc.
|
|
672
|
-
- If you use some sql function, use just Clickhouse and Tinybird compatible functions.
|
|
673
|
-
- Definition settings does not have indentation.
|
|
674
|
-
</instructions>
|
|
675
|
-
<sql_instructions>
|
|
676
678
|
- Use datasource names as table names when doing SELECT statements.
|
|
679
|
+
- Do not use pipe names as table names.
|
|
680
|
+
- The available datasource names to use in the SQL are the ones present in the existing_resources section or the ones you will create.
|
|
677
681
|
- Use node names as table names only when nodes are present in the same file.
|
|
678
682
|
- Do not reference the current node name in the SQL.
|
|
679
683
|
- SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.
|
|
684
|
+
- Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.
|
|
685
|
+
- Use ONLY SELECT statements in the SQL section.
|
|
686
|
+
- INSERT INTO is not supported in SQL section.
|
|
680
687
|
- General functions supported are: {general_functions}
|
|
681
688
|
- Character insensitive functions supported are: {general_functions_insensitive}
|
|
682
689
|
- Aggregate functions supported are: {aggregate_functions}
|
|
683
690
|
- Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.
|
|
684
691
|
- If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.
|
|
685
692
|
- When aliasing a column, use first the column name and then the alias.
|
|
693
|
+
- General functions and aggregate functions are case sensitive.
|
|
694
|
+
- Character insensitive functions are case insensitive.
|
|
686
695
|
</sql_instructions>
|
|
687
|
-
<datasource_file_instructions>
|
|
688
|
-
- No indentation is allowed for property names: DESCRIPTION, SCHEMA, ENGINE, ENGINE_PARTITION_KEY, ENGINE_SORTING_KEY, etc.
|
|
689
|
-
<datasource_file_instructions>
|
|
690
|
-
<pipe_file_instructions>
|
|
691
|
-
- No indentation is allowed for property names: DESCRIPTION, NODE, SQL, TYPE, etc.
|
|
692
|
-
<pipe_file_instructions>
|
|
693
|
-
<response>
|
|
694
|
-
<resource>
|
|
695
|
-
<type>[datasource or pipe]</type>
|
|
696
|
-
<name>[resource name here]</name>
|
|
697
|
-
<content>[resource content here]</content>
|
|
698
|
-
</resource>
|
|
699
|
-
</response>
|
|
700
696
|
|
|
701
697
|
<datasource_content>
|
|
702
698
|
DESCRIPTION >
|
|
@@ -713,19 +709,25 @@ ENGINE_PARTITION_KEY "partition_key"
|
|
|
713
709
|
ENGINE_SORTING_KEY "sorting_key_1, sorting_key_2, ..."
|
|
714
710
|
</datasource_content>
|
|
715
711
|
<pipe_content>
|
|
716
|
-
|
|
717
|
-
|
|
712
|
+
DESCRIPTION >
|
|
713
|
+
Some meaningful description of the pipe
|
|
718
714
|
|
|
719
715
|
NODE node_1
|
|
720
716
|
SQL >
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
...
|
|
717
|
+
[sql query using clickhouse syntax and tinybird templating syntax and starting always with SELECT or %\nSELECT]
|
|
724
718
|
|
|
725
|
-
NODE node_n
|
|
726
|
-
SQL >
|
|
727
|
-
sql_query_using_clickhouse_syntax_and_tinybird_templating_syntax
|
|
728
719
|
</pipe_content>
|
|
720
|
+
|
|
721
|
+
Use the following format to generate the response and do not wrap it in any other text, including the <response> tag.
|
|
722
|
+
|
|
723
|
+
<response>
|
|
724
|
+
<resource>
|
|
725
|
+
<type>[datasource or pipe]</type>
|
|
726
|
+
<name>[resource name here]</name>
|
|
727
|
+
<content>[resource content here]</content>
|
|
728
|
+
</resource>
|
|
729
|
+
</response>
|
|
730
|
+
|
|
729
731
|
""".format(
|
|
730
732
|
existing_resources=existing_resources,
|
|
731
733
|
general_functions=general_functions,
|
|
@@ -741,7 +743,7 @@ Given the schema for a Tinybird datasource, return a can you create a clickhouse
|
|
|
741
743
|
Response format MUST be just a valid clickhouse sql query.
|
|
742
744
|
|
|
743
745
|
<example>
|
|
744
|
-
<
|
|
746
|
+
<example_datasource_schema>
|
|
745
747
|
SCHEMA >
|
|
746
748
|
experience_gained Int16 `json:$.experience_gained`,
|
|
747
749
|
level Int16 `json:$.level`,
|
|
@@ -750,7 +752,7 @@ SCHEMA >
|
|
|
750
752
|
pvp_kills Int16 `json:$.pvp_kills`,
|
|
751
753
|
quest_completions Int16 `json:$.quest_completions`,
|
|
752
754
|
timestamp DateTime `json:$.timestamp`
|
|
753
|
-
</
|
|
755
|
+
</example_datasource_schema>
|
|
754
756
|
<example_output>
|
|
755
757
|
|
|
756
758
|
SELECT
|
|
@@ -770,8 +772,8 @@ FROM numbers({rows})
|
|
|
770
772
|
- The query MUST return a valid clickhouse sql query.
|
|
771
773
|
- The query MUST return a sample of EXACTLY {rows} rows.
|
|
772
774
|
- The query MUST be valid for clickhouse and Tinybird.
|
|
773
|
-
-
|
|
774
|
-
- Do NOT include ```clickhouse or ```sql or any other wrapping text.
|
|
775
|
+
- FROM numbers({rows}) part is mandatory.
|
|
776
|
+
- Do NOT include ```clickhouse or ```sql or any other wrapping text to the sql query.
|
|
775
777
|
- Do NOT use any of these functions: elementAt
|
|
776
778
|
- Do NOT add a semicolon at the end of the query
|
|
777
779
|
- Do NOT add any FORMAT at the end of the query, because it will be added later by Tinybird.
|
|
@@ -870,8 +872,9 @@ FROM
|
|
|
870
872
|
FROM numbers(ROWS)
|
|
871
873
|
)
|
|
872
874
|
</more_examples>
|
|
873
|
-
|
|
875
|
+
|
|
876
|
+
Follow the instructions and generate the following response with no additional text in the following format:
|
|
874
877
|
<response>
|
|
875
|
-
<sql>[sql query here]</sql>
|
|
878
|
+
<sql>[raw sql query here]</sql>
|
|
876
879
|
</response>
|
|
877
880
|
"""
|
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.
|
|
8
|
-
__revision__ = '
|
|
7
|
+
__version__ = '0.0.1.dev28'
|
|
8
|
+
__revision__ = 'bf7042d'
|
tinybird/tb/modules/create.py
CHANGED
|
@@ -77,15 +77,16 @@ async def create(
|
|
|
77
77
|
click.echo(FeedbackManager.success(message="✓ Scaffolding completed!\n"))
|
|
78
78
|
|
|
79
79
|
click.echo(FeedbackManager.highlight(message="\n» Creating resources..."))
|
|
80
|
-
await create_resources(local_client, tb_client, user_token, data, prompt, folder)
|
|
80
|
+
datasources_created = await create_resources(local_client, tb_client, user_token, data, prompt, folder)
|
|
81
81
|
click.echo(FeedbackManager.success(message="✓ Done!\n"))
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
if not already_has_cicd(folder):
|
|
84
|
+
click.echo(FeedbackManager.highlight(message="\n» Creating CI/CD files for GitHub and GitLab..."))
|
|
85
|
+
init_git(folder)
|
|
86
|
+
await init_cicd(data_project_dir=os.path.relpath(folder))
|
|
87
|
+
click.echo(FeedbackManager.success(message="✓ Done!\n"))
|
|
87
88
|
|
|
88
|
-
if validate_fixtures(folder):
|
|
89
|
+
if validate_fixtures(folder) and datasources_created:
|
|
89
90
|
click.echo(FeedbackManager.highlight(message="\n» Generating fixtures..."))
|
|
90
91
|
|
|
91
92
|
if data:
|
|
@@ -106,8 +107,10 @@ async def create(
|
|
|
106
107
|
datasource_content = datasource_path.read_text()
|
|
107
108
|
has_json_path = "`json:" in datasource_content
|
|
108
109
|
if has_json_path:
|
|
110
|
+
prompt = f"<datasource_schema>{datasource_content}</datasource_schema>\n<user_input>{prompt}</user_input>"
|
|
109
111
|
response = await llm.ask(prompt, system_prompt=mock_prompt(rows))
|
|
110
112
|
sql = extract_xml(response, "sql")
|
|
113
|
+
sql = sql.split("FORMAT")[0]
|
|
111
114
|
result = await local_client.query(f"{sql} FORMAT JSON")
|
|
112
115
|
data = result.get("data", [])
|
|
113
116
|
fixture_name = build_fixture_name(
|
|
@@ -130,7 +133,13 @@ def validate_project_structure(folder: str) -> bool:
|
|
|
130
133
|
|
|
131
134
|
|
|
132
135
|
def validate_fixtures(folder: str) -> bool:
|
|
133
|
-
|
|
136
|
+
datasource_files = [f for f in os.listdir(Path(folder) / "datasources") if f.endswith(".datasource")]
|
|
137
|
+
return len(datasource_files) > 0
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def already_has_cicd(folder: str) -> bool:
|
|
141
|
+
ci_cd_paths = (".gitlab", ".github")
|
|
142
|
+
return any((Path(folder) / path).exists() for path in ci_cd_paths)
|
|
134
143
|
|
|
135
144
|
|
|
136
145
|
def create_project_structure(folder: str):
|
|
@@ -157,10 +166,7 @@ async def create_resources(
|
|
|
157
166
|
if data:
|
|
158
167
|
path = folder_path / data
|
|
159
168
|
format = path.suffix.lstrip(".")
|
|
160
|
-
|
|
161
|
-
await _generate_datafile(str(path), local_client, format=format, force=force)
|
|
162
|
-
except Exception as e:
|
|
163
|
-
click.echo(FeedbackManager.error(message=f"Error: {str(e)}"))
|
|
169
|
+
await _generate_datafile(str(path), local_client, format=format, force=force)
|
|
164
170
|
name = data.split(".")[0]
|
|
165
171
|
generate_pipe_file(
|
|
166
172
|
f"{name}_endpoint",
|
|
@@ -172,68 +178,68 @@ TYPE ENDPOINT
|
|
|
172
178
|
""",
|
|
173
179
|
folder,
|
|
174
180
|
)
|
|
181
|
+
return True
|
|
175
182
|
elif prompt and user_token:
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
for pipe in pipes_paths
|
|
198
|
-
]
|
|
183
|
+
datasource_paths = [
|
|
184
|
+
Path(folder) / "datasources" / f
|
|
185
|
+
for f in os.listdir(Path(folder) / "datasources")
|
|
186
|
+
if f.endswith(".datasource")
|
|
187
|
+
]
|
|
188
|
+
pipes_paths = [
|
|
189
|
+
Path(folder) / "endpoints" / f for f in os.listdir(Path(folder) / "endpoints") if f.endswith(".pipe")
|
|
190
|
+
]
|
|
191
|
+
resources_xml = "\n".join(
|
|
192
|
+
[
|
|
193
|
+
f"<resource><type>{resource_type}</type><name>{resource_name}</name><content>{resource_content}</content></resource>"
|
|
194
|
+
for resource_type, resource_name, resource_content in [
|
|
195
|
+
("datasource", ds.stem, ds.read_text()) for ds in datasource_paths
|
|
196
|
+
]
|
|
197
|
+
+ [
|
|
198
|
+
(
|
|
199
|
+
"pipe",
|
|
200
|
+
pipe.stem,
|
|
201
|
+
pipe.read_text(),
|
|
202
|
+
)
|
|
203
|
+
for pipe in pipes_paths
|
|
199
204
|
]
|
|
205
|
+
]
|
|
206
|
+
)
|
|
207
|
+
llm = LLM(user_token=user_token, client=tb_client)
|
|
208
|
+
result = await llm.ask(prompt, system_prompt=create_prompt(resources_xml))
|
|
209
|
+
result = extract_xml(result, "response")
|
|
210
|
+
resources = parse_xml(result, "resource")
|
|
211
|
+
datasources = []
|
|
212
|
+
pipes = []
|
|
213
|
+
for resource_xml in resources:
|
|
214
|
+
resource_type = extract_xml(resource_xml, "type")
|
|
215
|
+
name = extract_xml(resource_xml, "name")
|
|
216
|
+
content = extract_xml(resource_xml, "content")
|
|
217
|
+
resource = {
|
|
218
|
+
"name": name,
|
|
219
|
+
"content": content,
|
|
220
|
+
}
|
|
221
|
+
if resource_type.lower() == "datasource":
|
|
222
|
+
datasources.append(resource)
|
|
223
|
+
elif resource_type.lower() == "pipe":
|
|
224
|
+
pipes.append(resource)
|
|
225
|
+
|
|
226
|
+
for ds in datasources:
|
|
227
|
+
content = ds["content"].replace("```", "")
|
|
228
|
+
filename = f"{ds['name']}.datasource"
|
|
229
|
+
generate_datafile(
|
|
230
|
+
content,
|
|
231
|
+
filename=filename,
|
|
232
|
+
data=None,
|
|
233
|
+
_format="ndjson",
|
|
234
|
+
force=force,
|
|
235
|
+
folder=folder,
|
|
200
236
|
)
|
|
201
|
-
llm = LLM(user_token=user_token, client=tb_client)
|
|
202
|
-
result = await llm.ask(prompt, system_prompt=create_prompt(resources_xml))
|
|
203
|
-
result = extract_xml(result, "response")
|
|
204
|
-
resources = parse_xml(result, "resource")
|
|
205
|
-
datasources = []
|
|
206
|
-
pipes = []
|
|
207
|
-
for resource_xml in resources:
|
|
208
|
-
resource_type = extract_xml(resource_xml, "type")
|
|
209
|
-
name = extract_xml(resource_xml, "name")
|
|
210
|
-
content = extract_xml(resource_xml, "content")
|
|
211
|
-
resource = {
|
|
212
|
-
"name": name,
|
|
213
|
-
"content": content,
|
|
214
|
-
}
|
|
215
|
-
if resource_type.lower() == "datasource":
|
|
216
|
-
datasources.append(resource)
|
|
217
|
-
elif resource_type.lower() == "pipe":
|
|
218
|
-
pipes.append(resource)
|
|
219
|
-
|
|
220
|
-
for ds in datasources:
|
|
221
|
-
content = ds["content"].replace("```", "")
|
|
222
|
-
filename = f"{ds['name']}.datasource"
|
|
223
|
-
generate_datafile(
|
|
224
|
-
content,
|
|
225
|
-
filename=filename,
|
|
226
|
-
data=None,
|
|
227
|
-
_format="ndjson",
|
|
228
|
-
force=force,
|
|
229
|
-
folder=folder,
|
|
230
|
-
)
|
|
231
237
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
238
|
+
for pipe in pipes:
|
|
239
|
+
content = pipe["content"].replace("```", "")
|
|
240
|
+
generate_pipe_file(pipe["name"], content, folder)
|
|
241
|
+
|
|
242
|
+
return len(datasources) > 0
|
|
237
243
|
|
|
238
244
|
|
|
239
245
|
def init_git(folder: str):
|
tinybird/tb/modules/deploy.py
CHANGED
|
@@ -9,6 +9,7 @@ import click
|
|
|
9
9
|
import requests
|
|
10
10
|
|
|
11
11
|
from tinybird.tb.modules.cli import cli
|
|
12
|
+
from tinybird.tb.modules.common import echo_safe_humanfriendly_tables_format_smart_table
|
|
12
13
|
from tinybird.tb.modules.config import CLIConfig
|
|
13
14
|
from tinybird.tb.modules.feedback_manager import FeedbackManager
|
|
14
15
|
|
|
@@ -34,6 +35,10 @@ def promote_deployment(host: str, headers: dict) -> None:
|
|
|
34
35
|
click.echo(FeedbackManager.error(message="No deployments found"))
|
|
35
36
|
return
|
|
36
37
|
|
|
38
|
+
if len(deployments) < 2:
|
|
39
|
+
click.echo(FeedbackManager.error(message="Only one deployment found"))
|
|
40
|
+
return
|
|
41
|
+
|
|
37
42
|
last_deployment, candidate_deployment = deployments[0], deployments[1]
|
|
38
43
|
|
|
39
44
|
if candidate_deployment.get("status") != "data_ready":
|
|
@@ -60,6 +65,47 @@ def promote_deployment(host: str, headers: dict) -> None:
|
|
|
60
65
|
click.echo(FeedbackManager.success(message="Deployment promoted successfully"))
|
|
61
66
|
|
|
62
67
|
|
|
68
|
+
def rollback_deployment(host: str, headers: dict) -> None:
|
|
69
|
+
TINYBIRD_API_URL = host + "/v1/deployments"
|
|
70
|
+
r = requests.get(TINYBIRD_API_URL, headers=headers)
|
|
71
|
+
result = r.json()
|
|
72
|
+
logging.debug(json.dumps(result, indent=2))
|
|
73
|
+
|
|
74
|
+
deployments = result.get("deployments")
|
|
75
|
+
if not deployments:
|
|
76
|
+
click.echo(FeedbackManager.error(message="No deployments found"))
|
|
77
|
+
return
|
|
78
|
+
|
|
79
|
+
if len(deployments) < 2:
|
|
80
|
+
click.echo(FeedbackManager.error(message="Only one deployment found"))
|
|
81
|
+
return
|
|
82
|
+
|
|
83
|
+
previous_deployment, current_deployment = deployments[0], deployments[1]
|
|
84
|
+
|
|
85
|
+
if previous_deployment.get("status") != "data_ready":
|
|
86
|
+
click.echo(FeedbackManager.error(message="Previous deployment is not ready"))
|
|
87
|
+
return
|
|
88
|
+
|
|
89
|
+
if previous_deployment.get("live"):
|
|
90
|
+
click.echo(FeedbackManager.error(message="Previous deployment is already live"))
|
|
91
|
+
else:
|
|
92
|
+
click.echo(FeedbackManager.success(message="Promoting previous deployment"))
|
|
93
|
+
|
|
94
|
+
TINYBIRD_API_URL = host + f"/v1/deployments/{previous_deployment.get('id')}/set-live"
|
|
95
|
+
r = requests.post(TINYBIRD_API_URL, headers=headers)
|
|
96
|
+
result = r.json()
|
|
97
|
+
logging.debug(json.dumps(result, indent=2))
|
|
98
|
+
|
|
99
|
+
click.echo(FeedbackManager.success(message="Removing current deployment"))
|
|
100
|
+
|
|
101
|
+
TINYBIRD_API_URL = host + f"/v1/deployments/{current_deployment.get('id')}"
|
|
102
|
+
r = requests.delete(TINYBIRD_API_URL, headers=headers)
|
|
103
|
+
result = r.json()
|
|
104
|
+
logging.debug(json.dumps(result, indent=2))
|
|
105
|
+
|
|
106
|
+
click.echo(FeedbackManager.success(message="Deployment rolled back successfully"))
|
|
107
|
+
|
|
108
|
+
|
|
63
109
|
@cli.command()
|
|
64
110
|
@click.argument("project_path", type=click.Path(exists=True), default=Path.cwd())
|
|
65
111
|
@click.option(
|
|
@@ -146,9 +192,43 @@ def deploy(project_path: Path, wait: bool, auto: bool) -> None:
|
|
|
146
192
|
promote_deployment((config.get_host() or ""), HEADERS)
|
|
147
193
|
|
|
148
194
|
|
|
149
|
-
@cli.
|
|
195
|
+
@cli.group(name="releases")
|
|
196
|
+
def releases_group() -> None:
|
|
197
|
+
"""
|
|
198
|
+
Release commands.
|
|
199
|
+
"""
|
|
200
|
+
pass
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
@releases_group.command(name="list")
|
|
150
204
|
@click.argument("project_path", type=click.Path(exists=True), default=Path.cwd())
|
|
151
|
-
def
|
|
205
|
+
def release_list(project_path: Path) -> None:
|
|
206
|
+
"""
|
|
207
|
+
List all the releases you have in the project.
|
|
208
|
+
"""
|
|
209
|
+
config = CLIConfig.get_project_config(str(project_path))
|
|
210
|
+
|
|
211
|
+
TINYBIRD_API_KEY = config.get_token()
|
|
212
|
+
HEADERS = {"Authorization": f"Bearer {TINYBIRD_API_KEY}"}
|
|
213
|
+
TINYBIRD_API_URL = (config.get_host() or "") + "/v1/deployments"
|
|
214
|
+
|
|
215
|
+
r = requests.get(TINYBIRD_API_URL, headers=HEADERS)
|
|
216
|
+
result = r.json()
|
|
217
|
+
logging.debug(json.dumps(result, indent=2))
|
|
218
|
+
|
|
219
|
+
columns = ["id", "status", "created_at", "live"]
|
|
220
|
+
table = []
|
|
221
|
+
for deployment in result.get("deployments"):
|
|
222
|
+
table.append(
|
|
223
|
+
[deployment.get("id"), deployment.get("status"), deployment.get("created_at"), deployment.get("live")]
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
echo_safe_humanfriendly_tables_format_smart_table(table, column_names=columns)
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
@releases_group.command(name="promote")
|
|
230
|
+
@click.argument("project_path", type=click.Path(exists=True), default=Path.cwd())
|
|
231
|
+
def release_promote(project_path: Path) -> None:
|
|
152
232
|
"""
|
|
153
233
|
Promote last deploy to ready and remove old one.
|
|
154
234
|
"""
|
|
@@ -158,3 +238,17 @@ def deploy_promote(project_path: Path) -> None:
|
|
|
158
238
|
HEADERS = {"Authorization": f"Bearer {TINYBIRD_API_KEY}"}
|
|
159
239
|
|
|
160
240
|
promote_deployment((config.get_host() or ""), HEADERS)
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
@releases_group.command(name="rollback")
|
|
244
|
+
@click.argument("project_path", type=click.Path(exists=True), default=Path.cwd())
|
|
245
|
+
def release_rollback(project_path: Path) -> None:
|
|
246
|
+
"""
|
|
247
|
+
Rollback to the previous release.
|
|
248
|
+
"""
|
|
249
|
+
config = CLIConfig.get_project_config(str(project_path))
|
|
250
|
+
|
|
251
|
+
TINYBIRD_API_KEY = config.get_token()
|
|
252
|
+
HEADERS = {"Authorization": f"Bearer {TINYBIRD_API_KEY}"}
|
|
253
|
+
|
|
254
|
+
rollback_deployment((config.get_host() or ""), HEADERS)
|
tinybird/tb/modules/mock.py
CHANGED
|
@@ -65,6 +65,7 @@ async def mock(datasource: str, rows: int, prompt: str, folder: str) -> None:
|
|
|
65
65
|
user_client.token = user_token
|
|
66
66
|
llm = LLM(user_token=user_token, client=user_client)
|
|
67
67
|
tb_client = await get_tinybird_local_client(os.path.abspath(folder))
|
|
68
|
+
prompt = f"<datasource_schema>{datasource_content}</datasource_schema>\n<user_input>{prompt}</user_input>"
|
|
68
69
|
response = await llm.ask(prompt, system_prompt=mock_prompt(rows))
|
|
69
70
|
sql = extract_xml(response, "sql")
|
|
70
71
|
if os.environ.get("TB_DEBUG", "") != "":
|
|
@@ -6,7 +6,7 @@ tinybird/context.py,sha256=kutUQ0kCwparowI74_YLXx6wtTzGLRouJ6oGHVBPzBo,1291
|
|
|
6
6
|
tinybird/datatypes.py,sha256=XNypumfqNjsvLJ5iNXnbVHRvAJe0aQwI3lS6Cxox-e0,10979
|
|
7
7
|
tinybird/feedback_manager.py,sha256=cNUbt0Jxim02UiIdlyP12DJfXfFFzxDCfJK9XRWZ9A0,67488
|
|
8
8
|
tinybird/git_settings.py,sha256=Sw_8rGmribEFJ4Z_6idrVytxpFYk7ez8ei0qHULzs3E,3934
|
|
9
|
-
tinybird/prompts.py,sha256=
|
|
9
|
+
tinybird/prompts.py,sha256=ZZ13gs6FzRr-oQ3W0kkZG5PAYd3HI7iJQ3WMqxIaMv8,28580
|
|
10
10
|
tinybird/sql.py,sha256=eulpRe05ZFrKFrxYawgxDxxrktFE8uL6hSL1gHIWKyg,46166
|
|
11
11
|
tinybird/sql_template.py,sha256=IqYRfUxDYBCoOYjqqvn--_8QXLv9FSRnJ0bInx7q1Xs,93051
|
|
12
12
|
tinybird/sql_template_fmt.py,sha256=1z-PuqSZXtzso8Z_mPqUc-NxIxUrNUcVIPezNieZk-M,10196
|
|
@@ -15,7 +15,7 @@ tinybird/syncasync.py,sha256=IPnOx6lMbf9SNddN1eBtssg8vCLHMt76SuZ6YNYm-Yk,27761
|
|
|
15
15
|
tinybird/tornado_template.py,sha256=oflXyoL2LSCegvl6bAzqw2JIqRaN5WPjhYYDtQcfuOE,41869
|
|
16
16
|
tinybird/ch_utils/constants.py,sha256=aYvg2C_WxYWsnqPdZB1ZFoIr8ZY-XjUXYyHKE9Ansj0,3890
|
|
17
17
|
tinybird/ch_utils/engine.py,sha256=OXkBhlzGjZotjD0vaT-rFIbSGV4tpiHxE8qO_ip0SyQ,40454
|
|
18
|
-
tinybird/tb/__cli__.py,sha256=
|
|
18
|
+
tinybird/tb/__cli__.py,sha256=oSnwZedLkWynsHicPpwRFJasCfsEVp6i_ZEM1_xCwYs,251
|
|
19
19
|
tinybird/tb/cli.py,sha256=D5Xs9RPbBY6U6lXTtzRSWNs2pG6uSzax-cfoKMpO7Jg,889
|
|
20
20
|
tinybird/tb/modules/auth.py,sha256=EzRWFmwRkXNhUmRaruEVFLdkbUg8xMSix0cAWl5D4Jg,9029
|
|
21
21
|
tinybird/tb/modules/build.py,sha256=8wzHG_8xrA5D3rjnACTuSeJS4AqFL5rJFzpJnYWCBnQ,8150
|
|
@@ -25,9 +25,9 @@ tinybird/tb/modules/cli.py,sha256=J3s9RHw1Xwx0q4qUYw0QQGAtjpxhbmKNEFpRiPf4NIU,20
|
|
|
25
25
|
tinybird/tb/modules/common.py,sha256=W4MyzUAMYl1xRF9bG374NzVjZrz9JCo90MGP5HDBf8o,71529
|
|
26
26
|
tinybird/tb/modules/config.py,sha256=fUO-rVPImPnk8DNt0_AUYDlG77eC9Cs2jiVlB9LXCmg,11255
|
|
27
27
|
tinybird/tb/modules/connection.py,sha256=FhDM-OAnLN2epbO2YonpjJQhHqBjyuanBsZmKlDXrqg,28679
|
|
28
|
-
tinybird/tb/modules/create.py,sha256=
|
|
28
|
+
tinybird/tb/modules/create.py,sha256=kVLEwTfT-SxcF_IWaSh3vVQ5qVPbKQhwVHNO1kzoNyw,10250
|
|
29
29
|
tinybird/tb/modules/datasource.py,sha256=Xz2syobLp7SSDFFjCNT90uI8iH-MZ4KC8p7g1SY499Y,32897
|
|
30
|
-
tinybird/tb/modules/deploy.py,sha256=
|
|
30
|
+
tinybird/tb/modules/deploy.py,sha256=95JKtsiIdB9IknNsXTnFlgZgPSkij3zZv2IqLcdn66s,9251
|
|
31
31
|
tinybird/tb/modules/exceptions.py,sha256=4A2sSjCEqKUMqpP3WI00zouCWW4uLaghXXLZBSw04mY,3363
|
|
32
32
|
tinybird/tb/modules/feedback_manager.py,sha256=e8tqehRR0Buhs8O0n8N2Sg2vnnBVb1NLtnZqkPrYD_A,68379
|
|
33
33
|
tinybird/tb/modules/fmt.py,sha256=poh6_cwVGSf-sBu6LKWuO2TANL_J8Sgm25sPpwxa3Aw,3558
|
|
@@ -37,7 +37,7 @@ tinybird/tb/modules/llm_utils.py,sha256=hIfBU7vMUHUt25pljim3WdZdJTNr9hDo3mHezqI5
|
|
|
37
37
|
tinybird/tb/modules/local.py,sha256=lHUji6FMhRv4J9sLrHDqyMT-8OwzFSVzDfapnUKS-ZA,5242
|
|
38
38
|
tinybird/tb/modules/local_common.py,sha256=fRHJrEix19lAOE4EpzRhWBJH8FUk7hCCvynP0Icf7Ww,2298
|
|
39
39
|
tinybird/tb/modules/login.py,sha256=NwpwPQYMVb0mW5-uPR5zb5hl06XqH7xAJfA1GntZzPk,6315
|
|
40
|
-
tinybird/tb/modules/mock.py,sha256=
|
|
40
|
+
tinybird/tb/modules/mock.py,sha256=b0MqSVvJsaXdUKvagXfPGrh-XB8cYmuyXJ2D4P7uyB0,3658
|
|
41
41
|
tinybird/tb/modules/pipe.py,sha256=eYmMBiSj1Ur_hXUs74YZ9mCSAyiICDmkuKuTemlxPUY,27018
|
|
42
42
|
tinybird/tb/modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
|
|
43
43
|
tinybird/tb/modules/shell.py,sha256=OfFQ4lx3v_XSTr5cm_mTDG6CLc3zFdikM2pOamifG84,13469
|
|
@@ -72,8 +72,8 @@ tinybird/tb_cli_modules/config.py,sha256=6u6B5QCdiQLbJkCkwtnKGs9H3nP-KXXhC75mF7B
|
|
|
72
72
|
tinybird/tb_cli_modules/exceptions.py,sha256=pmucP4kTF4irIt7dXiG-FcnI-o3mvDusPmch1L8RCWk,3367
|
|
73
73
|
tinybird/tb_cli_modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
|
|
74
74
|
tinybird/tb_cli_modules/telemetry.py,sha256=iEGnMuCuNhvF6ln__j6X9MSTwL_0Hm-GgFHHHvhfknk,10466
|
|
75
|
-
tinybird-0.0.1.
|
|
76
|
-
tinybird-0.0.1.
|
|
77
|
-
tinybird-0.0.1.
|
|
78
|
-
tinybird-0.0.1.
|
|
79
|
-
tinybird-0.0.1.
|
|
75
|
+
tinybird-0.0.1.dev28.dist-info/METADATA,sha256=VmwZ1uo4krIPqGkHCGN0_n1eyi5keIbfptaAoHG3B8w,2446
|
|
76
|
+
tinybird-0.0.1.dev28.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
|
77
|
+
tinybird-0.0.1.dev28.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
|
|
78
|
+
tinybird-0.0.1.dev28.dist-info/top_level.txt,sha256=pgw6AzERHBcW3YTi2PW4arjxLkulk2msOz_SomfOEuc,45
|
|
79
|
+
tinybird-0.0.1.dev28.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|