tinybird 0.0.1.dev181__py3-none-any.whl → 0.0.1.dev183__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of tinybird might be problematic. Click here for more details.

tinybird/tb/__cli__.py CHANGED
@@ -4,5 +4,5 @@ __description__ = 'Tinybird Command Line Tool'
4
4
  __url__ = 'https://www.tinybird.co/docs/forward/commands'
5
5
  __author__ = 'Tinybird'
6
6
  __author_email__ = 'support@tinybird.co'
7
- __version__ = '0.0.1.dev181'
8
- __revision__ = '0bfd0e2'
7
+ __version__ = '0.0.1.dev183'
8
+ __revision__ = '1e2d149'
tinybird/tb/client.py CHANGED
@@ -4,7 +4,7 @@ import logging
4
4
  import os
5
5
  import ssl
6
6
  from pathlib import Path
7
- from typing import Any, Callable, Dict, List, Mapping, Optional, Set, Union
7
+ from typing import Any, Callable, Dict, List, Mapping, Optional, Set, Tuple, Union
8
8
  from urllib.parse import quote, urlencode
9
9
 
10
10
  import aiofiles
@@ -696,12 +696,30 @@ class TinyB:
696
696
  else:
697
697
  return await self._req(f"/v0/sql?q={quote(sql, safe='')}&{urlencode(params)}")
698
698
 
699
- async def jobs(self, status=None):
700
- jobs = (await self._req("/v0/jobs"))["jobs"]
701
- if status:
702
- status = [status] if isinstance(status, str) else status
703
- jobs = [j for j in jobs if j["status"] in status]
704
- return jobs
699
+ async def jobs(
700
+ self, status: Optional[Tuple[str, ...]] = None, kind: Optional[Tuple[str, ...]] = None
701
+ ) -> List[Dict[str, Any]]:
702
+ async def fetch_jobs(params: Dict[str, str]) -> List[Dict[str, Any]]:
703
+ query_string = urlencode(params) if params else ""
704
+ endpoint = f"/v0/jobs?{query_string}" if query_string else "/v0/jobs"
705
+ response = await self._req(endpoint)
706
+ return response["jobs"]
707
+
708
+ if not status and not kind:
709
+ return await fetch_jobs({})
710
+ result: List[Dict[str, Any]] = []
711
+ if status and kind:
712
+ for s in status:
713
+ for k in kind:
714
+ result.extend(await fetch_jobs({"status": s, "kind": k}))
715
+ elif status:
716
+ for s in status:
717
+ result.extend(await fetch_jobs({"status": s}))
718
+ elif kind:
719
+ for k in kind:
720
+ result.extend(await fetch_jobs({"kind": k}))
721
+
722
+ return result
705
723
 
706
724
  async def job(self, job_id: str):
707
725
  return await self._req(f"/v0/jobs/{job_id}")
