tinybird 0.0.1.dev46__py3-none-any.whl → 0.0.1.dev48__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/client.py CHANGED
@@ -697,12 +697,7 @@ class TinyB:
697
697
  if local_host != self.host:
698
698
  return data
699
699
 
700
- local_workspaces = [
701
- x
702
- for x in data["workspaces"]
703
- if x["name"].startswith("Tinybird_Local_") and not x["name"].startswith("Tinybird_Local_Build_")
704
- ]
705
-
700
+ local_workspaces = [x for x in data["workspaces"] if not x["name"].startswith("Tinybird_Local_")]
706
701
  return {**data, "workspaces": local_workspaces}
707
702
 
708
703
  async def user_workspaces_and_branches(self):
tinybird/prompts.py CHANGED
@@ -837,7 +837,8 @@ You have commands at your disposal to develop a tinybird project:
837
837
  - {base_command} --build endpoint data <pipe_name>: to get the data of an endpoint. You can pass parameters to the endpoint like this: {base_command} --build endpoint data <pipe_name> --param1 value1 --param2 value2
838
838
  - {base_command} --build token ls: to list all the tokens
839
839
  There are other commands that you can use, but these are the most common ones. Run `{base_command} -h` to see all the commands if needed.
840
- When you need to check resources or data in the Tinybird environment that you updated with the build command, add always the --build flag before the command. Example: {base_command} --build datasource ls
840
+ When you need to work with resources or data in the Tinybird environment that you updated with the build command, add always the --build flag before the command. Example: {base_command} --build datasource ls
841
+ When you need to work with resources or data in production, add always the --prod flag before the command. Example: {base_command} --prod datasource ls
841
842
  </command_calling>
842
843
  <development_instructions>
843
844
  - When asking to create a tinybird data project, if the needed folders are not already created, use the following structure:
@@ -854,7 +855,12 @@ When you need to check resources or data in the Tinybird environment that you up
854
855
  - The format of the generated api endpoint urls is: http://localhost:80/v0/pipe/<pipe_name>.json?token=<token>
855
856
  - Before running the tests, remember to have the project built with `{base_command} build` with the latest changes.
856
857
  </development_instructions>
857
-
858
+ When asking for ingesting data, adding data or appending data do the following depending on the environment you want to work with:
859
+ <ingest_data_instructions>
860
+ - When building locally, create a .ndjson file with the data you want to ingest and do `{base_command} build` to ingest the data in the build env.
861
+ - When appending data in production, use `{base_command} --prod datasource append <datasource_name> <file_name>`
862
+ - When you have a response that says “there are rows in quarantine”, do `{base_command} --build|--prod datasource data <datasource_name>_quarantine` to understand what is the problem.
863
+ </ingest_data_instructions>
858
864
  <datasource_file_instructions>
859
865
  Follow these instructions when creating or updating .datasource files:
860
866
  {datasource_instructions}
tinybird/sql.py CHANGED
@@ -86,7 +86,7 @@ def get_format(sql: str) -> Optional[str]:
86
86
  """
87
87
  FORMAT_RE = r"\s+format\s+(\w+)\s*$"
88
88
  sql = sql.strip()
89
- format = re.findall(FORMAT_RE, sql, re.I)
89
+ format = re.findall(FORMAT_RE, sql, re.IGNORECASE)
90
90
  return format[0] if format else None
91
91
 
92
92
 
@@ -100,7 +100,7 @@ def get_format_group(sql: str) -> str:
100
100
  """
101
101
  FORMAT_RE = r"\s+format\s+(\w+)\s*$"
102
102
  sql = sql.strip()
103
- format = re.search(FORMAT_RE, sql, re.I)
103
+ format = re.search(FORMAT_RE, sql, re.IGNORECASE)
104
104
  return format.group() if format else ""
105
105
 
106
106
 
