tinybird 0.0.1.dev107__py3-none-any.whl → 0.0.1.dev109__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.
tinybird/prompts.py CHANGED
@@ -605,8 +605,9 @@ Follow the instructions and generate the following response with no additional t
605
605
  copy_pipe_instructions = """
606
606
  <copy_pipe_instructions>
607
607
  - Do not create copy pipes by default, unless the user asks for it.
608
+ - Copy pipes should be created in the /copies folder.
608
609
  - In a .pipe file you can define how to export the result of a Pipe to a Data Source, optionally with a schedule.
609
- - Do not include COPY_SCHEDULE in the .pipe file if it is not requested by the user.
610
+ - Do not include COPY_SCHEDULE in the .pipe file unless is specifically requested by the user.
610
611
  - COPY_SCHEDULE is a cron expression that defines the schedule of the copy pipe.
611
612
  - COPY_SCHEDULE is optional and if not provided, the copy pipe will be executed only once.
612
613
  - TARGET_DATASOURCE is the name of the Data Source to export the result to.
@@ -634,6 +635,7 @@ COPY_SCHEDULE 0 * * * *
634
635
  materialized_pipe_instructions = """
635
636
  <materialized_pipe_instructions>
636
637
  - Do not create materialized pipes by default, unless the user asks for it.
638
+ - Materialized pipes should be created in the /materializations folder.
637
639
  - In a .pipe file you can define how to materialize each row ingested in the earliest Data Source in the Pipe query to a materialized Data Source. Materialization happens at ingest.
638
640
  - DATASOURCE: Required when TYPE is MATERIALIZED. Sets the target Data Source for materialized nodes.
639
641
  - TYPE MATERIALIZED is the type of the pipe and it is mandatory for materialized pipes.
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.dev107'
8
- __revision__ = '76708c2'
7
+ __version__ = '0.0.1.dev109'
8
+ __revision__ = '421d6c4'
@@ -191,6 +191,14 @@ KAFKA_PARAMS = {
191
191
 
192
192
  REQUIRED_KAFKA_PARAMS = KAFKA_PARAMS
193
193
 
194
+ S3_PARAMS = {
195
+ "import_connection_name",
196
+ "import_schedule",
197
+ "import_bucket_uri",
198
+ }
199
+
200
+ REQUIRED_S3_PARAMS = S3_PARAMS
201
+
194
202
 
195
203
  class Datafile:
196
204
  def __init__(self) -> None:
@@ -261,6 +269,7 @@ class Datafile:
261
269
  # [x] Engine is present
262
270
  # [x] Token permissions are valid
263
271
  # [x] If it's a kafka datasource, all required kafka params are present
272
+ # [x] If it's an S3 datasource, all required S3 params are present
264
273
  # [ ] ...
265
274
  if len(self.nodes) > 1:
266
275
  # Our users are not aware of data source data files being a single-node data file, hence this error
@@ -283,6 +292,12 @@ class Datafile:
283
292
  raise DatafileValidationError(
284
293
  f"Some Kafka params have been provided, but the following required ones are missing: {missing}"
285
294
  )
295
+ # Validate S3 params
296
+ if any(param in node for param in S3_PARAMS) and not all(param in node for param in REQUIRED_S3_PARAMS):
297
+ missing = [param for param in S3_PARAMS if param not in node]
298
+ raise DatafileValidationError(
299
+ f"Some S3 params have been provided, but the following required ones are missing: {missing}"
300
+ )
286
301
  else:
287
302
  # We cannot validate a datafile whose kind is unknown
288
303
  pass
@@ -1,4 +1,3 @@
1
- import os
2
1
  import re
3
2
  import subprocess
4
3
  import time
@@ -7,6 +6,7 @@ import boto3
7
6
  import click
8
7
 
9
8
  import docker
9
+ from docker.client import DockerClient
10
10
  from tinybird.tb.modules.cli import cli
11
11
  from tinybird.tb.modules.common import coro
12
12
  from tinybird.tb.modules.exceptions import CLIException
@@ -15,8 +15,9 @@ from tinybird.tb.modules.local_common import TB_CONTAINER_NAME, TB_IMAGE_NAME, T
15
15
 
16
16
 
17
17
  def start_tinybird_local(
18
- docker_client,
19
- ):
18
+ docker_client: DockerClient,
19
+ use_aws_creds: bool,
20
+ ) -> None:
20
21
  """Start the Tinybird container."""
