tinybird 0.0.1.dev39__py3-none-any.whl → 0.0.1.dev41__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 +22 -0
- tinybird/tb/__cli__.py +2 -2
- tinybird/tb/modules/build.py +18 -14
- tinybird/tb/modules/create.py +16 -1
- tinybird/tb/modules/mock.py +1 -1
- {tinybird-0.0.1.dev39.dist-info → tinybird-0.0.1.dev41.dist-info}/METADATA +1 -1
- {tinybird-0.0.1.dev39.dist-info → tinybird-0.0.1.dev41.dist-info}/RECORD +10 -10
- {tinybird-0.0.1.dev39.dist-info → tinybird-0.0.1.dev41.dist-info}/WHEEL +0 -0
- {tinybird-0.0.1.dev39.dist-info → tinybird-0.0.1.dev41.dist-info}/entry_points.txt +0 -0
- {tinybird-0.0.1.dev39.dist-info → tinybird-0.0.1.dev41.dist-info}/top_level.txt +0 -0
tinybird/prompts.py
CHANGED
|
@@ -646,6 +646,7 @@ datasource_instructions = """
|
|
|
646
646
|
- No indentation is allowed for property names: DESCRIPTION, SCHEMA, ENGINE, ENGINE_PARTITION_KEY, ENGINE_SORTING_KEY, etc.
|
|
647
647
|
- Use MergeTree engine by default.
|
|
648
648
|
- Use AggregatingMergeTree engine when the datasource is the target of a materialized pipe.
|
|
649
|
+
- Use always json paths to define the schema. Example: `user_id` String `json:$.user_id`,
|
|
649
650
|
</datasource_file_instructions>
|
|
650
651
|
"""
|
|
651
652
|
|
|
@@ -779,3 +780,24 @@ Use the following format to generate the response and do not wrap it in any othe
|
|
|
779
780
|
copy_pipe_instructions=copy_pipe_instructions,
|
|
780
781
|
materialized_pipe_instructions=materialized_pipe_instructions,
|
|
781
782
|
)
|
|
783
|
+
|
|
784
|
+
|
|
785
|
+
cursorrules_prompt = """
|
|
786
|
+
You are an expert in SQL and Tinybird. Follow these instructions when working with .datasource and .pipe files:
|
|
787
|
+
|
|
788
|
+
{datasource_instructions}
|
|
789
|
+
{pipe_instructions}
|
|
790
|
+
{sql_instructions}
|
|
791
|
+
{datasource_example}
|
|
792
|
+
{pipe_example}
|
|
793
|
+
{copy_pipe_instructions}
|
|
794
|
+
{materialized_pipe_instructions}
|
|
795
|
+
""".format(
|
|
796
|
+
datasource_instructions=datasource_instructions,
|
|
797
|
+
pipe_instructions=pipe_instructions,
|
|
798
|
+
sql_instructions=sql_instructions,
|
|
799
|
+
datasource_example=datasource_example,
|
|
800
|
+
pipe_example=pipe_example,
|
|
801
|
+
copy_pipe_instructions=copy_pipe_instructions,
|
|
802
|
+
materialized_pipe_instructions=materialized_pipe_instructions,
|
|
803
|
+
)
|
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.dev41'
|
|
8
|
+
__revision__ = '86b5c65'
|
tinybird/tb/modules/build.py
CHANGED
|
@@ -36,7 +36,7 @@ def build(ctx: click.Context, watch: bool) -> None:
|
|
|
36
36
|
|
|
37
37
|
def process(file_changed: Optional[str] = None) -> None:
|
|
38
38
|
if file_changed and file_changed.endswith(".ndjson"):
|
|
39
|
-
rebuild_fixture(project,
|
|
39
|
+
rebuild_fixture(project, file_changed)
|
|
40
40
|
else:
|
|
41
41
|
build_project(project, tb_client)
|
|
42
42
|
new_tb_client = asyncio.run(get_tinybird_local_client(str(project.path)))
|
|
@@ -154,7 +154,6 @@ def append_fixture(
|
|
|
154
154
|
datasource_name: str,
|
|
155
155
|
url: str,
|
|
156
156
|
):
|
|
157
|
-
asyncio.run(tb_client.datasource_truncate(datasource_name))
|
|
158
157
|
asyncio.run(
|
|
159
158
|
push_data(
|
|
160
159
|
tb_client,
|
|
@@ -167,21 +166,26 @@ def append_fixture(
|
|
|
167
166
|
)
|
|
168
167
|
|
|
169
168
|
|
|
170
|
-
def rebuild_fixture(project: Project,
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
169
|
+
def rebuild_fixture(project: Project, fixture: str) -> None:
|
|
170
|
+
try:
|
|
171
|
+
tb_client = asyncio.run(get_tinybird_local_client(str(project.path)))
|
|
172
|
+
fixture_path = Path(fixture)
|
|
173
|
+
datasources_path = Path(project.folder) / "datasources"
|
|
174
|
+
ds_name = fixture_path.stem
|
|
174
175
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
176
|
+
if ds_name not in project.datasources:
|
|
177
|
+
try:
|
|
178
|
+
ds_name = "_".join(fixture_path.stem.split("_")[:-1])
|
|
179
|
+
except Exception:
|
|
180
|
+
pass
|
|
180
181
|
|
|
181
|
-
|
|
182
|
+
ds_path = datasources_path / f"{ds_name}.datasource"
|
|
182
183
|
|
|
183
|
-
|
|
184
|
-
|
|
184
|
+
if ds_path.exists():
|
|
185
|
+
asyncio.run(tb_client.datasource_truncate(ds_name))
|
|
186
|
+
append_fixture(tb_client, ds_name, str(fixture_path))
|
|
187
|
+
except Exception as e:
|
|
188
|
+
click.echo(FeedbackManager.error_exception(error=e))
|
|
185
189
|
|
|
186
190
|
|
|
187
191
|
def build_and_print_resource(tb_client: TinyB, filename: str):
|
tinybird/tb/modules/create.py
CHANGED
|
@@ -7,7 +7,7 @@ from typing import Optional
|
|
|
7
7
|
import click
|
|
8
8
|
|
|
9
9
|
from tinybird.client import TinyB
|
|
10
|
-
from tinybird.prompts import create_prompt, mock_prompt
|
|
10
|
+
from tinybird.prompts import create_prompt, cursorrules_prompt, mock_prompt
|
|
11
11
|
from tinybird.tb.modules.cicd import init_cicd
|
|
12
12
|
from tinybird.tb.modules.cli import cli
|
|
13
13
|
from tinybird.tb.modules.common import _generate_datafile, check_user_token_with_client, coro, generate_datafile
|
|
@@ -40,12 +40,14 @@ from tinybird.tb.modules.local_common import get_tinybird_local_client
|
|
|
40
40
|
help="Folder where datafiles will be placed",
|
|
41
41
|
)
|
|
42
42
|
@click.option("--rows", type=int, default=10, help="Number of events to send")
|
|
43
|
+
@click.option("--cursor", default=False, is_flag=True, help="Create .cursorrules file with Tinybird rules")
|
|
43
44
|
@coro
|
|
44
45
|
async def create(
|
|
45
46
|
data: Optional[str],
|
|
46
47
|
prompt: Optional[str],
|
|
47
48
|
folder: Optional[str],
|
|
48
49
|
rows: int,
|
|
50
|
+
cursor: bool,
|
|
49
51
|
) -> None:
|
|
50
52
|
"""Initialize a new project."""
|
|
51
53
|
folder = folder or getcwd()
|
|
@@ -121,7 +123,11 @@ async def create(
|
|
|
121
123
|
persist_fixture(fixture_name, data, folder)
|
|
122
124
|
click.echo(FeedbackManager.info(message=f"✓ /fixtures/{datasource_name}"))
|
|
123
125
|
|
|
126
|
+
if cursor and not already_has_cursorrules(folder):
|
|
127
|
+
click.echo(FeedbackManager.highlight(message="\n» Creating .cursorrules..."))
|
|
128
|
+
create_cursorrules(folder)
|
|
124
129
|
click.echo(FeedbackManager.success(message="✓ Done!\n"))
|
|
130
|
+
|
|
125
131
|
except Exception as e:
|
|
126
132
|
click.echo(FeedbackManager.error(message=f"Error: {str(e)}"))
|
|
127
133
|
|
|
@@ -286,3 +292,12 @@ def generate_pipe_file(name: str, content: str, folder: str):
|
|
|
286
292
|
with open(f"{f}", "w") as file:
|
|
287
293
|
file.write(content)
|
|
288
294
|
click.echo(FeedbackManager.info_file_created(file=f.relative_to(folder)))
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
def already_has_cursorrules(folder: str) -> bool:
|
|
298
|
+
return (Path(folder) / ".cursorrules").exists()
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
def create_cursorrules(folder: str):
|
|
302
|
+
cursorrules_file = Path(folder) / ".cursorrules"
|
|
303
|
+
cursorrules_file.write_text(cursorrules_prompt)
|
tinybird/tb/modules/mock.py
CHANGED
|
@@ -47,7 +47,7 @@ async def mock(datasource: str, rows: int, prompt: str, folder: str) -> None:
|
|
|
47
47
|
datasource_path = Path(folder) / datasource_path
|
|
48
48
|
|
|
49
49
|
prompt_path = Path(folder) / "fixtures" / f"{datasource_name}.prompt"
|
|
50
|
-
if not prompt:
|
|
50
|
+
if not prompt or prompt == "Use the datasource schema to generate sample data":
|
|
51
51
|
# load the prompt from the fixture.prompt file if it exists
|
|
52
52
|
if prompt_path.exists():
|
|
53
53
|
prompt = prompt_path.read_text()
|
|
@@ -6,7 +6,7 @@ tinybird/context.py,sha256=A3GBApac9xO6hrAMJ1s9dMrI_ou9aKF84CdEjtPddMk,1417
|
|
|
6
6
|
tinybird/datatypes.py,sha256=XNypumfqNjsvLJ5iNXnbVHRvAJe0aQwI3lS6Cxox-e0,10979
|
|
7
7
|
tinybird/feedback_manager.py,sha256=ON5Zu-G3-QDVfH2i_P-V4EtyhlNtAzyp1YDZsnce0_U,67826
|
|
8
8
|
tinybird/git_settings.py,sha256=Sw_8rGmribEFJ4Z_6idrVytxpFYk7ez8ei0qHULzs3E,3934
|
|
9
|
-
tinybird/prompts.py,sha256=
|
|
9
|
+
tinybird/prompts.py,sha256=2UdLOCjIWbLINI1TuUSDXOW2T0YaPD0RHZAa26j6VlE,25247
|
|
10
10
|
tinybird/sql.py,sha256=eulpRe05ZFrKFrxYawgxDxxrktFE8uL6hSL1gHIWKyg,46166
|
|
11
11
|
tinybird/sql_template.py,sha256=GmMLAI10MTqjQo9qztuQHLRWs67teozsWDxUBdvkAn4,93668
|
|
12
12
|
tinybird/sql_template_fmt.py,sha256=1z-PuqSZXtzso8Z_mPqUc-NxIxUrNUcVIPezNieZk-M,10196
|
|
@@ -15,17 +15,17 @@ 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=Py43Okm6MRi1REBHdZBS-rEI97DI49FulIJwEZXDzhs,251
|
|
19
19
|
tinybird/tb/cli.py,sha256=_kYDnDS3a45MMKJFZnYZx1gLuVqs4N_Rt8GO4sueAeg,957
|
|
20
20
|
tinybird/tb/modules/auth.py,sha256=EzRWFmwRkXNhUmRaruEVFLdkbUg8xMSix0cAWl5D4Jg,9029
|
|
21
|
-
tinybird/tb/modules/build.py,sha256=
|
|
21
|
+
tinybird/tb/modules/build.py,sha256=N1I_MWPChBdfrFMcHdIbsTbMrGSNDBPBmhv2xSLsoWw,7500
|
|
22
22
|
tinybird/tb/modules/build_client.py,sha256=na4MH0D4_yXMkNEW2a9bslW6t1fBRnr8JTN68MfRvvw,7229
|
|
23
23
|
tinybird/tb/modules/cicd.py,sha256=SjCyvvy0WUnsjFs2biwwXvcf0Ddpmghhd8-SnMyfsRM,5355
|
|
24
24
|
tinybird/tb/modules/cli.py,sha256=hD_mUAXtUofU20UC9j8Pzc4QI1gV0Y9Zefwe24T-qZA,19427
|
|
25
25
|
tinybird/tb/modules/common.py,sha256=e4U7AT0dUBG6O-7Iq2CVN1UHPd6-ZCFucyW0L5gBi4g,70592
|
|
26
26
|
tinybird/tb/modules/config.py,sha256=mie3oMVTf5YOUFEiLs88P16U4LkJafJjSpjwyAkFHog,10979
|
|
27
27
|
tinybird/tb/modules/copy.py,sha256=qrtU1PFXmu-xhq1LR2uo7-1MoCOOQeVb_j10vcasXmI,2415
|
|
28
|
-
tinybird/tb/modules/create.py,sha256=
|
|
28
|
+
tinybird/tb/modules/create.py,sha256=iUYt5XG-GPwE3LnHrWqlOHmke0Bv8VMPxjAffxRFYoQ,11438
|
|
29
29
|
tinybird/tb/modules/datasource.py,sha256=-VG2qKlu0fmkhsIB5bPiTp3XuktB_r-ZkIoohEBEXtI,13713
|
|
30
30
|
tinybird/tb/modules/deployment.py,sha256=fCWHlfMrAbHLst_-pveH6oPHPnDsXqv1bAkzoFtxvEM,9597
|
|
31
31
|
tinybird/tb/modules/endpoint.py,sha256=iYSWzi3_VJzHcq1_j_Hv4cfG1GFKXKxqEY4jLjKhxag,6488
|
|
@@ -38,7 +38,7 @@ tinybird/tb/modules/llm_utils.py,sha256=zUwcF8hgBsxWVWgCzSRh--O7lWVZ_wzj7bxN8Yl5
|
|
|
38
38
|
tinybird/tb/modules/local.py,sha256=x4xuCGVkoa8KLYGZEJnFUP8HUkKX05Frp_djRVjVjTs,5669
|
|
39
39
|
tinybird/tb/modules/local_common.py,sha256=afPW6bSc-YI7Q4ngvBV53sM7QxnPGBMe5N91iETM2yE,2783
|
|
40
40
|
tinybird/tb/modules/login.py,sha256=0cS-f3MsQFHc6xjw8FRWJm4EJBH9C7Ri68EcO_tiwes,6508
|
|
41
|
-
tinybird/tb/modules/mock.py,sha256=
|
|
41
|
+
tinybird/tb/modules/mock.py,sha256=XoCaFFroJf2jWVxEztPelwXYNle__KilON1e81Mxkd4,3764
|
|
42
42
|
tinybird/tb/modules/pipe.py,sha256=Kay7AZVf_M5biIvX5hi-Vaz4l9C7AV-s0C2Nle_gkJo,17528
|
|
43
43
|
tinybird/tb/modules/project.py,sha256=EyrX5-5i3vhWk6v3KzbrZg8im4ey23hpzM7U651u6OE,1432
|
|
44
44
|
tinybird/tb/modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
|
|
@@ -75,8 +75,8 @@ tinybird/tb_cli_modules/config.py,sha256=6u6B5QCdiQLbJkCkwtnKGs9H3nP-KXXhC75mF7B
|
|
|
75
75
|
tinybird/tb_cli_modules/exceptions.py,sha256=pmucP4kTF4irIt7dXiG-FcnI-o3mvDusPmch1L8RCWk,3367
|
|
76
76
|
tinybird/tb_cli_modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
|
|
77
77
|
tinybird/tb_cli_modules/telemetry.py,sha256=iEGnMuCuNhvF6ln__j6X9MSTwL_0Hm-GgFHHHvhfknk,10466
|
|
78
|
-
tinybird-0.0.1.
|
|
79
|
-
tinybird-0.0.1.
|
|
80
|
-
tinybird-0.0.1.
|
|
81
|
-
tinybird-0.0.1.
|
|
82
|
-
tinybird-0.0.1.
|
|
78
|
+
tinybird-0.0.1.dev41.dist-info/METADATA,sha256=VrfRatTvL5BvgKELZsK-vEW6vu_4_5cbWnWf7Penawo,2482
|
|
79
|
+
tinybird-0.0.1.dev41.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
|
80
|
+
tinybird-0.0.1.dev41.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
|
|
81
|
+
tinybird-0.0.1.dev41.dist-info/top_level.txt,sha256=pgw6AzERHBcW3YTi2PW4arjxLkulk2msOz_SomfOEuc,45
|
|
82
|
+
tinybird-0.0.1.dev41.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|