tinybird 0.0.1.dev113__tar.gz → 0.0.1.dev114__tar.gz
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-0.0.1.dev113 → tinybird-0.0.1.dev114}/PKG-INFO +1 -1
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/__cli__.py +2 -2
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/cli.py +0 -1
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/build.py +124 -3
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/cli.py +1 -1
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird.egg-info/PKG-INFO +1 -1
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird.egg-info/SOURCES.txt +0 -1
- tinybird-0.0.1.dev113/tinybird/tb/modules/playground.py +0 -135
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/setup.cfg +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/__cli__.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/ch_utils/constants.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/ch_utils/engine.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/check_pypi.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/client.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/config.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/connectors.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/context.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/datafile.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/datatypes.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/feedback_manager.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/git_settings.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/prompts.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/sql.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/sql_template.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/sql_template_fmt.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/sql_toolset.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/syncasync.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/auth.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/cicd.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/common.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/config.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/connection.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/copy.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/create.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/datafile/build.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/datafile/build_common.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/datafile/build_datasource.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/datafile/build_pipe.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/datafile/common.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/datafile/diff.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/datafile/exceptions.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/datafile/fixture.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/datafile/format_common.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/datafile/format_datasource.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/datafile/format_pipe.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/datafile/parse_datasource.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/datafile/parse_pipe.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/datafile/pipe_checker.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/datafile/playground.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/datafile/pull.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/datasource.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/deployment.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/endpoint.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/exceptions.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/feedback_manager.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/fmt.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/infra.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/job.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/llm.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/llm_utils.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/local.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/local_common.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/login.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/logout.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/materialization.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/mock.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/open.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/pipe.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/project.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/regions.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/secret.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/shell.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/table.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/tag.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/telemetry.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/test.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/tinyunit/tinyunit.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/tinyunit/tinyunit_lib.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/token.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/watch.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/workspace.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/workspace_members.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb_cli.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb_cli_modules/auth.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb_cli_modules/branch.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb_cli_modules/cicd.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb_cli_modules/cli.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb_cli_modules/common.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb_cli_modules/config.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb_cli_modules/connection.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb_cli_modules/datasource.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb_cli_modules/exceptions.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb_cli_modules/fmt.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb_cli_modules/job.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb_cli_modules/pipe.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb_cli_modules/regions.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb_cli_modules/tag.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb_cli_modules/telemetry.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb_cli_modules/test.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb_cli_modules/tinyunit/tinyunit.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb_cli_modules/tinyunit/tinyunit_lib.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb_cli_modules/workspace.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb_cli_modules/workspace_members.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tornado_template.py +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird.egg-info/dependency_links.txt +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird.egg-info/entry_points.txt +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird.egg-info/requires.txt +0 -0
- {tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird.egg-info/top_level.txt +0 -0
|
@@ -4,5 +4,5 @@ __description__ = 'Tinybird Command Line Tool'
|
|
|
4
4
|
__url__ = 'https://www.tinybird.co/docs/cli/introduction.html'
|
|
5
5
|
__author__ = 'Tinybird'
|
|
6
6
|
__author_email__ = 'support@tinybird.co'
|
|
7
|
-
__version__ = '0.0.1.
|
|
8
|
-
__revision__ = '
|
|
7
|
+
__version__ = '0.0.1.dev114'
|
|
8
|
+
__revision__ = '9878107'
|
|
@@ -24,7 +24,6 @@ import tinybird.tb.modules.materialization
|
|
|
24
24
|
import tinybird.tb.modules.mock
|
|
25
25
|
import tinybird.tb.modules.open
|
|
26
26
|
import tinybird.tb.modules.pipe
|
|
27
|
-
import tinybird.tb.modules.playground
|
|
28
27
|
import tinybird.tb.modules.secret
|
|
29
28
|
import tinybird.tb.modules.tag
|
|
30
29
|
import tinybird.tb.modules.test
|
|
@@ -4,23 +4,30 @@ import logging
|
|
|
4
4
|
import sys
|
|
5
5
|
import threading
|
|
6
6
|
import time
|
|
7
|
+
from copy import deepcopy
|
|
7
8
|
from functools import partial
|
|
8
9
|
from pathlib import Path
|
|
9
|
-
from typing import Callable, Optional
|
|
10
|
+
from typing import Callable, List, Optional
|
|
10
11
|
from urllib.parse import urlencode
|
|
11
12
|
|
|
12
13
|
import click
|
|
13
14
|
import requests
|
|
14
15
|
|
|
16
|
+
import tinybird.context as context
|
|
15
17
|
from tinybird.client import TinyB
|
|
16
18
|
from tinybird.tb.modules.cli import cli
|
|
17
19
|
from tinybird.tb.modules.common import push_data
|
|
20
|
+
from tinybird.tb.modules.config import CLIConfig
|
|
18
21
|
from tinybird.tb.modules.datafile.build import folder_build
|
|
22
|
+
from tinybird.tb.modules.datafile.exceptions import ParseException
|
|
19
23
|
from tinybird.tb.modules.datafile.fixture import get_fixture_dir, persist_fixture
|
|
24
|
+
from tinybird.tb.modules.datafile.parse_datasource import parse_datasource
|
|
25
|
+
from tinybird.tb.modules.datafile.parse_pipe import parse_pipe
|
|
26
|
+
from tinybird.tb.modules.datafile.playground import folder_playground
|
|
20
27
|
from tinybird.tb.modules.feedback_manager import FeedbackManager
|
|
21
28
|
from tinybird.tb.modules.project import Project
|
|
22
29
|
from tinybird.tb.modules.shell import Shell, print_table_formatted
|
|
23
|
-
from tinybird.tb.modules.watch import watch_project
|
|
30
|
+
from tinybird.tb.modules.watch import watch_files, watch_project
|
|
24
31
|
|
|
25
32
|
|
|
26
33
|
@cli.command()
|
|
@@ -43,8 +50,12 @@ def build(ctx: click.Context, watch: bool) -> None:
|
|
|
43
50
|
|
|
44
51
|
|
|
45
52
|
@cli.command("dev", help="Build the project server side and watch for changes.")
|
|
53
|
+
@click.option("--data-origin", type=str, default="", help="Data origin: local or cloud")
|
|
46
54
|
@click.pass_context
|
|
47
|
-
def dev(ctx: click.Context) -> None:
|
|
55
|
+
def dev(ctx: click.Context, data_origin: str) -> None:
|
|
56
|
+
if data_origin == "cloud":
|
|
57
|
+
return dev_cloud(ctx)
|
|
58
|
+
|
|
48
59
|
project: Project = ctx.ensure_object(dict)["project"]
|
|
49
60
|
tb_client: TinyB = ctx.ensure_object(dict)["client"]
|
|
50
61
|
click.echo(FeedbackManager.highlight_building_project())
|
|
@@ -284,3 +295,113 @@ def rebuild_fixture_sql(project: Project, tb_client: TinyB, sql_file: str) -> No
|
|
|
284
295
|
result = asyncio.run(tb_client.query(f"{sql} FORMAT JSON"))
|
|
285
296
|
data = result.get("data", [])
|
|
286
297
|
persist_fixture(datasource_name, data, project.folder)
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
def is_vendor(f: Path) -> bool:
|
|
301
|
+
return f.parts[0] == "vendor"
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
def get_vendor_workspace(f: Path) -> str:
|
|
305
|
+
return f.parts[1]
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
def is_endpoint(f: Path) -> bool:
|
|
309
|
+
return f.suffix == ".pipe" and not is_vendor(f) and f.parts[0] == "endpoints"
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
def is_pipe(f: Path) -> bool:
|
|
313
|
+
return f.suffix == ".pipe" and not is_vendor(f)
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
def check_filenames(filenames: List[str]):
|
|
317
|
+
parser_matrix = {".pipe": parse_pipe, ".datasource": parse_datasource}
|
|
318
|
+
incl_suffix = ".incl"
|
|
319
|
+
|
|
320
|
+
for filename in filenames:
|
|
321
|
+
file_suffix = Path(filename).suffix
|
|
322
|
+
if file_suffix == incl_suffix:
|
|
323
|
+
continue
|
|
324
|
+
|
|
325
|
+
parser = parser_matrix.get(file_suffix)
|
|
326
|
+
if not parser:
|
|
327
|
+
raise ParseException(FeedbackManager.error_unsupported_datafile(extension=file_suffix))
|
|
328
|
+
|
|
329
|
+
parser(filename)
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
def dev_cloud(
|
|
333
|
+
ctx: click.Context,
|
|
334
|
+
) -> None:
|
|
335
|
+
project: Project = ctx.ensure_object(dict)["project"]
|
|
336
|
+
config = CLIConfig.get_project_config()
|
|
337
|
+
tb_client: TinyB = config.get_client()
|
|
338
|
+
context.disable_template_security_validation.set(True)
|
|
339
|
+
|
|
340
|
+
async def process(filenames: List[str], watch: bool = False):
|
|
341
|
+
datafiles = [f for f in filenames if f.endswith(".datasource") or f.endswith(".pipe")]
|
|
342
|
+
if len(datafiles) > 0:
|
|
343
|
+
check_filenames(filenames=datafiles)
|
|
344
|
+
await folder_playground(
|
|
345
|
+
project, config, tb_client, filenames=datafiles, is_internal=False, current_ws=None, local_ws=None
|
|
346
|
+
)
|
|
347
|
+
if len(filenames) > 0 and watch:
|
|
348
|
+
filename = filenames[0]
|
|
349
|
+
await build_and_print_resource(config, tb_client, filename)
|
|
350
|
+
|
|
351
|
+
datafiles = project.get_project_files()
|
|
352
|
+
filenames = datafiles
|
|
353
|
+
|
|
354
|
+
async def build_once(filenames: List[str]):
|
|
355
|
+
ok = False
|
|
356
|
+
try:
|
|
357
|
+
click.echo(FeedbackManager.highlight(message="» Building project...\n"))
|
|
358
|
+
time_start = time.time()
|
|
359
|
+
await process(filenames=filenames, watch=False)
|
|
360
|
+
time_end = time.time()
|
|
361
|
+
elapsed_time = time_end - time_start
|
|
362
|
+
|
|
363
|
+
click.echo(FeedbackManager.success(message=f"\n✓ Build completed in {elapsed_time:.1f}s"))
|
|
364
|
+
ok = True
|
|
365
|
+
except Exception as e:
|
|
366
|
+
error_path = Path(".tb_error.txt")
|
|
367
|
+
if error_path.exists():
|
|
368
|
+
content = error_path.read_text()
|
|
369
|
+
content += f"\n\n{str(e)}"
|
|
370
|
+
error_path.write_text(content)
|
|
371
|
+
else:
|
|
372
|
+
error_path.write_text(str(e))
|
|
373
|
+
click.echo(FeedbackManager.error_exception(error=e))
|
|
374
|
+
ok = False
|
|
375
|
+
return ok
|
|
376
|
+
|
|
377
|
+
build_ok = asyncio.run(build_once(filenames))
|
|
378
|
+
|
|
379
|
+
shell = Shell(project=project, tb_client=tb_client, playground=True)
|
|
380
|
+
click.echo(FeedbackManager.gray(message="\nWatching for changes..."))
|
|
381
|
+
watcher_thread = threading.Thread(
|
|
382
|
+
target=watch_files, args=(filenames, process, shell, project, build_ok), daemon=True
|
|
383
|
+
)
|
|
384
|
+
watcher_thread.start()
|
|
385
|
+
shell.run()
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
async def build_and_print_resource(config: CLIConfig, tb_client: TinyB, filename: str):
|
|
389
|
+
resource_path = Path(filename)
|
|
390
|
+
name = resource_path.stem
|
|
391
|
+
playground_name = name if filename.endswith(".pipe") else None
|
|
392
|
+
user_client = deepcopy(tb_client)
|
|
393
|
+
user_client.token = config.get_user_token() or ""
|
|
394
|
+
cli_params = {}
|
|
395
|
+
cli_params["workspace_id"] = config.get("id", None)
|
|
396
|
+
data = await user_client._req(f"/v0/playgrounds?{urlencode(cli_params)}")
|
|
397
|
+
playgrounds = data["playgrounds"]
|
|
398
|
+
playground = next((p for p in playgrounds if p["name"] == (f"{playground_name}" + "__tb__playground")), None)
|
|
399
|
+
if not playground:
|
|
400
|
+
return
|
|
401
|
+
playground_id = playground["id"]
|
|
402
|
+
last_node = playground["nodes"][-1]
|
|
403
|
+
if not last_node:
|
|
404
|
+
return
|
|
405
|
+
node_sql = last_node["sql"]
|
|
406
|
+
res = await tb_client.query(f"{node_sql} FORMAT JSON", playground=playground_id)
|
|
407
|
+
print_table_formatted(res, name)
|
|
@@ -372,7 +372,7 @@ async def create_ctx_client(ctx: Context, config: Dict[str, Any], cloud: bool, b
|
|
|
372
372
|
if command in commands_without_ctx_client:
|
|
373
373
|
return None
|
|
374
374
|
|
|
375
|
-
commands_always_cloud = ["pull", "
|
|
375
|
+
commands_always_cloud = ["pull", "infra"]
|
|
376
376
|
commands_always_build = ["build", "test", "dev", "create"]
|
|
377
377
|
commands_always_local: List[str] = []
|
|
378
378
|
if (
|
|
@@ -53,7 +53,6 @@ tinybird/tb/modules/materialization.py
|
|
|
53
53
|
tinybird/tb/modules/mock.py
|
|
54
54
|
tinybird/tb/modules/open.py
|
|
55
55
|
tinybird/tb/modules/pipe.py
|
|
56
|
-
tinybird/tb/modules/playground.py
|
|
57
56
|
tinybird/tb/modules/project.py
|
|
58
57
|
tinybird/tb/modules/regions.py
|
|
59
58
|
tinybird/tb/modules/secret.py
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import asyncio
|
|
2
|
-
import threading
|
|
3
|
-
import time
|
|
4
|
-
from copy import deepcopy
|
|
5
|
-
from pathlib import Path
|
|
6
|
-
from typing import List
|
|
7
|
-
from urllib.parse import urlencode
|
|
8
|
-
|
|
9
|
-
import click
|
|
10
|
-
|
|
11
|
-
import tinybird.context as context
|
|
12
|
-
from tinybird.client import TinyB
|
|
13
|
-
from tinybird.tb.modules.cli import cli
|
|
14
|
-
from tinybird.tb.modules.config import CLIConfig
|
|
15
|
-
from tinybird.tb.modules.datafile.exceptions import ParseException
|
|
16
|
-
from tinybird.tb.modules.datafile.parse_datasource import parse_datasource
|
|
17
|
-
from tinybird.tb.modules.datafile.parse_pipe import parse_pipe
|
|
18
|
-
from tinybird.tb.modules.datafile.playground import folder_playground
|
|
19
|
-
from tinybird.tb.modules.feedback_manager import FeedbackManager
|
|
20
|
-
from tinybird.tb.modules.project import Project
|
|
21
|
-
from tinybird.tb.modules.shell import Shell, print_table_formatted
|
|
22
|
-
from tinybird.tb.modules.watch import watch_files
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def is_vendor(f: Path) -> bool:
|
|
26
|
-
return f.parts[0] == "vendor"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def get_vendor_workspace(f: Path) -> str:
|
|
30
|
-
return f.parts[1]
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
def is_endpoint(f: Path) -> bool:
|
|
34
|
-
return f.suffix == ".pipe" and not is_vendor(f) and f.parts[0] == "endpoints"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def is_pipe(f: Path) -> bool:
|
|
38
|
-
return f.suffix == ".pipe" and not is_vendor(f)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
def check_filenames(filenames: List[str]):
|
|
42
|
-
parser_matrix = {".pipe": parse_pipe, ".datasource": parse_datasource}
|
|
43
|
-
incl_suffix = ".incl"
|
|
44
|
-
|
|
45
|
-
for filename in filenames:
|
|
46
|
-
file_suffix = Path(filename).suffix
|
|
47
|
-
if file_suffix == incl_suffix:
|
|
48
|
-
continue
|
|
49
|
-
|
|
50
|
-
parser = parser_matrix.get(file_suffix)
|
|
51
|
-
if not parser:
|
|
52
|
-
raise ParseException(FeedbackManager.error_unsupported_datafile(extension=file_suffix))
|
|
53
|
-
|
|
54
|
-
parser(filename)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
@cli.command()
|
|
58
|
-
@click.pass_context
|
|
59
|
-
def playground(
|
|
60
|
-
ctx: click.Context,
|
|
61
|
-
) -> None:
|
|
62
|
-
"""Build the project in Tinybird Local."""
|
|
63
|
-
project: Project = ctx.ensure_object(dict)["project"]
|
|
64
|
-
tb_client: TinyB = ctx.ensure_object(dict)["client"]
|
|
65
|
-
config = CLIConfig.get_project_config()
|
|
66
|
-
context.disable_template_security_validation.set(True)
|
|
67
|
-
|
|
68
|
-
async def process(filenames: List[str], watch: bool = False):
|
|
69
|
-
datafiles = [f for f in filenames if f.endswith(".datasource") or f.endswith(".pipe")]
|
|
70
|
-
if len(datafiles) > 0:
|
|
71
|
-
check_filenames(filenames=datafiles)
|
|
72
|
-
await folder_playground(
|
|
73
|
-
project, config, tb_client, filenames=datafiles, is_internal=False, current_ws=None, local_ws=None
|
|
74
|
-
)
|
|
75
|
-
if len(filenames) > 0 and watch:
|
|
76
|
-
filename = filenames[0]
|
|
77
|
-
await build_and_print_resource(config, tb_client, filename)
|
|
78
|
-
|
|
79
|
-
datafiles = project.get_project_files()
|
|
80
|
-
filenames = datafiles
|
|
81
|
-
|
|
82
|
-
async def build_once(filenames: List[str]):
|
|
83
|
-
ok = False
|
|
84
|
-
try:
|
|
85
|
-
click.echo(FeedbackManager.highlight(message="» Building project...\n"))
|
|
86
|
-
time_start = time.time()
|
|
87
|
-
await process(filenames=filenames, watch=False)
|
|
88
|
-
time_end = time.time()
|
|
89
|
-
elapsed_time = time_end - time_start
|
|
90
|
-
|
|
91
|
-
click.echo(FeedbackManager.success(message=f"\n✓ Build completed in {elapsed_time:.1f}s"))
|
|
92
|
-
ok = True
|
|
93
|
-
except Exception as e:
|
|
94
|
-
error_path = Path(".tb_error.txt")
|
|
95
|
-
if error_path.exists():
|
|
96
|
-
content = error_path.read_text()
|
|
97
|
-
content += f"\n\n{str(e)}"
|
|
98
|
-
error_path.write_text(content)
|
|
99
|
-
else:
|
|
100
|
-
error_path.write_text(str(e))
|
|
101
|
-
click.echo(FeedbackManager.error_exception(error=e))
|
|
102
|
-
ok = False
|
|
103
|
-
return ok
|
|
104
|
-
|
|
105
|
-
build_ok = asyncio.run(build_once(filenames))
|
|
106
|
-
|
|
107
|
-
shell = Shell(project=project, tb_client=tb_client, playground=True)
|
|
108
|
-
click.echo(FeedbackManager.gray(message="\nWatching for changes..."))
|
|
109
|
-
watcher_thread = threading.Thread(
|
|
110
|
-
target=watch_files, args=(filenames, process, shell, project, build_ok), daemon=True
|
|
111
|
-
)
|
|
112
|
-
watcher_thread.start()
|
|
113
|
-
shell.run()
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
async def build_and_print_resource(config: CLIConfig, tb_client: TinyB, filename: str):
|
|
117
|
-
resource_path = Path(filename)
|
|
118
|
-
name = resource_path.stem
|
|
119
|
-
playground_name = name if filename.endswith(".pipe") else None
|
|
120
|
-
user_client = deepcopy(tb_client)
|
|
121
|
-
user_client.token = config.get_user_token() or ""
|
|
122
|
-
cli_params = {}
|
|
123
|
-
cli_params["workspace_id"] = config.get("id", None)
|
|
124
|
-
data = await user_client._req(f"/v0/playgrounds?{urlencode(cli_params)}")
|
|
125
|
-
playgrounds = data["playgrounds"]
|
|
126
|
-
playground = next((p for p in playgrounds if p["name"] == (f"{playground_name}" + "__tb__playground")), None)
|
|
127
|
-
if not playground:
|
|
128
|
-
return
|
|
129
|
-
playground_id = playground["id"]
|
|
130
|
-
last_node = playground["nodes"][-1]
|
|
131
|
-
if not last_node:
|
|
132
|
-
return
|
|
133
|
-
node_sql = last_node["sql"]
|
|
134
|
-
res = await tb_client.query(f"{node_sql} FORMAT JSON", playground=playground_id)
|
|
135
|
-
print_table_formatted(res, name)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/datafile/build_common.py
RENAMED
|
File without changes
|
{tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/datafile/build_datasource.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/datafile/format_common.py
RENAMED
|
File without changes
|
{tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/datafile/format_datasource.py
RENAMED
|
File without changes
|
|
File without changes
|
{tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/datafile/parse_datasource.py
RENAMED
|
File without changes
|
|
File without changes
|
{tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/datafile/pipe_checker.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb/modules/tinyunit/tinyunit_lib.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb_cli_modules/tinyunit/tinyunit.py
RENAMED
|
File without changes
|
{tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb_cli_modules/tinyunit/tinyunit_lib.py
RENAMED
|
File without changes
|
|
File without changes
|
{tinybird-0.0.1.dev113 → tinybird-0.0.1.dev114}/tinybird/tb_cli_modules/workspace_members.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|