tinybird 0.0.1.dev183__py3-none-any.whl → 0.0.1.dev185__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/common.py +12 -3
- tinybird/tb/modules/create.py +54 -20
- {tinybird-0.0.1.dev183.dist-info → tinybird-0.0.1.dev185.dist-info}/METADATA +1 -1
- {tinybird-0.0.1.dev183.dist-info → tinybird-0.0.1.dev185.dist-info}/RECORD +8 -8
- {tinybird-0.0.1.dev183.dist-info → tinybird-0.0.1.dev185.dist-info}/WHEEL +0 -0
- {tinybird-0.0.1.dev183.dist-info → tinybird-0.0.1.dev185.dist-info}/entry_points.txt +0 -0
- {tinybird-0.0.1.dev183.dist-info → tinybird-0.0.1.dev185.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.dev185'
|
|
8
|
+
__revision__ = 'b79d3c1'
|
tinybird/tb/modules/common.py
CHANGED
|
@@ -174,8 +174,12 @@ def generate_datafile(
|
|
|
174
174
|
base = Path(folder) / base
|
|
175
175
|
datasource_name = normalize_datasource_name(p.stem)
|
|
176
176
|
if not base.exists():
|
|
177
|
-
|
|
177
|
+
if folder:
|
|
178
|
+
base = Path(folder)
|
|
179
|
+
else:
|
|
180
|
+
base = Path()
|
|
178
181
|
f = base / (datasource_name + ".datasource")
|
|
182
|
+
|
|
179
183
|
if not f.exists() or force:
|
|
180
184
|
with open(f"{f}", "w") as ds_file:
|
|
181
185
|
ds_file.write(datafile)
|
|
@@ -421,13 +425,18 @@ async def _analyze(filename: str, client: TinyB, format: str, connector: Optiona
|
|
|
421
425
|
|
|
422
426
|
|
|
423
427
|
async def _generate_datafile(
|
|
424
|
-
filename: str,
|
|
428
|
+
filename: str,
|
|
429
|
+
client: TinyB,
|
|
430
|
+
format: str,
|
|
431
|
+
connector: Optional["Connector"] = None,
|
|
432
|
+
force: Optional[bool] = False,
|
|
433
|
+
folder: Optional[str] = None,
|
|
425
434
|
):
|
|
426
435
|
meta, data = await _analyze(filename, client, format, connector=connector)
|
|
427
436
|
schema = meta["analysis"]["schema"]
|
|
428
437
|
schema = schema.replace(", ", ",\n ")
|
|
429
438
|
datafile = f"""DESCRIPTION >\n Generated from {filename}\n\nSCHEMA >\n {schema}"""
|
|
430
|
-
return generate_datafile(datafile, filename, data, force, _format=format)
|
|
439
|
+
return generate_datafile(datafile, filename, data, force, _format=format, folder=folder)
|
|
431
440
|
|
|
432
441
|
|
|
433
442
|
async def configure_connector(connector):
|
tinybird/tb/modules/create.py
CHANGED
|
@@ -3,8 +3,10 @@ import os
|
|
|
3
3
|
import re
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
from typing import Any, Dict, List, Optional
|
|
6
|
+
from urllib.parse import urlparse
|
|
6
7
|
|
|
7
8
|
import click
|
|
9
|
+
import requests
|
|
8
10
|
|
|
9
11
|
from tinybird.prompts import create_prompt, readme_prompt, rules_prompt
|
|
10
12
|
from tinybird.tb.client import TinyB
|
|
@@ -25,7 +27,7 @@ from tinybird.tb.modules.project import Project
|
|
|
25
27
|
@cli.command()
|
|
26
28
|
@click.option(
|
|
27
29
|
"--data",
|
|
28
|
-
type=
|
|
30
|
+
type=str,
|
|
29
31
|
default=None,
|
|
30
32
|
help="Initial data to be used to create the project. Tinybird Local and authentication are required.",
|
|
31
33
|
)
|
|
@@ -54,9 +56,6 @@ async def create(
|
|
|
54
56
|
config.persist_to_file()
|
|
55
57
|
project.folder = folder
|
|
56
58
|
|
|
57
|
-
if cwd := config.get("cwd"):
|
|
58
|
-
click.echo(FeedbackManager.gray(message=f"Using '{cwd.replace(os.getcwd(), '')}' as target folder"))
|
|
59
|
-
|
|
60
59
|
root_folder = os.getcwd()
|
|
61
60
|
if config._path:
|
|
62
61
|
root_folder = os.path.dirname(config._path)
|
|
@@ -76,7 +75,7 @@ async def create(
|
|
|
76
75
|
if not user_token:
|
|
77
76
|
raise Exception("This action requires authentication. Run 'tb login' first.")
|
|
78
77
|
|
|
79
|
-
if not validate_project_structure(
|
|
78
|
+
if not validate_project_structure(project):
|
|
80
79
|
click.echo(FeedbackManager.highlight(message="\n» Creating new project structure..."))
|
|
81
80
|
create_project_structure(folder)
|
|
82
81
|
click.echo(FeedbackManager.success(message="✓ Scaffolding completed!\n"))
|
|
@@ -87,7 +86,10 @@ async def create(
|
|
|
87
86
|
|
|
88
87
|
data_result: List[Path] = []
|
|
89
88
|
if data:
|
|
90
|
-
|
|
89
|
+
if urlparse(data).scheme in ("http", "https"):
|
|
90
|
+
data_result = await create_resources_from_url(data, project, ctx_config)
|
|
91
|
+
else:
|
|
92
|
+
data_result = await create_resources_from_data(data, project, ctx_config)
|
|
91
93
|
result.extend(data_result)
|
|
92
94
|
|
|
93
95
|
prompt_result: List[Path] = []
|
|
@@ -134,14 +136,22 @@ async def create(
|
|
|
134
136
|
|
|
135
137
|
if data:
|
|
136
138
|
for ds_path in [ds for ds in data_result if ds.suffix == ".datasource"]:
|
|
137
|
-
|
|
138
|
-
|
|
139
|
+
parsed_url = urlparse(data)
|
|
140
|
+
if parsed_url.scheme in ("http", "https"):
|
|
141
|
+
response = requests.get(data) # noqa: ASYNC210
|
|
142
|
+
data_content = response.text
|
|
143
|
+
data_format = parsed_url.path.split(".")[-1]
|
|
144
|
+
else:
|
|
145
|
+
data_path = Path(data)
|
|
146
|
+
data_content = data_path.read_text()
|
|
147
|
+
data_format = data_path.suffix.lstrip(".")
|
|
148
|
+
|
|
139
149
|
ds_name = ds_path.stem
|
|
140
|
-
data_format = data_path.suffix.lstrip(".")
|
|
141
150
|
datasource_path = Path(folder) / "datasources" / f"{ds_name}.datasource"
|
|
142
|
-
click.echo(FeedbackManager.info(message=f"✓ /fixtures/{ds_name}"))
|
|
151
|
+
click.echo(FeedbackManager.info(message=f"✓ /fixtures/{ds_name}.{data_format}"))
|
|
143
152
|
persist_fixture(ds_name, data_content, folder, format=data_format)
|
|
144
153
|
created_something = True
|
|
154
|
+
|
|
145
155
|
elif prompt and prompt_result:
|
|
146
156
|
ds_results = [path for path in prompt_result if path.suffix == ".datasource"]
|
|
147
157
|
for datasource_path in ds_results:
|
|
@@ -175,14 +185,13 @@ async def create(
|
|
|
175
185
|
PROJECT_PATHS = ("datasources", "endpoints", "materializations", "copies", "pipes", "fixtures", "tests", "connections")
|
|
176
186
|
|
|
177
187
|
|
|
178
|
-
def validate_project_structure(
|
|
179
|
-
some_folder_created = any((Path(folder) / path).exists() for path in PROJECT_PATHS)
|
|
188
|
+
def validate_project_structure(project: Project) -> bool:
|
|
189
|
+
some_folder_created = any((Path(project.folder) / path).exists() for path in PROJECT_PATHS)
|
|
180
190
|
if some_folder_created:
|
|
181
191
|
return True
|
|
182
192
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
pipes = list(folder_path.glob("**/*.pipe"))
|
|
193
|
+
datasources = project.get_datasource_files()
|
|
194
|
+
pipes = project.get_pipe_files()
|
|
186
195
|
|
|
187
196
|
return len(datasources) > 0 or len(pipes) > 0
|
|
188
197
|
|
|
@@ -452,12 +461,37 @@ async def create_resources_from_data(
|
|
|
452
461
|
project: Project,
|
|
453
462
|
config: Dict[str, Any],
|
|
454
463
|
) -> List[Path]:
|
|
455
|
-
folder_path = project.path
|
|
456
464
|
local_client = await get_tinybird_local_client(config)
|
|
465
|
+
folder_path = project.path
|
|
457
466
|
path = folder_path / data
|
|
467
|
+
if not path.exists():
|
|
468
|
+
path = Path(data)
|
|
458
469
|
result: List[Path] = []
|
|
459
470
|
format = path.suffix.lstrip(".")
|
|
460
|
-
ds_file = await _generate_datafile(str(path), local_client, format=format, force=True)
|
|
471
|
+
ds_file = await _generate_datafile(str(path), local_client, format=format, force=True, folder=project.folder)
|
|
472
|
+
result.append(ds_file)
|
|
473
|
+
name = ds_file.stem
|
|
474
|
+
no_pipes = len(project.get_pipe_files()) == 0
|
|
475
|
+
if no_pipes:
|
|
476
|
+
pipe_file = generate_pipe_file(
|
|
477
|
+
f"{name}_endpoint",
|
|
478
|
+
f"""
|
|
479
|
+
NODE endpoint
|
|
480
|
+
SQL >
|
|
481
|
+
SELECT * from {name}
|
|
482
|
+
TYPE ENDPOINT
|
|
483
|
+
""",
|
|
484
|
+
project.folder,
|
|
485
|
+
)
|
|
486
|
+
result.append(pipe_file)
|
|
487
|
+
return result
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
async def create_resources_from_url(url: str, project: Project, config: Dict[str, Any]) -> List[Path]:
|
|
491
|
+
result: List[Path] = []
|
|
492
|
+
local_client = await get_tinybird_local_client(config)
|
|
493
|
+
format = url.split(".")[-1]
|
|
494
|
+
ds_file = await _generate_datafile(url, local_client, format=format, force=True, folder=project.folder)
|
|
461
495
|
result.append(ds_file)
|
|
462
496
|
name = ds_file.stem
|
|
463
497
|
no_pipes = len(project.get_pipe_files()) == 0
|
|
@@ -465,10 +499,10 @@ async def create_resources_from_data(
|
|
|
465
499
|
pipe_file = generate_pipe_file(
|
|
466
500
|
f"{name}_endpoint",
|
|
467
501
|
f"""
|
|
468
|
-
|
|
469
|
-
|
|
502
|
+
NODE endpoint
|
|
503
|
+
SQL >
|
|
470
504
|
SELECT * from {name}
|
|
471
|
-
|
|
505
|
+
TYPE ENDPOINT
|
|
472
506
|
""",
|
|
473
507
|
project.folder,
|
|
474
508
|
)
|
|
@@ -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=X4tE9OrfaUy6kO9cqVEzyI9cDcmOF3IAssRRzsTsfEQ,40781
|
|
15
|
-
tinybird/tb/__cli__.py,sha256=
|
|
15
|
+
tinybird/tb/__cli__.py,sha256=frxkVk6NxktDwMyUqzmr41eBNhcoihthUbTM38gL06E,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=59GH0IoYSV_KUG0eEbDDYHSWH4OlkVnSRFXE3mYAM0s,56571
|
|
@@ -20,11 +20,11 @@ tinybird/tb/config.py,sha256=jT9xndpeCY_g0HdB5qE2EquC0TFRRnkPnQFWZWd04jo,3998
|
|
|
20
20
|
tinybird/tb/modules/build.py,sha256=rRL5XKBdadMc9uVDEUt0GXm0h09Y6XXw199rdmRI1qo,19127
|
|
21
21
|
tinybird/tb/modules/cicd.py,sha256=MnShTTJzKBYeajswF2jg7p7ZzupaeCgSriAN05MeEdg,7330
|
|
22
22
|
tinybird/tb/modules/cli.py,sha256=dXZs-MuqYPvxStVj7aLg36LwXtEB8NzTobDmHV9nzZI,15508
|
|
23
|
-
tinybird/tb/modules/common.py,sha256=
|
|
23
|
+
tinybird/tb/modules/common.py,sha256=DYCjpj0iBaCDZ8BJ0MNG_6m6NyFMCrpQShIajHKLIfM,83373
|
|
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
|
-
tinybird/tb/modules/create.py,sha256=
|
|
27
|
+
tinybird/tb/modules/create.py,sha256=3ccvOCcuJfhhaaoX60-6dSmnF8SfnOLTfVqLJs48jOA,18672
|
|
28
28
|
tinybird/tb/modules/datasource.py,sha256=0_6Cn07p5GoNBBGdu88pSeLvTWojln1-k23FsS8jTDs,17801
|
|
29
29
|
tinybird/tb/modules/deployment.py,sha256=t6DDLJ1YdY3SJiTPbEG7CRblSLkbuqwzauQ9y65FWtY,27147
|
|
30
30
|
tinybird/tb/modules/deprecations.py,sha256=rrszC1f_JJeJ8mUxGoCxckQTJFBCR8wREf4XXXN-PRc,4507
|
|
@@ -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.dev185.dist-info/METADATA,sha256=BYrQoaKZjaVJWTz6p19nmNwYT-SJgF0O-g07BCTduH4,1608
|
|
84
|
+
tinybird-0.0.1.dev185.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
85
|
+
tinybird-0.0.1.dev185.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
|
|
86
|
+
tinybird-0.0.1.dev185.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
|
|
87
|
+
tinybird-0.0.1.dev185.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|