tinybird 0.0.1.dev24__tar.gz → 0.0.1.dev26__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.

Files changed (96) hide show
  1. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/PKG-INFO +1 -1
  2. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/prompts.py +87 -0
  3. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/__cli__.py +2 -2
  4. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/build.py +3 -3
  5. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/create.py +3 -3
  6. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/datafile/build.py +13 -4
  7. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/feedback_manager.py +1 -1
  8. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/mock.py +3 -3
  9. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/test.py +52 -39
  10. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/watch.py +1 -1
  11. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird.egg-info/PKG-INFO +1 -1
  12. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/setup.cfg +0 -0
  13. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/__cli__.py +0 -0
  14. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/ch_utils/constants.py +0 -0
  15. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/ch_utils/engine.py +0 -0
  16. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/check_pypi.py +0 -0
  17. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/client.py +0 -0
  18. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/config.py +0 -0
  19. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/connectors.py +0 -0
  20. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/context.py +0 -0
  21. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/datafile.py +0 -0
  22. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/datatypes.py +0 -0
  23. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/feedback_manager.py +0 -0
  24. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/git_settings.py +0 -0
  25. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/sql.py +0 -0
  26. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/sql_template.py +0 -0
  27. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/sql_template_fmt.py +0 -0
  28. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/sql_toolset.py +0 -0
  29. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/syncasync.py +0 -0
  30. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/cli.py +0 -0
  31. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/auth.py +0 -0
  32. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/cicd.py +0 -0
  33. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/cli.py +0 -0
  34. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/common.py +0 -0
  35. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/config.py +0 -0
  36. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/connection.py +0 -0
  37. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/datafile/build_common.py +0 -0
  38. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/datafile/build_datasource.py +0 -0
  39. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/datafile/build_pipe.py +0 -0
  40. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/datafile/common.py +0 -0
  41. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/datafile/diff.py +0 -0
  42. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/datafile/exceptions.py +0 -0
  43. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/datafile/fixture.py +0 -0
  44. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/datafile/format_common.py +0 -0
  45. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/datafile/format_datasource.py +0 -0
  46. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/datafile/format_pipe.py +0 -0
  47. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/datafile/parse_datasource.py +0 -0
  48. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/datafile/parse_pipe.py +0 -0
  49. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/datafile/pipe_checker.py +0 -0
  50. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/datafile/pull.py +0 -0
  51. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/datasource.py +0 -0
  52. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/exceptions.py +0 -0
  53. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/fmt.py +0 -0
  54. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/job.py +0 -0
  55. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/llm.py +0 -0
  56. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/local.py +0 -0
  57. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/local_common.py +0 -0
  58. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/login.py +0 -0
  59. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/pipe.py +0 -0
  60. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/regions.py +0 -0
  61. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/shell.py +0 -0
  62. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/table.py +0 -0
  63. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/tag.py +0 -0
  64. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/telemetry.py +0 -0
  65. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/tinyunit/tinyunit.py +0 -0
  66. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/tinyunit/tinyunit_lib.py +0 -0
  67. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/token.py +0 -0
  68. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/workspace.py +0 -0
  69. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb/modules/workspace_members.py +0 -0
  70. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb_cli.py +0 -0
  71. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb_cli_modules/auth.py +0 -0
  72. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb_cli_modules/branch.py +0 -0
  73. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb_cli_modules/cicd.py +0 -0
  74. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb_cli_modules/cli.py +0 -0
  75. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb_cli_modules/common.py +0 -0
  76. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb_cli_modules/config.py +0 -0
  77. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb_cli_modules/connection.py +0 -0
  78. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb_cli_modules/datasource.py +0 -0
  79. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb_cli_modules/exceptions.py +0 -0
  80. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb_cli_modules/fmt.py +0 -0
  81. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb_cli_modules/job.py +0 -0
  82. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb_cli_modules/pipe.py +0 -0
  83. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb_cli_modules/regions.py +0 -0
  84. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb_cli_modules/tag.py +0 -0
  85. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb_cli_modules/telemetry.py +0 -0
  86. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb_cli_modules/test.py +0 -0
  87. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb_cli_modules/tinyunit/tinyunit.py +0 -0
  88. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb_cli_modules/tinyunit/tinyunit_lib.py +0 -0
  89. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb_cli_modules/workspace.py +0 -0
  90. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tb_cli_modules/workspace_members.py +0 -0
  91. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird/tornado_template.py +0 -0
  92. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird.egg-info/SOURCES.txt +0 -0
  93. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird.egg-info/dependency_links.txt +0 -0
  94. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird.egg-info/entry_points.txt +0 -0
  95. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird.egg-info/requires.txt +0 -0
  96. {tinybird-0.0.1.dev24 → tinybird-0.0.1.dev26}/tinybird.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tinybird
