tinybird 0.0.1.dev24__tar.gz → 0.0.1.dev25__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.dev24 → tinybird-0.0.1.dev25}/PKG-INFO +1 -1
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/prompts.py +87 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/__cli__.py +2 -2
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/datafile/build.py +13 -4
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/feedback_manager.py +1 -1
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/test.py +52 -39
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird.egg-info/PKG-INFO +1 -1
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/setup.cfg +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/__cli__.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/ch_utils/constants.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/ch_utils/engine.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/check_pypi.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/client.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/config.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/connectors.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/context.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/datafile.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/datatypes.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/feedback_manager.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/git_settings.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/sql.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/sql_template.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/sql_template_fmt.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/sql_toolset.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/syncasync.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/cli.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/auth.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/build.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/cicd.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/cli.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/common.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/config.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/connection.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/create.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/datafile/build_common.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/datafile/build_datasource.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/datafile/build_pipe.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/datafile/common.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/datafile/diff.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/datafile/exceptions.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/datafile/fixture.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/datafile/format_common.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/datafile/format_datasource.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/datafile/format_pipe.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/datafile/parse_datasource.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/datafile/parse_pipe.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/datafile/pipe_checker.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/datafile/pull.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/datasource.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/exceptions.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/fmt.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/job.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/llm.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/local.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/local_common.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/login.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/mock.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/pipe.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/regions.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/shell.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/table.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/tag.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/telemetry.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/tinyunit/tinyunit.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/tinyunit/tinyunit_lib.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/token.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/watch.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/workspace.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/workspace_members.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb_cli.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb_cli_modules/auth.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb_cli_modules/branch.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb_cli_modules/cicd.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb_cli_modules/cli.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb_cli_modules/common.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb_cli_modules/config.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb_cli_modules/connection.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb_cli_modules/datasource.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb_cli_modules/exceptions.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb_cli_modules/fmt.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb_cli_modules/job.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb_cli_modules/pipe.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb_cli_modules/regions.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb_cli_modules/tag.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb_cli_modules/telemetry.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb_cli_modules/test.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb_cli_modules/tinyunit/tinyunit.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb_cli_modules/tinyunit/tinyunit_lib.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb_cli_modules/workspace.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb_cli_modules/workspace_members.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tornado_template.py +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird.egg-info/SOURCES.txt +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird.egg-info/dependency_links.txt +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird.egg-info/entry_points.txt +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird.egg-info/requires.txt +0 -0
- {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird.egg-info/top_level.txt +0 -0
|
@@ -117,6 +117,93 @@ FROM numbers({rows})
|
|
|
117
117
|
- Do NOT add a semicolon at the end of the query
|
|
118
118
|
- Do NOT add any FORMAT at the end of the query, because it will be added later by Tinybird.
|
|
119
119
|
|
|
120
|
+
# Examples with different schemas, like an array field or a nested JSON field:
|
|
121
|
+
|
|
122
|
+
## Example schema with an array field:
|
|
123
|
+
|
|
124
|
+
### Schema:
|
|
125
|
+
|
|
126
|
+
SCHEMA >
|
|
127
|
+
`order_id` UInt64 `json:$.order_id`,
|
|
128
|
+
`customer_id` UInt64 `json:$.customer_id`,
|
|
129
|
+
`order_date` DateTime `json:$.order_date`,
|
|
130
|
+
`total_amount` Float64 `json:$.total_amount`,
|
|
131
|
+
`items` Array(String) `json:$.items[:]` // This is an array field
|
|
132
|
+
|
|
133
|
+
### Desired final output of the query:
|
|
134
|
+
{
|
|
135
|
+
"order_id": 123456,
|
|
136
|
+
"customer_id": 7890,
|
|
137
|
+
"order_date": "2024-11-30T10:30:00.000Z",
|
|
138
|
+
"total_amount": 150.0,
|
|
139
|
+
"items": ["item1", "item2", "item3"]
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
### Example SQL output with an array field:
|
|
143
|
+
|
|
144
|
+
SELECT
|
|
145
|
+
concat('ord_', toString(rand() % 10000)) AS order_id,
|
|
146
|
+
concat('cust_', toString(rand() % 10000)) AS customer_id,
|
|
147
|
+
now() - rand() % 86400 AS order_date,
|
|
148
|
+
rand() % 1000 AS total_amount,
|
|
149
|
+
arrayMap(x -> concat('item_', toString(x)), range(1, rand() % 5 + 1)) AS items
|
|
150
|
+
FROM numbers(ROWS)
|
|
151
|
+
|
|
152
|
+
## Example schema with a nested JSON field:
|
|
153
|
+
|
|
154
|
+
### Schema:
|
|
155
|
+
|
|
156
|
+
SCHEMA >
|
|
157
|
+
`request_id` String `json:$.request_id`,
|
|
158
|
+
`timestamp` DateTime `json:$.timestamp`,
|
|
159
|
+
`model` String `json:$.request.model`,
|
|
160
|
+
`temperature` Float32 `json:$.request.options.temperature`,
|
|
161
|
+
`max_tokens` UInt32 `json:$.request.options.max_tokens`,
|
|
162
|
+
`stream` UInt8 `json:$.request.options.stream`
|
|
163
|
+
|
|
164
|
+
### Desired final output of the query:
|
|
165
|
+
|
|
166
|
+
Note that the important part is generating the nested fields:
|
|
167
|
+
json:$.request.options.max_tokens > this means that the max_tokens field is nested inside the options field inside the request field.
|
|
168
|
+
|
|
169
|
+
{
|
|
170
|
+
"request_id": "req_abc123",
|
|
171
|
+
"timestamp": "2024-11-30T10:30:00.000Z",
|
|
172
|
+
"request": {
|
|
173
|
+
"model": "gpt-4",
|
|
174
|
+
"options": {
|
|
175
|
+
"temperature": 0.7,
|
|
176
|
+
"max_tokens": 1000,
|
|
177
|
+
"stream": false
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
### Example SQL output with nested fields:
|
|
183
|
+
|
|
184
|
+
SELECT
|
|
185
|
+
request_id,
|
|
186
|
+
timestamp,
|
|
187
|
+
CAST(concat('{
|
|
188
|
+
"model": "', model, '",
|
|
189
|
+
"options": {
|
|
190
|
+
"temperature": ', temperature, ',
|
|
191
|
+
"max_tokens": ', max_tokens, ',
|
|
192
|
+
"stream": ', IF(stream = 1, 'true', 'false'), '
|
|
193
|
+
}
|
|
194
|
+
}'), 'JSON') AS request
|
|
195
|
+
FROM
|
|
196
|
+
(
|
|
197
|
+
SELECT
|
|
198
|
+
concat('req_', lower(hex(randomString(6)))) AS request_id,
|
|
199
|
+
(now() - toIntervalDay(rand() % 30)) + toIntervalSecond(rand() % 86400) AS timestamp,
|
|
200
|
+
['gpt-4', 'gpt-3.5-turbo', 'gpt-4-turbo'][(rand() % 3) + 1] AS model,
|
|
201
|
+
round(rand() / 10, 2) AS temperature,
|
|
202
|
+
500 + (rand() % 2500) AS max_tokens,
|
|
203
|
+
rand() % 2 AS stream
|
|
204
|
+
FROM numbers(ROWS)
|
|
205
|
+
)
|
|
206
|
+
|
|
120
207
|
# Extra context:
|
|
121
208
|
{context}
|
|
122
209
|
|
|
@@ -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.dev25'
|
|
8
|
+
__revision__ = 'd7ae6dd'
|
|
@@ -773,11 +773,11 @@ async def get_processed(
|
|
|
773
773
|
filenames: Iterable[str],
|
|
774
774
|
changed: Optional[Dict[str, Any]] = None,
|
|
775
775
|
verbose: bool = False,
|
|
776
|
-
deps: List[str] =
|
|
777
|
-
dep_map: Dict[str, Any] =
|
|
778
|
-
to_run: Dict[str, Any] =
|
|
776
|
+
deps: Optional[List[str]] = None,
|
|
777
|
+
dep_map: Optional[Dict[str, Any]] = None,
|
|
778
|
+
to_run: Optional[Dict[str, Any]] = None,
|
|
779
779
|
vendor_paths: Optional[List[Tuple[str, str]]] = None,
|
|
780
|
-
processed: Set[str] =
|
|
780
|
+
processed: Optional[Set[str]] = None,
|
|
781
781
|
tb_client: TinyB = None,
|
|
782
782
|
skip_connectors: bool = False,
|
|
783
783
|
current_ws: Optional[Dict[str, Any]] = None,
|
|
@@ -786,6 +786,15 @@ async def get_processed(
|
|
|
786
786
|
dir_path: Optional[str] = None,
|
|
787
787
|
embedded_datasources: Optional[Dict[str, Any]] = None,
|
|
788
788
|
):
|
|
789
|
+
if deps is None:
|
|
790
|
+
deps = []
|
|
791
|
+
if dep_map is None:
|
|
792
|
+
dep_map = {}
|
|
793
|
+
if to_run is None:
|
|
794
|
+
to_run = {}
|
|
795
|
+
if processed is None:
|
|
796
|
+
processed = set()
|
|
797
|
+
|
|
789
798
|
for filename in filenames:
|
|
790
799
|
# just process changed filenames (tb deploy and --only-changes)
|
|
791
800
|
if changed:
|
|
@@ -25,7 +25,7 @@ def print_message(message: str, color: str = bcolors.ENDC) -> Callable[..., str]
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
def error_message(message: str) -> Callable[..., str]:
|
|
28
|
-
return print_message(f"
|
|
28
|
+
return print_message(f"{message}", bcolors.FAIL)
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
def error_exception(message: str) -> Callable[..., str]:
|
|
@@ -81,7 +81,7 @@ async def test_create(pipe: str, prompt: Optional[str], folder: str) -> None:
|
|
|
81
81
|
if not pipe_path.exists():
|
|
82
82
|
pipe_path = Path("pipes", f"{pipe}.pipe")
|
|
83
83
|
|
|
84
|
-
click.echo(FeedbackManager.
|
|
84
|
+
click.echo(FeedbackManager.highlight(message=f"\n» Creating tests for {pipe_name} endpoint..."))
|
|
85
85
|
pipe_path = Path(folder) / pipe_path
|
|
86
86
|
pipe_content = pipe_path.read_text()
|
|
87
87
|
|
|
@@ -96,7 +96,7 @@ async def test_create(pipe: str, prompt: Optional[str], folder: str) -> None:
|
|
|
96
96
|
test_expectations = await llm.create_tests(
|
|
97
97
|
pipe_content=pipe_content, pipe_params=pipe_params, prompt=prompt or ""
|
|
98
98
|
)
|
|
99
|
-
valid_test_expectations = []
|
|
99
|
+
valid_test_expectations: List[Dict[str, Any]] = []
|
|
100
100
|
for test in test_expectations.tests:
|
|
101
101
|
valid_test = test.model_dump()
|
|
102
102
|
test_params = (
|
|
@@ -118,9 +118,13 @@ async def test_create(pipe: str, prompt: Optional[str], folder: str) -> None:
|
|
|
118
118
|
valid_test["expected_result"] = response.text or ""
|
|
119
119
|
|
|
120
120
|
valid_test_expectations.append(valid_test)
|
|
121
|
+
|
|
121
122
|
if valid_test_expectations:
|
|
122
123
|
generate_test_file(pipe_name, valid_test_expectations, folder, mode="a")
|
|
123
|
-
|
|
124
|
+
for test in valid_test_expectations:
|
|
125
|
+
test_name = test["name"]
|
|
126
|
+
click.echo(FeedbackManager.info(message=f"✓ {test_name} created"))
|
|
127
|
+
|
|
124
128
|
click.echo(FeedbackManager.success(message="✓ Done!\n"))
|
|
125
129
|
except Exception as e:
|
|
126
130
|
raise CLIException(FeedbackManager.error_exception(error=e))
|
|
@@ -139,37 +143,43 @@ async def test_create(pipe: str, prompt: Optional[str], folder: str) -> None:
|
|
|
139
143
|
)
|
|
140
144
|
@coro
|
|
141
145
|
async def test_update(pipe: str, folder: str) -> None:
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
pipe_tests_path = Path("tests", f"{pipe}.yaml")
|
|
149
|
-
|
|
150
|
-
click.echo(FeedbackManager.gray(message=f"\nUpdating tests expectations for {pipe_name} endpoint..."))
|
|
151
|
-
pipe_tests_path = Path(folder) / pipe_tests_path
|
|
152
|
-
pipe_tests_content = yaml.safe_load(pipe_tests_path.read_text())
|
|
153
|
-
for test in pipe_tests_content:
|
|
154
|
-
test_params = test["parameters"] if test["parameters"].startswith("?") else f"?{test['parameters']}"
|
|
155
|
-
response = None
|
|
156
|
-
try:
|
|
157
|
-
response = await client._req_raw(f"/v0/pipes/{pipe_name}.ndjson{test_params}")
|
|
158
|
-
except Exception:
|
|
159
|
-
continue
|
|
160
|
-
|
|
161
|
-
if response.status_code >= 400:
|
|
162
|
-
test["expected_http_status"] = response.status_code
|
|
163
|
-
test["expected_result"] = response.json()["error"]
|
|
146
|
+
try:
|
|
147
|
+
client = await get_tinybird_local_client(os.path.abspath(folder))
|
|
148
|
+
pipe_tests_path = Path(pipe)
|
|
149
|
+
pipe_name = pipe
|
|
150
|
+
if pipe_tests_path.suffix == ".yaml":
|
|
151
|
+
pipe_name = pipe_tests_path.stem
|
|
164
152
|
else:
|
|
165
|
-
|
|
166
|
-
del test["expected_http_status"]
|
|
153
|
+
pipe_tests_path = Path("tests", f"{pipe}.yaml")
|
|
167
154
|
|
|
168
|
-
|
|
155
|
+
click.echo(FeedbackManager.highlight(message=f"\n» Updating tests expectations for {pipe_name} endpoint..."))
|
|
156
|
+
pipe_tests_path = Path(folder) / pipe_tests_path
|
|
157
|
+
pipe_tests_content = yaml.safe_load(pipe_tests_path.read_text())
|
|
158
|
+
for test in pipe_tests_content:
|
|
159
|
+
test_params = test["parameters"] if test["parameters"].startswith("?") else f"?{test['parameters']}"
|
|
160
|
+
response = None
|
|
161
|
+
try:
|
|
162
|
+
response = await client._req_raw(f"/v0/pipes/{pipe_name}.ndjson{test_params}")
|
|
163
|
+
except Exception:
|
|
164
|
+
continue
|
|
165
|
+
|
|
166
|
+
if response.status_code >= 400:
|
|
167
|
+
test["expected_http_status"] = response.status_code
|
|
168
|
+
test["expected_result"] = response.json()["error"]
|
|
169
|
+
else:
|
|
170
|
+
if "expected_http_status" in test:
|
|
171
|
+
del test["expected_http_status"]
|
|
169
172
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
+
test["expected_result"] = response.text or ""
|
|
174
|
+
|
|
175
|
+
generate_test_file(pipe_name, pipe_tests_content, folder)
|
|
176
|
+
for test in pipe_tests_content:
|
|
177
|
+
test_name = test["name"]
|
|
178
|
+
click.echo(FeedbackManager.info(message=f"✓ {test_name} updated"))
|
|
179
|
+
|
|
180
|
+
click.echo(FeedbackManager.success(message="✓ Done!\n"))
|
|
181
|
+
except Exception as e:
|
|
182
|
+
click.echo(FeedbackManager.error(message=str(e)))
|
|
173
183
|
|
|
174
184
|
|
|
175
185
|
@test.command(
|
|
@@ -185,6 +195,7 @@ async def test_update(pipe: str, folder: str) -> None:
|
|
|
185
195
|
)
|
|
186
196
|
@coro
|
|
187
197
|
async def test_run(name: Tuple[str, ...], folder: str) -> None:
|
|
198
|
+
click.echo(FeedbackManager.highlight(message="\n» Running tests"))
|
|
188
199
|
client = await get_tinybird_local_client(os.path.abspath(folder))
|
|
189
200
|
paths = [Path(n) for n in name]
|
|
190
201
|
endpoints = [f"./tests/{p.stem}.yaml" for p in paths]
|
|
@@ -192,6 +203,7 @@ async def test_run(name: Tuple[str, ...], folder: str) -> None:
|
|
|
192
203
|
|
|
193
204
|
async def run_test(test_file):
|
|
194
205
|
test_file_path = Path(test_file)
|
|
206
|
+
click.echo(FeedbackManager.info(message=f"\n* {test_file_path.stem}{test_file_path.suffix}"))
|
|
195
207
|
test_file_content = yaml.safe_load(test_file_path.read_text())
|
|
196
208
|
for test in test_file_content:
|
|
197
209
|
try:
|
|
@@ -219,20 +231,21 @@ async def test_run(name: Tuple[str, ...], folder: str) -> None:
|
|
|
219
231
|
raise Exception(
|
|
220
232
|
f"\nExpected: \n{test['expected_result']}\nGot: \n{expected_result}\nDiff: \n{printable_diff}"
|
|
221
233
|
)
|
|
222
|
-
click.echo(FeedbackManager.
|
|
234
|
+
click.echo(FeedbackManager.info(message=f"✓ {test['name']} passed"))
|
|
223
235
|
except Exception as e:
|
|
224
|
-
click.echo(FeedbackManager.error(message=f"✗ {
|
|
225
|
-
click.echo(FeedbackManager.error(message=f"Output and expected output are different: \n{e}"))
|
|
236
|
+
click.echo(FeedbackManager.error(message=f"✗ {test['name']} failed"))
|
|
237
|
+
click.echo(FeedbackManager.error(message=f"\n** Output and expected output are different: \n{e}"))
|
|
226
238
|
return False
|
|
227
239
|
return True
|
|
228
240
|
|
|
229
|
-
|
|
241
|
+
failed_tests_count = 0
|
|
242
|
+
test_count = len(file_list)
|
|
230
243
|
for test_file in file_list:
|
|
231
244
|
if not await run_test(test_file):
|
|
232
|
-
|
|
245
|
+
failed_tests_count += 1
|
|
233
246
|
|
|
234
|
-
if
|
|
235
|
-
click.echo(FeedbackManager.error(message="✗
|
|
247
|
+
if failed_tests_count:
|
|
248
|
+
click.echo(FeedbackManager.error(message=f"\n✗ {test_count - failed_tests_count}/{test_count} passed"))
|
|
236
249
|
exit(1)
|
|
237
250
|
else:
|
|
238
|
-
click.echo(FeedbackManager.success(message="✓
|
|
251
|
+
click.echo(FeedbackManager.success(message=f"\n✓ {test_count}/{test_count} passed"))
|
|
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.dev24 → tinybird-0.0.1.dev25}/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
|
|
File without changes
|
{tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/datafile/format_datasource.py
RENAMED
|
File without changes
|
|
File without changes
|
{tinybird-0.0.1.dev24 → tinybird-0.0.1.dev25}/tinybird/tb/modules/datafile/parse_datasource.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
|
|
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.dev24 → tinybird-0.0.1.dev25}/tinybird/tb_cli_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
|