tinybird 0.0.1.dev154__py3-none-any.whl → 0.0.1.dev156__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/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__ = '0.0.1.dev154'
8
- __revision__ = 'db74d7e'
7
+ __version__ = '0.0.1.dev156'
8
+ __revision__ = '888fa61'
@@ -7,6 +7,7 @@ from typing import Optional
7
7
 
8
8
  import boto3
9
9
  import click
10
+ import requests
10
11
 
11
12
  import docker
12
13
  from docker.client import DockerClient
@@ -15,7 +16,7 @@ from tinybird.tb.modules.cli import cli
15
16
  from tinybird.tb.modules.common import coro
16
17
  from tinybird.tb.modules.exceptions import CLIException, CLILocalException
17
18
  from tinybird.tb.modules.feedback_manager import FeedbackManager
18
- from tinybird.tb.modules.local_common import TB_CONTAINER_NAME, TB_IMAGE_NAME, TB_LOCAL_PORT
19
+ from tinybird.tb.modules.local_common import TB_CONTAINER_NAME, TB_IMAGE_NAME, TB_LOCAL_ADDRESS, TB_LOCAL_PORT
19
20
  from tinybird.tb.modules.telemetry import add_telemetry_event
20
21
 
21
22
 
@@ -397,3 +398,10 @@ async def restart(use_aws_creds: bool) -> None:
397
398
  click.echo(FeedbackManager.info(message="✓ Tinybird Local stopped"))
398
399
  start_tinybird_local(docker_client, use_aws_creds)
399
400
  click.echo(FeedbackManager.success(message="✓ Tinybird Local is ready!"))
401
+
402
+
403
+ @local.command()
404
+ def version() -> None:
405
+ """Show Tinybird Local version"""
406
+ response = requests.get(f"{TB_LOCAL_ADDRESS}/version")
407
+ click.echo(FeedbackManager.success(message=f"✓ Tinybird Local version: {response.text}"))
@@ -3,7 +3,7 @@
3
3
  # - If it makes sense and only when strictly necessary, you can create utility functions in this file.
4
4
  # - But please, **do not** interleave utility functions and command definitions.
5
5
 
6
- from typing import Optional
6
+ from typing import Any, Dict, List, Optional
7
7
 
8
8
  import click
9
9
  from click import Context
@@ -21,8 +21,8 @@ from tinybird.tb.modules.common import (
21
21
  get_organizations_by_user,
22
22
  get_user_token,
23
23
  is_valid_starterkit,
24
- print_current_workspace,
25
24
  switch_workspace,
25
+ try_update_config_with_remote,
26
26
  )
27
27
  from tinybird.tb.modules.config import CLIConfig
28
28
  from tinybird.tb.modules.exceptions import CLIWorkspaceException
@@ -70,21 +70,65 @@ async def workspace_ls(ctx: Context) -> None:
70
70
 
71
71
  @workspace.command(name="use")
72
72
  @click.argument("workspace_name_or_id")
73
+ @click.pass_context
73
74
  @coro
74
- async def workspace_use(workspace_name_or_id: str) -> None:
75
+ async def workspace_use(ctx: Context, workspace_name_or_id: str) -> None:
75
76
  """Switch to another workspace. Use 'tb workspace ls' to list the workspaces you have access to."""
76
77
  config = CLIConfig.get_project_config()
78
+ is_cloud = ctx.ensure_object(dict)["env"] == "cloud"
79
+ if not is_cloud:
80
+ raise CLIWorkspaceException(
81
+ FeedbackManager.error(
82
+ message="`tb workspace use` is not available in local mode. Use --cloud to switch to a cloud workspace and it will be used in Tinybird Local."
83
+ )
84
+ )
77
85
 
78
86
  await switch_workspace(config, workspace_name_or_id)
79
87
 
80
88
 
81
89
  @workspace.command(name="current")
90
+ @click.pass_context
82
91
  @coro
83
- async def workspace_current():
92
+ async def workspace_current(ctx: Context):
84
93
  """Show the workspace you're currently authenticated to"""
85
94
  config = CLIConfig.get_project_config()
