tinybird-cli 6.1.1.dev0__tar.gz → 6.2.1.dev0__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.
Files changed (47) hide show
  1. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/PKG-INFO +6 -1
  2. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/__cli__.py +2 -2
  3. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/ch_utils/engine.py +2 -2
  4. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/client.py +4 -4
  5. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/datafile_common.py +13 -14
  6. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/sql.py +3 -3
  7. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/sql_template.py +1 -1
  8. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/sql_toolset.py +1 -1
  9. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/tb_cli_modules/branch.py +1 -3
  10. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/tb_cli_modules/cicd.py +3 -3
  11. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/tb_cli_modules/cli.py +2 -2
  12. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/tb_cli_modules/common.py +1 -1
  13. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/tb_cli_modules/datasource.py +1 -3
  14. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/tb_cli_modules/tinyunit/tinyunit.py +2 -2
  15. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/tornado_template.py +1 -1
  16. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird_cli.egg-info/PKG-INFO +6 -1
  17. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/setup.cfg +0 -0
  18. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/ch_utils/constants.py +0 -0
  19. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/check_pypi.py +0 -0
  20. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/config.py +0 -0
  21. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/context.py +0 -0
  22. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/datatypes.py +0 -0
  23. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/feedback_manager.py +0 -0
  24. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/git_settings.py +0 -0
  25. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/sql_template_fmt.py +0 -0
  26. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/syncasync.py +0 -0
  27. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/tb_cli.py +0 -0
  28. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/tb_cli_modules/auth.py +0 -0
  29. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/tb_cli_modules/config.py +0 -0
  30. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/tb_cli_modules/connection.py +0 -0
  31. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/tb_cli_modules/exceptions.py +0 -0
  32. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/tb_cli_modules/fmt.py +0 -0
  33. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/tb_cli_modules/job.py +0 -0
  34. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/tb_cli_modules/pipe.py +0 -0
  35. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/tb_cli_modules/regions.py +0 -0
  36. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/tb_cli_modules/tag.py +0 -0
  37. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/tb_cli_modules/telemetry.py +0 -0
  38. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/tb_cli_modules/test.py +0 -0
  39. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/tb_cli_modules/tinyunit/tinyunit_lib.py +0 -0
  40. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/tb_cli_modules/token.py +0 -0
  41. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/tb_cli_modules/workspace.py +0 -0
  42. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird/tb_cli_modules/workspace_members.py +0 -0
  43. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird_cli.egg-info/SOURCES.txt +0 -0
  44. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird_cli.egg-info/dependency_links.txt +0 -0
  45. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird_cli.egg-info/entry_points.txt +0 -0
  46. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird_cli.egg-info/requires.txt +0 -0
  47. {tinybird_cli-6.1.1.dev0 → tinybird_cli-6.2.1.dev0}/tinybird_cli.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: tinybird_cli
3
- Version: 6.1.1.dev0
3
+ Version: 6.2.1.dev0
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/cli
6
6
  Author: Tinybird
@@ -43,6 +43,11 @@ The Tinybird command-line tool allows you to use all the Tinybird functionality
43
43
  Changelog
44
44
  ----------
45
45
 
46
+ 6.2.0
47
+ ***********
48
+
49
+ - `Fixed` `tb push` with `SHARED_WITH` now uses the user token to fetch workspaces, avoiding failures caused by using the wrong token
50
+
46
51
  6.0.2
47
52
  ***********
48
53
 
@@ -4,5 +4,5 @@ __description__ = 'Tinybird Command Line Tool'
4
4
  __url__ = 'https://www.tinybird.co/docs/cli'
5
5
  __author__ = 'Tinybird'
6
6
  __author_email__ = 'support@tinybird.co'
7
- __version__ = '6.1.1.dev0'
8
- __revision__ = 'cdfa249'
7
+ __version__ = '6.2.1.dev0'
8
+ __revision__ = '0284e51'
@@ -298,7 +298,7 @@ class EngineOption:
298
298
  self.required = required
299
299
  self.default_value = default_value
300
300
  self.is_valid = is_valid
301
- self.tb_param = tb_param if tb_param else "_".join(["engine", name])
301
+ self.tb_param = tb_param or "_".join(["engine", name])
302
302
 
303
303
 
304
304
  class EngineParam:
@@ -314,7 +314,7 @@ class EngineParam:
314
314
  self.required = required
