buildai-cli 0.3.30__tar.gz → 0.3.31__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 (45) hide show
  1. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/PKG-INFO +1 -1
  2. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/context.py +2 -2
  3. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/dev_context.py +24 -6
  4. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/ops_init.py +7 -8
  5. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/pyproject.toml +1 -1
  6. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/.gitignore +0 -0
  7. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/AGENTS.md +0 -0
  8. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/CLAUDE.md +0 -0
  9. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/__init__.py +0 -0
  10. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/_has_core.py +0 -0
  11. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/commands/__init__.py +0 -0
  12. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/commands/api_proxy.py +0 -0
  13. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/commands/assets_cli.py +0 -0
  14. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/commands/auth_lite.py +0 -0
  15. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/commands/clips.py +0 -0
  16. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/commands/database.py +0 -0
  17. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/commands/dev.py +0 -0
  18. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/commands/embed.py +0 -0
  19. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/commands/external.py +0 -0
  20. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/commands/inference.py +0 -0
  21. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/commands/jobs.py +0 -0
  22. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/commands/keys.py +0 -0
  23. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/commands/medoid.py +0 -0
  24. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/commands/operations.py +0 -0
  25. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/commands/partners.py +0 -0
  26. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/commands/permissions.py +0 -0
  27. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/commands/projection.py +0 -0
  28. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/commands/query.py +0 -0
  29. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/commands/query_api.py +0 -0
  30. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/commands/reports.py +0 -0
  31. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/commands/schema.py +0 -0
  32. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/commands/search.py +0 -0
  33. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/commands/stats.py +0 -0
  34. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/commands/sync/ddl.py +0 -0
  35. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/commands/sync/models.py +0 -0
  36. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/commands/sync/queries.py +0 -0
  37. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/config.py +0 -0
  38. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/console.py +0 -0
  39. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/guard.py +0 -0
  40. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/main.py +0 -0
  41. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/nl_query/__init__.py +0 -0
  42. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/nl_query/dataset_tools.py +0 -0
  43. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/output.py +0 -0
  44. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/pagination.py +0 -0
  45. {buildai_cli-0.3.30 → buildai_cli-0.3.31}/cli/sdk_client.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: buildai-cli
3
- Version: 0.3.30
3
+ Version: 0.3.31
4
4
  Summary: Build AI CLI (Typer)
5
5
  Requires-Python: >=3.11
6
6
  Requires-Dist: buildai-data