@@ -135,7 +135,7 @@ def remove_format(sql: str) -> str:
135
135
  """
136
136
  FORMAT_RE = r"\s+(format)\s+(\w+)\s*$"
137
137
  sql = sql.strip()
138
- return re.sub(FORMAT_RE, "", sql, flags=re.I)
138
+ return re.sub(FORMAT_RE, "", sql, flags=re.IGNORECASE)
139
139
 
140
140
 
141
141
  def col_name(name: str, backquotes: bool = True) -> str:
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.dev46'
8
- __revision__ = '7b9942e'
7
+ __version__ = '0.0.1.dev48'
8
+ __revision__ = '6d638e9'
@@ -79,7 +79,7 @@ async def cli(
79
79
  """
80
80
  project = Project(folder=folder or os.getcwd())
81
81
  # We need to unpatch for our tests not to break
82
- if show_tokens or not prod or ctx.invoked_subcommand == "build":
82
+ if show_tokens or not prod or ctx.invoked_subcommand == "build" or build:
83
83
  __unpatch_click_output()
84
84
  else:
85
85
  __patch_click_output()
@@ -425,7 +425,7 @@ def __patch_click_output():
425
425
  if isinstance(substitution, str):
426
426
  msg = re.sub(pattern, substitution, str(msg))
427
427
  else:
428
- msg = re.sub(pattern, lambda m: substitution(m.group(0)), str(msg)) # noqa
428
+ msg = re.sub(pattern, lambda m: substitution(m.group(0)), str(msg)) # noqa: B023
429
429
  return msg
430
430
 
431
431
  def _obfuscate_echo(msg: Any, *args: Any, **kwargs: Any) -> None:
@@ -358,3 +358,36 @@ async def datasource_delete_rows(ctx, datasource_name, sql_condition, yes, wait,
358
358
  raise CLIDatasourceException(FeedbackManager.error_datasource_does_not_exist(datasource=datasource_name))
359
359
  except Exception as e:
360
360
  raise CLIDatasourceException(FeedbackManager.error_exception(error=e))
361
+
362
+
363
+ @datasource.command(
364
+ name="data",
365
+ context_settings=dict(
366
+ allow_extra_args=True,
367
+ ignore_unknown_options=True,
368
+ ),
369
+ )
370
+ @click.argument("datasource")
371
+ @click.option("--limit", type=int, default=5, help="Limit the number of rows to return")
372
+ @click.pass_context
373
+ @coro
374
+ async def datasource_data(ctx: Context, datasource: str, limit: int):
375
+ """Print data returned by an endpoint
376
+
377
+ Syntax: tb datasource data <datasource_name>
378
+ """
379
+
380
+ client: TinyB = ctx.ensure_object(dict)["client"]
381
+ try:
382
+ res = await client.query(f"SELECT * FROM {datasource} LIMIT {limit} FORMAT JSON")
383
+ except AuthNoTokenException:
384
+ raise
385
+ except Exception as e:
386
+ raise CLIDatasourceException(FeedbackManager.error_exception(error=str(e)))
387
+
388
+ if not res["data"]:
389
+ click.echo(FeedbackManager.info_no_rows())
390
+ else:
391
+ echo_safe_humanfriendly_tables_format_smart_table(
392
+ data=[d.values() for d in res["data"]], column_names=res["data"][0].keys()
393
+ )
@@ -40,20 +40,14 @@ async def get_tinybird_local_config(path: str, build: bool = False) -> CLIConfig
40
40
  if path:
41
41
  folder_hash = hashlib.sha256(path.encode()).hexdigest()
42
42
  user_client = config.get_client(host=TB_LOCAL_HOST, token=user_token)
43
- ws_name = f"Tinybird_Local_Build_{folder_hash}" if build else f"Tinybird_Local_{folder_hash}"
43
+ ws_name = config.get("name")
44
+ ws_name = f"Tinybird_Local_Build_{folder_hash}" if build else ws_name
44
45
  logging.debug(f"Workspace used for build: {ws_name}")
45
46
 
46
47
  user_workspaces = requests.get(f"{TB_LOCAL_HOST}/v0/user/workspaces?token={user_token}").json()
47
- local_workspaces = (
48
- [ws for ws in user_workspaces["workspaces"] if ws["name"].startswith(ws_name)]
49
- if user_workspaces.get("workspaces")
50
- else []
51
- )
52
- local_workspaces = sorted(local_workspaces, key=lambda x: x["name"])
53
-
54
- ws = None
55
- if len(local_workspaces) > 0:
56
- ws = local_workspaces[-1]
48
+ local_workspaces = user_workspaces.get("workspaces", [])
49
+
50
+ ws = next((ws for ws in local_workspaces if ws["name"] == ws_name), None)
57
51
 
58
52
  if not ws:
59
53
  await user_client.create_workspace(ws_name, template=None)
@@ -61,7 +61,7 @@ async def workspace_ls(ctx: Context) -> None:
61
61
  workspace["id"],
62
62
  workspace["role"],
63
63
  _get_workspace_plan_name(workspace["plan"]),
64
- current_main_workspace["id"] == workspace["id"],
64
+ current_main_workspace["name"] == workspace["name"],
65
65
  ]