3
- Version: 0.0.1.dev24
3
+ Version: 0.0.1.dev26
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/cli/introduction.html
6
6
  Author: Tinybird
@@ -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.dev24'
8
- __revision__ = '3de7f2a'
7
+ __version__ = '0.0.1.dev26'
8
+ __revision__ = 'f0e9917'
@@ -105,7 +105,7 @@ def build(
105
105
  async def build_once(filenames: List[str]):
106
106
  ok = False
107
107
  try:
108
- click.echo(" Building project...\n")
108
+ click.echo(FeedbackManager.highlight(message="» Building project...\n"))
109
109
  time_start = time.time()
110
110
  await process(filenames=filenames, watch=False)
111
111
  time_end = time.time()
@@ -117,7 +117,7 @@ def build(
117
117
  fixture_path = get_fixture_dir() / f"{name}.ndjson"
118
118
  if fixture_path.exists():
119
119
  await append_datasource(tb_client, ds_path.stem, str(fixture_path), silent=True)
120
- click.echo(FeedbackManager.success(message=f"\n✓ Build completed in {elapsed_time:.1f}s\n"))
120
+ click.echo(FeedbackManager.success(message=f"\n✓ Build completed in {elapsed_time:.1f}s"))
121
121
  ok = True
122
122
  except Exception as e:
123
123
  click.echo(FeedbackManager.error_exception(error=e))
@@ -154,7 +154,7 @@ def build(
154
154
  pipes=pipes,
155
155
  endpoints=endpoints,
156
156
  )
157
- click.echo(FeedbackManager.highlight(message=" Watching for changes..."))
157
+ click.echo(FeedbackManager.gray(message="\nWatching for changes..."))
158
158
  watcher_thread = threading.Thread(
159
159
  target=watch_files, args=(filenames, process, shell, folder, build_ok), daemon=True
160
160
  )
@@ -71,16 +71,16 @@ async def create(
71
71
  )
72
72
  return
73
73
  local_client = await get_tinybird_local_client(folder)
74
- click.echo(FeedbackManager.gray(message="Creating new project structure..."))
74
+ click.echo(FeedbackManager.highlight(message="\n» Creating new project structure..."))
75
75
  await project_create(local_client, tb_client, user_token, data, prompt, folder)
76
76
  click.echo(FeedbackManager.success(message="✓ Scaffolding completed!\n"))
77
77
 
78
- click.echo(FeedbackManager.gray(message="\nCreating CI/CD files for GitHub and GitLab..."))
78
+ click.echo(FeedbackManager.highlight(message="\ Creating CI/CD files for GitHub and GitLab..."))
79
79
  init_git(folder)
80
80
  await init_cicd(data_project_dir=os.path.relpath(folder))
81
81
  click.echo(FeedbackManager.success(message="✓ Done!\n"))
82
82
 
83
- click.echo(FeedbackManager.gray(message="Building fixtures..."))
83
+ click.echo(FeedbackManager.highlight(message="\n» Building fixtures..."))
84
84
 
85
85
  if demo:
86
86
  # Users datasource
@@ -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] = set(),
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"\n** {message}", bcolors.FAIL)
28
+ return print_message(f"{message}", bcolors.FAIL)
29
29
 
30
30
 
31
31
  def error_exception(message: str) -> Callable[..., str]:
