tinybird 0.0.1.dev7__py3-none-any.whl → 0.0.1.dev8__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.

@@ -32,6 +32,7 @@ from tinybird.tb.modules.datafile.common import (
32
32
  INTERNAL_TABLES,
33
33
  ON_DEMAND,
34
34
  PREVIEW_CONNECTOR_SERVICES,
35
+ TB_LOCAL_WORKSPACE_NAME,
35
36
  CopyModes,
36
37
  CopyParameters,
37
38
  DataFileExtensions,
@@ -55,6 +56,9 @@ async def folder_build(
55
56
  ignore_sql_errors: bool = False,
56
57
  is_internal: bool = False,
57
58
  only_pipes: bool = False,
59
+ is_vendor: bool = False,
60
+ current_ws: Optional[Dict[str, Any]] = None,
61
+ workspaces: Optional[List[Dict[str, Any]]] = None,
58
62
  ):
59
63
  if only_pipes:
60
64
  filenames = [f for f in filenames if f.endswith(".pipe")]
@@ -71,9 +75,8 @@ async def folder_build(
71
75
  populate_subset = None
72
76
  populate_condition = None
73
77
  tests_to_run = 0
74
- user_token = None
75
78
  tests_failfast = True
76
- override_datasource = True
79
+ override_datasource = False
77
80
  tests_check_requests_from_branch = False
78
81
  skip_confirmation = True
79
82
  wait = False
@@ -102,20 +105,44 @@ async def folder_build(
102
105
  tests_check_requests_from_branch = False
103
106
  git_release = False
104
107
  workspace_lib_paths = []
105
- workspaces: List[Dict[str, Any]] = (await tb_client.user_workspaces()).get("workspaces", [])
106
- current_ws: Dict[str, Any] = next(
107
- (workspace for workspace in workspaces if config and workspace.get("id", ".") == config.get("id", "..")), {}
108
- )
109
108
 
110
109
  workspace_lib_paths = list(workspace_lib_paths)
111
110
  # include vendor libs without overriding user ones
112
111
  existing_workspaces = set(x[1] for x in workspace_lib_paths)
113
112
  vendor_path = Path("vendor")
114
- if vendor_path.exists():
113
+ user_token = config.get_user_token()
114
+ user_client = deepcopy(tb_client)
115
+
116
+ if user_token:
117
+ user_client.token = user_token
118
+
119
+ vendor_workspaces = []
120
+ user_workspaces = await user_client.user_workspaces()
121
+ if vendor_path.exists() and not is_vendor:
115
122
  for x in vendor_path.iterdir():
116
123
  if x.is_dir() and x.name not in existing_workspaces:
124
+ if user_token:
125
+ try:
126
+ ws_to_delete = next((ws for ws in user_workspaces["workspaces"] if ws["name"] == x.name), None)
127
+ if ws_to_delete:
128
+ await user_client.delete_workspace(ws_to_delete["id"], hard_delete_confirmation=x.name)
129
+ except Exception:
130
+ pass
131
+ vendor_ws = await user_client.create_workspace(x.name, template=None)
132
+ vendor_workspaces.append(vendor_ws)
117
133
  workspace_lib_paths.append((x.name, x))
118
134
 
135
+ workspaces: List[Dict[str, Any]] = (await user_client.user_workspaces()).get("workspaces", [])
136
+ local_ws = next((ws for ws in workspaces if ws["name"] == TB_LOCAL_WORKSPACE_NAME), {})
137
+ current_ws: Dict[str, Any] = current_ws or local_ws
138
+ for vendor_ws in [ws for ws in workspaces if ws["name"] in [ws["name"] for ws in vendor_workspaces]]:
139
+ ws_client = deepcopy(tb_client)
140
+ ws_client.token = vendor_ws["token"]
141
+ shared_ws_path = Path(folder) / "vendor" / vendor_ws["name"]
142
+
143
+ if shared_ws_path.exists() and not is_vendor:
144
+ await folder_build(ws_client, folder=shared_ws_path.as_posix(), is_vendor=True, current_ws=vendor_ws)
145
+
119
146
  datasources: List[Dict[str, Any]] = await tb_client.datasources()
120
147
  pipes: List[Dict[str, Any]] = await tb_client.pipes(dependencies=True)
121
148
 
@@ -253,10 +280,12 @@ async def folder_build(
253
280
  tests_validate_processed_bytes,
254
281
  tests_check_requests_from_branch,
255
282
  current_ws,
283
+ local_ws,
256
284
  fork_downstream,
257
285
  fork,
258
286
  git_release,
259
287
  build,
288
+ is_vendor,
260
289
  )
261
290
  if not run_tests:
262
291
  click.echo(
@@ -683,10 +712,12 @@ async def exec_file(
683
712
  tests_validate_processed_bytes: bool = False,
684
713
  tests_check_requests_from_branch: bool = False,
685
714
  current_ws: Optional[Dict[str, Any]] = None,
715
+ local_ws: Optional[Dict[str, Any]] = None,
686
716
  fork_downstream: Optional[bool] = False,
687
717
  fork: Optional[bool] = False,
688
718
  git_release: Optional[bool] = False,
689
719
  build: Optional[bool] = False,
720
+ is_vendor: Optional[bool] = False,
690
721
  ):
691
722
  if debug:
692
723
  click.echo(FeedbackManager.debug_running_file(file=pp.pformat(r)))
@@ -726,9 +757,11 @@ async def exec_file(
726
757
  force,
727
758
  skip_confirmation=skip_confirmation,
728
759
  current_ws=current_ws,
760
+ local_ws=local_ws,
729
761
  fork_downstream=fork_downstream,
730
762
  fork=fork,
731
763
  build=build,
764
+ is_vendor=is_vendor,
732
765
  )
733
766
  await update_tags_in_resource(r, "datasource", tb_client)
734
767
  else:
@@ -17,9 +17,11 @@ async def new_ds(
17
17
  force: bool = False,
18
18
  skip_confirmation: bool = False,
19
19
  current_ws=None,
20
+ local_ws=None,
20
21
  fork_downstream: Optional[bool] = False,
21
22
  fork: Optional[bool] = False,
22
23
  build: Optional[bool] = False,
24
+ is_vendor: Optional[bool] = False,
23
25
  ):
24
26
  ds_name = ds["params"]["name"]
25
27
 
@@ -93,7 +95,7 @@ async def new_ds(
93
95
  if ds.get("tokens"):
94
96
  await manage_tokens()
95
97
 
96
- if ds.get("shared_with"):
98
+ if ds.get("shared_with") and not build:
97
99
  if not user_token:
98
100
  click.echo(FeedbackManager.info_skipping_shared_with_entry())
99
101
  else:
@@ -105,6 +107,14 @@ async def new_ds(
105
107
  workspaces_to_share=ds["shared_with"],
106
108
  current_ws=current_ws,
107
109
  )
110
+ if is_vendor and user_token and local_ws and current_ws:
111
+ user_client: TinyB = deepcopy(client)
112
+ user_client.token = user_token
113
+ await user_client.datasource_share(
114
+ datasource_id=datasource.get("id", ""),
115
+ current_workspace_id=current_ws.get("id", ""),
116
+ destination_workspace_id=local_ws.get("id", ""),
117
+ )
108
118
 
109
119
  except Exception as e:
110
120
  raise click.ClickException(FeedbackManager.error_creating_datasource(error=str(e)))
@@ -85,6 +85,7 @@ INTERNAL_TABLES: Tuple[str, ...] = (
85
85
  )
86
86
 
87
87
  PREVIEW_CONNECTOR_SERVICES = ["s3", "s3_iamrole", "gcs"]
88
+ TB_LOCAL_WORKSPACE_NAME = "Tinybird_Local_Testing"
88
89
 
89
90
  pp = pprint.PrettyPrinter()
90
91
 
@@ -120,8 +120,11 @@ def get_tinybird_local_client():
120
120
  raise CLIException("Tinybird local environment is not running. Please start it with `tb local start`.")
121
121
 
122
122
  token = tokens["workspace_admin_token"]
123
+ user_token = tokens["user_token"]
123
124
  config.set_token(token)
124
125
  config.set_host(TB_LOCAL_HOST)
126
+ config.set_user_token(user_token)
127
+ config.persist_to_file()
125
128
  return config.get_client(host=TB_LOCAL_HOST, token=token)
126
129
 
127
130
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tinybird
3
- Version: 0.0.1.dev7
3
+ Version: 0.0.1.dev8
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/cli/introduction.html
6
6
  Author: Tinybird
@@ -30,7 +30,7 @@ tinybird/tb/modules/exceptions.py,sha256=4A2sSjCEqKUMqpP3WI00zouCWW4uLaghXXLZBSw
30
30
  tinybird/tb/modules/fmt.py,sha256=UszEQO15fdzQ49QEj7Unhu68IKwSuKPsOrKhk2p2TAg,3547
31
31
  tinybird/tb/modules/job.py,sha256=eoBVyA24lYIPonU88Jn7FF9hBKz1kScy9_w_oWreuc4,2952
32
32
  tinybird/tb/modules/llm.py,sha256=D6ShlqCorZpRLjE5srI7Ws4VUTH6kSotTi88CvUwoGw,2446
33
- tinybird/tb/modules/local.py,sha256=nCaN05ntqIGFbBqyhRwpwdLpcYwsx6Vvp0atU_KKaTo,5893
33
+ tinybird/tb/modules/local.py,sha256=R7L0Inn23OXVs7nssra8mto52fbP7rU2eUU4Bj6_AXU,5998
34
34
  tinybird/tb/modules/mock.py,sha256=dYxm8_1zXGZnf4X8OYmG9hK1I-csHakD64Hag8mAn4Q,2069
35
35
  tinybird/tb/modules/pipe.py,sha256=9wnfKbp2FkmLiJgVk3qbra76ktwsUTXghu6j9cCEahQ,31058
36
36
  tinybird/tb/modules/prompts.py,sha256=u_-VSsqk8fXJTsLO3sCv9DR1Qx2V_M_Z_gBfiyvn5jA,7251
@@ -42,11 +42,11 @@ tinybird/tb/modules/test.py,sha256=psINFpSYT1eGgy32-_4q6CJ7LOcdwBpAfasMA0_tNOU,4
42
42
  tinybird/tb/modules/token.py,sha256=r0oeG1RpOOzHtqbUaHBiOmhE55HfNIvReAAWyKl9fJg,12695
43
43
  tinybird/tb/modules/workspace.py,sha256=FVlh-kbiZp5Gvp6dGFxi0UD8ail77rMamXLhqdVwrZ0,10916
44
44
  tinybird/tb/modules/workspace_members.py,sha256=08W0onEYkKLEC5TkAI07cxN9XSquEm7HnL7OkHAVDjo,8715
45
- tinybird/tb/modules/datafile/build.py,sha256=NAvtZS8skAt_8HIdzOJhbp-d9kMIqFQJ9tupQ6M9IK0,90180
45
+ tinybird/tb/modules/datafile/build.py,sha256=SWPkmMQYde11LOt0B1JuYoyU8SsSTLjjVp_tPSgMoTM,91754
46
46
  tinybird/tb/modules/datafile/build_common.py,sha256=74547h5ja4C66DAwDMabj75FA_BUTJxTJv-24tSFmrs,4551
47
- tinybird/tb/modules/datafile/build_datasource.py,sha256=cJee7crf57gAGIa76Du0TznVU9gtk7F88eBCI7930tk,16836
47
+ tinybird/tb/modules/datafile/build_datasource.py,sha256=fquzEGwk9NL_0K5YYG86Xtvgn4J5YHtRUoKJxbQGO0s,17344
48
48
  tinybird/tb/modules/datafile/build_pipe.py,sha256=X4a-UM_GSOmR8ks2kBITgebXz-aE-iEdG5F1eEUzIyc,27555
49
- tinybird/tb/modules/datafile/common.py,sha256=g5G0jXC-okEiKPnWa8X3p3-VxXoZlQQUwKzhxVA0tfs,33918
49
+ tinybird/tb/modules/datafile/common.py,sha256=hoIm6mvXO49Jy2W2XPGE7NgOj-GmYw7zALXREQ0C3eQ,33969
50
50
  tinybird/tb/modules/datafile/diff.py,sha256=ZaTPGjRFJWokhaad_rMSxfYT92PA96s4WhhvlZubgyA,6769
51
51
  tinybird/tb/modules/datafile/exceptions.py,sha256=8rw2umdZjtby85QbuRKFO5ETz_eRHwUY5l7eHsy1wnI,556
52
52
  tinybird/tb/modules/datafile/format_common.py,sha256=zNWDXvwSKC9_T5e9R92LLj9ekDflVWwsllhGQilZsnY,2184
@@ -64,8 +64,8 @@ tinybird/tb_cli_modules/config.py,sha256=6NTgIdwf0X132A1j6G_YrdPep87ymZ9b5pABabK
64
64
  tinybird/tb_cli_modules/exceptions.py,sha256=pmucP4kTF4irIt7dXiG-FcnI-o3mvDusPmch1L8RCWk,3367
65
65
  tinybird/tb_cli_modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
66
66
  tinybird/tb_cli_modules/telemetry.py,sha256=iEGnMuCuNhvF6ln__j6X9MSTwL_0Hm-GgFHHHvhfknk,10466
67
- tinybird-0.0.1.dev7.dist-info/METADATA,sha256=MDbMCTsirb0x3yH4RirvEzBzYvjieV1ucRH1R89aPAw,2404
68
- tinybird-0.0.1.dev7.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
69
- tinybird-0.0.1.dev7.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
70
- tinybird-0.0.1.dev7.dist-info/top_level.txt,sha256=pgw6AzERHBcW3YTi2PW4arjxLkulk2msOz_SomfOEuc,45
71
- tinybird-0.0.1.dev7.dist-info/RECORD,,
67
+ tinybird-0.0.1.dev8.dist-info/METADATA,sha256=Z6CrHg4Jy8Q1nchU5NvMULizHxbZuswk0sVrqrbaC4Q,2404
68
+ tinybird-0.0.1.dev8.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
69
+ tinybird-0.0.1.dev8.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
70
+ tinybird-0.0.1.dev8.dist-info/top_level.txt,sha256=pgw6AzERHBcW3YTi2PW4arjxLkulk2msOz_SomfOEuc,45
71
+ tinybird-0.0.1.dev8.dist-info/RECORD,,