66
66
  )
67
67
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tinybird
3
- Version: 0.0.1.dev46
3
+ Version: 0.0.1.dev48
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/cli/introduction.html
6
6
  Author: Tinybird
@@ -1,13 +1,13 @@
1
1
  tinybird/__cli__.py,sha256=esPl5QDTzuQgHe5FuxWLm-fURFigGGwjnYLh9GuWUw4,232
2
- tinybird/client.py,sha256=Qh7UH6mT7rBFwTZis9PBfi88GBWdAubYFvLxNPmhc9s,52110
2
+ tinybird/client.py,sha256=W5Xttnz0bzwqqVGNJJs-4Ca2AbtCMh3URuQYPJ5APsE,52013
3
3
  tinybird/config.py,sha256=ENRNyEMXHj_P882o31iFz0hTveziLabVRrxiWE5RRBE,6233
4
4
  tinybird/connectors.py,sha256=7Gjms7b5MAaBFGi3xytsJurCylprONpFcYrzp4Fw2Rc,15241
5
5
  tinybird/context.py,sha256=A3GBApac9xO6hrAMJ1s9dMrI_ou9aKF84CdEjtPddMk,1417
6
6
  tinybird/datatypes.py,sha256=XNypumfqNjsvLJ5iNXnbVHRvAJe0aQwI3lS6Cxox-e0,10979
7
7
  tinybird/feedback_manager.py,sha256=g1r9NcFfKXdk_13soaiTZLvdoUGleVfawl6Yfj3zmRw,67823
8
8
  tinybird/git_settings.py,sha256=Sw_8rGmribEFJ4Z_6idrVytxpFYk7ez8ei0qHULzs3E,3934
9
- tinybird/prompts.py,sha256=XpHaObqoKwIkx1qpAPVCupGwInJ6LirAy9OH9LCiubE,31856
10
- tinybird/sql.py,sha256=igHaRIeEREN5XYowwpIGYG8gDB5kn5p2cDNL1t8uc40,46168
9
+ tinybird/prompts.py,sha256=M9Gh6XO1utkGZYLB6dmW8iSHl_LxOy4m2On_THMCgEU,32645
10
+ tinybird/sql.py,sha256=LBi74GxhNAYTb6m2-KNGpAkguSKh7rcvBbERbE7nalA,46195
11
11
  tinybird/sql_template.py,sha256=GmMLAI10MTqjQo9qztuQHLRWs67teozsWDxUBdvkAn4,93668
12
12
  tinybird/sql_template_fmt.py,sha256=KUHdj5rYCYm_rKKdXYSJAE9vIyXUQLB0YSZnUXHeBlY,10196