@@ -87,7 +87,7 @@ async def new_ds(
87
87
  if datasource.get("service") == "dynamodb":
88
88
  job_id = datasource_response.get("import_id", None)
89
89
  if job_id:
90
- jobs = await client.jobs(status=["waiting", "working"])
90
+ jobs = await client.jobs(status=("waiting", "working"))
91
91
  job_url = next((job["job_url"] for job in jobs if job["id"] == job_id), None)
92
92
  if job_url:
93
93
  click.echo(FeedbackManager.success_dynamodb_initial_load(job_url=job_url))
@@ -1,5 +1,5 @@
1
1
  from pathlib import Path
2
- from typing import Any, Dict, List, Union
2
+ from typing import Any, Dict, List, Optional, Union
3
3
 
4
4
  from tinybird.tb.modules.common import format_data_to_ndjson
5
5
 
@@ -17,10 +17,16 @@ def persist_fixture_sql(fixture_name: str, sql: str, folder: str) -> Path:
17
17
  return fixture_file
18
18
 
19
19
 
20
- def persist_fixture(fixture_name: str, data: Union[List[Dict[str, Any]], str], folder: str, format: str) -> Path:
21
- fixture_dir = get_fixture_dir(folder)
22
- fixture_file = fixture_dir / f"{fixture_name}.{format}"
23
- extension = f".{format}"
20
+ def persist_fixture(
21
+ fixture_name: str, data: Union[List[Dict[str, Any]], str], folder: str, format: str, target: Optional[str] = None
22
+ ) -> Path:
23
+ if target:
24
+ fixture_file = Path(target)
25
+ extension = fixture_file.suffix
26
+ else:
27
+ fixture_dir = get_fixture_dir(folder)
28
+ fixture_file = fixture_dir / f"{fixture_name}.{format}"
29
+ extension = f".{format}"
24
30
  if extension == FixtureExtension.NDJSON:
25
31
  fixture_file.write_text(data if isinstance(data, str) else format_data_to_ndjson(data))
26
32
  elif extension == FixtureExtension.CSV:
@@ -423,19 +423,15 @@ async def datasource_export(
423
423
  Example usage:
424
424
  - Export all rows as CSV: tb datasource export my_datasource
425
425
  - Export 1000 rows as NDJSON: tb datasource export my_datasource --format ndjson --rows 1000
426
- - Export to specific file: tb datasource export my_datasource --output ./data/export.csv
426
+ - Export to specific file: tb datasource export my_datasource --target ./data/export.csv
427
427
  """
428
428
  client: TinyB = ctx.ensure_object(dict)["client"]
429
429
  project: Project = ctx.ensure_object(dict)["project"]
430
430
 
431
- # Determine output filename if not provided
432
- if not target:
433
- target = f"{datasource}.{format_}"
434
-
435
431
  # Build query with optional row limit
436
432
  query = f"SELECT * FROM {datasource} WHERE {where or 1} LIMIT {rows}"
437
433
 
438
- click.echo(FeedbackManager.highlight(message=f"\n» Exporting {datasource} to {target}"))
434
+ click.echo(FeedbackManager.highlight(message=f"\n» Exporting {datasource}"))
439
435
 
440
436
  try:
441
437
  if format_ == "csv":
@@ -445,11 +441,13 @@ async def datasource_export(
445
441
 
446
442
  res = await client.query(query)
447
443
 
448
- fixture_path = persist_fixture(datasource, res, project.folder, format=format_)
449
- file_size = os.path.getsize(fixture_path)
444
+ target_path = persist_fixture(datasource, res, project.folder, format=format_, target=target)
445
+ file_size = os.path.getsize(target_path)
450
446
 
451
447
  click.echo(
452
- FeedbackManager.success(message=f"✓ Exported data to {target} ({humanfriendly.format_size(file_size)})")
448
+ FeedbackManager.success(
449
+ message=f"✓ Exported data to {str(target_path).replace(project.folder, '')} ({humanfriendly.format_size(file_size)})"
450
+ )
453
451
  )
454
452
 
455
453
  except Exception as e:
@@ -3,6 +3,8 @@
3
3
  # - If it makes sense and only when strictly necessary, you can create utility functions in this file.
4
4
  # - But please, **do not** interleave utility functions and command definitions.
5
5
 
6
+ from typing import Tuple
7
+
6
8
  import click
7
9
  from click import Context
8
10
 
@@ -24,16 +26,23 @@ def job(ctx: Context) -> None:
24
26
  "-s",
25
27
  "--status",
26
28
  help="Show only jobs with this status",
27
- type=click.Choice(["waiting", "working", "done", "error"], case_sensitive=False),
29
+ type=click.Choice(["waiting", "working", "done", "error", "cancelling", "cancelled"], case_sensitive=False),
30
+ multiple=True,
31
+ default=None,
32
+ )
33
+ @click.option(
34
+ "-k",
35
+ "--kind",
36
+ help="Show only jobs of this kind",
28
37
  multiple=True,
29
38
  default=None,
30
39
  )
31
40
  @click.pass_context
32
41
  @coro
33
- async def jobs_ls(ctx: Context, status: str) -> None:
34
- """List jobs, up to 100 in the last 48h"""
42
+ async def jobs_ls(ctx: Context, status: Tuple[str, ...], kind: Tuple[str, ...]) -> None:
43
+ """List jobs, up to 100"""
35
44
  client: TinyB = ctx.ensure_object(dict)["client"]
36
- jobs = await client.jobs(status=status)
45
+ jobs = await client.jobs(status=status, kind=kind)
37
46
  columns = ["id", "kind", "status", "created at", "updated at", "job url"]
38
47
  click.echo(FeedbackManager.info_jobs())
39
48
  table = []
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: tinybird
3
- Version: 0.0.1.dev181
3
+ Version: 0.0.1.dev183
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/forward/commands
6
6
  Author: Tinybird
@@ -12,10 +12,10 @@ tinybird/syncasync.py,sha256=IPnOx6lMbf9SNddN1eBtssg8vCLHMt76SuZ6YNYm-Yk,27761
12
12
  tinybird/tornado_template.py,sha256=jjNVDMnkYFWXflmT8KU_Ssbo5vR8KQq3EJMk5vYgXRw,41959
13
13
  tinybird/ch_utils/constants.py,sha256=aYvg2C_WxYWsnqPdZB1ZFoIr8ZY-XjUXYyHKE9Ansj0,3890
14
14
  tinybird/ch_utils/engine.py,sha256=X4tE9OrfaUy6kO9cqVEzyI9cDcmOF3IAssRRzsTsfEQ,40781
15
- tinybird/tb/__cli__.py,sha256=8iTlE27daJeiOAX4_hsaWWMEON1KBeHGMIVXpVUdIBQ,247
15
+ tinybird/tb/__cli__.py,sha256=I3YL2OnI6jdHeZZqhxx8ydlJp5zrUKANN9Bqmzf28WY,247
16
16
  tinybird/tb/check_pypi.py,sha256=rW4QmDRbtgKdUUwJCnBkVjmTjZSZGN-XgZhx7vMkC0w,1009
17
17
  tinybird/tb/cli.py,sha256=u3eGOhX0MHkuT6tiwaZ0_3twqLmqKXDAOxF7yV_Nn9Q,1075
18
- tinybird/tb/client.py,sha256=QOGhsppeY5J5t0_buigAZ1U8Lmg9Hp-cVg6_wtOyjVI,55844
18
+ tinybird/tb/client.py,sha256=59GH0IoYSV_KUG0eEbDDYHSWH4OlkVnSRFXE3mYAM0s,56571
19
19
  tinybird/tb/config.py,sha256=jT9xndpeCY_g0HdB5qE2EquC0TFRRnkPnQFWZWd04jo,3998
20
20
  tinybird/tb/modules/build.py,sha256=rRL5XKBdadMc9uVDEUt0GXm0h09Y6XXw199rdmRI1qo,19127
21
21
  tinybird/tb/modules/cicd.py,sha256=MnShTTJzKBYeajswF2jg7p7ZzupaeCgSriAN05MeEdg,7330
@@ -25,7 +25,7 @@ tinybird/tb/modules/config.py,sha256=ziqW_t_mRVvWOd85VoB4vKyvgMkEfpXDf9H4v38p2xc
25
25
  tinybird/tb/modules/connection.py,sha256=7oOR7x4PhBcm1ETFFCH2YJ_3oeGXjAbmx1cnZX9_L70,9014
26
26
  tinybird/tb/modules/copy.py,sha256=2Mm4FWKehOG7CoOhiF1m9UZJgJn0W1_cMolqju8ONYg,5805
27
27
  tinybird/tb/modules/create.py,sha256=jz5jswVntvsnNN-IbCXoKw9pUKySx_IubpP0rxi7Iy0,17528
28
- tinybird/tb/modules/datasource.py,sha256=mZ9N9LxbNA9QoKSMbxcMiQkdaQkfFqLeFB9_88e3_68,17843
28
+ tinybird/tb/modules/datasource.py,sha256=0_6Cn07p5GoNBBGdu88pSeLvTWojln1-k23FsS8jTDs,17801
29
29
  tinybird/tb/modules/deployment.py,sha256=t6DDLJ1YdY3SJiTPbEG7CRblSLkbuqwzauQ9y65FWtY,27147
30
30
  tinybird/tb/modules/deprecations.py,sha256=rrszC1f_JJeJ8mUxGoCxckQTJFBCR8wREf4XXXN-PRc,4507
31
31
  tinybird/tb/modules/dev_server.py,sha256=57FCKuWpErwYUYgHspYDkLWEm9F4pbvVOtMrFXX1fVU,10129
@@ -34,7 +34,7 @@ tinybird/tb/modules/exceptions.py,sha256=5jK91w1LPmtqIUfDpHe_Op5OxGz8-p1BPgtLREM
34
34
  tinybird/tb/modules/feedback_manager.py,sha256=c0ZOpG7IHFq3doodezctX64cTcTquIOhO38w9uPuU8Q,76798
35
35
  tinybird/tb/modules/info.py,sha256=iKeFbFkos7vYaBU7Vr5SI-fa1x7AbuUHB748jsGsaA4,5944
36
36
  tinybird/tb/modules/infra.py,sha256=fve30Gj3mG9zbquGxS2e4ipcOYOxviWQCpNFfEzJN_Q,33195
37
- tinybird/tb/modules/job.py,sha256=n4dSSBgnA8NqD7srGahf2xRj6wxkmX9Vl0J-QJ_a2w0,2966
37
+ tinybird/tb/modules/job.py,sha256=AsUCRNzy7HG5oJ4fyk9NpIm5NtNJgBZSy8MtJdXBe5A,3167
38
38
  tinybird/tb/modules/llm.py,sha256=KfsCYmKeW1VQz0iDZhGKCRkQv_Y3kTHh6JuxvofOguE,1076
39
39
  tinybird/tb/modules/llm_utils.py,sha256=nS9r4FAElJw8yXtmdYrx-rtI2zXR8qXfi1QqUDCfxvg,3469
40
40
  tinybird/tb/modules/local.py,sha256=SUaGWH9TLDFFF9uCw4y7UW4NsKgnXG8uxTcxz1dbkCM,14230
@@ -58,12 +58,12 @@ tinybird/tb/modules/workspace.py,sha256=-XUvL2PB5GcviJ8m30h-ZDc5kwJcm1wy1dreYa2l
58
58
  tinybird/tb/modules/workspace_members.py,sha256=RYLpyPM1ECCasHRg3uvpckzXplX0_KgNFsSPZn_i6qk,8744
59
59
  tinybird/tb/modules/datafile/build.py,sha256=d_h3pRFDPFrDKGhpFx2iejY25GuB2k8yfNouj6s8caw,50973
60
60
  tinybird/tb/modules/datafile/build_common.py,sha256=LU24kAQmxDJIyoIapDaYG-SU3P4FrMG9UBf8m9PgVSI,4565
61
- tinybird/tb/modules/datafile/build_datasource.py,sha256=nXEQ0qHdq2ai7jJTv8H2d7eeDPBYzLn8VY7zMtOYb8M,17382
61
+ tinybird/tb/modules/datafile/build_datasource.py,sha256=y4WVe_d2h9zqs7jAzPsUOOCqBaMAvmRQX5oHPJfTV4Y,17382
62
62
  tinybird/tb/modules/datafile/build_pipe.py,sha256=6Cwjf3BKEF3-oQ9PipsQfK-Z43nSwtA4qJAUoysI7Uc,11385
63
63
  tinybird/tb/modules/datafile/common.py,sha256=9mZqagXTjw6XXdNBvTWv_jQDaLIwNBmKAd6VxhxRuVo,91721
64
64
  tinybird/tb/modules/datafile/diff.py,sha256=MTmj53RYjER4neLgWVjabn-FKVFgh8h8uYiBo55lFQg,6757
65
65
  tinybird/tb/modules/datafile/exceptions.py,sha256=8rw2umdZjtby85QbuRKFO5ETz_eRHwUY5l7eHsy1wnI,556
66
- tinybird/tb/modules/datafile/fixture.py,sha256=DrRWivcvo_1rn7LlVUnHcXccdgx9yVj63mzBkUwCzk8,1420
66
+ tinybird/tb/modules/datafile/fixture.py,sha256=gftYWeweeQDFK3cHgUmSOfltNjZVOuMt8v7WTMLhGBw,1579
67
67
  tinybird/tb/modules/datafile/format_common.py,sha256=1V1ZQuphp8EH2hT-IfZQEgz_0b9QqY177nwX8aMUte4,1962
68
68
  tinybird/tb/modules/datafile/format_datasource.py,sha256=iWbeXruxC7OBmjNgurWt6ymcJlYzxfKwkGnhpcoSKEo,6190
69
69
  tinybird/tb/modules/datafile/format_pipe.py,sha256=DUGdmlzI146YDqTwW-7kSIOXocz4AH-md_LFGUm9hrc,7436
@@ -80,8 +80,8 @@ tinybird/tb_cli_modules/config.py,sha256=IsgdtFRnUrkY8-Zo32lmk6O7u3bHie1QCxLwgp4
80
80
  tinybird/tb_cli_modules/exceptions.py,sha256=pmucP4kTF4irIt7dXiG-FcnI-o3mvDusPmch1L8RCWk,3367
81
81
  tinybird/tb_cli_modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
82
82
  tinybird/tb_cli_modules/telemetry.py,sha256=Hh2Io8ZPROSunbOLuMvuIFU4TqwWPmQTqal4WS09K1A,10449
83
- tinybird-0.0.1.dev181.dist-info/METADATA,sha256=O18GXI84iGtB6bfQS-DeCKWRwrteeTp8JI_t-UOST4k,1608
84
- tinybird-0.0.1.dev181.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
85
- tinybird-0.0.1.dev181.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
86
- tinybird-0.0.1.dev181.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
87
- tinybird-0.0.1.dev181.dist-info/RECORD,,
83
+ tinybird-0.0.1.dev183.dist-info/METADATA,sha256=PHYeXR2ipg3vhMXXloKq0_uhArBd_xQyvQ9Wg_O64QE,1608
84
+ tinybird-0.0.1.dev183.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
85
+ tinybird-0.0.1.dev183.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
86
+ tinybird-0.0.1.dev183.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
87
+ tinybird-0.0.1.dev183.dist-info/RECORD,,