tinybird 4.6.2.dev0__py3-none-any.whl → 4.6.3.dev0__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.
File without changes
@@ -0,0 +1,9 @@
1
+ from enum import Enum
2
+
3
+
4
+ class DataBranchMode(Enum):
5
+ LAST_PARTITION = "last_partition"
6
+ ALL_PARTITIONS = "all_partitions"
7
+
8
+
9
+ DATA_BRANCH_MODES = [a.value for a in DataBranchMode]
tinybird/tb/__cli__.py CHANGED
@@ -4,5 +4,5 @@ __description__ = 'Tinybird Command Line Tool'
4
4
  __url__ = 'https://www.tinybird.co/docs/forward/commands'
5
5
  __author__ = 'Tinybird'
6
6
  __author_email__ = 'support@tinybird.co'
7
- __version__ = '4.6.2.dev0'
8
- __revision__ = '41da03f'
7
+ __version__ = '4.6.3.dev0'
8
+ __revision__ = '78e5916'
tinybird/tb/client.py CHANGED
@@ -772,14 +772,11 @@ class TinyB:
772
772
  branch_name: str,
773
773
  last_partition: Optional[bool],
774
774
  all: Optional[bool],
775
- ignore_datasources: Optional[List[str]],
776
775
  ):
777
776
  params = {
778
777
  "name": branch_name,
779
778
  "data": LAST_PARTITION if last_partition else (ALL_PARTITIONS if all else ""),
780
779
  }
781
- if ignore_datasources:
782
- params["ignore_datasources"] = ",".join(ignore_datasources)
783
780
  return self._req(f"/v1/environments?{urlencode(params)}", method="POST", data=b"")
784
781
 
785
782
  def branch_workspace_data(
@@ -93,8 +93,14 @@ def branch_ls(sort: bool) -> None:
93
93
  help="Wait for data branch jobs to finish, showing a progress bar. Disabled by default.",
94
94
  )
95
95
  def create_branch(branch_name: Optional[str], last_partition: bool, ignore_datasources: List[str], wait: bool) -> None:
96
+ if ignore_datasources:
97
+ click.echo(
98
+ FeedbackManager.warning_deprecated(
99
+ warning="--ignore-datasource is no longer supported for `tb branch create` and will be ignored."
100
+ )
101
+ )
96
102
  normalized_branch_name = ensure_valid_workspace_name(branch_name) if branch_name else branch_name
97
- create_workspace_branch(normalized_branch_name, last_partition, False, list(ignore_datasources), wait)
103
+ create_workspace_branch(normalized_branch_name, last_partition, False, wait)
98
104
 
99
105
 
100
106
  @branch.command(name="rm", short_help="Removes an branch from the workspace. It can't be recovered.")
@@ -182,6 +188,12 @@ def clear_branch(
182
188
  yes: bool,
183
189
  ) -> None:
184
190
  """Clear a branch by deleting and recreating it."""
191
+ if ignore_datasources:
192
+ click.echo(
193
+ FeedbackManager.warning_deprecated(
194
+ warning="--ignore-datasource is no longer supported for `tb branch clear` and will be ignored."
195
+ )
196
+ )
185
197
  config = CLIConfig.get_project_config()
186
198
  _ = try_update_config_with_remote(config, only_if_needed=True)
187
199
 