13
13
  tinybird/sql_toolset.py,sha256=NEUj8Ro5x9XlfVLlGr6nWt9o7OLWVxlqs6TIpgumUNs,14678
@@ -15,17 +15,17 @@ tinybird/syncasync.py,sha256=IPnOx6lMbf9SNddN1eBtssg8vCLHMt76SuZ6YNYm-Yk,27761
15
15
  tinybird/tornado_template.py,sha256=FL85SMPq2dH4JqKovmSbaolGdEzwOO91NqOzqXo2Qr0,41863
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=wWCBkLJ6jQtVEUW3Uqk-4Vw4LjWoj5iFSAW3axQ9-iI,251
18
+ tinybird/tb/__cli__.py,sha256=1T9gM4V33CKJ7ISsAivZ7G4ve2JMT0lY6SqWdJEd0sg,251
19
19
  tinybird/tb/cli.py,sha256=X6zLCVI10wOxcu-USGfbp_jjz1cojH5X-9dL7D8c8aI,960
20
20
  tinybird/tb/modules/auth.py,sha256=EzRWFmwRkXNhUmRaruEVFLdkbUg8xMSix0cAWl5D4Jg,9029
21
21
  tinybird/tb/modules/build.py,sha256=lQXivX0kn3ej0CzeJK34ZFYBWAm2QB1JyPWciuH2c-Q,8060
22
22
  tinybird/tb/modules/cicd.py,sha256=xxXwy-QekJcG14kkJeGNl7LkHduhZXfvBZE8WrU6-t4,5351
23
- tinybird/tb/modules/cli.py,sha256=yBCyRs25Z1ucuX9LnjHkVIEaPoyM8WPBsp5J6t_TCO8,17608
23
+ tinybird/tb/modules/cli.py,sha256=KlG4ii--pqestUILJwSx9-e-D_X1MBllwojWpejg7s8,17623
24
24
  tinybird/tb/modules/common.py,sha256=TWcGJUgzJCQvzI1oMKbNdx-KTRmMGvB25BawHpsaV8Q,70610
25
25
  tinybird/tb/modules/config.py,sha256=mie3oMVTf5YOUFEiLs88P16U4LkJafJjSpjwyAkFHog,10979
26
26
  tinybird/tb/modules/copy.py,sha256=wxyxZg8BPiWDgbW5HXJKYQp7_EumBXmAilo3McbCQOo,5916
27
27
  tinybird/tb/modules/create.py,sha256=fqEI83cENISWgFnoNPlXNsNx_R0Im-zMaL1PfJDGWUQ,14263
28
- tinybird/tb/modules/datasource.py,sha256=hHt-rn4VWrQ4EWG797wnLqRhRP-3C4chAdk_vXxCmVI,13712
28
+ tinybird/tb/modules/datasource.py,sha256=TQ4wSag3CCw34d54FEXPJFGLQNYyNqv2nQbU6QT9uAE,14725
29
29
  tinybird/tb/modules/deployment.py,sha256=0e00lLMaNoVnONYdA51Zy9Sa_-4jWqePoYeFyHUn5PU,10241
30
30
  tinybird/tb/modules/endpoint.py,sha256=9arqN1JQCMb0Nd3-EJ7lukOYkGHHCpQmiiZpp5FqPhc,9432
31
31
  tinybird/tb/modules/exceptions.py,sha256=4A2sSjCEqKUMqpP3WI00zouCWW4uLaghXXLZBSw04mY,3363
@@ -35,7 +35,7 @@ tinybird/tb/modules/job.py,sha256=956Pj8BEEsiD2GZsV9RKKVM3I_CveOLgS82lykO5ukk,29
35
35
  tinybird/tb/modules/llm.py,sha256=AC0VSphTOM2t-v1_3NLvNN_FIbgMo4dTyMqIv5nniPo,835