95
+ env = ctx.ensure_object(dict)["env"]
96
+ client: TinyB = ctx.ensure_object(dict)["client"]
97
+ if env == "cloud":
98
+ _ = await try_update_config_with_remote(config, only_if_needed=True)
99
+
100
+ user_workspaces = await client.user_workspaces(version="v1")
101
+ current_workspace = await client.workspace_info(version="v1")
102
+
103
+ def _get_current_workspace(user_workspaces: Dict[str, Any], current_workspace_id: str) -> Optional[Dict[str, Any]]:
104
+ def get_workspace_by_name(workspaces: List[Dict[str, Any]], name: str) -> Optional[Dict[str, Any]]:
105
+ return next((ws for ws in workspaces if ws["name"] == name), None)
106
+
107
+ workspaces: Optional[List[Dict[str, Any]]] = user_workspaces.get("workspaces")
108
+ if not workspaces:
109
+ return None
110
+
111
+ current: Optional[Dict[str, Any]] = get_workspace_by_name(workspaces, current_workspace_id)
112
+ return current
86
113
 
87
- await print_current_workspace(config)
114
+ current_main_workspace = _get_current_workspace(user_workspaces, config.get("name", current_workspace["name"]))
115
+
116
+ assert isinstance(current_main_workspace, dict)
117
+
118
+ columns = ["name", "id", "role", "plan", "current"]
119
+
120
+ table = [
121
+ (
122
+ current_main_workspace["name"],
123
+ current_main_workspace["id"],
124
+ current_main_workspace["role"],
125
+ _get_workspace_plan_name(current_main_workspace["plan"]),
126
+ True,
127
+ )
128
+ ]
129
+
130
+ click.echo(FeedbackManager.info_current_workspace())
131
+ echo_safe_humanfriendly_tables_format_smart_table(table, column_names=columns)
88
132
 
89
133
 
90
134
  @workspace.command(name="create", short_help="Create a new Workspace for your Tinybird user")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: tinybird
3
- Version: 0.0.1.dev154
3
+ Version: 0.0.1.dev156
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/forward/commands
6
6
  Author: Tinybird
@@ -12,7 +12,7 @@ tinybird/syncasync.py,sha256=IPnOx6lMbf9SNddN1eBtssg8vCLHMt76SuZ6YNYm-Yk,27761
12
12
  tinybird/tornado_template.py,sha256=jjNVDMnkYFWXflmT8KU_Ssbo5vR8KQq3EJMk5vYgXRw,41959
13
13
  tinybird/ch_utils/constants.py,sha256=aYvg2C_WxYWsnqPdZB1ZFoIr8ZY-XjUXYyHKE9Ansj0,3890
14
14
  tinybird/ch_utils/engine.py,sha256=BZuPM7MFS7vaEKK5tOMR2bwSAgJudPrJt27uVEwZmTY,40512
15
- tinybird/tb/__cli__.py,sha256=OrWQsqWlL7qgpSbsPAJ-mQZxZnMtsVL0MZkOzFitD88,247
15
+ tinybird/tb/__cli__.py,sha256=9Uom43LFpjyePOXqbI6-l2C6x4WEikJFuS8e2W83184,247
16
16
  tinybird/tb/check_pypi.py,sha256=rW4QmDRbtgKdUUwJCnBkVjmTjZSZGN-XgZhx7vMkC0w,1009
17
17
  tinybird/tb/cli.py,sha256=uPV6pvi4aYVfaiGs0DQO-eoi1g9dHlrgvhutkXkdJko,1075
18
18
  tinybird/tb/client.py,sha256=aaPKq5C77e72kR7IMv9WrvnvNki8mKMOTi9EsCp0eUc,55962
@@ -37,7 +37,7 @@ tinybird/tb/modules/infra.py,sha256=fve30Gj3mG9zbquGxS2e4ipcOYOxviWQCpNFfEzJN_Q,
37
37
  tinybird/tb/modules/job.py,sha256=n4dSSBgnA8NqD7srGahf2xRj6wxkmX9Vl0J-QJ_a2w0,2966
38
38
  tinybird/tb/modules/llm.py,sha256=KfsCYmKeW1VQz0iDZhGKCRkQv_Y3kTHh6JuxvofOguE,1076
