tinybird 0.0.1.dev19__py3-none-any.whl → 0.0.1.dev21__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/client.py +2 -2
- tinybird/config.py +1 -1
- tinybird/feedback_manager.py +8 -30
- tinybird/prompts.py +2 -2
- tinybird/tb/__cli__.py +2 -2
- tinybird/tb/modules/auth.py +1 -1
- tinybird/tb/modules/build.py +10 -78
- tinybird/tb/modules/cicd.py +1 -1
- tinybird/tb/modules/cli.py +9 -837
- tinybird/tb/modules/common.py +1 -55
- tinybird/tb/modules/connection.py +1 -1
- tinybird/tb/modules/create.py +26 -13
- tinybird/tb/modules/datafile/build.py +142 -971
- tinybird/tb/modules/datafile/build_common.py +1 -1
- tinybird/tb/modules/datafile/build_datasource.py +1 -1
- tinybird/tb/modules/datafile/build_pipe.py +1 -1
- tinybird/tb/modules/datafile/common.py +11 -11
- tinybird/tb/modules/datafile/diff.py +1 -1
- tinybird/tb/modules/datafile/fixture.py +1 -1
- tinybird/tb/modules/datafile/format_common.py +0 -7
- tinybird/tb/modules/datafile/format_datasource.py +0 -2
- tinybird/tb/modules/datafile/format_pipe.py +0 -2
- tinybird/tb/modules/datafile/parse_datasource.py +1 -1
- tinybird/tb/modules/datafile/parse_pipe.py +1 -1
- tinybird/tb/modules/datafile/pull.py +1 -1
- tinybird/tb/modules/datasource.py +4 -75
- tinybird/tb/modules/feedback_manager.py +1048 -0
- tinybird/tb/modules/fmt.py +1 -1
- tinybird/tb/modules/job.py +1 -1
- tinybird/tb/modules/llm.py +15 -26
- tinybird/tb/modules/local.py +33 -32
- tinybird/tb/modules/local_common.py +2 -1
- tinybird/tb/modules/login.py +8 -8
- tinybird/tb/modules/mock.py +19 -9
- tinybird/tb/modules/pipe.py +4 -126
- tinybird/tb/modules/{build_shell.py → shell.py} +9 -21
- tinybird/tb/modules/table.py +88 -5
- tinybird/tb/modules/tag.py +2 -2
- tinybird/tb/modules/test.py +13 -15
- tinybird/tb/modules/tinyunit/tinyunit.py +1 -1
- tinybird/tb/modules/token.py +2 -2
- tinybird/tb/modules/watch.py +72 -0
- tinybird/tb/modules/workspace.py +1 -1
- tinybird/tb/modules/workspace_members.py +1 -1
- {tinybird-0.0.1.dev19.dist-info → tinybird-0.0.1.dev21.dist-info}/METADATA +1 -1
- tinybird-0.0.1.dev21.dist-info/RECORD +76 -0
- tinybird-0.0.1.dev19.dist-info/RECORD +0 -74
- {tinybird-0.0.1.dev19.dist-info → tinybird-0.0.1.dev21.dist-info}/WHEEL +0 -0
- {tinybird-0.0.1.dev19.dist-info → tinybird-0.0.1.dev21.dist-info}/entry_points.txt +0 -0
- {tinybird-0.0.1.dev19.dist-info → tinybird-0.0.1.dev21.dist-info}/top_level.txt +0 -0
tinybird/tb/modules/common.py
CHANGED
|
@@ -37,7 +37,6 @@ from packaging.version import Version
|
|
|
37
37
|
from tinybird.client import (
|
|
38
38
|
AuthException,
|
|
39
39
|
AuthNoTokenException,
|
|
40
|
-
ConnectorNothingToLoad,
|
|
41
40
|
DoesNotExistException,
|
|
42
41
|
JobException,
|
|
43
42
|
OperationCanNotBePerformed,
|
|
@@ -46,8 +45,6 @@ from tinybird.client import (
|
|
|
46
45
|
from tinybird.config import (
|
|
47
46
|
DEFAULT_API_HOST,
|
|
48
47
|
DEFAULT_UI_HOST,
|
|
49
|
-
DEPRECATED_PROJECT_PATHS,
|
|
50
|
-
PROJECT_PATHS,
|
|
51
48
|
SUPPORTED_CONNECTORS,
|
|
52
49
|
VERSION,
|
|
53
50
|
FeatureFlags,
|
|
@@ -60,7 +57,6 @@ from tinybird.tb.modules.table import format_table
|
|
|
60
57
|
if TYPE_CHECKING:
|
|
61
58
|
from tinybird.connectors import Connector
|
|
62
59
|
|
|
63
|
-
from tinybird.feedback_manager import FeedbackManager, warning_message
|
|
64
60
|
from tinybird.syncasync import async_to_sync, sync_to_async
|
|
65
61
|
from tinybird.tb.modules.config import CLIConfig
|
|
66
62
|
from tinybird.tb.modules.exceptions import (
|
|
@@ -70,6 +66,7 @@ from tinybird.tb.modules.exceptions import (
|
|
|
70
66
|
CLIReleaseException,
|
|
71
67
|
CLIWorkspaceException,
|
|
72
68
|
)
|
|
69
|
+
from tinybird.tb.modules.feedback_manager import FeedbackManager, warning_message
|
|
73
70
|
from tinybird.tb.modules.regions import Region
|
|
74
71
|
from tinybird.tb.modules.telemetry import (
|
|
75
72
|
add_telemetry_event,
|
|
@@ -347,29 +344,6 @@ async def _generate_datafile(
|
|
|
347
344
|
return generate_datafile(datafile, filename, data, force, _format=format)
|
|
348
345
|
|
|
349
346
|
|
|
350
|
-
async def folder_init(
|
|
351
|
-
client: TinyB,
|
|
352
|
-
folder: str,
|
|
353
|
-
generate_datasources: Optional[bool] = False,
|
|
354
|
-
force: Optional[bool] = False,
|
|
355
|
-
generate_releases: Optional[bool] = False,
|
|
356
|
-
):
|
|
357
|
-
for x in filter(lambda x: x not in DEPRECATED_PROJECT_PATHS, PROJECT_PATHS):
|
|
358
|
-
try:
|
|
359
|
-
f = Path(folder) / x
|
|
360
|
-
f.mkdir()
|
|
361
|
-
click.echo(FeedbackManager.info_path_created(path=x))
|
|
362
|
-
except FileExistsError:
|
|
363
|
-
if not force:
|
|
364
|
-
click.echo(FeedbackManager.info_path_already_exists(path=x))
|
|
365
|
-
pass
|
|
366
|
-
|
|
367
|
-
if generate_datasources:
|
|
368
|
-
for format in SUPPORTED_FORMATS:
|
|
369
|
-
for path in Path(folder).glob(f"*.{format}"):
|
|
370
|
-
await _generate_datafile(str(path), client, format=format, force=force)
|
|
371
|
-
|
|
372
|
-
|
|
373
347
|
async def configure_connector(connector):
|
|
374
348
|
if connector not in SUPPORTED_CONNECTORS:
|
|
375
349
|
raise CLIException(FeedbackManager.error_invalid_connector(connectors=", ".join(SUPPORTED_CONNECTORS)))
|
|
@@ -876,39 +850,18 @@ def get_format_from_filename_or_url(filename_or_url: str) -> str:
|
|
|
876
850
|
|
|
877
851
|
|
|
878
852
|
async def push_data(
|
|
879
|
-
ctx: Context,
|
|
880
853
|
client: TinyB,
|
|
881
854
|
datasource_name: str,
|
|
882
855
|
url,
|
|
883
|
-
connector: Optional[str],
|
|
884
|
-
sql: Optional[str],
|
|
885
856
|
mode: str = "append",
|
|
886
857
|
sql_condition: Optional[str] = None,
|
|
887
858
|
replace_options=None,
|
|
888
|
-
ignore_empty: bool = False,
|
|
889
859
|
concurrency: int = 1,
|
|
890
860
|
silent: bool = False,
|
|
891
861
|
):
|
|
892
862
|
if url and type(url) is tuple:
|
|
893
863
|
url = url[0]
|
|
894
864
|
|
|
895
|
-
if connector and sql:
|
|
896
|
-
load_connector_config(ctx, connector, False, check_uninstalled=False)
|
|
897
|
-
if connector not in ctx.obj:
|
|
898
|
-
raise CLIException(FeedbackManager.error_connector_not_configured(connector=connector))
|
|
899
|
-
else:
|
|
900
|
-
_connector: "Connector" = ctx.obj[connector]
|
|
901
|
-
if not silent:
|
|
902
|
-
click.echo(FeedbackManager.info_starting_export_process(connector=connector))
|
|
903
|
-
try:
|
|
904
|
-
url = _connector.export_to_gcs(sql, datasource_name, mode)
|
|
905
|
-
except ConnectorNothingToLoad as e:
|
|
906
|
-
if ignore_empty:
|
|
907
|
-
click.echo(str(e))
|
|
908
|
-
return
|
|
909
|
-
else:
|
|
910
|
-
raise e
|
|
911
|
-
|
|
912
865
|
def cb(res):
|
|
913
866
|
if cb.First: # type: ignore[attr-defined]
|
|
914
867
|
blocks_to_process = len([x for x in res["block_log"] if x["status"] == "idle"])
|
|
@@ -1008,13 +961,6 @@ async def push_data(
|
|
|
1008
961
|
|
|
1009
962
|
click.echo(FeedbackManager.success_progress_blocks())
|
|
1010
963
|
|
|
1011
|
-
finally:
|
|
1012
|
-
try:
|
|
1013
|
-
for url in urls:
|
|
1014
|
-
_connector.clean(urlparse(url).path.split("/")[-1])
|
|
1015
|
-
except Exception:
|
|
1016
|
-
pass
|
|
1017
|
-
|
|
1018
964
|
|
|
1019
965
|
async def sync_data(ctx, datasource_name: str, yes: bool):
|
|
1020
966
|
client: TinyB = ctx.obj["client"]
|
|
@@ -13,7 +13,6 @@ import click
|
|
|
13
13
|
from click import Context
|
|
14
14
|
|
|
15
15
|
from tinybird.client import DoesNotExistException, TinyB
|
|
16
|
-
from tinybird.feedback_manager import FeedbackManager
|
|
17
16
|
from tinybird.tb.modules.cli import cli
|
|
18
17
|
from tinybird.tb.modules.common import (
|
|
19
18
|
ConnectionReplacements,
|
|
@@ -34,6 +33,7 @@ from tinybird.tb.modules.common import (
|
|
|
34
33
|
validate_string_connector_param,
|
|
35
34
|
)
|
|
36
35
|
from tinybird.tb.modules.exceptions import CLIConnectionException
|
|
36
|
+
from tinybird.tb.modules.feedback_manager import FeedbackManager
|
|
37
37
|
from tinybird.tb.modules.telemetry import is_ci_environment
|
|
38
38
|
|
|
39
39
|
DATA_CONNECTOR_SETTINGS: Dict[DataConnectorType, List[str]] = {
|
tinybird/tb/modules/create.py
CHANGED
|
@@ -7,13 +7,13 @@ import click
|
|
|
7
7
|
import requests
|
|
8
8
|
|
|
9
9
|
from tinybird.client import TinyB
|
|
10
|
-
from tinybird.feedback_manager import FeedbackManager
|
|
11
10
|
from tinybird.tb.modules.cicd import init_cicd
|
|
12
11
|
from tinybird.tb.modules.cli import cli
|
|
13
12
|
from tinybird.tb.modules.common import _generate_datafile, check_user_token, coro, generate_datafile
|
|
14
13
|
from tinybird.tb.modules.config import CLIConfig
|
|
15
14
|
from tinybird.tb.modules.datafile.fixture import build_fixture_name, persist_fixture
|
|
16
15
|
from tinybird.tb.modules.exceptions import CLIException
|
|
16
|
+
from tinybird.tb.modules.feedback_manager import FeedbackManager
|
|
17
17
|
from tinybird.tb.modules.llm import LLM
|
|
18
18
|
|
|
19
19
|
|
|
@@ -56,10 +56,13 @@ async def create(
|
|
|
56
56
|
folder = folder or getcwd()
|
|
57
57
|
try:
|
|
58
58
|
config = CLIConfig.get_project_config(folder)
|
|
59
|
+
user_token: Optional[str] = None
|
|
59
60
|
|
|
60
61
|
if prompt:
|
|
61
|
-
user_token = config.get_user_token()
|
|
62
62
|
try:
|
|
63
|
+
user_token = config.get_user_token()
|
|
64
|
+
if not user_token:
|
|
65
|
+
raise CLIException("No user token found")
|
|
63
66
|
await check_user_token(ctx, token=user_token)
|
|
64
67
|
except Exception:
|
|
65
68
|
click.echo(FeedbackManager.error(message="This action requires authentication. Run 'tb login' first."))
|
|
@@ -67,7 +70,7 @@ async def create(
|
|
|
67
70
|
|
|
68
71
|
tb_client = config.get_client()
|
|
69
72
|
click.echo(FeedbackManager.gray(message="Creating new project structure..."))
|
|
70
|
-
await project_create(tb_client, data, prompt, folder)
|
|
73
|
+
await project_create(tb_client, user_token, data, prompt, folder)
|
|
71
74
|
click.echo(FeedbackManager.success(message="✓ Scaffolding completed!\n"))
|
|
72
75
|
|
|
73
76
|
click.echo(FeedbackManager.gray(message="\nCreating CI/CD files for GitHub and GitLab..."))
|
|
@@ -91,7 +94,9 @@ async def create(
|
|
|
91
94
|
fixture_content = fetch_gist_content(
|
|
92
95
|
"https://gist.githubusercontent.com/gnzjgo/8e8f66a39d7576ce3a2529bf773334a8/raw/9cab636767990e97d44a141867e5f226e992de8c/users.ndjson"
|
|
93
96
|
)
|
|
94
|
-
fixture_name = build_fixture_name(
|
|
97
|
+
fixture_name = build_fixture_name(
|
|
98
|
+
datasource_path.absolute().as_posix(), ds_name, datasource_path.read_text()
|
|
99
|
+
)
|
|
95
100
|
persist_fixture(fixture_name, fixture_content)
|
|
96
101
|
click.echo(FeedbackManager.info(message=f"✓ /fixtures/{ds_name}"))
|
|
97
102
|
|
|
@@ -108,7 +113,9 @@ async def create(
|
|
|
108
113
|
fixture_content = fetch_gist_content(
|
|
109
114
|
"https://gist.githubusercontent.com/gnzjgo/859ab9439c17e77241d0c14a5a532809/raw/251f2f3f00a968f8759ec4068cebde915256b054/events.ndjson"
|
|
110
115
|
)
|
|
111
|
-
fixture_name = build_fixture_name(
|
|
116
|
+
fixture_name = build_fixture_name(
|
|
117
|
+
datasource_path.absolute().as_posix(), ds_name, datasource_path.read_text()
|
|
118
|
+
)
|
|
112
119
|
persist_fixture(fixture_name, fixture_content)
|
|
113
120
|
click.echo(FeedbackManager.info(message=f"✓ /fixtures/{ds_name}"))
|
|
114
121
|
|
|
@@ -134,14 +141,16 @@ async def create(
|
|
|
134
141
|
ds_name = os.path.basename(data.split(".")[0])
|
|
135
142
|
data_content = Path(data).read_text()
|
|
136
143
|
datasource_path = Path(folder) / "datasources" / f"{ds_name}.datasource"
|
|
137
|
-
fixture_name = build_fixture_name(
|
|
144
|
+
fixture_name = build_fixture_name(
|
|
145
|
+
datasource_path.absolute().as_posix(), ds_name, datasource_path.read_text()
|
|
146
|
+
)
|
|
138
147
|
click.echo(FeedbackManager.info(message=f"✓ /fixtures/{ds_name}"))
|
|
139
148
|
persist_fixture(fixture_name, data_content)
|
|
140
|
-
elif prompt:
|
|
149
|
+
elif prompt and user_token:
|
|
141
150
|
datasource_files = [f for f in os.listdir(Path(folder) / "datasources") if f.endswith(".datasource")]
|
|
142
151
|
for datasource_file in datasource_files:
|
|
143
152
|
datasource_path = Path(folder) / "datasources" / datasource_file
|
|
144
|
-
llm = LLM(client=tb_client)
|
|
153
|
+
llm = LLM(user_token=user_token, client=tb_client)
|
|
145
154
|
datasource_name = datasource_path.stem
|
|
146
155
|
datasource_content = datasource_path.read_text()
|
|
147
156
|
has_json_path = "`json:" in datasource_content
|
|
@@ -149,9 +158,12 @@ async def create(
|
|
|
149
158
|
sql = await llm.generate_sql_sample_data(schema=datasource_content, rows=rows, prompt=prompt)
|
|
150
159
|
result = await tb_client.query(f"{sql} FORMAT JSON")
|
|
151
160
|
data = result.get("data", [])
|
|
152
|
-
fixture_name = build_fixture_name(
|
|
153
|
-
|
|
154
|
-
|
|
161
|
+
fixture_name = build_fixture_name(
|
|
162
|
+
datasource_path.absolute().as_posix(), datasource_name, datasource_content
|
|
163
|
+
)
|
|
164
|
+
if data:
|
|
165
|
+
persist_fixture(fixture_name, data)
|
|
166
|
+
click.echo(FeedbackManager.info(message=f"✓ /fixtures/{datasource_name}"))
|
|
155
167
|
|
|
156
168
|
click.echo(FeedbackManager.success(message="✓ Done!\n"))
|
|
157
169
|
except Exception as e:
|
|
@@ -160,6 +172,7 @@ async def create(
|
|
|
160
172
|
|
|
161
173
|
async def project_create(
|
|
162
174
|
client: TinyB,
|
|
175
|
+
user_token: Optional[str],
|
|
163
176
|
data: Optional[str],
|
|
164
177
|
prompt: Optional[str],
|
|
165
178
|
folder: str,
|
|
@@ -192,9 +205,9 @@ TYPE ENDPOINT
|
|
|
192
205
|
""",
|
|
193
206
|
folder,
|
|
194
207
|
)
|
|
195
|
-
elif prompt:
|
|
208
|
+
elif prompt and user_token:
|
|
196
209
|
try:
|
|
197
|
-
llm = LLM(client=client)
|
|
210
|
+
llm = LLM(user_token=user_token, client=client)
|
|
198
211
|
result = await llm.create_project(prompt)
|
|
199
212
|
for ds in result.datasources:
|
|
200
213
|
content = ds.content.replace("```", "")
|