@@ -85,14 +85,14 @@ def resolve_admin_connection_config(
85
85
  deployment profile, then the production password fallback already used by
86
86
  privileged database commands.
87
87
  """
88
- from infra.deployment_profiles import deployment_profile_for_app_env, resolve_deployment_profile
88
+ from infra.deployment_profiles import resolve_deployment_profile
89
89
 
90
90
  admin_iam_user = settings.effective_alloydb_admin_iam_user
91
91
  admin_impersonate_sa = settings.effective_alloydb_admin_impersonate_sa
92
92
 
93
93
  if not admin_iam_user or not admin_impersonate_sa:
94
94
  try:
95
- profile_name = deployment_profile_for_app_env(settings.app_env.value)
95
+ profile_name = os.environ.get("BUILDAI_DEPLOYMENT_PROFILE", "production")
96
96
  profile = resolve_deployment_profile(profile_name)
97
97
  if profile.database_admin:
98
98
  admin_iam_user = admin_iam_user or profile.database_admin.iam_user
@@ -2,8 +2,10 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ import hashlib
5
6
  import json
6
7
  import os
8
+ import re
7
9
  import shlex
8
10
  import subprocess
9
11
  from datetime import datetime, timezone
@@ -12,10 +14,23 @@ from typing import Any
12
14
 
13
15
  from infra.deployment_profiles import (
14
16
  list_deployment_profiles,
15
- normalize_preview_env_id,
16
17
  resolve_deployment_profile,
17
18
  )
18
19
 
20
+ _PREVIEW_ENV_ID_MAX_LEN = 26
21
+
22
+
23
+ def _normalize_env_id(branch_name: str) -> str:
24
+ """Normalize a branch name into a DNS-safe env id (max 26 chars)."""
25
+ slug = re.sub(r"[^a-z0-9]+", "-", branch_name.lower()).strip("-")
26
+ if not slug:
27
+ slug = "preview"
28
+ if len(slug) <= _PREVIEW_ENV_ID_MAX_LEN:
29
+ return slug
30
+ digest = hashlib.sha256(branch_name.encode()).hexdigest()[:8]
31
+ return f"{slug[:_PREVIEW_ENV_ID_MAX_LEN - 1 - len(digest)]}-{digest}".rstrip("-")
32
+
33
+
19
34
  DEV_CONTEXT_DIRNAME = ".buildai"
20
35
  DEV_CONTEXT_FILENAME = "context.json"
21
36
  DEV_CONTEXT_SUMMARY_FILENAME = "context.md"
@@ -90,15 +105,19 @@ def get_branch_preview_name(branch: str | None, start_path: Path | None = None)
90
105
  return None
91
106
  cwd = (start_path or Path.cwd()).resolve()
92
107
  value = _git_output(["config", "--local", "--get", f"branch.{branch}.buildaiPreviewName"], cwd)
93
- return normalize_preview_env_id(value) if value else None
108
+ return _normalize_env_id(value) if value else None
94
109
 
95
110
 
96
- def set_branch_preview_name(branch: str | None, preview_name: str, start_path: Path | None = None) -> None:
111
+ def set_branch_preview_name(
112
+ branch: str | None,
113
+ preview_name: str,
114
+ start_path: Path | None = None,
115
+ ) -> None:
97
116
  """Persist one branch-local preview alias into local git config."""
98
117
  if not branch:
99
118
  raise RuntimeError("Cannot save preview alias without an active git branch.")
100
119
  cwd = (start_path or Path.cwd()).resolve()
101
- normalized = normalize_preview_env_id(preview_name)
120
+ normalized = _normalize_env_id(preview_name)
102
121
  subprocess.run(
103
122
  ["git", "config", "--local", f"branch.{branch}.buildaiPreviewName", normalized],
104
123
  cwd=str(cwd),
@@ -129,7 +148,7 @@ def _repo_metadata(start_path: Path | None = None) -> dict[str, Any]:
129
148
  cwd = (start_path or Path.cwd()).resolve()
130
149
  branch = _git_output(["branch", "--show-current"], cwd) if repo_root else None
131
150
  commit_sha = _git_output(["rev-parse", "HEAD"], cwd) if repo_root else None
132
- preview_env_id = normalize_preview_env_id(branch) if branch else None
151
+ preview_env_id = _normalize_env_id(branch) if branch else None
133
152
  return {
134
153
  "repo_root": str(repo_root) if repo_root else None,
135
154
  "worktree_path": str(cwd),
@@ -145,7 +164,6 @@ def _profile_defaults(profile: str, metadata: dict[str, Any]) -> dict[str, Any]:
145
164
  resolved = resolve_deployment_profile(
146
165
  profile,
147
166
  env_id=env_id,
148
- override_key=metadata.get("branch"),
149
167
  )
150
168
  return {
151
169
  "deployment_profile": resolved.name,
@@ -11,7 +11,7 @@ import os
11
11
  from enum import Enum
12
12
 
13
13
  import typer
14
- from infra.deployment_profiles import deployment_profile_for_app_env, resolve_deployment_profile
14
+ from infra.deployment_profiles import resolve_deployment_profile
15
15
 
16
16
  from cli.console import error, info, warning
17
17
 
@@ -59,11 +59,6 @@ def _apply_context_database_target(
59
59
  if isinstance(context, dict) and context.get("preview_env_id")
60
60
  else None
61
61
  ),
62
- override_key=(
63
- str(context.get("branch")).strip()
64
- if isinstance(context, dict) and context.get("branch")
65
- else None
66
- ),
67
62
  )
68
63
  database_target = resolved_profile.database_target.as_context_dict()
69
64
  runtime_target["region"] = resolved_profile.runtime_region
@@ -189,10 +184,14 @@ def init_ops_context(ctx: typer.Context):
189
184
  os.environ["BUILDAI_PREVIEW_ENV_ID"] = preview_env_id.strip()
190
185
  if env_flag is not None:
191
186
  deployment_profile = (
192
- "" if app_env == Environment.TEST else deployment_profile_for_app_env(app_env.value)
187
+ ""
188
+ if app_env == Environment.TEST
189
+ else "local"
190
+ if app_env == Environment.DEVELOPMENT
191
+ else "production"
193
192
  )
194
193
  elif deployment_profile is None and app_env != Environment.TEST:
195
- deployment_profile = deployment_profile_for_app_env(app_env.value)
194
+ deployment_profile = "local" if app_env == Environment.DEVELOPMENT else "production"
196
195
  if deployment_profile:
197
196
  os.environ["BUILDAI_DEPLOYMENT_PROFILE"] = deployment_profile
198
197
  _apply_context_database_target(workspace_context, deployment_profile=deployment_profile)
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "buildai-cli"
7
- version = "0.3.30"
7
+ version = "0.3.31"
8
8
  description = "Build AI CLI (Typer)"
9
9
  requires-python = ">=3.11"
10
10
  dependencies = [
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes