tinybird 4.3.2.dev0__tar.gz → 4.3.3.dev0__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.
Files changed (126) hide show
  1. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/PKG-INFO +6 -1
  2. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/syncasync.py +0 -26
  3. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/__cli__.py +2 -2
  4. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/client.py +10 -1
  5. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/build_common.py +3 -2
  6. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/cli.py +8 -5
  7. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/common.py +10 -3
  8. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/connection.py +1 -0
  9. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/connection_kafka.py +1 -0
  10. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/datasource.py +6 -1
  11. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/deployment.py +6 -5
  12. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/deployment_common.py +38 -15
  13. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird.egg-info/PKG-INFO +6 -1
  14. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/setup.cfg +0 -0
  15. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/__cli__.py +0 -0
  16. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/ch_utils/constants.py +0 -0
  17. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/ch_utils/engine.py +0 -0
  18. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/check_pypi.py +0 -0
  19. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/client.py +0 -0
  20. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/config.py +0 -0
  21. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/context.py +0 -0
  22. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/datafile/common.py +0 -0
  23. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/datafile/exceptions.py +0 -0
  24. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/datafile/parse_connection.py +0 -0
  25. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/datafile/parse_datasource.py +0 -0
  26. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/datafile/parse_pipe.py +0 -0
  27. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/datatypes.py +0 -0
  28. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/feedback_manager.py +0 -0
  29. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/git_settings.py +0 -0
  30. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/prompts.py +0 -0
  31. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/service_datasources.py +0 -0
  32. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/sql.py +0 -0
  33. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/sql_template.py +0 -0
  34. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/sql_template_fmt.py +0 -0
  35. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/sql_toolset.py +0 -0
  36. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/check_pypi.py +0 -0
  37. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/cli.py +0 -0
  38. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/config.py +0 -0
  39. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/branch.py +0 -0
  40. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/build.py +0 -0
  41. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/cicd.py +0 -0
  42. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/config.py +0 -0
  43. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/connection_s3.py +0 -0
  44. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/copy.py +0 -0
  45. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/create.py +0 -0
  46. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/datafile/build.py +0 -0
  47. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/datafile/build_common.py +0 -0
  48. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/datafile/build_datasource.py +0 -0
  49. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/datafile/build_pipe.py +0 -0
  50. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/datafile/diff.py +0 -0
  51. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/datafile/fixture.py +0 -0
  52. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/datafile/format_common.py +0 -0
  53. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/datafile/format_connection.py +0 -0
  54. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/datafile/format_datasource.py +0 -0
  55. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/datafile/format_pipe.py +0 -0
  56. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/datafile/pipe_checker.py +0 -0
  57. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/datafile/playground.py +0 -0
  58. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/datafile/pull.py +0 -0
  59. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/deprecations.py +0 -0
  60. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/endpoint.py +0 -0
  61. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/exceptions.py +0 -0
  62. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/feedback_manager.py +0 -0
  63. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/fmt.py +0 -0
  64. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/info.py +0 -0
  65. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/infra.py +0 -0
  66. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/job.py +0 -0
  67. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/job_common.py +0 -0
  68. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/llm.py +0 -0
  69. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/llm_utils.py +0 -0
  70. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/local.py +0 -0
  71. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/local_common.py +0 -0
  72. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/local_logs.py +0 -0
  73. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/login.py +0 -0
  74. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/login_common.py +0 -0
  75. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/logout.py +0 -0
  76. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/logs.py +0 -0
  77. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/materialization.py +0 -0
  78. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/open.py +0 -0
  79. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/pipe.py +0 -0
  80. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/preview.py +0 -0
  81. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/project.py +0 -0
  82. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/project_commands.py +0 -0
  83. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/py_project.py +0 -0
  84. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/query_output.py +0 -0
  85. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/regions.py +0 -0
  86. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/secret.py +0 -0
  87. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/secret_common.py +0 -0
  88. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/sink.py +0 -0
  89. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/table.py +0 -0
  90. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/telemetry.py +0 -0
  91. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/test.py +0 -0
  92. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/test_common.py +0 -0
  93. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/tinyunit/tinyunit.py +0 -0
  94. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/tinyunit/tinyunit_lib.py +0 -0
  95. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/token.py +0 -0
  96. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/ts_project.py +0 -0
  97. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/watch.py +0 -0
  98. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/workspace.py +0 -0
  99. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb/modules/workspace_members.py +0 -0
  100. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb_cli.py +0 -0
  101. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb_cli_modules/auth.py +0 -0
  102. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb_cli_modules/branch.py +0 -0
  103. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb_cli_modules/cicd.py +0 -0
  104. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb_cli_modules/cli.py +0 -0
  105. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb_cli_modules/common.py +0 -0
  106. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb_cli_modules/config.py +0 -0
  107. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb_cli_modules/connection.py +0 -0
  108. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb_cli_modules/datasource.py +0 -0
  109. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb_cli_modules/exceptions.py +0 -0
  110. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb_cli_modules/fmt.py +0 -0
  111. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb_cli_modules/job.py +0 -0
  112. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb_cli_modules/pipe.py +0 -0
  113. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb_cli_modules/regions.py +0 -0
  114. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb_cli_modules/tag.py +0 -0
  115. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb_cli_modules/telemetry.py +0 -0
  116. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb_cli_modules/test.py +0 -0
  117. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb_cli_modules/tinyunit/tinyunit.py +0 -0
  118. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb_cli_modules/tinyunit/tinyunit_lib.py +0 -0
  119. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb_cli_modules/workspace.py +0 -0
  120. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tb_cli_modules/workspace_members.py +0 -0
  121. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird/tornado_template.py +0 -0
  122. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird.egg-info/SOURCES.txt +0 -0
  123. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird.egg-info/dependency_links.txt +0 -0
  124. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird.egg-info/entry_points.txt +0 -0
  125. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird.egg-info/requires.txt +0 -0
  126. {tinybird-4.3.2.dev0 → tinybird-4.3.3.dev0}/tinybird.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: tinybird
3
- Version: 4.3.2.dev0
3
+ Version: 4.3.3.dev0
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/forward/commands
6
6
  Author: Tinybird
@@ -52,6 +52,11 @@ The Tinybird command-line tool allows you to use all the Tinybird functionality
52
52
  Changelog
53
53
  ----------
54
54
 
55
+ 4.3.2
56
+ *******
57
+
58
+ - `Changed` CLI API requests now set the `from` parameter dynamically from the detected project type (`python-sdk`, `ts-sdk`, or `cli`) instead of using a hardcoded source.
59
+
55
60
  4.3.1
56
61
  *******
57
62
 
@@ -681,29 +681,3 @@ def sync_to_async(
681
681
  thread_sensitive=thread_sensitive,
682
682
  executor=executor,
683
683
  )
684
-
685
-
686
- def run_function_in_event_loop(func_def: Callable[..., Any], *args: Any, **kwargs: Any) -> Any:
687
- """Run an async function, handling the case where an event loop may already be running."""
688
- try:
689
- asyncio.get_running_loop()
690
- # If we're already in an event loop, we need to run the coroutine in a thread
691
- # to avoid blocking the current event loop
692
- import concurrent.futures
693
-
694
- def run_in_new_loop() -> Any:
695
- # Create a new event loop for this thread
696
- new_loop = asyncio.new_event_loop()
697
- asyncio.set_event_loop(new_loop)
698
- try:
699
- return new_loop.run_until_complete(func_def(*args, **kwargs))
700
- finally:
701
- new_loop.close()
702
-
703
- # Run in a separate thread to avoid blocking the current event loop
704
- with concurrent.futures.ThreadPoolExecutor() as executor:
705
- future = executor.submit(run_in_new_loop)
706
- return future.result()
707
- except RuntimeError:
708
- # No event loop running, use asyncio.run()
709
- return asyncio.run(func_def(*args, **kwargs))
@@ -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__ = '4.3.2.dev0'
8
- __revision__ = '7f221c6'
7
+ __version__ = '4.3.3.dev0'
8
+ __revision__ = '894a8b6'
@@ -5,7 +5,7 @@ import ssl
5
5
  import time
6
6
  from pathlib import Path
7
7
  from typing import Any, Callable, Dict, List, Mapping, Optional, Set, Tuple, Union
8
- from urllib.parse import quote, urlencode
8
+ from urllib.parse import parse_qsl, quote, urlencode, urlsplit
9
9
 
10
10
  import requests
11
11
  import requests.adapters
@@ -89,6 +89,7 @@ class TinyB:
89
89
  semver: Optional[str] = None,
90
90
  env: Optional[str] = "production",
91
91
  staging: bool = False,
92
+ request_from: Optional[str] = None,
92
93
  ):
93
94
  ctx = ssl.create_default_context()
94
95
  ctx.check_hostname = False
@@ -102,6 +103,12 @@ class TinyB:
102
103
  self.semver = semver
103
104
  self.env = env
104
105
  self.staging = staging
106
+ self.request_from = request_from
107
+
108
+ @staticmethod
109
+ def _has_query_param(url: str, param_name: str) -> bool:
110
+ query_params = parse_qsl(urlsplit(url).query, keep_blank_values=True)
111
+ return any(key == param_name for key, _ in query_params)
105
112
 
106
113
  def _req_raw(
107
114
  self,
@@ -124,6 +131,8 @@ class TinyB:
124
131
  url += ("&" if "?" in url else "?") + "__tb__semver=" + self.semver
125
132
  if self.staging:
126
133
  url += ("&" if "?" in url else "?") + "__tb__deployment=staging"
134
+ if self.request_from and not self._has_query_param(url, "from"):
135
+ url += ("&" if "?" in url else "?") + "from=" + quote(self.request_from, safe="")
127
136
 
128
137
  verify_ssl = not self.disable_ssl_checks
129
138
  try:
@@ -209,6 +209,7 @@ def build_project(
209
209
  TINYBIRD_API_URL = urljoin(tb_client.host, build_url)
210
210
  logging.debug(TINYBIRD_API_URL)
211
211
  TINYBIRD_API_KEY = tb_client.token
212
+ request_from = getattr(tb_client, "request_from", None)
212
213
  error: Optional[str] = None
213
214
 
214
215
  try:
@@ -235,8 +236,8 @@ def build_project(
235
236
 
236
237
  files.append((MULTIPART_BOUNDARY_DATA_PROJECT, (relative_path, content, content_type)))
237
238
  HEADERS = {"Authorization": f"Bearer {TINYBIRD_API_KEY}"}
238
-
239
- r = requests.post(TINYBIRD_API_URL, files=files, headers=HEADERS)
239
+ params = {"from": request_from} if request_from else None
240
+ r = requests.post(TINYBIRD_API_URL, files=files, headers=HEADERS, params=params)
240
241
  try:
241
242
  result = r.json()
242
243
  except Exception as e:
@@ -64,8 +64,8 @@ DEV_MODE_ROUTED_COMMANDS = {"build", "deploy"}
64
64
  SDK_PROJECT_ROUTED_COMMANDS = {"build", "deploy", "preview"}
65
65
  TS_PROJECT_ROUTED_COMMANDS = SDK_PROJECT_ROUTED_COMMANDS
66
66
  COMMANDS_ALWAYS_CLOUD = {"infra", "branch", "environment", "workspace", "preview"}
67
- PROJECT_TYPE_TYPESCRIPT = "typescript"
68
- PROJECT_TYPE_PYTHON = "python"
67
+ PROJECT_TYPE_TYPESCRIPT = "ts-sdk"
68
+ PROJECT_TYPE_PYTHON = "python-sdk"
69
69
  PROJECT_TYPE_CLI = "cli"
70
70
  PROJECT_TYPES = {PROJECT_TYPE_TYPESCRIPT, PROJECT_TYPE_PYTHON, PROJECT_TYPE_CLI}
71
71
  CLI_PROJECT_MARKERS = (
@@ -613,7 +613,9 @@ def cli(
613
613
  user_token = os.environ.get("TB_USER_TOKEN", "")
614
614
 
615
615
  config = get_config(host, token, user_token=user_token, config_file=config_temp._path)
616
- client = _get_tb_client(config.get("token", ""), config["host"])
616
+ project_type = get_project_type_from_tinybird_config(os.getcwd()) or PROJECT_TYPE_CLI
617
+ ctx.ensure_object(dict)["project_type"] = project_type
618
+ client = _get_tb_client(config.get("token", ""), config["host"], request_from=project_type)
617
619
 
618
620
  tinybird_dev_mode = get_dev_mode_from_tinybird_config(os.getcwd())
619
621
  if tinybird_dev_mode:
@@ -632,8 +634,6 @@ def cli(
632
634
 
633
635
  project = Project(folder=folder, workspace_name=config.get("name", ""), max_depth=max_depth)
634
636
 
635
- project_type = get_project_type_from_tinybird_config(os.getcwd())
636
-
637
637
  sdk_virtual_project: Optional[Union[PythonVirtualProject, TypescriptVirtualProject]] = None
638
638
  if ctx.invoked_subcommand in SDK_PROJECT_ROUTED_COMMANDS:
639
639
  try:
@@ -724,6 +724,7 @@ def cli(
724
724
  effective_cloud,
725
725
  staging,
726
726
  project=project,
727
+ project_type=project_type,
727
728
  show_warnings=version_warning,
728
729
  branch=effective_branch,
729
730
  create_branch_if_missing=(
@@ -1013,6 +1014,7 @@ def create_ctx_client(
1013
1014
  cloud: bool,
1014
1015
  staging: bool,
1015
1016
  project: Project,
1017
+ project_type: str = PROJECT_TYPE_CLI,
1016
1018
  show_warnings: bool = True,
1017
1019
  branch: Optional[str] = None,
1018
1020
  create_branch_if_missing: bool = False,
@@ -1066,6 +1068,7 @@ def create_ctx_client(
1066
1068
  staging=staging,
1067
1069
  branch=branch,
1068
1070
  create_branch_if_missing=create_branch_if_missing,
1071
+ request_from=project_type,
1069
1072
  )
1070
1073
  test = command in command_always_test
1071
1074
  if show_warnings and command:
@@ -360,7 +360,9 @@ def _get_tb_client(
360
360
  staging: bool = False,
361
361
  branch: Optional[str] = None,
362
362
  create_branch_if_missing: bool = False,
363
+ request_from: Optional[str] = None,
363
364
  ) -> TinyB:
365
+ resolved_request_from = request_from
364
366
  disable_ssl: bool = getenv_bool("TB_DISABLE_SSL_CHECKS", False)
365
367
  cloud_client = TinyB(
366
368
  token,
@@ -369,6 +371,7 @@ def _get_tb_client(
369
371
  disable_ssl_checks=disable_ssl,
370
372
  send_telemetry=True,
371
373
  staging=staging,
374
+ request_from=resolved_request_from,
372
375
  )
373
376
 
374
377
  if not branch:
@@ -402,13 +405,16 @@ def _get_tb_client(
402
405
  disable_ssl_checks=disable_ssl,
403
406
  send_telemetry=True,
404
407
  staging=staging,
408
+ request_from=resolved_request_from,
405
409
  )
406
410
 
407
411
 
408
412
  def create_tb_client(ctx: Context) -> TinyB:
409
- token = ctx.ensure_object(dict)["config"].get("token", "")
410
- host = ctx.ensure_object(dict)["config"].get("host", DEFAULT_API_HOST)
411
- return _get_tb_client(token, host)
413
+ obj = ctx.ensure_object(dict)
414
+ token = obj["config"].get("token", "")
415
+ host = obj["config"].get("host", DEFAULT_API_HOST)
416
+ request_from = obj.get("project_type")
417
+ return _get_tb_client(token, host, request_from=request_from)
412
418
 
413
419
 
414
420
  def _analyze(filename: str, client: TinyB, format: str):
@@ -1668,6 +1674,7 @@ def run_aws_iamrole_connection_flow(
1668
1674
  token=config.get("token", ""),
1669
1675
  host=config.get("host", ""),
1670
1676
  staging=False,
1677
+ request_from=getattr(client, "request_from", None),
1671
1678
  )
1672
1679
  except Exception as e:
1673
1680
  click.echo(FeedbackManager.warning(message=f"Failed to initialize cloud client: {e}"))
@@ -222,6 +222,7 @@ def connection_create_gcs(ctx: Context) -> None:
222
222
  token=token,
223
223
  host=host,
224
224
  staging=False,
225
+ request_from=getattr(client, "request_from", None),
225
226
  )
226
227
  creds_json = get_gcs_svc_account_creds()
227
228
  secret_name = f"gcs_svc_account_creds_{connection_name}_{unique_suffix}"
@@ -190,6 +190,7 @@ def connection_create_kafka(
190
190
  token=token,
191
191
  host=host,
192
192
  staging=False,
193
+ request_from=getattr(obj.get("client"), "request_from", None),
193
194
  )
194
195
  if tb_secret_bootstrap_servers:
195
196
  prod_client.create_secret(name=tb_secret_bootstrap_servers, value=bootstrap_servers)
@@ -298,9 +298,14 @@ def datasource_append(
298
298
 
299
299
  if events:
300
300
  click.echo(FeedbackManager.highlight(message=f"\n» Sending events to {datasource_name}"))
301
+ events_params = {"name": datasource_name}
302
+ request_from = getattr(client, "request_from", None)
303
+ if request_from:
304
+ events_params["from"] = request_from
301
305
  response = requests.post(
302
- f"{client.host}/v0/events?name={datasource_name}",
306
+ f"{client.host}/v0/events",
303
307
  headers={"Authorization": f"Bearer {client.token}"},
308
+ params=events_params,
304
309
  data=events,
305
310
  )
306
311
 
@@ -131,8 +131,9 @@ def download_github_template(url: str) -> Optional[Path]:
131
131
 
132
132
 
133
133
  # TODO(eclbg): This should eventually end up in client.py, but we're not using it here yet.
134
- def api_fetch(url: str, headers: dict) -> dict:
135
- r = requests.get(url, headers=headers)
134
+ def api_fetch(url: str, headers: dict, request_from: Optional[str] = None) -> dict:
135
+ request_params = {"from": request_from} if request_from and "from=" not in url else None
136
+ r = requests.get(url, headers=headers, params=request_params)
136
137
  if r.status_code == 200:
137
138
  logging.debug(json.dumps(r.json(), indent=2))
138
139
  return r.json()
@@ -232,7 +233,7 @@ def deployment_ls(ctx: click.Context, include_deleted: bool) -> None:
232
233
  if include_deleted:
233
234
  url += "?include_deleted=true"
234
235
 
235
- result = api_fetch(url, HEADERS)
236
+ result = api_fetch(url, HEADERS, request_from=getattr(client, "request_from", None))
236
237
  status_map = {
237
238
  "calculating": "Creating - Calculating steps",
238
239
  "creating_schema": "Creating - Creating schemas",
@@ -297,7 +298,7 @@ def deployment_promote(ctx: click.Context, wait: bool) -> None:
297
298
  TINYBIRD_API_KEY = client.token
298
299
  HEADERS = {"Authorization": f"Bearer {TINYBIRD_API_KEY}"}
299
300
 
300
- promote_deployment(client.host, HEADERS, wait=wait)
301
+ promote_deployment(client.host, HEADERS, wait=wait, request_from=getattr(client, "request_from", None))
301
302
 
302
303
 
303
304
  @deployment_group.command(name="discard")
@@ -317,7 +318,7 @@ def deployment_discard(ctx: click.Context, wait: bool) -> None:
317
318
  TINYBIRD_API_KEY = client.token
318
319
  HEADERS = {"Authorization": f"Bearer {TINYBIRD_API_KEY}"}
319
320
 
320
- discard_deployment(client.host, HEADERS, wait=wait)
321
+ discard_deployment(client.host, HEADERS, wait=wait, request_from=getattr(client, "request_from", None))
321
322
 
322
323
 
323
324
  @cli.command(name="deploy")
@@ -21,11 +21,18 @@ from tinybird.tb.modules.project import Project
21
21
 
22
22
 
23
23
  # TODO(eclbg): This should eventually end up in client.py, but we're not using it here yet.
24
- def api_fetch(url: str, headers: dict, max_retries: int = 3, backoff_factor: float = 0.5) -> dict:
24
+ def api_fetch(
25
+ url: str,
26
+ headers: dict,
27
+ max_retries: int = 3,
28
+ backoff_factor: float = 0.5,
29
+ request_from: Optional[str] = None,
30
+ ) -> dict:
31
+ request_params = {"from": request_from} if request_from and "from=" not in url else None
25
32
  retries = 0
26
33
  while retries <= max_retries:
27
34
  try:
28
- r = requests.get(url, headers=headers)
35
+ r = requests.get(url, headers=headers, params=request_params)
29
36
  if r.status_code == 200:
30
37
  logging.debug(json.dumps(r.json(), indent=2))
31
38
  return r.json()
@@ -59,8 +66,13 @@ def api_post(
59
66
  headers: dict,
60
67
  files: Optional[list] = None,
61
68
  params: Optional[dict] = None,
69
+ request_from: Optional[str] = None,
62
70
  ) -> dict:
63
- r = requests.post(url, headers=headers, files=files, params=params)
71
+ request_params = dict(params or {})
72
+ if request_from and "from=" not in url:
73
+ request_params.setdefault("from", request_from)
74
+
75
+ r = requests.post(url, headers=headers, files=files, params=request_params)
64
76
  try:
65
77
  if r.status_code < 300:
66
78
  logging.debug(json.dumps(r.json(), indent=2))
@@ -124,9 +136,15 @@ def _get_deployment_job(client: TinyB, deployment_id: Optional[Union[str, int]])
124
136
 
125
137
  # TODO(eclbg): This logic should be in the server, and there should be a dedicated endpoint for promoting a deployment
126
138
  # potato
127
- def promote_deployment(host: Optional[str], headers: dict, wait: bool, ingest_hint: Optional[bool] = True) -> None:
139
+ def promote_deployment(
140
+ host: Optional[str],
141
+ headers: dict,
142
+ wait: bool,
143
+ ingest_hint: Optional[bool] = True,
144
+ request_from: Optional[str] = None,
145
+ ) -> None:
128
146
  TINYBIRD_API_DEPLOYMENTS_BASE_URL = f"{host}/v1/deployments"
129
- result = api_fetch(TINYBIRD_API_DEPLOYMENTS_BASE_URL, headers)
147
+ result = api_fetch(TINYBIRD_API_DEPLOYMENTS_BASE_URL, headers, request_from=request_from)
130
148
 
131
149
  deployments = result.get("deployments")
132
150
  if not deployments:
@@ -156,12 +174,13 @@ def promote_deployment(host: Optional[str], headers: dict, wait: bool, ingest_hi
156
174
  else:
157
175
  tb_api_set_live_url = f"{TINYBIRD_API_DEPLOYMENTS_BASE_URL}/{candidate_deployment.get('id')}/set-live"
158
176
  click.echo(FeedbackManager.highlight(message="» Waiting for deployment to be promoted..."))
159
- result = api_post(tb_api_set_live_url, headers=headers)
177
+ result = api_post(tb_api_set_live_url, headers=headers, request_from=request_from)
160
178
  click.echo(FeedbackManager.info(message="✓ Deployment promoted"))
161
179
 
162
180
  last_deployment_id = last_deployment.get("id")
163
181
  tb_api_last_deployment_url = f"{TINYBIRD_API_DEPLOYMENTS_BASE_URL}/{last_deployment_id}"
164
- r = requests.delete(tb_api_last_deployment_url, headers=headers)
182
+ request_params = {"from": request_from} if request_from and "from=" not in tb_api_last_deployment_url else None
183
+ r = requests.delete(tb_api_last_deployment_url, headers=headers, params=request_params)
165
184
 
166
185
  result = r.json()
167
186
  logging.debug(json.dumps(result, indent=2))
@@ -181,7 +200,7 @@ def promote_deployment(host: Optional[str], headers: dict, wait: bool, ingest_hi
181
200
 
182
201
  if wait:
183
202
  while True:
184
- result = api_fetch(tb_api_last_deployment_url, headers=headers)
203
+ result = api_fetch(tb_api_last_deployment_url, headers=headers, request_from=request_from)
185
204
 
186
205
  last_deployment = result.get("deployment")
187
206
  if not last_deployment:
@@ -204,9 +223,9 @@ def promote_deployment(host: Optional[str], headers: dict, wait: bool, ingest_hi
204
223
  )
205
224
 
206
225
 
207
- def discard_deployment(host: Optional[str], headers: dict, wait: bool) -> None:
226
+ def discard_deployment(host: Optional[str], headers: dict, wait: bool, request_from: Optional[str] = None) -> None:
208
227
  TINYBIRD_API_URL = f"{host}/v1/deployments"
209
- result = api_fetch(TINYBIRD_API_URL, headers=headers)
228
+ result = api_fetch(TINYBIRD_API_URL, headers=headers, request_from=request_from)
210
229
 
211
230
  deployments = result.get("deployments")
212
231
  if not deployments:
@@ -233,7 +252,8 @@ def discard_deployment(host: Optional[str], headers: dict, wait: bool) -> None:
233
252
  click.echo(FeedbackManager.success(message=f"{verb} deployment {deployment_to_discard['id']}"))
234
253
 
235
254
  TINYBIRD_API_URL = f"{host}/v1/deployments/{deployment_to_discard.get('id')}"
236
- r = requests.delete(TINYBIRD_API_URL, headers=headers)
255
+ request_params = {"from": request_from} if request_from and "from=" not in TINYBIRD_API_URL else None
256
+ r = requests.delete(TINYBIRD_API_URL, headers=headers, params=request_params)
237
257
  result = r.json()
238
258
  logging.debug(json.dumps(result, indent=2))
239
259
  if result.get("error"):
@@ -246,7 +266,7 @@ def discard_deployment(host: Optional[str], headers: dict, wait: bool) -> None:
246
266
  if wait:
247
267
  while True:
248
268
  TINYBIRD_API_URL = f"{host}/v1/deployments/{deployment_to_discard.get('id')}"
249
- result = api_fetch(TINYBIRD_API_URL, headers)
269
+ result = api_fetch(TINYBIRD_API_URL, headers, request_from=request_from)
250
270
 
251
271
  deployment_to_discard = result.get("deployment")
252
272
  if deployment_to_discard and deployment_to_discard.get("status") == "deleted":
@@ -311,8 +331,9 @@ def create_deployment(
311
331
  deployment_job: Optional[Dict[str, Any]] = None
312
332
  deployment_request_sent = False
313
333
  deployment = {}
334
+ HEADERS = {"Authorization": f"Bearer {TINYBIRD_API_KEY}"}
335
+ request_from = getattr(client, "request_from", None)
314
336
  try:
315
- HEADERS = {"Authorization": f"Bearer {TINYBIRD_API_KEY}"}
316
337
  params = {}
317
338
  if check:
318
339
  click.echo(FeedbackManager.highlight(message="\n» Validating deployment...\n"))
@@ -323,7 +344,9 @@ def create_deployment(
323
344
  params["allow_destructive_operations"] = "true"
324
345
 
325
346
  deployment_request_sent = True
326
- result = api_post(TINYBIRD_API_DEPLOY_ENDPOINT_URL, headers=HEADERS, files=files, params=params)
347
+ result = api_post(
348
+ TINYBIRD_API_DEPLOY_ENDPOINT_URL, headers=HEADERS, files=files, params=params, request_from=request_from
349
+ )
327
350
 
328
351
  print_changes(result, project, output)
329
352
 
@@ -440,7 +463,7 @@ def create_deployment(
440
463
  try:
441
464
  while True:
442
465
  url = f"{client.host}/v1/deployments/{deployment.get('id')}"
443
- res = api_fetch(url, HEADERS)
466
+ res = api_fetch(url, HEADERS, request_from=request_from)
444
467
  deployment = res.get("deployment", {})
445
468
  if not deployment:
446
469
  click.echo(FeedbackManager.error(message="Error parsing deployment from response"))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: tinybird
3
- Version: 4.3.2.dev0
3
+ Version: 4.3.3.dev0
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/forward/commands
6
6
  Author: Tinybird
@@ -52,6 +52,11 @@ The Tinybird command-line tool allows you to use all the Tinybird functionality
52
52
  Changelog
53
53
  ----------
54
54
 
55
+ 4.3.2
56
+ *******
57
+
58
+ - `Changed` CLI API requests now set the `from` parameter dynamically from the detected project type (`python-sdk`, `ts-sdk`, or `cli`) instead of using a hardcoded source.
59
+
55
60
  4.3.1
56
61
  *******
57
62
 
File without changes