tinybird 0.0.1.dev49__tar.gz → 0.0.1.dev51__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 (101) hide show
  1. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/PKG-INFO +1 -1
  2. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/prompts.py +4 -3
  3. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/__cli__.py +2 -2
  4. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/build.py +2 -2
  5. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/cli.py +12 -10
  6. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/datafile/common.py +1 -8
  7. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/local_common.py +10 -8
  8. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird.egg-info/PKG-INFO +1 -1
  9. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/setup.cfg +0 -0
  10. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/__cli__.py +0 -0
  11. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/ch_utils/constants.py +0 -0
  12. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/ch_utils/engine.py +0 -0
  13. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/check_pypi.py +0 -0
  14. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/client.py +0 -0
  15. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/config.py +0 -0
  16. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/connectors.py +0 -0
  17. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/context.py +0 -0
  18. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/datafile.py +0 -0
  19. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/datatypes.py +0 -0
  20. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/feedback_manager.py +0 -0
  21. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/git_settings.py +0 -0
  22. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/sql.py +0 -0
  23. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/sql_template.py +0 -0
  24. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/sql_template_fmt.py +0 -0
  25. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/sql_toolset.py +0 -0
  26. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/syncasync.py +0 -0
  27. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/cli.py +0 -0
  28. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/auth.py +0 -0
  29. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/cicd.py +0 -0
  30. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/common.py +0 -0
  31. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/config.py +0 -0
  32. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/copy.py +0 -0
  33. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/create.py +0 -0
  34. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/datafile/build.py +0 -0
  35. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/datafile/build_common.py +0 -0
  36. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/datafile/build_datasource.py +0 -0
  37. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/datafile/build_pipe.py +0 -0
  38. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/datafile/diff.py +0 -0
  39. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/datafile/exceptions.py +0 -0
  40. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/datafile/fixture.py +0 -0
  41. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/datafile/format_common.py +0 -0
  42. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/datafile/format_datasource.py +0 -0
  43. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/datafile/format_pipe.py +0 -0
  44. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/datafile/parse_datasource.py +0 -0
  45. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/datafile/parse_pipe.py +0 -0
  46. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/datafile/pipe_checker.py +0 -0
  47. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/datafile/pull.py +0 -0
  48. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/datasource.py +0 -0
  49. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/deployment.py +0 -0
  50. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/endpoint.py +0 -0
  51. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/exceptions.py +0 -0
  52. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/feedback_manager.py +0 -0
  53. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/fmt.py +0 -0
  54. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/job.py +0 -0
  55. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/llm.py +0 -0
  56. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/llm_utils.py +0 -0
  57. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/local.py +0 -0
  58. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/login.py +0 -0
  59. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/materialization.py +0 -0
  60. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/mock.py +0 -0
  61. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/pipe.py +0 -0
  62. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/project.py +0 -0
  63. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/regions.py +0 -0
  64. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/shell.py +0 -0
  65. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/table.py +0 -0
  66. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/tag.py +0 -0
  67. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/telemetry.py +0 -0
  68. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/test.py +0 -0
  69. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/tinyunit/tinyunit.py +0 -0
  70. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/tinyunit/tinyunit_lib.py +0 -0
  71. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/token.py +0 -0
  72. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/watch.py +0 -0
  73. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/workspace.py +0 -0
  74. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb/modules/workspace_members.py +0 -0
  75. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb_cli.py +0 -0
  76. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb_cli_modules/auth.py +0 -0
  77. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb_cli_modules/branch.py +0 -0
  78. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb_cli_modules/cicd.py +0 -0
  79. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb_cli_modules/cli.py +0 -0
  80. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb_cli_modules/common.py +0 -0
  81. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb_cli_modules/config.py +0 -0
  82. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb_cli_modules/connection.py +0 -0
  83. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb_cli_modules/datasource.py +0 -0
  84. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb_cli_modules/exceptions.py +0 -0
  85. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb_cli_modules/fmt.py +0 -0
  86. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb_cli_modules/job.py +0 -0
  87. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb_cli_modules/pipe.py +0 -0
  88. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb_cli_modules/regions.py +0 -0
  89. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb_cli_modules/tag.py +0 -0
  90. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb_cli_modules/telemetry.py +0 -0
  91. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb_cli_modules/test.py +0 -0
  92. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb_cli_modules/tinyunit/tinyunit.py +0 -0
  93. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb_cli_modules/tinyunit/tinyunit_lib.py +0 -0
  94. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb_cli_modules/workspace.py +0 -0
  95. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tb_cli_modules/workspace_members.py +0 -0
  96. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird/tornado_template.py +0 -0
  97. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird.egg-info/SOURCES.txt +0 -0
  98. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird.egg-info/dependency_links.txt +0 -0
  99. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird.egg-info/entry_points.txt +0 -0
  100. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/tinybird.egg-info/requires.txt +0 -0
  101. {tinybird-0.0.1.dev49 → tinybird-0.0.1.dev51}/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.dev49
3
+ Version: 0.0.1.dev51
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/cli/introduction.html
6
6
  Author: Tinybird
@@ -779,7 +779,7 @@ You have commands at your disposal to develop a tinybird project:
779
779
  - {base_command} --build token ls: to list all the tokens
780
780
  There are other commands that you can use, but these are the most common ones. Run `{base_command} -h` to see all the commands if needed.
781
781
  When you need to work with resources or data in the Tinybird environment that you updated with the build command, add always the --build flag before the command. Example: {base_command} --build datasource ls
782
- When you need to work with resources or data in production, add always the --prod flag before the command. Example: {base_command} --prod datasource ls
782
+ When you need to work with resources or data in cloud, add always the --cloud flag before the command. Example: {base_command} --cloud datasource ls
783
783
  </command_calling>
784
784
  <development_instructions>
785
785
  - When asking to create a tinybird data project, if the needed folders are not already created, use the following structure:
@@ -799,8 +799,9 @@ When you need to work with resources or data in production, add always the --pro
799
799
  When asking for ingesting data, adding data or appending data do the following depending on the environment you want to work with:
800
800
  <ingest_data_instructions>
801
801
  - When building locally, create a .ndjson file with the data you want to ingest and do `{base_command} build` to ingest the data in the build env.
802
- - When appending data in production, use `{base_command} --prod datasource append <datasource_name> <file_name>`
803
- - When you have a response that says “there are rows in quarantine”, do `{base_command} --build|--prod datasource data <datasource_name>_quarantine` to understand what is the problem.
802
+ - We call `cloud` the production environment.
803
+ - When appending data in cloud, use `{base_command} --cloud datasource append <datasource_name> <file_name>`
804
+ - When you have a response that says “there are rows in quarantine”, do `{base_command} --build|--cloud datasource data <datasource_name>_quarantine` to understand what is the problem.
804
805
  </ingest_data_instructions>
805
806
  <datasource_file_instructions>
806
807
  Follow these instructions when creating or updating .datasource files:
