tinybird 0.0.1.dev170__py3-none-any.whl → 0.0.1.dev172__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 +2 -2
- tinybird/tb/modules/cli.py +29 -3
- tinybird/tb/modules/common.py +4 -0
- tinybird/tb/modules/deployment.py +10 -2
- tinybird/tb/modules/info.py +29 -12
- {tinybird-0.0.1.dev170.dist-info → tinybird-0.0.1.dev172.dist-info}/METADATA +1 -1
- {tinybird-0.0.1.dev170.dist-info → tinybird-0.0.1.dev172.dist-info}/RECORD +10 -10
- {tinybird-0.0.1.dev170.dist-info → tinybird-0.0.1.dev172.dist-info}/WHEEL +0 -0
- {tinybird-0.0.1.dev170.dist-info → tinybird-0.0.1.dev172.dist-info}/entry_points.txt +0 -0
- {tinybird-0.0.1.dev170.dist-info → tinybird-0.0.1.dev172.dist-info}/top_level.txt +0 -0
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.
|
|
8
|
-
__revision__ = '
|
|
7
|
+
__version__ = '0.0.1.dev172'
|
|
8
|
+
__revision__ = '418a96d'
|
tinybird/tb/modules/cli.py
CHANGED
|
@@ -71,6 +71,9 @@ VERSION = f"{__cli__.__version__} (rev {__cli__.__revision__})"
|
|
|
71
71
|
@click.option("--show-tokens", is_flag=True, default=False, help="Enable the output of tokens.")
|
|
72
72
|
@click.option("--cloud/--local", is_flag=True, default=False, help="Run against cloud or local.")
|
|
73
73
|
@click.option("--staging", is_flag=True, default=False, help="Run against a staging deployment.")
|
|
74
|
+
@click.option(
|
|
75
|
+
"--output", type=click.Choice(["json", "human"], case_sensitive=False), default="human", help="Output format"
|
|
76
|
+
)
|
|
74
77
|
@click.version_option(version=VERSION)
|
|
75
78
|
@click.pass_context
|
|
76
79
|
@coro
|
|
@@ -84,15 +87,19 @@ async def cli(
|
|
|
84
87
|
show_tokens: bool,
|
|
85
88
|
cloud: bool,
|
|
86
89
|
staging: bool,
|
|
90
|
+
output: str,
|
|
87
91
|
) -> None:
|
|
88
92
|
"""
|
|
89
93
|
Use `OBFUSCATE_REGEX_PATTERN` and `OBFUSCATE_PATTERN_SEPARATOR` environment variables to define a regex pattern and a separator (in case of a single string with multiple regex) to obfuscate secrets in the CLI output.
|
|
90
94
|
"""
|
|
91
95
|
# We need to unpatch for our tests not to break
|
|
92
|
-
if
|
|
93
|
-
|
|
96
|
+
if output == "json":
|
|
97
|
+
__hide_click_output()
|
|
94
98
|
else:
|
|
95
|
-
|
|
99
|
+
if show_tokens or not cloud or ctx.invoked_subcommand == "build":
|
|
100
|
+
__unpatch_click_output()
|
|
101
|
+
else:
|
|
102
|
+
__patch_click_output()
|
|
96
103
|
|
|
97
104
|
if getenv_bool("TB_DISABLE_SSL_CHECKS", False):
|
|
98
105
|
click.echo(FeedbackManager.warning_disabled_ssl_checks())
|
|
@@ -167,6 +174,7 @@ async def cli(
|
|
|
167
174
|
|
|
168
175
|
ctx.ensure_object(dict)["project"] = project
|
|
169
176
|
ctx.ensure_object(dict)["env"] = get_target_env(cloud)
|
|
177
|
+
ctx.ensure_object(dict)["output"] = output
|
|
170
178
|
|
|
171
179
|
|
|
172
180
|
@cli.command(hidden=True)
|
|
@@ -316,6 +324,24 @@ def __unpatch_click_output():
|
|
|
316
324
|
click.secho = __old_click_secho
|
|
317
325
|
|
|
318
326
|
|
|
327
|
+
def __hide_click_output() -> None:
|
|
328
|
+
"""
|
|
329
|
+
Modify click.echo and click.secho to only output when explicitly requested.
|
|
330
|
+
Adds a 'force_output' parameter to both functions that defaults to False.
|
|
331
|
+
"""
|
|
332
|
+
|
|
333
|
+
def silent_echo(msg: Any, *args: Any, force_output: bool = False, **kwargs: Any) -> None:
|
|
334
|
+
if force_output:
|
|
335
|
+
__old_click_echo(msg, *args, **kwargs)
|
|
336
|
+
|
|
337
|
+
def silent_secho(msg: Any, *args: Any, force_output: bool = False, **kwargs: Any) -> None:
|
|
338
|
+
if force_output:
|
|
339
|
+
__old_click_secho(msg, *args, **kwargs)
|
|
340
|
+
|
|
341
|
+
click.echo = silent_echo # type: ignore
|
|
342
|
+
click.secho = silent_secho # type: ignore
|
|
343
|
+
|
|
344
|
+
|
|
319
345
|
async def create_ctx_client(ctx: Context, config: Dict[str, Any], cloud: bool, staging: bool):
|
|
320
346
|
commands_without_ctx_client = [
|
|
321
347
|
"auth",
|
tinybird/tb/modules/common.py
CHANGED
|
@@ -2227,3 +2227,7 @@ def get_error_event(error: str) -> Tuple[str, str]:
|
|
|
2227
2227
|
error_event = "error"
|
|
2228
2228
|
silent_error_msg = "Unknown error"
|
|
2229
2229
|
return error_event, silent_error_msg
|
|
2230
|
+
|
|
2231
|
+
|
|
2232
|
+
def echo_json(data: Dict[str, Any]) -> None:
|
|
2233
|
+
click.echo(json.dumps(data), force_output=True) # type: ignore
|
|
@@ -360,7 +360,15 @@ def deployment_ls(ctx: click.Context, include_deleted: bool) -> None:
|
|
|
360
360
|
url += "?include_deleted=true"
|
|
361
361
|
|
|
362
362
|
result = api_fetch(url, HEADERS)
|
|
363
|
-
status_map = {
|
|
363
|
+
status_map = {
|
|
364
|
+
"calculating": "Creating - Calculating steps",
|
|
365
|
+
"creating_schema": "Creating - Creating schemas",
|
|
366
|
+
"schema_ready": "Creating - Migrating data",
|
|
367
|
+
"data_ready": "Staging",
|
|
368
|
+
"deleting": "Deleting",
|
|
369
|
+
"deleted": "Deleted",
|
|
370
|
+
"failed": "Failed",
|
|
371
|
+
}
|
|
364
372
|
columns = ["ID", "Status", "Created at"]
|
|
365
373
|
table = []
|
|
366
374
|
for deployment in result.get("deployments", []):
|
|
@@ -370,7 +378,7 @@ def deployment_ls(ctx: click.Context, include_deleted: bool) -> None:
|
|
|
370
378
|
table.append(
|
|
371
379
|
[
|
|
372
380
|
deployment.get("id"),
|
|
373
|
-
"Live" if deployment.get("live") else status_map.get(deployment.get("status", "In progress")
|
|
381
|
+
"Live" if deployment.get("live") else status_map.get(deployment.get("status"), "In progress"),
|
|
374
382
|
datetime.fromisoformat(deployment.get("created_at")).strftime("%Y-%m-%d %H:%M:%S"),
|
|
375
383
|
]
|
|
376
384
|
)
|
tinybird/tb/modules/info.py
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import os
|
|
2
|
-
from typing import Any, Dict, Iterable, List, Optional
|
|
2
|
+
from typing import Any, Dict, Iterable, List, Optional, Tuple
|
|
3
3
|
|
|
4
4
|
import click
|
|
5
5
|
|
|
6
6
|
from tinybird.tb.client import TinyB
|
|
7
7
|
from tinybird.tb.config import get_display_cloud_host
|
|
8
8
|
from tinybird.tb.modules.cli import CLIConfig, cli
|
|
9
|
-
from tinybird.tb.modules.common import coro, format_robust_table
|
|
9
|
+
from tinybird.tb.modules.common import coro, echo_json, format_robust_table
|
|
10
10
|
from tinybird.tb.modules.feedback_manager import FeedbackManager
|
|
11
11
|
from tinybird.tb.modules.local_common import TB_LOCAL_ADDRESS, get_tinybird_local_config
|
|
12
12
|
from tinybird.tb.modules.project import Project
|
|
@@ -19,15 +19,29 @@ async def info(ctx: click.Context) -> None:
|
|
|
19
19
|
"""Get information about the project that is currently being used"""
|
|
20
20
|
ctx_config = ctx.ensure_object(dict)["config"]
|
|
21
21
|
project: Project = ctx.ensure_object(dict)["project"]
|
|
22
|
+
is_json = ctx.ensure_object(dict)["output"] == "json"
|
|
22
23
|
click.echo(FeedbackManager.highlight(message="» Tinybird Cloud:"))
|
|
23
|
-
await get_cloud_info(ctx_config)
|
|
24
|
+
cloud_table, cloud_columns = await get_cloud_info(ctx_config)
|
|
24
25
|
click.echo(FeedbackManager.highlight(message="\n» Tinybird Local:"))
|
|
25
|
-
await get_local_info(ctx_config)
|
|
26
|
+
local_table, local_columns = await get_local_info(ctx_config)
|
|
26
27
|
click.echo(FeedbackManager.highlight(message="\n» Project:"))
|
|
27
|
-
await get_project_info(project.folder)
|
|
28
|
+
project_table, project_columns = await get_project_info(project.folder)
|
|
29
|
+
if is_json:
|
|
30
|
+
cloud_data = {}
|
|
31
|
+
if cloud_columns and cloud_table and isinstance(cloud_table, list) and len(cloud_table) > 0:
|
|
32
|
+
cloud_data = {column: cloud_table[0][i] for i, column in enumerate(cloud_columns)}
|
|
28
33
|
|
|
34
|
+
local_data = {}
|
|
35
|
+
if local_columns and local_table and isinstance(local_table, list) and len(local_table) > 0:
|
|
36
|
+
local_data = {column: local_table[0][i] for i, column in enumerate(local_columns)}
|
|
29
37
|
|
|
30
|
-
|
|
38
|
+
project_data = {}
|
|
39
|
+
if project_columns and project_table and isinstance(project_table, list) and len(project_table) > 0:
|
|
40
|
+
project_data = {column: project_table[0][i] for i, column in enumerate(project_columns)}
|
|
41
|
+
echo_json({"cloud": cloud_data, "local": local_data, "project": project_data})
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
async def get_cloud_info(ctx_config: Dict[str, Any]) -> Tuple[Iterable[Any], List[str]]:
|
|
31
45
|
config = CLIConfig.get_project_config()
|
|
32
46
|
|
|
33
47
|
try:
|
|
@@ -37,16 +51,17 @@ async def get_cloud_info(ctx_config: Dict[str, Any]) -> None:
|
|
|
37
51
|
ui_host = get_display_cloud_host(api_host)
|
|
38
52
|
user_email = config.get("user_email") or "No user email found"
|
|
39
53
|
user_token = config.get_user_token() or "No user token found"
|
|
40
|
-
await get_env_info(client, ctx_config, user_email, token, user_token, api_host, ui_host)
|
|
54
|
+
return await get_env_info(client, ctx_config, user_email, token, user_token, api_host, ui_host)
|
|
41
55
|
except Exception:
|
|
42
56
|
click.echo(
|
|
43
57
|
FeedbackManager.warning(
|
|
44
58
|
message="\n⚠ Could not retrieve Tinybird Cloud info. Please run `tb login` first or check that you are located in the correct directory."
|
|
45
59
|
)
|
|
46
60
|
)
|
|
61
|
+
return [], []
|
|
47
62
|
|
|
48
63
|
|
|
49
|
-
async def get_local_info(config: Dict[str, Any]) ->
|
|
64
|
+
async def get_local_info(config: Dict[str, Any]) -> Tuple[Iterable[Any], List[str]]:
|
|
50
65
|
try:
|
|
51
66
|
local_config = await get_tinybird_local_config(config, test=False, silent=False)
|
|
52
67
|
local_client = local_config.get_client(host=TB_LOCAL_ADDRESS, staging=False)
|
|
@@ -55,19 +70,19 @@ async def get_local_info(config: Dict[str, Any]) -> None:
|
|
|
55
70
|
user_token = local_config.get_user_token() or "No user token found"
|
|
56
71
|
api_host = TB_LOCAL_ADDRESS
|
|
57
72
|
ui_host = get_display_cloud_host(api_host)
|
|
58
|
-
await get_env_info(local_client, config, user_email, token, user_token, api_host, ui_host)
|
|
73
|
+
return await get_env_info(local_client, config, user_email, token, user_token, api_host, ui_host)
|
|
59
74
|
except Exception:
|
|
60
75
|
click.echo(
|
|
61
76
|
FeedbackManager.warning(
|
|
62
77
|
message="\n⚠ Could not retrieve Tinybird Local info. Please run `tb local start` first."
|
|
63
78
|
)
|
|
64
79
|
)
|
|
65
|
-
return
|
|
80
|
+
return [], []
|
|
66
81
|
|
|
67
82
|
|
|
68
83
|
async def get_env_info(
|
|
69
84
|
client: TinyB, config: Dict[str, Any], user_email: str, token: str, user_token: str, api_host: str, ui_host: str
|
|
70
|
-
) ->
|
|
85
|
+
) -> Tuple[List[Any], List[str]]:
|
|
71
86
|
user_workspaces = await client.user_workspaces(version="v1")
|
|
72
87
|
current_workspace = await client.workspace_info(version="v1")
|
|
73
88
|
|
|
@@ -94,9 +109,10 @@ async def get_env_info(
|
|
|
94
109
|
]
|
|
95
110
|
|
|
96
111
|
click.echo(format_robust_table(table, column_names=columns))
|
|
112
|
+
return table, columns
|
|
97
113
|
|
|
98
114
|
|
|
99
|
-
async def get_project_info(project_path: Optional[str] = None) ->
|
|
115
|
+
async def get_project_info(project_path: Optional[str] = None) -> Tuple[Iterable[Any], List[str]]:
|
|
100
116
|
config = CLIConfig.get_project_config()
|
|
101
117
|
tinyb_path = config.get_tinyb_file()
|
|
102
118
|
current_path = os.getcwd()
|
|
@@ -110,3 +126,4 @@ async def get_project_info(project_path: Optional[str] = None) -> None:
|
|
|
110
126
|
columns = ["current", ".tinyb", "project"]
|
|
111
127
|
table: Iterable[Any] = [(current_path, tinyb_path, project_path)]
|
|
112
128
|
click.echo(format_robust_table(table, column_names=columns))
|
|
129
|
+
return table, columns
|
|
@@ -12,27 +12,27 @@ 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=X4tE9OrfaUy6kO9cqVEzyI9cDcmOF3IAssRRzsTsfEQ,40781
|
|
15
|
-
tinybird/tb/__cli__.py,sha256=
|
|
15
|
+
tinybird/tb/__cli__.py,sha256=KsLyZAzU6SHnlZIzZ3NaPcvV_l0uNff_p7roROhkP0c,247
|
|
16
16
|
tinybird/tb/check_pypi.py,sha256=rW4QmDRbtgKdUUwJCnBkVjmTjZSZGN-XgZhx7vMkC0w,1009
|
|
17
17
|
tinybird/tb/cli.py,sha256=u3eGOhX0MHkuT6tiwaZ0_3twqLmqKXDAOxF7yV_Nn9Q,1075
|
|
18
18
|
tinybird/tb/client.py,sha256=CSBl_JRuioPyY0H8Ac96dJ9wQXDXfrvK2lwqlOxKGoY,55715
|
|
19
19
|
tinybird/tb/config.py,sha256=jT9xndpeCY_g0HdB5qE2EquC0TFRRnkPnQFWZWd04jo,3998
|
|
20
20
|
tinybird/tb/modules/build.py,sha256=zakH5812Lop-XHjGmDRdOPeofPtoeyb_2un_T6e50xw,19177
|
|
21
21
|
tinybird/tb/modules/cicd.py,sha256=MnShTTJzKBYeajswF2jg7p7ZzupaeCgSriAN05MeEdg,7330
|
|
22
|
-
tinybird/tb/modules/cli.py,sha256=
|
|
23
|
-
tinybird/tb/modules/common.py,sha256=
|
|
22
|
+
tinybird/tb/modules/cli.py,sha256=3gDO1smcH1e2qEvbFCGbo4oNdgubDr3hC3fsKlB4ylY,15373
|
|
23
|
+
tinybird/tb/modules/common.py,sha256=lu1Z3VYImwocaHvqOW2FzBJP6F3Ev7RuXsItkCZ6jpo,83237
|
|
24
24
|
tinybird/tb/modules/config.py,sha256=ziqW_t_mRVvWOd85VoB4vKyvgMkEfpXDf9H4v38p2xc,11422
|
|
25
25
|
tinybird/tb/modules/connection.py,sha256=7oOR7x4PhBcm1ETFFCH2YJ_3oeGXjAbmx1cnZX9_L70,9014
|
|
26
26
|
tinybird/tb/modules/copy.py,sha256=2Mm4FWKehOG7CoOhiF1m9UZJgJn0W1_cMolqju8ONYg,5805
|
|
27
27
|
tinybird/tb/modules/create.py,sha256=_s_vdb9pjq1ORajE_gFMxSGVuns1imNgiD5H8KuI2gQ,17231
|
|
28
28
|
tinybird/tb/modules/datasource.py,sha256=V314rkpdVxVMjsp5qcSCTqDlmp4Vu--qM07BoWh-aqs,17783
|
|
29
|
-
tinybird/tb/modules/deployment.py,sha256=
|
|
29
|
+
tinybird/tb/modules/deployment.py,sha256=j-6zGvlAlr__ERRJg98-jEtwpR3ZbUJQeRJIj5YS94I,27070
|
|
30
30
|
tinybird/tb/modules/deprecations.py,sha256=rrszC1f_JJeJ8mUxGoCxckQTJFBCR8wREf4XXXN-PRc,4507
|
|
31
31
|
tinybird/tb/modules/dev_server.py,sha256=57FCKuWpErwYUYgHspYDkLWEm9F4pbvVOtMrFXX1fVU,10129
|
|
32
32
|
tinybird/tb/modules/endpoint.py,sha256=XySDt3pk66vxOZ0egUfz4bY8bEk3BjOXkv-L0OIJ3sc,12083
|
|
33
33
|
tinybird/tb/modules/exceptions.py,sha256=5jK91w1LPmtqIUfDpHe_Op5OxGz8-p1BPgtLREMIni0,5217
|
|
34
34
|
tinybird/tb/modules/feedback_manager.py,sha256=c0ZOpG7IHFq3doodezctX64cTcTquIOhO38w9uPuU8Q,76798
|
|
35
|
-
tinybird/tb/modules/info.py,sha256=
|
|
35
|
+
tinybird/tb/modules/info.py,sha256=iKeFbFkos7vYaBU7Vr5SI-fa1x7AbuUHB748jsGsaA4,5944
|
|
36
36
|
tinybird/tb/modules/infra.py,sha256=fve30Gj3mG9zbquGxS2e4ipcOYOxviWQCpNFfEzJN_Q,33195
|
|
37
37
|
tinybird/tb/modules/job.py,sha256=n4dSSBgnA8NqD7srGahf2xRj6wxkmX9Vl0J-QJ_a2w0,2966
|
|
38
38
|
tinybird/tb/modules/llm.py,sha256=KfsCYmKeW1VQz0iDZhGKCRkQv_Y3kTHh6JuxvofOguE,1076
|
|
@@ -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.
|
|
84
|
-
tinybird-0.0.1.
|
|
85
|
-
tinybird-0.0.1.
|
|
86
|
-
tinybird-0.0.1.
|
|
87
|
-
tinybird-0.0.1.
|
|
83
|
+
tinybird-0.0.1.dev172.dist-info/METADATA,sha256=9aQWivLU7rd3lXCxFMfmwjDLDYBIlQtD1caqljQeVp8,1607
|
|
84
|
+
tinybird-0.0.1.dev172.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
85
|
+
tinybird-0.0.1.dev172.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
|
|
86
|
+
tinybird-0.0.1.dev172.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
|
|
87
|
+
tinybird-0.0.1.dev172.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|