@@ -31,6 +31,7 @@ async def mock(ctx: click.Context, datasource: str, rows: int, prompt: str, fold
31
31
  try:
32
32
  datasource_path = Path(datasource)
33
33
  datasource_name = datasource
34
+ click.echo(FeedbackManager.highlight(message=f"\n» Creating fixture for {datasource_name}..."))
34
35
  if datasource_path.suffix == ".datasource":
35
36
  datasource_name = datasource_path.stem
36
37
  else:
@@ -43,10 +44,9 @@ async def mock(ctx: click.Context, datasource: str, rows: int, prompt: str, fold
43
44
  if prompt_path.exists():
44
45
  prompt = prompt_path.read_text()
45
46
  else:
46
- click.echo(FeedbackManager.gray(message=f"Overriding prompt for {datasource_name}..."))
47
+ click.echo(FeedbackManager.info(message="* Overriding last prompt..."))
47
48
  prompt_path.write_text(prompt)
48
49
 
49
- click.echo(FeedbackManager.gray(message=f"Creating fixture for {datasource_name}..."))
50
50
  datasource_content = datasource_path.read_text()
51
51
  config = CLIConfig.get_project_config()
52
52
  user_client = config.get_client()
@@ -69,7 +69,7 @@ async def mock(ctx: click.Context, datasource: str, rows: int, prompt: str, fold
69
69
  data = result.get("data", [])[:rows]
70
70
  fixture_name = build_fixture_name(datasource_path.absolute().as_posix(), datasource_name, datasource_content)
71
71
  persist_fixture(fixture_name, data)
72
- click.echo(FeedbackManager.success(message="✓ Done!"))
72
+ click.echo(FeedbackManager.success(message=f"✓ /fixtures/{fixture_name}.ndjson created with {rows} rows"))
73
73
 
74
74
  except Exception as e:
75
75
  raise CLIException(FeedbackManager.error_exception(error=e))
@@ -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.gray(message=f"\nCreating tests for {pipe_name} endpoint..."))
84
+ click.echo(FeedbackManager.highlight(message=f"\ 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
- click.echo(FeedbackManager.info(message=f"✓ /tests/{pipe_name}.yaml"))
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
- client = await get_tinybird_local_client(os.path.abspath(folder))
143
- pipe_tests_path = Path(pipe)
144
- pipe_name = pipe
145
- if pipe_tests_path.suffix == ".yaml":
146
- pipe_name = pipe_tests_path.stem
147
- else:
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
- if "expected_http_status" in test:
166
- del test["expected_http_status"]
153
+ pipe_tests_path = Path("tests", f"{pipe}.yaml")
167
154
 
168
- test["expected_result"] = response.text or ""
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
- generate_test_file(pipe_name, pipe_tests_content, folder)
171
- click.echo(FeedbackManager.info(message=f"✓ /tests/{pipe_name}.yaml"))
172
- click.echo(FeedbackManager.success(message="✓ Done!\n"))
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.success(message=f"✓ {test_file_path.name} - {test['name']}"))
234
+ click.echo(FeedbackManager.info(message=f"✓ {test['name']} passed"))
223
235
  except Exception as e:
224
- click.echo(FeedbackManager.error(message=f"✗ {test_file_path.name} - {test['name']}"))
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
- tests_failed = False
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
- tests_failed = True
245
+ failed_tests_count += 1
233
246
 
234
- if tests_failed:
235
- click.echo(FeedbackManager.error(message="✗ Some tests failed"))
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="✓ All tests passed"))
251
+ click.echo(FeedbackManager.success(message=f"\n{test_count}/{test_count} passed"))
@@ -82,7 +82,7 @@ def watch_files(
82
82
  ) -> None:
83
83
  # Handle both sync and async process functions
84
84
  async def process_wrapper(files: List[str]) -> None:
85
- click.echo(" Rebuilding...")
85
+ click.echo(FeedbackManager.highlight(message="» Rebuilding..."))
86
86
  time_start = time.time()
87
87
  if asyncio.iscoroutinefunction(process):
88
88
  await process(files, watch=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tinybird
3
- Version: 0.0.1.dev24
3
+ Version: 0.0.1.dev26
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/cli/introduction.html
6
6
  Author: Tinybird
File without changes