@@ -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.dev49'
8
- __revision__ = 'a0a2378'
7
+ __version__ = '0.0.1.dev51'
8
+ __revision__ = '0583356'
@@ -103,7 +103,7 @@ def build_project(project: Project, tb_client: TinyB, file_changed: Optional[str
103
103
  except Exception as e:
104
104
  logging.debug(e, exc_info=True)
105
105
  click.echo(FeedbackManager.error(message="Couldn't parse response from server"))
106
- return
106
+ sys.exit(1)
107
107
 
108
108
  logging.debug(json.dumps(result, indent=2))
109
109
 
@@ -170,7 +170,7 @@ def build_project(project: Project, tb_client: TinyB, file_changed: Optional[str
170
170
  for fd in fds:
171
171
  fd.close()
172
172
  if error:
173
- raise click.ClickException(FeedbackManager.error_build_failed())
173
+ raise click.ClickException(FeedbackManager.error(message="Error: Build failed"))
174
174
 
175
175
 
176
176
  def append_fixture(
@@ -55,7 +55,7 @@ VERSION = f"{__cli__.__version__} (rev {__cli__.__revision__})"
55
55
  @click.option("--token", help="Use auth token, defaults to TB_TOKEN envvar, then to the .tinyb file")
56
56
  @click.option("--host", help="Use custom host, defaults to TB_HOST envvar, then to https://api.tinybird.co")
57
57
  @click.option("--show-tokens", is_flag=True, default=False, help="Enable the output of tokens")
58
- @click.option("--prod/--local", is_flag=True, default=False, help="Run against production or local")
58
+ @click.option("--cloud/--local", is_flag=True, default=False, help="Run against cloud or local")
59
59
  @click.option("--build", is_flag=True, default=False, help="Run against build mode")
60
60
  @click.option("--folder", type=str, help="Folder where files will be placed")
61
61
  @click.version_option(version=VERSION)
@@ -67,7 +67,7 @@ async def cli(
67
67
  token: str,
68
68
  host: str,
69
69
  show_tokens: bool,
70
- prod: bool,
70
+ cloud: bool,
71
71
  build: bool,
72
72
  folder: Optional[str],
73
73
  ) -> None:
@@ -76,7 +76,7 @@ async def cli(
76
76
  """
77
77
  project = Project(folder=folder or os.getcwd())
78
78
  # We need to unpatch for our tests not to break
79
- if show_tokens or not prod or ctx.invoked_subcommand == "build" or build:
79
+ if show_tokens or not cloud or ctx.invoked_subcommand == "build" or build:
80
80
  __unpatch_click_output()
81
81
  else:
82
82
  __patch_click_output()
@@ -108,11 +108,13 @@ async def cli(
108
108
  config = await get_config(host, token)
109
109
  client = _get_tb_client(config.get("token", None), config["host"])
110
110
 
111
+ config["path"] = str(project.path)
111
112
  # If they have passed a token or host as paramter and it's different that record in .tinyb, refresh the workspace id
112
113
  if token or host:
113
114
  try:
114
115
  workspace = await client.workspace_info()
115
116
  config["id"] = workspace.get("id", "")
117
+ config["name"] = workspace.get("name", "")
116
118
  # If we can not get this info, we continue with the id on the file
117
119
  except (AuthNoTokenException, AuthException):
118
120
  pass
@@ -121,7 +123,7 @@ async def cli(
121
123
 
122
124
  logging.debug("debug enabled")
123
125
 
124
- client = await create_ctx_client(ctx, config, prod, build, project)
126
+ client = await create_ctx_client(ctx, config, cloud, build, project)
125
127
 
126
128
  if client:
127
129
  ctx.ensure_object(dict)["client"] = client
@@ -129,7 +131,7 @@ async def cli(
129
131
  ctx.ensure_object(dict)["project"] = project
130
132
 
131
133
 
132
- @cli.command()
134
+ @cli.command(hidden=True)
133
135
  @click.option(
134
136
  "--folder", default=None, type=click.Path(exists=True, file_okay=False), help="Folder where files will be placed"
135
137
  )
@@ -388,23 +390,23 @@ def __unpatch_click_output():
388
390
  click.secho = __old_click_secho
389
391
 
390
392
 
391
- async def create_ctx_client(ctx: Context, config: Dict[str, Any], prod: bool, build: bool, project: Project):
393
+ async def create_ctx_client(ctx: Context, config: Dict[str, Any], cloud: bool, build: bool, project: Project):
392
394
  commands_without_ctx_client = ["auth", "check", "login", "local"]
393
395
  command = ctx.invoked_subcommand
394
396
  if command in commands_without_ctx_client:
395
397
  return None
396
398
 
397
- commands_always_prod = ["pull"]
399
+ commands_always_cloud = ["pull"]
398
400
  commands_always_build = ["build", "test"]
399
401
  commands_always_local = ["create", "mock"]
400
402
  if (
401
- (prod or command in commands_always_prod)
403
+ (cloud or command in commands_always_cloud)
402
404
  and command not in commands_always_build
403
405
  and command not in commands_always_local
404
406
  ):
405
- click.echo(FeedbackManager.gray(message=f"Running against {config.get('name') or 'production'}"))
407
+ click.echo(FeedbackManager.gray(message=f"Running against {config.get('name') or 'cloud'}"))
406
408
  return _get_tb_client(config.get("token", None), config["host"])
407
409
  build = command in commands_always_build or build
408
410
  if not build and command not in commands_always_local and command not in commands_always_build:
409
411
  click.echo(FeedbackManager.gray(message="Running against Tinybird local\n"))
410
- return await get_tinybird_local_client(str(project.path), build=build)
412
+ return await get_tinybird_local_client(config, build=build)
@@ -11,7 +11,7 @@ import shlex
11
11
  import string
12
12
  import textwrap
13
13
  import traceback
14
- from collections import Counter, namedtuple
14
+ from collections import namedtuple
15
15
  from dataclasses import dataclass
16
16
  from enum import Enum
17
17
  from io import StringIO
@@ -209,13 +209,6 @@ class Datafile:
209
209
  # [x] Only one materialized node
210
210
  # [x] Only one node of any specific type
211
211
  # [ ] ...
212
- repeated_node_names = [
213
- name for name, count in filter(lambda x: x[1] > 1, Counter(n["name"] for n in self.nodes).items())
214
- ]
215
- if repeated_node_names:
216
- raise DatafileValidationError(
217
- f"Pipe node names must be unique. These names are repeated: {repeated_node_names}"
218
- )
219
212
  for node in self.nodes:
220
213
  if "sql" not in node:
221
214
  raise DatafileValidationError(f"SQL missing for node {repr(node['name'])}")
@@ -1,6 +1,7 @@
1
1
  import hashlib
2
2
  import logging
3
3
  import os
4
+ from typing import Any, Dict
4
5
 
5
6
  import requests
6
7
 
@@ -8,23 +9,24 @@ from tinybird.client import AuthNoTokenException, TinyB
8
9
  from tinybird.tb.modules.config import CLIConfig
9
10
  from tinybird.tb.modules.exceptions import CLIException
10
11
 
11
- TB_IMAGE_NAME = "registry.gitlab.com/tinybird/analytics/tinybird-local-jammy-3.11:beta"
12
+ TB_IMAGE_NAME = "tinybirdco/tinybird-local:beta"
12
13
  TB_CONTAINER_NAME = "tinybird-local"
13
14
  TB_LOCAL_PORT = int(os.getenv("TB_LOCAL_PORT", 80))
14
15
  TB_LOCAL_HOST = f"http://localhost:{TB_LOCAL_PORT}"
15
16
 
16
17
 
17
- async def get_tinybird_local_client(path: str, build: bool = False) -> TinyB:
18
+ async def get_tinybird_local_client(config_obj: Dict[str, Any], build: bool = False) -> TinyB:
18
19
  """Get a Tinybird client connected to the local environment."""
19
- config = await get_tinybird_local_config(path, build=build)
20
+ config = await get_tinybird_local_config(config_obj, build=build)
20
21
  return config.get_client(host=TB_LOCAL_HOST)
21
22
 
22
23
 
23
- async def get_tinybird_local_config(path: str, build: bool = False) -> CLIConfig:
24
+ async def get_tinybird_local_config(config_obj: Dict[str, Any], build: bool = False) -> CLIConfig:
24
25
  """Craft a client config with a workspace name based on the path of the project files
25
26
 
26
27
  It uses the tokens from tinybird local
27
28
  """
29
+ path = config_obj.get("path")
28
30
  config = CLIConfig.get_project_config(path)
29
31
 
30
32
  try:
@@ -34,26 +36,26 @@ async def get_tinybird_local_config(path: str, build: bool = False) -> CLIConfig
34
36
  raise CLIException("Tinybird local is not running. Please run `tb local start` first.")
35
37
 
36
38
  user_token = tokens["user_token"]
39
+ admin_token = tokens["admin_token"]
37
40
  default_token = tokens["workspace_admin_token"]
38
41
  # Create a new workspace if path is provided. This is used to isolate the build in a different workspace.
39
- path = path or os.getcwd()
40
42
  if path:
41
43
  folder_hash = hashlib.sha256(path.encode()).hexdigest()
42
44
  user_client = config.get_client(host=TB_LOCAL_HOST, token=user_token)
43
- ws_name = f"Tinybird_Local_Build_{folder_hash}" if build else config.get("name")
45
+ ws_name = f"Tinybird_Local_Build_{folder_hash}" if build else config.get("name") or config_obj.get("name")
44
46
  if not ws_name:
45
47
  raise AuthNoTokenException()
46
48
 
47
49
  logging.debug(f"Workspace used for build: {ws_name}")
48
50
 
49
- user_workspaces = requests.get(f"{TB_LOCAL_HOST}/v0/user/workspaces?token={user_token}").json()
51
+ user_workspaces = requests.get(f"{TB_LOCAL_HOST}/v0/user/workspaces?token={admin_token}").json()
50
52
  local_workspaces = user_workspaces.get("workspaces", [])
51
53
 
52
54
  ws = next((ws for ws in local_workspaces if ws["name"] == ws_name), None)
53
55
 
54
56
  if not ws:
55
57
  await user_client.create_workspace(ws_name, template=None)
56
- user_workspaces = requests.get(f"{TB_LOCAL_HOST}/v0/user/workspaces?token={user_token}").json()
58
+ user_workspaces = requests.get(f"{TB_LOCAL_HOST}/v0/user/workspaces?token={admin_token}").json()
57
59
  ws = next((ws for ws in user_workspaces["workspaces"] if ws["name"] == ws_name), None)
58
60
  if not ws:
59
61
  raise AuthNoTokenException()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tinybird
3
- Version: 0.0.1.dev49
3
+ Version: 0.0.1.dev51
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