36
36
  tinybird/tb/modules/llm_utils.py,sha256=nS9r4FAElJw8yXtmdYrx-rtI2zXR8qXfi1QqUDCfxvg,3469
37
37
  tinybird/tb/modules/local.py,sha256=x4xuCGVkoa8KLYGZEJnFUP8HUkKX05Frp_djRVjVjTs,5669
38
- tinybird/tb/modules/local_common.py,sha256=8Igj0Lxw5awEKGV87eJDg37UkhqLbozRcSr2dEnu_Ik,2954
38
+ tinybird/tb/modules/local_common.py,sha256=lUcMIqMJxygtpBEf-B57pTt68FpVz-W9YC5tBpnqOws,2744
39
39
  tinybird/tb/modules/login.py,sha256=0cS-f3MsQFHc6xjw8FRWJm4EJBH9C7Ri68EcO_tiwes,6508
40
40
  tinybird/tb/modules/materialization.py,sha256=HQKRTH6lkcYiDQJihbFqF_in58ezXG4ggZ_7Ywp_nUM,5738
41
41
  tinybird/tb/modules/mock.py,sha256=maaPY91mQx8m9x-1-2r9svljRO8VO8-uqD-71VfXBCU,5271
@@ -50,7 +50,7 @@ tinybird/tb/modules/test.py,sha256=s15UQg1TzYrI-9WUA7eYpQcx-BsCRTa6Oj71K-Zbcr0,1
50
50
  tinybird/tb/modules/token.py,sha256=sPdJoBE-6dd3Sd6W-prst7VOoJ0NbvP0uTaB6dXHs5s,12711
51
51
  tinybird/tb/modules/update.py,sha256=GWYfbKnB0yf4ywAUp8jItaZY0ltBnaIMcLSiPpwtbMc,6832
52
52
  tinybird/tb/modules/watch.py,sha256=Kredt5C7OOiI6YOivuR5QBdiDY4J_xLiwqHOROnfcsU,8591
53
- tinybird/tb/modules/workspace.py,sha256=bSV_aMK_05LvkT-Y0kj_stoGCQu8SgUie9BuMuKcRZs,6400
53
+ tinybird/tb/modules/workspace.py,sha256=sfT9QkoeFlN7ndUXxyImp4a7EFEHjY9MlGlldOViz0Y,6404
54
54
  tinybird/tb/modules/workspace_members.py,sha256=Ai6iCOzXX1zQ8q9iXIFSFHsBJlT-8Q28DaG5Ie-UweY,8726
55
55
  tinybird/tb/modules/datafile/build.py,sha256=VgQ0k-dBNE0hXdnxB12NW5I0XpxEosN2vaszboj3LZY,51045
56
56
  tinybird/tb/modules/datafile/build_common.py,sha256=IXl-Z51zUi1dypV7meNenX0iu2UmowNeqgG6WHyMHlk,4562
@@ -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.dev46.dist-info/METADATA,sha256=LrKDawiKiRC2LI8bb0GTS9ujjyOTKUJEfu6PT1lunXM,2482
79
- tinybird-0.0.1.dev46.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
80
- tinybird-0.0.1.dev46.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
81
- tinybird-0.0.1.dev46.dist-info/top_level.txt,sha256=pgw6AzERHBcW3YTi2PW4arjxLkulk2msOz_SomfOEuc,45
82
- tinybird-0.0.1.dev46.dist-info/RECORD,,
78
+ tinybird-0.0.1.dev48.dist-info/METADATA,sha256=onz2vfZ9IkLQVpwSoaCIuUPbnzAsqFH1FIoe9wRDceg,2482
79
+ tinybird-0.0.1.dev48.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
80
+ tinybird-0.0.1.dev48.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
81
+ tinybird-0.0.1.dev48.dist-info/top_level.txt,sha256=pgw6AzERHBcW3YTi2PW4arjxLkulk2msOz_SomfOEuc,45
82
+ tinybird-0.0.1.dev48.dist-info/RECORD,,