315
315
  self.default_value = default_value
316
316
  self.is_valid = is_valid
317
- self.tb_param = tb_param if tb_param else self.build_engine_param_name(name)
317
+ self.tb_param = tb_param or self.build_engine_param_name(name)
318
318
 
319
319
  @staticmethod
320
320
  def build_engine_param_name(name: str):
@@ -118,7 +118,7 @@ class TinyB:
118
118
  ) -> Response:
119
119
  url = f"{self.host.strip('/')}/{endpoint.strip('/')}"
120
120
 
121
- token_to_use = use_token if use_token else self.token
121
+ token_to_use = use_token or self.token
122
122
  if token_to_use:
123
123
  url += ("&" if "?" in endpoint else "?") + "token=" + token_to_use
124
124
  if self.version:
@@ -191,7 +191,7 @@ class TinyB:
191
191
  use_token: Optional[str] = None,
192
192
  **kwargs,
193
193
  ):
194
- token_to_use = use_token if use_token else self.token
194
+ token_to_use = use_token or self.token
195
195
  response = await self._req_raw(endpoint, data, files, method, retries, use_token, **kwargs)
196
196
 
197
197
  if response.status_code == 403:
@@ -565,8 +565,8 @@ class TinyB:
565
565
  async def pipes(self, branch=None, dependencies: bool = False, node_attrs=None, attrs=None) -> List[Dict[str, Any]]:
566
566
  params = {
567
567
  "dependencies": "true" if dependencies else "false",
568
- "attrs": attrs if attrs else "",
569
- "node_attrs": node_attrs if node_attrs else "",
568
+ "attrs": attrs or "",
569
+ "node_attrs": node_attrs or "",
570
570
  }
571
571
  response = await self._req(f"/v0/pipes?{urlencode(params)}")
572
572
  pipes = response["pipes"]
@@ -445,10 +445,12 @@ class CLIGitRelease:
445
445
  # not expected suffixes
446
446
  return list(
447
447
  filter(
448
- lambda d: d.change_type in [c.value for c in self.ChangeType]
449
- and d.a_path
450
- and d.a_path not in self.NO_DATAFILES_PATHS
451
- and Path(d.a_path).resolve().suffix in self.DATAFILES_SUFFIXES,
448
+ lambda d: (
449
+ d.change_type in [c.value for c in self.ChangeType]
450
+ and d.a_path
451
+ and d.a_path not in self.NO_DATAFILES_PATHS
452
+ and Path(d.a_path).resolve().suffix in self.DATAFILES_SUFFIXES
453
+ ),
452
454
  self.diff(current_ws_commit),
453
455
  )
454
456
  )
@@ -533,9 +535,7 @@ class CLIGitRelease:
533
535
  async def update_release(
534
536
  self, tb_client: TinyB, current_ws: Dict[str, Any], commit: Optional[str] = None
535
537
  ) -> Dict[str, Any]:
536
- release = await tb_client.workspace_commit_update(
537
- current_ws["id"], commit if commit else self.head().commit.hexsha
538
- )
538
+ release = await tb_client.workspace_commit_update(current_ws["id"], commit or self.head().commit.hexsha)
539
539
  return release
540
540
 
541
541
 
@@ -3145,24 +3145,23 @@ async def share_and_unshare_datasource(
3145
3145
  datasource_name = datasource.get("name", "")
3146
3146
  datasource_id = datasource.get("id", "")
3147
3147
  workspaces: List[Dict[str, Any]]
3148
+ # We duplicate the client to use the user_token in workspace discovery and sharing operations.
3149
+ user_client: TinyB = deepcopy(client)
3150
+ user_client.token = user_token
3148
3151
 
3149
3152
  # In case we are pushing to a branch, we don't share the datasource
3150
3153
  # FIXME: Have only once way to get the current workspace
3151
3154
  if current_ws:
3152
- # Force to get all the workspaces the user can access
3153
3155
  workspace = current_ws
3154
- workspaces = (await client.user_workspaces()).get("workspaces", [])
3155
3156
  else:
3156
3157
  workspace = await client.user_workspace_branches()
3157
- workspaces = workspace.get("workspaces", [])
3158
3158
 
3159
3159
  if workspace.get("is_branch", False):
3160
3160
  click.echo(FeedbackManager.info_skipping_sharing_datasources_branch(datasource=datasource["name"]))
3161
3161
  return
3162
3162
 
3163
- # We duplicate the client to use the user_token
3164
- user_client: TinyB = deepcopy(client)
3165
- user_client.token = user_token
3163
+ # Use the user token for workspace discovery, as workspace/admin tokens may not list all targets.
3164
+ workspaces = (await user_client.user_workspaces()).get("workspaces", [])
3166
3165
  if not workspaces_current_shared_with:
3167
3166
  for workspace_to_share in workspaces_to_share:
3168
3167
  w: Optional[Dict[str, Any]] = next((w for w in workspaces if w["name"] == workspace_to_share), None)
@@ -5029,7 +5028,7 @@ async def format_engine(
5029
5028
  file_parts.append(DATAFILE_NEW_LINE)
5030
5029
  for arg in sorted(node["engine"].get("args", [])):
5031
5030
  elem = ", ".join([x.strip() for x in arg[1].split(",")])
5032
- file_parts.append(f"ENGINE_{arg[0].upper()} {elem if elem else empty}")
5031
+ file_parts.append(f"ENGINE_{arg[0].upper()} {elem or empty}")
5033
5032
  file_parts.append(DATAFILE_NEW_LINE)
5034
5033
  file_parts.append(DATAFILE_NEW_LINE)
5035
5034
  return file_parts
@@ -821,11 +821,11 @@ def _parse_table_structure(schema: str) -> List[Dict[str, Any]]:
821
821
  nullable = column["type"].lower().startswith("nullable")
822
822
  column["type"] = column["type"] if not nullable else column["type"][len("Nullable(") : -1] # ')'
823
823
  column["nullable"] = nullable
824
- column["codec"] = column["codec"] if column["codec"] else None
824
+ column["codec"] = column["codec"] or None
825
825
  column["name"] = column["name"]
826
826
  column["normalized_name"] = column["name"]
827
- column["jsonpath"] = column["jsonpath"] if column["jsonpath"] else None
828
- default_value = column["default_value"] if column["default_value"] else None
827
+ column["jsonpath"] = column["jsonpath"] or None
828
+ default_value = column["default_value"] or None
829
829
  if nullable and default_value and default_value.lower() == "default null":
830
830
  default_value = None
831
831
  column["default_value"] = default_value
@@ -199,7 +199,7 @@ class Comment:
199
199
 
200
200
  class Placeholder:
201
201
  def __init__(self, name=None, line=None):
202
- self.name = name if name else "__no_value__"
202
+ self.name = name or "__no_value__"
203
203
  self.line = line or "unknown"
204
204
 
205
205
  def __str__(self):
@@ -539,7 +539,7 @@ def replace_tables(
539
539
  if (
540
540
  dependent_table[2]
541
541
  and dependent_table[2] not in _enabled_table_functions
542
- and not (dependent_table[2] in ["cluster"] and replacement[0] == VALID_REMOTE)
542
+ and not (dependent_table[2] == "cluster" and replacement[0] == VALID_REMOTE)
543
543
  ):
544
544
  raise InvalidFunction(table_function_name=dependent_table[2])
545
545
  if dependent_table[0] or dependent_table[1]:
@@ -1014,9 +1014,7 @@ async def datasource_copy_from_main(datasource_name: str, sql: str, sql_from_mai
1014
1014
 
1015
1015
  client = config.get_client()
1016
1016
 
1017
- response = await client.datasource_query_copy(
1018
- datasource_name, sql if sql else f"SELECT * FROM main.{datasource_name}"
1019
- )
1017
+ response = await client.datasource_query_copy(datasource_name, sql or f"SELECT * FROM main.{datasource_name}")
1020
1018
  if "job" not in response:
1021
1019
  raise CLIBranchException(response)
1022
1020
  job_id = response["job"]["job_id"]
@@ -405,8 +405,8 @@ async def init_cicd(
405
405
  ):
406
406
  provider = ask_provider_interactively()
407
407
  if provider:
408
- path = path if path else getcwd()
409
- data_project_dir = data_project_dir if data_project_dir else "."
408
+ path = path or getcwd()
409
+ data_project_dir = data_project_dir or "."
410
410
  generator = CICDGeneratorBase.build_generator(provider)
411
411
  workspace_info = await client.workspace_info()
412
412
  token = await client.get_token_by_name("admin token")
@@ -426,7 +426,7 @@ async def init_cicd(
426
426
 
427
427
 
428
428
  async def check_cicd_exists(path: Optional[str] = None) -> Optional[Provider]:
429
- path = path if path else getcwd()
429
+ path = path or getcwd()
430
430
  for provider in Provider:
431
431
  generator = CICDGeneratorBase.build_generator(provider.name)
432
432
  if generator.is_already_generated(path):
@@ -229,7 +229,7 @@ async def init(
229
229
  config = CLIConfig.get_project_config()
230
230
  if config.get("token") is None:
231
231
  raise AuthNoTokenException
232
- folder = folder if folder else getcwd()
232
+ folder = folder or getcwd()
233
233
 
234
234
  workspaces: List[Dict[str, Any]] = (await client.user_workspaces_and_branches()).get("workspaces", [])
235
235
  current_ws: Dict[str, Any] = next(
@@ -644,7 +644,7 @@ async def pull(ctx: Context, folder: str, auto: bool, match: Optional[str], forc
644
644
  """Retrieve latest versions for project files from Tinybird."""
645
645
 
646
646
  client = ctx.ensure_object(dict)["client"]
647
- folder = folder if folder else getcwd()
647
+ folder = folder or getcwd()
648
648
 
649
649
  return await folder_pull(client, folder, auto, match, force, fmt=fmt)
650
650
 
@@ -1601,7 +1601,7 @@ async def wait_job(
1601
1601
  if "progress_percentage" in res:
1602
1602
  progress_bar.update(int(round(res["progress_percentage"])) - progress_bar.pos)
1603
1603
  elif res["status"] != "working":
1604
- progress_bar.update(progress_bar.length if progress_bar.length else 0)
1604
+ progress_bar.update(progress_bar.length or 0)
1605
1605
 
1606
1606
  try:
1607
1607
  # TODO: Simplify this as it's not needed to use two functions for
@@ -728,9 +728,7 @@ async def datasource_copy_from_main(
728
728
  click.echo(FeedbackManager.error_exception(error="Use --sql or --sql-from-main"))
729
729
  return
730
730
 
731
- response = await client.datasource_query_copy(
732
- datasource_name, sql if sql else f"SELECT * FROM main.{datasource_name}"
733
- )
731
+ response = await client.datasource_query_copy(datasource_name, sql or f"SELECT * FROM main.{datasource_name}")
734
732
  if "job" not in response:
735
733
  raise Exception(response)
736
734
  job_id = response["job"]["job_id"]
@@ -226,7 +226,7 @@ async def run_test_file(tb_client: TinyB, file: str) -> List[TestResult]:
226
226
  pipe = test_case.pipe.name
227
227
  params = test_case.pipe.params
228
228
  try:
229
- sql = test_case.sql if test_case.sql else None
229
+ sql = test_case.sql or None
230
230
  test_response = await tb_client.pipe_data(pipe, format="json", params=params, sql=sql)
231
231
  results.append(
232
232
  TestResult(
@@ -263,7 +263,7 @@ def test_run_summary(results: List[TestSummaryResults], only_fail: bool = False,
263
263
  total_counts[test.status] = total_counts.get(test.status, 0) + 1
264
264
 
265
265
  # Skip the PASS tests if we only want the failed ones
266
- if only_fail and test.status in [PASS]:
266
+ if only_fail and test.status == PASS:
267
267
  continue
268
268
 
269
269
  summary.append(
@@ -283,7 +283,7 @@ class Template:
283
283
  .. versionchanged:: 4.3
284
284
  Added ``whitespace`` parameter; deprecated ``compress_whitespace``.
285
285
  """
286
- name = name if name else "<string>"
286
+ name = name or "<string>"
287
287
  self.name = escape.native_str(name)
288
288
 
289
289
  if compress_whitespace is not _UNSET:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: tinybird_cli
3
- Version: 6.1.1.dev0
3
+ Version: 6.2.1.dev0
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/cli
6
6
  Author: Tinybird
@@ -43,6 +43,11 @@ The Tinybird command-line tool allows you to use all the Tinybird functionality
43
43
  Changelog
44
44
  ----------
45
45
 
46
+ 6.2.0
47
+ ***********
48
+
49
+ - `Fixed` `tb push` with `SHARED_WITH` now uses the user token to fetch workspaces, avoiding failures caused by using the wrong token
50
+
46
51
  6.0.2
47
52
  ***********
48
53