@@ -227,7 +239,7 @@ def clear_branch(
227
239
  client = config.get_client(token=current_main_workspace.get("token"))
228
240
  try:
229
241
  client.delete_branch(workspace_to_clear["id"])
230
- response = client.create_workspace_branch(branch_name, last_partition, False, list(ignore_datasources))
242
+ response = client.create_workspace_branch(branch_name, last_partition, False)
231
243
  if wait and "job" in response:
232
244
  job_id = response["job"]["job_id"]
233
245
  job_url = response["job"]["job_url"]
@@ -21,6 +21,7 @@ import humanfriendly
21
21
  import requests
22
22
  from click import Context
23
23
 
24
+ from tinybird.iterating.data_branch_modes import DataBranchMode
24
25
  from tinybird.tb import __cli__
25
26
  from tinybird.tb.check_pypi import CheckPypi
26
27
  from tinybird.tb.client import (
@@ -307,6 +308,37 @@ def get_dev_mode_from_tinybird_config(start_dir: str) -> Optional[str]:
307
308
  return mode
308
309
 
309
310
 
311
+ def _resolve_branch_data_mode(raw: Dict[str, Any]) -> Tuple[Optional[str], bool]:
312
+ if "branch_data_on_create" in raw:
313
+ raise CLIException(
314
+ FeedbackManager.error(message="`branch_data_on_create` has been renamed to `branch_data_mode`.")
315
+ )
316
+
317
+ value = raw.get("branch_data_mode")
318
+ if value is None:
319
+ return DataBranchMode.LAST_PARTITION.value, False
320
+ if not isinstance(value, str):
321
+ raise CLIException(FeedbackManager.error(message="branch_data_mode must be a string."))
322
+
323
+ mode = value.strip().lower()
324
+ if not mode:
325
+ return DataBranchMode.LAST_PARTITION.value, False
326
+ if mode != DataBranchMode.LAST_PARTITION.value:
327
+ allowed = DataBranchMode.LAST_PARTITION.value
328
+ raise CLIException(
329
+ FeedbackManager.error(message=f"Invalid branch_data_mode '{value}'. Allowed values are: {allowed}.")
330
+ )
331
+ return mode, True
332
+
333
+
334
+ def get_branch_data_mode_from_tinybird_config(start_dir: str) -> Tuple[Optional[str], bool]:
335
+ _, raw = _read_project_json_config(start_dir)
336
+ if not isinstance(raw, dict):
337
+ return DataBranchMode.LAST_PARTITION.value, False
338
+
339
+ return _resolve_branch_data_mode(raw)
340
+
341
+
310
342
  def find_project_config_file(start_dir: Path) -> Optional[Path]:
311
343
  current = start_dir.resolve()
312
344
  while True:
@@ -653,6 +685,17 @@ def cli(
653
685
  if tinybird_dev_mode:
654
686
  config["dev_mode"] = tinybird_dev_mode
655
687
 
688
+ branch_data_mode, branch_data_mode_explicit = get_branch_data_mode_from_tinybird_config(os.getcwd())
689
+ if branch_data_mode:
690
+ config["branch_data_mode"] = branch_data_mode
691
+ if branch_data_mode_explicit and config.get("dev_mode") == DEV_MODE_LOCAL:
692
+ click.echo(
693
+ FeedbackManager.warning(
694
+ message="branch_data_mode is set in tinybird.config.json but dev_mode='local'. "
695
+ "Branch data settings only apply to cloud branches."
696
+ )
697
+ )
698
+
656
699
  # Resolve project folder from tinybird.config.json (preferred) or legacy .tinyb cwd.
657
700
  folder_from_config = get_project_folder_from_tinybird_config(os.getcwd())
658
701
  if folder_from_config:
@@ -754,6 +797,12 @@ def cli(
754
797
  FeedbackManager.gray(message=f"Using dev_mode={dev_mode}. Running deploy against Tinybird Cloud main.")
755
798
  )
756
799
 
800
+ _auto_create_branch = (
801
+ not explicit_env_selector
802
+ and ctx.invoked_subcommand == "build"
803
+ and dev_mode == DEV_MODE_BRANCH
804
+ and bool(effective_branch)
805
+ )
757
806
  client = create_ctx_client(
758
807
  ctx,
759
808
  config,
@@ -763,12 +812,8 @@ def cli(
763
812
  project_type=project_type,
764
813
  show_warnings=version_warning,
765
814
  branch=effective_branch,
766
- create_branch_if_missing=(
767
- not explicit_env_selector
768
- and ctx.invoked_subcommand == "build"
769
- and dev_mode == DEV_MODE_BRANCH
770
- and bool(effective_branch)
771
- ),
815
+ create_branch_if_missing=_auto_create_branch,
816
+ branch_data_mode=config.get("branch_data_mode") if _auto_create_branch else None,
772
817
  )
773
818
 
774
819
  if client:
@@ -1052,6 +1097,7 @@ def create_ctx_client(
1052
1097
  show_warnings: bool = True,
1053
1098
  branch: Optional[str] = None,
1054
1099
  create_branch_if_missing: bool = False,
1100
+ branch_data_mode: Optional[str] = None,
1055
1101
  ):
1056
1102
  commands_without_ctx_client = [
1057
1103
  "auth",
@@ -1103,6 +1149,7 @@ def create_ctx_client(
1103
1149
  branch=branch,
1104
1150
  create_branch_if_missing=create_branch_if_missing,
1105
1151
  request_from=project_type,
1152
+ branch_data_mode=branch_data_mode,
1106
1153
  )
1107
1154
  ctx.ensure_object(dict)["branch_created"] = branch_created
1108
1155
  return client
@@ -33,6 +33,7 @@ from click._termui_impl import ProgressBar
33
33
  from humanfriendly.tables import format_pretty_table
34
34
  from thefuzz import process
35
35
 
36
+ from tinybird.iterating.data_branch_modes import DataBranchMode
36
37
  from tinybird.tb.client import (
37
38
  AuthException,
38
39
  AuthNoTokenException,
@@ -369,6 +370,7 @@ def _get_tb_client(
369
370
  branch: Optional[str] = None,
370
371
  create_branch_if_missing: bool = False,
371
372
  request_from: Optional[str] = None,
373
+ branch_data_mode: Optional[str] = None,
372
374
  ) -> Tuple[TinyB, bool]:
373
375
  """Returns a tuple of (client, branch_created)."""
374
376
  resolved_request_from = request_from
@@ -390,11 +392,13 @@ def _get_tb_client(
390
392
  workspaces = cloud_client.user_workspaces_and_branches(version="v1")
391
393
  workspace = next((w for w in workspaces.get("workspaces", []) if w.get("name") == branch), None)
392
394
  if not workspace and create_branch_if_missing:
395
+ _last_partition = branch_data_mode == DataBranchMode.LAST_PARTITION.value
396
+ mode_label = branch_data_mode or "no data"
397
+ click.echo(FeedbackManager.gray(message=f"Creating branch '{branch}' with data_mode={mode_label}..."))
393
398
  response = cloud_client.create_workspace_branch(
394
399
  branch_name=branch,
395
- last_partition=False,
400
+ last_partition=_last_partition,
396
401
  all=False,
397
- ignore_datasources=None,
398
402
  )
399
403
  job_data = response.get("job") if isinstance(response, dict) else None
400
404
  if isinstance(job_data, dict):
@@ -2464,7 +2468,6 @@ def create_workspace_branch(
2464
2468
  branch_name: Optional[str],
2465
2469
  last_partition: bool,
2466
2470
  all: bool,
2467
- ignore_datasources: Optional[List[str]],
2468
2471
  wait: Optional[bool],
2469
2472
  ) -> None:
2470
2473
  """
@@ -2490,7 +2493,6 @@ def create_workspace_branch(
2490
2493
  branch_name,
2491
2494
  last_partition,
2492
2495
  all,
2493
- ignore_datasources,
2494
2496
  )
2495
2497
  assert isinstance(response, dict)
2496
2498
 
@@ -44,7 +44,6 @@ def _create_preview_branch(cloud_client: TinyB, preview_branch_name: str) -> Non
44
44
  branch_name=preview_branch_name,
45
45
  last_partition=False,
46
46
  all=False,
47
- ignore_datasources=None,
48
47
  )
49
48
 
50
49
  job_data = response.get("job") if isinstance(response, dict) else None
@@ -679,7 +679,6 @@ async def create_workspace_branch(
679
679
  branch_name: Optional[str],
680
680
  last_partition: bool,
681
681
  all: bool,
682
- ignore_datasources: Optional[List[str]],
683
682
  wait: Optional[bool],
684
683
  ) -> None:
685
684
  """
@@ -703,7 +702,6 @@ async def create_workspace_branch(
703
702
  branch_name,
704
703
  last_partition,
705
704
  all,
706
- ignore_datasources,
707
705
  )
708
706
  assert isinstance(response, dict)
709
707
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: tinybird
3
- Version: 4.6.2.dev0
3
+ Version: 4.6.3.dev0
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/forward/commands
6
6
  Author: Tinybird
@@ -52,6 +52,14 @@ The Tinybird command-line tool allows you to use all the Tinybird functionality
52
52
  Changelog
53
53
  ----------
54
54
 
55
+ 4.6.2
56
+ *******
57
+
58
+ - `Changed` Replaced `branch_data_on_create` with `branch_data_mode` in CLI project config handling. The legacy key now raises an explicit migration error.
59
+ - `Changed` `branch_data_mode` now only accepts `last_partition` as a user-facing value.
60
+ - `Fixed` `dev_mode=local` now warns about branch data mode only when `branch_data_mode` is explicitly set in `tinybird.config.json`.
61
+ - `Changed` `tb branch create` and `tb branch clear` now show a deprecation warning (instead of failing) when `--ignore-datasource` is provided, and continue by ignoring that flag.
62
+
55
63
  4.6.1
56
64
  *******
57
65
 
@@ -17,17 +17,19 @@ tinybird/datafile/exceptions.py,sha256=8rw2umdZjtby85QbuRKFO5ETz_eRHwUY5l7eHsy1w
17
17
  tinybird/datafile/parse_connection.py,sha256=GxmGp_XnWbDZPDbh_PBxitlIMqZRYfDwxMBw-JQBp1g,1890
18
18
  tinybird/datafile/parse_datasource.py,sha256=yd58HrUF4yNJXLn6OsvKGpZJpvrcjLGAeJG1lgBe_zk,1891
19
19
  tinybird/datafile/parse_pipe.py,sha256=-9bbgVuiWRyDYydrLVflDBt8GstZotMy6dklsrc6MUY,3859
20
- tinybird/tb/__cli__.py,sha256=ghH8YiRtCEUACEVbZgch3RDH11g2M0Pxuf6s4Y3opmI,245
20
+ tinybird/iterating/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
+ tinybird/iterating/data_branch_modes.py,sha256=5YuDa-gr8mKwmES8Xro6TRKbQtaOtIw4GbC606Qhu3o,184
22
+ tinybird/tb/__cli__.py,sha256=eh_8cfZSX_SsoNyJmyjPZu23B2buyeF98MGawLnIsqU,245
21
23
  tinybird/tb/check_pypi.py,sha256=Gp0HkHHDFMSDL6nxKlOY51z7z1Uv-2LRexNTZSHHGmM,552
22
24
  tinybird/tb/cli.py,sha256=IjiGfNIpxSxi1odK1kMj9s8lEhx3sAUgGA263XdmyR0,1119
23
- tinybird/tb/client.py,sha256=SEp4-XoRDXMEBj2_C1jfJKtZOkbiwNIYERPQN6uoolI,55646
25
+ tinybird/tb/client.py,sha256=nrNFU8pLqzQbKqU4b2Jm1PQRthFrpFzDsetE84o-1k0,55494
24
26
  tinybird/tb/config.py,sha256=CGCfBbCMlmVcBHQ0IMGc2IE4O2-1tZEPyD564JZoTbw,5659
25
- tinybird/tb/modules/branch.py,sha256=QxcMPc_4xhw8WPz85YZ5L6SQZY-lZrF3CleujBEBJQU,9746
27
+ tinybird/tb/modules/branch.py,sha256=U50nj2kZllCkOHQfJWQ-YQ260pvlcssgStMSovmqMiU,10157
26
28
  tinybird/tb/modules/build.py,sha256=bGFoFppR_UbGUMDWFGDzfJ4nT3CGFwzCzl2o4OpwR2o,10420
27
29
  tinybird/tb/modules/build_common.py,sha256=o04aeaoyGTnwhR0cEXAgQzc7SJya97YECoEihsi4SyU,24979
28
30
  tinybird/tb/modules/cicd.py,sha256=IO4qqsoLRXcubALb7vx_QnRpg3zIIxfaVO9bGomlESY,8267
29
- tinybird/tb/modules/cli.py,sha256=n_B9EapB1eYOWOfRHN1Jefip6LcmYrkLDIz5GoGCJhA,41889
30
- tinybird/tb/modules/common.py,sha256=5oyFPfrM4ct9-U3AmhtAKXTPUWw5eDoX55jxF3TK5H0,95286
31
+ tinybird/tb/modules/cli.py,sha256=4Z0lqbGjikdO0L-wJDttFdGnT5aHrjAHnoIjkOPhXbc,43889
32
+ tinybird/tb/modules/common.py,sha256=2bISIRdjHLc8SNty6vih-zCjRCssLW8WEM7r08uZcMA,95534
31
33
  tinybird/tb/modules/config.py,sha256=Z47lMZxFeX68b62bTzgj9379zn-9eT4cPbrcMJ_xTGQ,11431
32
34
  tinybird/tb/modules/connection.py,sha256=HwHn0YgwqcKEYCLr2OqDzJzAUFd65Wv8MZiSUw_TLII,18452
33
35
  tinybird/tb/modules/connection_dynamodb.py,sha256=j1Z0tXrlTZJU1LJ0rEzv3ezo0pS4PJJKfVjUTGrH3nk,9473
@@ -59,7 +61,7 @@ tinybird/tb/modules/logs.py,sha256=uSQi_A6QIFOjAoj1h8XOI_51AQ3uk5UEg2TjYbZxDJA,2
59
61
  tinybird/tb/modules/materialization.py,sha256=SaomNeaAzLWtcnsZdetYBxEq0ihY1cRzh23n3Z1P_c4,5643
60
62
  tinybird/tb/modules/open.py,sha256=ddABA4guIrBhrCKXYpkH4cfiAcFOG2B1eVePk5BEXto,1799
61
63
  tinybird/tb/modules/pipe.py,sha256=xPKtezhnWZ6k_g82r4XpgKslofhuIxb_PvynH4gdUzI,2393
62
- tinybird/tb/modules/preview.py,sha256=712lVUgFE2a1qCmBGVrU_JyiaRyo5-S0dypcBxmKlnM,4659
64
+ tinybird/tb/modules/preview.py,sha256=SuXpwlag02Mz4m1eJ_HVzBkeFodzq4r0JxiiKlNcD1I,4626
63
65
  tinybird/tb/modules/project.py,sha256=sb-561KV6RQiYrq4nHSULFNMOodq8Ywxwp6Dfogs0KY,9171
64
66
  tinybird/tb/modules/project_commands.py,sha256=t7h5JJWNA5eGth_Nrj0fak5B9eyVPGeDluF-41OBkhw,1877
65
67
  tinybird/tb/modules/py_project.py,sha256=DE3N-GPhcvVulELMINZQmw0zG6xZ1YeVkyJt1vn2E4I,7799
@@ -91,15 +93,14 @@ tinybird/tb/modules/datafile/pipe_checker.py,sha256=dxsCQoA6ruxg1fvF6sMLFowpjaqw
91
93
  tinybird/tb/modules/datafile/playground.py,sha256=TB4ebscUaNPqYzn0zBWqFBtK6TyzhcenHeTf62ac-2E,55269
92
94
  tinybird/tb/modules/datafile/pull.py,sha256=WbFCv0rp-ThcCcfH6gqs9Be-NawJfEEkY-aU78O93hk,6004
93
95
  tinybird/tb/modules/tinyunit/tinyunit.py,sha256=GHdp_6uDcCO2C-Z5bXu4OJQGXMm9Y_yjrcLVYdWy65o,11238
94
- tinybird/tb/modules/tinyunit/tinyunit_lib.py,sha256=NHoXcCHPDcKWYLzgP3NViho3Ey-6RV-ynPDzySPrTPE,1817
95
96
  tinybird/tb_cli_modules/cicd.py,sha256=i2Mw8AbmEVNBcEPYdio7liy3PGqh1ezVFZ0OmJ9ww5o,13809
96
- tinybird/tb_cli_modules/common.py,sha256=_J0ovBGdMqdrYCMdkw4ub74pMLuMdkm1yAsu_OAFMwQ,77443
97
+ tinybird/tb_cli_modules/common.py,sha256=763GkBOgXIcB48UnuSjnGfxdfoSx5iqCniK15R0Aq5Y,77366
97
98
  tinybird/tb_cli_modules/config.py,sha256=0kFDmsDcjKon32rgFGMHHKSbv4j5dOrXtVOlyuAyEkk,11510
98
99
  tinybird/tb_cli_modules/exceptions.py,sha256=pmucP4kTF4irIt7dXiG-FcnI-o3mvDusPmch1L8RCWk,3367
99
100
  tinybird/tb_cli_modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
100
101
  tinybird/tb_cli_modules/telemetry.py,sha256=W098H6jmS4kpE7hN3tadaREBTf7oMocel-lkKWN0pU8,10466
101
- tinybird-4.6.2.dev0.dist-info/METADATA,sha256=NUakUIjMH63SvEAurFVKJ1PsHBKbV9WbO-9KdACgETk,12684
102
- tinybird-4.6.2.dev0.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
103
- tinybird-4.6.2.dev0.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
104
- tinybird-4.6.2.dev0.dist-info/top_level.txt,sha256=ZIQJTPCzMqnfDzM_hEGZrJqDSEcKnIK_49T86DGWpyQ,78
105
- tinybird-4.6.2.dev0.dist-info/RECORD,,
102
+ tinybird-4.6.3.dev0.dist-info/METADATA,sha256=eQdmwvUn8LjwYvXjblOOydgSuh3Fkxg7bC8pWONQVl4,13260
103
+ tinybird-4.6.3.dev0.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
104
+ tinybird-4.6.3.dev0.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
105
+ tinybird-4.6.3.dev0.dist-info/top_level.txt,sha256=ZIQJTPCzMqnfDzM_hEGZrJqDSEcKnIK_49T86DGWpyQ,78
106
+ tinybird-4.6.3.dev0.dist-info/RECORD,,
@@ -1,65 +0,0 @@
1
- import json
2
- from collections import namedtuple
3
- from json import JSONEncoder
4
- from typing import Optional
5
-
6
-
7
- class MyJSONEncoder(JSONEncoder):
8
- # def default(self, in_obj):
9
- # loaded_data = [
10
- # DataUnitTest(
11
- # getattr(unitDataTest, 'name'),
12
- # getattr(unitDataTest, 'description'),
13
- # getattr(unitDataTest, 'enabled'),
14
- # getattr(unitDataTest, 'endpoint'),
15
- # getattr(unitDataTest, 'result'),
16
- # getattr(unitDataTest, 'time'),
17
- # getattr(unitDataTest, 'sql'))
18
- # for unitDataTest in in_obj]
19
- # return loaded_data
20
- def default(self, obj):
21
- return obj.to_json()
22
-
23
-
24
- class DataUnitTest:
25
- def __init__(
26
- self,
27
- name: str,
28
- description: str,
29
- enabled: bool,
30
- endpoint: Optional[str],
31
- result: Optional[str],
32
- time: int,
33
- sql: str,
34
- ):
35
- self.name = name
36
- self.description = description
37
- self.enabled = enabled
38
- self.endpoint = endpoint
39
- self.result = result
40
- self.time = time
41
- self.sql = sql
42
-
43
- def __iter__(self):
44
- yield from {
45
- "name": self.name,
46
- "description": self.description,
47
- "enabled": self.enabled,
48
- "endpoint": self.endpoint,
49
- "sql": self.sql,
50
- "result": self.result,
51
- "time": self.time,
52
- }.items()
53
-
54
- def __str__(self):
55
- return json.dumps(dict(self), ensure_ascii=False)
56
-
57
- def __repr__(self):
58
- return self.__str__()
59
-
60
- def to_json(self):
61
- return self.__str__()
62
-
63
-
64
- def customDataUnitTestDecoder(dataUnitTestDict):
65
- return namedtuple("X", dataUnitTestDict.keys())(*dataUnitTestDict.values())