39
39
  tinybird/tb/modules/llm_utils.py,sha256=nS9r4FAElJw8yXtmdYrx-rtI2zXR8qXfi1QqUDCfxvg,3469
40
- tinybird/tb/modules/local.py,sha256=bMrDxvhNuc3O1Gb2CL51IgoT1XXujs0NqwWpoE_bOS4,14299
40
+ tinybird/tb/modules/local.py,sha256=4CJfqAyojnwj1fN2UuKMWO28DeOGrGJ9WkHUUDAfPas,14568
41
41
  tinybird/tb/modules/local_common.py,sha256=GMbA0aKaDXzOIHVCfi_IJyQ7ziWPUhTWk0I_CZm8nmQ,4763
42
42
  tinybird/tb/modules/login.py,sha256=fmXPSdvJnKPv03chptGuu3_Fm6LhP6kUsUKhrmT8rJc,8269
43
43
  tinybird/tb/modules/logout.py,sha256=ULooy1cDBD02-r7voZmhV7udA0ML5tVuflJyShrh56Y,1022
@@ -54,7 +54,7 @@ tinybird/tb/modules/telemetry.py,sha256=IHHks8-jnrkyQIY_Y6ZmU8hdVHMGSS0pkSUOgCPc
54
54
  tinybird/tb/modules/test.py,sha256=Yopg89cRwOQpgRzsb9nvu2Z-UR2as2vBjVa5PF3uiK0,13420
55
55
  tinybird/tb/modules/token.py,sha256=2fmKwu10_M0pqs6YmJVeILR9ZQB0ejRAET86agASbKM,13488
56
56
  tinybird/tb/modules/watch.py,sha256=_92co0BjTikQuy7MbHr4TDu9A75QdHsrAO8v7DlYLg4,8898
57
- tinybird/tb/modules/workspace.py,sha256=SlK08psp0tu5t_URHyIczm696buW6KD6FPs9Lg1aNRE,6614
57
+ tinybird/tb/modules/workspace.py,sha256=JIPfsh243gCiCkB3bw0Zx0VcivCeMq34xqlfuT3aURE,8518
58
58
  tinybird/tb/modules/workspace_members.py,sha256=RYLpyPM1ECCasHRg3uvpckzXplX0_KgNFsSPZn_i6qk,8744
59
59
  tinybird/tb/modules/datafile/build.py,sha256=d_h3pRFDPFrDKGhpFx2iejY25GuB2k8yfNouj6s8caw,50973
60
60
  tinybird/tb/modules/datafile/build_common.py,sha256=LU24kAQmxDJIyoIapDaYG-SU3P4FrMG9UBf8m9PgVSI,4565
@@ -80,8 +80,8 @@ tinybird/tb_cli_modules/config.py,sha256=IsgdtFRnUrkY8-Zo32lmk6O7u3bHie1QCxLwgp4
80
80
  tinybird/tb_cli_modules/exceptions.py,sha256=pmucP4kTF4irIt7dXiG-FcnI-o3mvDusPmch1L8RCWk,3367
81
81
  tinybird/tb_cli_modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
82
82
  tinybird/tb_cli_modules/telemetry.py,sha256=Hh2Io8ZPROSunbOLuMvuIFU4TqwWPmQTqal4WS09K1A,10449
83
- tinybird-0.0.1.dev154.dist-info/METADATA,sha256=PnWxtxSIaHMNfsIBGjf2-dFk1zw2g1wx80rl_2u1Gw4,1607
84
- tinybird-0.0.1.dev154.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
85
- tinybird-0.0.1.dev154.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
86
- tinybird-0.0.1.dev154.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
87
- tinybird-0.0.1.dev154.dist-info/RECORD,,
83
+ tinybird-0.0.1.dev156.dist-info/METADATA,sha256=aukxrlc7qfXhgKxSlMHSAOoWo15HAwKnXu2stIMf4bI,1607
84
+ tinybird-0.0.1.dev156.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
85
+ tinybird-0.0.1.dev156.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
86
+ tinybird-0.0.1.dev156.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
87
+ tinybird-0.0.1.dev156.dist-info/RECORD,,