21
22
  pull_show_prompt = False
22
23
  pull_required = False
@@ -52,13 +53,13 @@ def start_tinybird_local(
52
53
  if container:
53
54
  container.remove(force=True)
54
55
 
55
- environment = get_local_aws_credentials()
56
+ environment = get_use_aws_creds() if use_aws_creds else {}
56
57
 
57
58
  container = docker_client.containers.run(
58
59
  TB_IMAGE_NAME,
59
60
  name=TB_CONTAINER_NAME,
60
61
  detach=True,
61
- ports={"80/tcp": TB_LOCAL_PORT},
62
+ ports={"7181/tcp": TB_LOCAL_PORT},
62
63
  remove=False,
63
64
  platform="linux/amd64",
64
65
  environment=environment,
@@ -81,7 +82,7 @@ def start_tinybird_local(
81
82
  image.remove(force=True)
82
83
 
83
84
 
84
- def get_docker_client():
85
+ def get_docker_client() -> DockerClient:
85
86
  """Check if Docker is installed and running."""
86
87
  try:
87
88
  client = docker.from_env() # type: ignore
@@ -93,7 +94,7 @@ def get_docker_client():
93
94
  )
94
95
 
95
96
 
96
- def get_local_aws_credentials():
97
+ def get_use_aws_creds():
97
98
  credentials: dict[str, str] = {}
98
99
  try:
99
100
  # Get the boto3 session and credentials
@@ -132,19 +133,31 @@ def remove_tinybird_local(docker_client):
132
133
  """Remove the Tinybird container."""
133
134
  try:
134
135
  container = docker_client.containers.get(TB_CONTAINER_NAME)
135
- container.remove(force=True)
136
+ if click.confirm(
137
+ FeedbackManager.warning(
138
+ message="△ This step will remove all your data inside Tinybird Local. Are you sure? [y/N]:"
139
+ ),
140
+ show_default=False,
141
+ prompt_suffix="",
142
+ ):
143
+ container.remove(force=True)
136
144
  except Exception:
137
145
  pass
138
146
 
139
147
 
140
148
  def update_cli():
141
149
  click.echo(FeedbackManager.highlight(message="» Updating Tinybird CLI..."))
142
- process = subprocess.Popen(
143
- [f"{os.getenv('HOME')}/.local/bin/uv", "tool", "upgrade", "tinybird"],
144
- stdout=subprocess.PIPE,
145
- stderr=subprocess.PIPE,
146
- text=True,
147
- )
150
+
151
+ try:
152
+ process = subprocess.Popen(
153
+ ["uv", "tool", "upgrade", "tinybird"],
154
+ stdout=subprocess.PIPE,
155
+ stderr=subprocess.PIPE,
156
+ text=True,
157
+ )
158
+ except FileNotFoundError:
159
+ raise CLIException("Cannot find required tool: uv. Reinstall using: curl -LsSf tbrd.co/fwd | sh")
160
+
148
161
  stdout, stderr = process.communicate()
149
162
  if "Nothing to upgrade" not in stdout + stderr:
150
163
  for line in stdout.split("\n") + stderr.split("\n"):
@@ -195,21 +208,23 @@ async def remove() -> None:
195
208
 
196
209
  @local.command()
197
210
  @coro
198
- async def start() -> None:
211
+ @click.option("--use-aws-creds", default=False, is_flag=True, help="Use local AWS credentials")
212
+ async def start(use_aws_creds: bool) -> None:
199
213
  """Start Tinybird Local"""
200
214
  click.echo(FeedbackManager.highlight(message="» Starting Tinybird Local..."))
201
215
  docker_client = get_docker_client()
202
- start_tinybird_local(docker_client)
216
+ start_tinybird_local(docker_client, use_aws_creds)
203
217
  click.echo(FeedbackManager.success(message="✓ Tinybird Local is ready!"))
204
218
 
205
219
 
206
220
  @local.command()
207
221
  @coro
208
- async def restart() -> None:
222
+ @click.option("--use-aws-creds", is_flag=True, help="Use local AWS credentials")
223
+ async def restart(use_aws_creds: bool) -> None:
209
224
  """Restart Tinybird Local"""
210
225
  click.echo(FeedbackManager.highlight(message="» Restarting Tinybird Local..."))
211
226
  docker_client = get_docker_client()
212
227
  remove_tinybird_local(docker_client)
213
228
  click.echo(FeedbackManager.info(message="✓ Tinybird Local stopped"))
214
- start_tinybird_local(docker_client)
229
+ start_tinybird_local(docker_client, use_aws_creds)
215
230
  click.echo(FeedbackManager.success(message="✓ Tinybird Local is ready!"))
@@ -99,7 +99,7 @@ def start_server(auth_callback, auth_host):
99
99
  @click.option(
100
100
  "--host",
101
101
  default="https://api.europe-west2.gcp.tinybird.co",
102
- help="Set custom host if it's different than https://api.tinybird.co. See https://www.tinybird.co/docs/api-reference/overview#regions-and-endpoints for the available list of regions.",
102
+ help="Set custom host if it's different than https://api.europe-west2.gcp.tinybird.co. See https://www.tinybird.co/docs/api-reference/overview#regions-and-endpoints for the available list of regions.",
103
103
  )
104
104
  @click.option(
105
105
  "--auth-host",
@@ -113,6 +113,9 @@ def start_server(auth_callback, auth_host):
113
113
  @coro
114
114
  async def login(host: str, auth_host: str, workspace: str):
115
115
  """Authenticate using the browser."""
116
+ host = host.rstrip("/")
117
+ auth_host = auth_host.rstrip("/")
118
+
116
119
  auth_event = threading.Event()
117
120
  auth_code: list[str] = [] # Using a list to store the code, as it's mutable
118
121
 
@@ -153,8 +156,8 @@ async def login(host: str, auth_host: str, workspace: str):
153
156
  cli_config.set_token(data.get("workspace_token", ""))
154
157
  cli_config.set_token_for_host(data.get("workspace_token", ""), host)
155
158
  cli_config.set_user_token(data.get("user_token", ""))
156
- cli_config.set_host(host or data.get("api_host", ""))
157
-
159
+ host = data.get("api_host", host)
160
+ cli_config.set_host(host)
158
161
  ws = await cli_config.get_client(token=data.get("workspace_token", ""), host=host).workspace_info(version="v1")
159
162
  for k in ("id", "name", "user_email", "user_id", "scope"):
160
163
  if k in ws:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: tinybird
3
- Version: 0.0.1.dev107
3
+ Version: 0.0.1.dev109
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/cli/introduction.html
6
6
  Author: Tinybird
@@ -6,7 +6,7 @@ tinybird/context.py,sha256=FfqYfrGX_I7PKGTQo93utaKPDNVYWelg4Hsp3evX5wM,1291
6
6
  tinybird/datatypes.py,sha256=XNypumfqNjsvLJ5iNXnbVHRvAJe0aQwI3lS6Cxox-e0,10979
7
7
  tinybird/feedback_manager.py,sha256=a_ZhFX2zcB7vRknIcmHKMdQbb0c7TqlTBQ_5hPuWh88,69267
8
8
  tinybird/git_settings.py,sha256=Sw_8rGmribEFJ4Z_6idrVytxpFYk7ez8ei0qHULzs3E,3934
9
- tinybird/prompts.py,sha256=RgV1B7-b6-1xXStNlhKikYSCG1WNaddDVeSp8hSgBlE,33753
9
+ tinybird/prompts.py,sha256=0i4Bzg-60lV6NlrQ1Vu6NZ_2we3GqV3rExu77YfA0V4,33889
10
10
  tinybird/sql.py,sha256=J35bhdpuu84HW2tiLp-cs_nzkRwPhiy1yPcFhcWMCR4,46248
11
11
  tinybird/sql_template.py,sha256=mK0yeRFctbXTAu0VNMjIzoFBJoh9PoniAVgEatA5SG4,99832
12
12
  tinybird/sql_template_fmt.py,sha256=KUHdj5rYCYm_rKKdXYSJAE9vIyXUQLB0YSZnUXHeBlY,10196
@@ -15,7 +15,7 @@ tinybird/syncasync.py,sha256=IPnOx6lMbf9SNddN1eBtssg8vCLHMt76SuZ6YNYm-Yk,27761
15
15
  tinybird/tornado_template.py,sha256=jjNVDMnkYFWXflmT8KU_Ssbo5vR8KQq3EJMk5vYgXRw,41959
16
16
  tinybird/ch_utils/constants.py,sha256=aYvg2C_WxYWsnqPdZB1ZFoIr8ZY-XjUXYyHKE9Ansj0,3890
17
17
  tinybird/ch_utils/engine.py,sha256=BZuPM7MFS7vaEKK5tOMR2bwSAgJudPrJt27uVEwZmTY,40512
18
- tinybird/tb/__cli__.py,sha256=t8MFy2-t9fuw6aYIBOtbd_R7b7PF-LjKaUPwssmRWnA,252
18
+ tinybird/tb/__cli__.py,sha256=gq1iOJ_OD1Jr2fuf07Ot_OShPnS-FIvM36rsSSSVtzs,252
19
19
  tinybird/tb/cli.py,sha256=H_HaZhkimKgkryYXpBjHfY9Qtg-ZORiONU3psDNpzDk,1135
20
20
  tinybird/tb/modules/auth.py,sha256=L1IatO2arRSzys3t8px8xVt8uPWUL5EVD0sFzAV_uVU,9022
21
21
  tinybird/tb/modules/build.py,sha256=h5drdmDFX8NHts9dA2Zepao7KSgMAl3DZGyFufVZP78,11085
@@ -36,9 +36,9 @@ tinybird/tb/modules/infra.py,sha256=GA5xnYLlVItPfJu_3_5NIdHQDuyfk2Z71wtcn9NncGA,
36
36
  tinybird/tb/modules/job.py,sha256=956Pj8BEEsiD2GZsV9RKKVM3I_CveOLgS82lykO5ukk,2963
37
37
  tinybird/tb/modules/llm.py,sha256=AC0VSphTOM2t-v1_3NLvNN_FIbgMo4dTyMqIv5nniPo,835
38
38
  tinybird/tb/modules/llm_utils.py,sha256=nS9r4FAElJw8yXtmdYrx-rtI2zXR8qXfi1QqUDCfxvg,3469
39
- tinybird/tb/modules/local.py,sha256=ju4pckNbtCUD9eQpvxEKP_YsVIny8WPidoCxqXEyh3Y,7111
39
+ tinybird/tb/modules/local.py,sha256=4BhxfkSTHpckXmH4aU_BothlV5n4JyAIoBKX3wP_BZg,7863
40
40
  tinybird/tb/modules/local_common.py,sha256=RN5OEncHdq7ua4AZ--WgKtaFuEsLvIhq_ROHJadRXXA,3188
41
- tinybird/tb/modules/login.py,sha256=dAaBBn_ZIQRm9BFl6Uw_HgZa2qoLuAO6mBOxob_17ms,6253
41
+ tinybird/tb/modules/login.py,sha256=lLCJ1kIq3sLcoSMH1kZge5isHh-fDwHPRHApIqbaCkw,6350
42
42
  tinybird/tb/modules/logout.py,sha256=ULooy1cDBD02-r7voZmhV7udA0ML5tVuflJyShrh56Y,1022
43
43
  tinybird/tb/modules/materialization.py,sha256=r8Q9HXcYEmfrEzP4WpiasCKDJdSkTPaAKJtZMoJKhi8,5749
44
44
  tinybird/tb/modules/mock.py,sha256=2E26N8TMK1sP7eRc9N1nODdc_vU1jBeGRs8e-fbQ5Dc,4516
@@ -61,7 +61,7 @@ tinybird/tb/modules/datafile/build.py,sha256=jhfIJ2xt0N13XsLPe3iMQIyCPApHS13_Df2
61
61
  tinybird/tb/modules/datafile/build_common.py,sha256=rT7VJ5mnQ68R_8US91DAtkusfvjWuG_NObOzNgtN_ko,4562
62
62
  tinybird/tb/modules/datafile/build_datasource.py,sha256=CCU3eQ8Rax9RgHHfbAXDRL6rQ49N35h_GDQnGrUUUzA,17379
63
63
  tinybird/tb/modules/datafile/build_pipe.py,sha256=w-Wd08gZYAEcak9FdBijVfIU2_Wn_PPdgAZddPpoGTo,11382
64
- tinybird/tb/modules/datafile/common.py,sha256=4Jv20MUMaQl2NlbviRGHH41ncoDc6h9g4IWC0nl0j3M,82579
64
+ tinybird/tb/modules/datafile/common.py,sha256=4pvW92X9BXomaN3-WhQOjvnAHY96O4dTsp4USBdknzk,83192
65
65
  tinybird/tb/modules/datafile/diff.py,sha256=-0J7PsBO64T7LOZSkZ4ZFHHCPvT7cKItnJkbz2PkndU,6754
66
66
  tinybird/tb/modules/datafile/exceptions.py,sha256=8rw2umdZjtby85QbuRKFO5ETz_eRHwUY5l7eHsy1wnI,556
67
67
  tinybird/tb/modules/datafile/fixture.py,sha256=si-9LB-LdKQSWDtVW82xDrHtFfko5bgBG1cvjqqrcPU,1064
@@ -81,8 +81,8 @@ tinybird/tb_cli_modules/config.py,sha256=IsgdtFRnUrkY8-Zo32lmk6O7u3bHie1QCxLwgp4
81
81
  tinybird/tb_cli_modules/exceptions.py,sha256=pmucP4kTF4irIt7dXiG-FcnI-o3mvDusPmch1L8RCWk,3367
82
82
  tinybird/tb_cli_modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
83
83
  tinybird/tb_cli_modules/telemetry.py,sha256=Hh2Io8ZPROSunbOLuMvuIFU4TqwWPmQTqal4WS09K1A,10449
84
- tinybird-0.0.1.dev107.dist-info/METADATA,sha256=O5fKB-GC4H563pOpRl3NOiRPDOjoCcE661OrM-gzza4,1612
85
- tinybird-0.0.1.dev107.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
86
- tinybird-0.0.1.dev107.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
87
- tinybird-0.0.1.dev107.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
88
- tinybird-0.0.1.dev107.dist-info/RECORD,,
84
+ tinybird-0.0.1.dev109.dist-info/METADATA,sha256=v6-T3y67YWXtDvTUvKDY54ywJvMNaNpb150tom2JvtM,1612
85
+ tinybird-0.0.1.dev109.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
86
+ tinybird-0.0.1.dev109.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
87
+ tinybird-0.0.1.dev109.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
88
+ tinybird-0.0.1.dev109.dist-info/RECORD,,