tinybird 0.0.1.dev183__py3-none-any.whl → 0.0.1.dev184__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.dev183'
8
- __revision__ = '1e2d149'
7
+ __version__ = '0.0.1.dev184'
8
+ __revision__ = '0d5d2de'
@@ -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=click.Path(exists=True),
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
  )
@@ -87,7 +89,10 @@ async def create(
87
89
 
88
90
  data_result: List[Path] = []
89
91
  if data:
90
- data_result = await create_resources_from_data(data, project, ctx_config)
92
+ if urlparse(data).scheme in ("http", "https"):
93
+ data_result = await create_resources_from_url(data, project, ctx_config)
94
+ else:
95
+ data_result = await create_resources_from_data(data, project, ctx_config)
91
96
  result.extend(data_result)
92
97
 
93
98
  prompt_result: List[Path] = []
@@ -134,14 +139,22 @@ async def create(
134
139
 
135
140
  if data:
136
141
  for ds_path in [ds for ds in data_result if ds.suffix == ".datasource"]:
137
- data_path = Path(data)
138
- data_content = data_path.read_text()
142
+ parsed_url = urlparse(data)
143
+ if parsed_url.scheme in ("http", "https"):
144
+ response = requests.get(data) # noqa: ASYNC210
145
+ data_content = response.text
146
+ data_format = parsed_url.path.split(".")[-1]
147
+ else:
148
+ data_path = Path(data)
149
+ data_content = data_path.read_text()
150
+ data_format = data_path.suffix.lstrip(".")
151
+
139
152
  ds_name = ds_path.stem
140
- data_format = data_path.suffix.lstrip(".")
141
153
  datasource_path = Path(folder) / "datasources" / f"{ds_name}.datasource"
142
- click.echo(FeedbackManager.info(message=f"✓ /fixtures/{ds_name}"))
154
+ click.echo(FeedbackManager.info(message=f"✓ /fixtures/{ds_name}.{data_format}"))
143
155
  persist_fixture(ds_name, data_content, folder, format=data_format)
144
156
  created_something = True
157
+
145
158
  elif prompt and prompt_result:
146
159
  ds_results = [path for path in prompt_result if path.suffix == ".datasource"]
147
160
  for datasource_path in ds_results:
@@ -452,8 +465,8 @@ async def create_resources_from_data(
452
465
  project: Project,
453
466
  config: Dict[str, Any],
454
467
  ) -> List[Path]:
455
- folder_path = project.path
456
468
  local_client = await get_tinybird_local_client(config)
469
+ folder_path = project.path
457
470
  path = folder_path / data
458
471
  result: List[Path] = []
459
472
  format = path.suffix.lstrip(".")
@@ -465,10 +478,33 @@ async def create_resources_from_data(
465
478
  pipe_file = generate_pipe_file(
466
479
  f"{name}_endpoint",
467
480
  f"""
468
- NODE endpoint
469
- SQL >
481
+ NODE endpoint
482
+ SQL >
483
+ SELECT * from {name}
484
+ TYPE ENDPOINT
485
+ """,
486
+ project.folder,
487
+ )
488
+ result.append(pipe_file)
489
+ return result
490
+
491
+
492
+ async def create_resources_from_url(url: str, project: Project, config: Dict[str, Any]) -> List[Path]:
493
+ result: List[Path] = []
494
+ local_client = await get_tinybird_local_client(config)
495
+ format = url.split(".")[-1]
496
+ ds_file = await _generate_datafile(url, local_client, format=format, force=True)
497
+ result.append(ds_file)
498
+ name = ds_file.stem
499
+ no_pipes = len(project.get_pipe_files()) == 0
500
+ if no_pipes:
501
+ pipe_file = generate_pipe_file(
502
+ f"{name}_endpoint",
503
+ f"""
504
+ NODE endpoint
505
+ SQL >
470
506
  SELECT * from {name}
471
- TYPE ENDPOINT
507
+ TYPE ENDPOINT
472
508
  """,
473
509
  project.folder,
474
510
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: tinybird
3
- Version: 0.0.1.dev183
3
+ Version: 0.0.1.dev184
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=X4tE9OrfaUy6kO9cqVEzyI9cDcmOF3IAssRRzsTsfEQ,40781
15
- tinybird/tb/__cli__.py,sha256=I3YL2OnI6jdHeZZqhxx8ydlJp5zrUKANN9Bqmzf28WY,247
15
+ tinybird/tb/__cli__.py,sha256=53aFe84vyt7b02YzNl7TMyome7H2Q6p-1cvE7VbeusE,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
@@ -24,7 +24,7 @@ tinybird/tb/modules/common.py,sha256=lu1Z3VYImwocaHvqOW2FzBJP6F3Ev7RuXsItkCZ6jpo
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=jz5jswVntvsnNN-IbCXoKw9pUKySx_IubpP0rxi7Iy0,17528
27
+ tinybird/tb/modules/create.py,sha256=sT0d7hbM1TX6nws6jY4TQIVGBtmt2xPUqUYmgHgHK30,18756
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.dev183.dist-info/METADATA,sha256=PHYeXR2ipg3vhMXXloKq0_uhArBd_xQyvQ9Wg_O64QE,1608
84
- tinybird-0.0.1.dev183.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
85
- tinybird-0.0.1.dev183.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
86
- tinybird-0.0.1.dev183.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
87
- tinybird-0.0.1.dev183.dist-info/RECORD,,
83
+ tinybird-0.0.1.dev184.dist-info/METADATA,sha256=rBeUzI1isxMpgMebrnRzC64xPiVvvz2OnQrIDq-Ppyw,1608
84
+ tinybird-0.0.1.dev184.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
85
+ tinybird-0.0.1.dev184.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
86
+ tinybird-0.0.1.dev184.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
87
+ tinybird-0.0.1.dev184.dist-info/RECORD,,