llama-deploy-core 0.2.7a1__tar.gz → 0.3.0a1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: llama-deploy-core
3
- Version: 0.2.7a1
3
+ Version: 0.3.0a1
4
4
  Summary: Core models and schemas for LlamaDeploy
5
5
  License: MIT
6
6
  Requires-Dist: pydantic>=2.0.0
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "llama-deploy-core"
3
- version = "0.2.7a1"
3
+ version = "0.3.0a1"
4
4
  description = "Core models and schemas for LlamaDeploy"
5
5
  readme = "README.md"
6
6
  license = { text = "MIT" }
@@ -46,20 +46,42 @@ def parse_github_repo_url(repo_url: str) -> tuple[str, str]:
46
46
  def inject_basic_auth(url: str, basic_auth: str | None = None) -> str:
47
47
  """Inject basic auth into a URL if provided"""
48
48
  if basic_auth and "://" in url and "@" not in url:
49
- url = url.replace("https://", f"https://{basic_auth}@")
49
+ scheme, rest = url.split("://", 1)
50
+ url = f"{scheme}://{basic_auth}@{rest}"
50
51
  return url
51
52
 
52
53
 
53
- def _run_process(args: list[str], cwd: str | None = None) -> str:
54
- """Run a process and raise an exception if it fails"""
55
- result = subprocess.run(
56
- args, cwd=cwd, capture_output=True, text=True, check=True, timeout=30
57
- )
54
+ def _run_process(args: list[str], cwd: str | None = None, timeout: int = 30) -> str:
55
+ """Run a process and raise a GitAccessError with detailed output if it fails.
56
+
57
+ The error message includes the command, return code, working directory,
58
+ and both stdout and stderr to aid debugging (e.g., git fetch failures).
59
+ """
60
+ try:
61
+ result = subprocess.run(
62
+ args, cwd=cwd, capture_output=True, text=True, check=False, timeout=timeout
63
+ )
64
+ except subprocess.TimeoutExpired:
65
+ cmd = " ".join(args)
66
+ where = f" (cwd={cwd})" if cwd else ""
67
+ raise GitAccessError(f"Command timed out after {timeout}s: {cmd}{where}")
68
+
58
69
  if result.returncode != 0:
59
- raise subprocess.CalledProcessError(
60
- result.returncode, args, result.stdout, result.stderr
70
+ cmd = " ".join(args)
71
+ where = f" (cwd={cwd})" if cwd else ""
72
+ stdout = (result.stdout or "").strip()
73
+ stderr = (result.stderr or "").strip()
74
+ details = []
75
+ if stdout:
76
+ details.append(f"stdout:\n{stdout}")
77
+ if stderr:
78
+ details.append(f"stderr:\n{stderr}")
79
+ detail_block = "\n\n".join(details) if details else "(no output)"
80
+ raise GitAccessError(
81
+ f"Command failed with exit code {result.returncode}: {cmd}{where}\n{detail_block}"
61
82
  )
62
- return result.stdout.strip()
83
+
84
+ return (result.stdout or "").strip()
63
85
 
64
86
 
65
87
  class GitAccessError(Exception):
@@ -120,6 +142,7 @@ def clone_repo(
120
142
  if resolved_branch:
121
143
  git_ref = resolved_branch
122
144
  else:
145
+ # Try exact tag match; if it fails, we just ignore and proceed
123
146
  try:
124
147
  resolved_tag = _run_process(
125
148
  ["git", "describe", "--tags", "--exact-match"],
@@ -127,34 +150,23 @@ def clone_repo(
127
150
  )
128
151
  if resolved_tag:
129
152
  git_ref = resolved_tag
130
- except subprocess.CalledProcessError:
153
+ except GitAccessError:
131
154
  pass
132
155
  else: # Checkout the ref
133
156
  if did_exist:
134
- try:
135
- _run_process(
136
- ["git", "fetch", "origin"], cwd=str(dest_dir.absolute())
137
- )
138
- except subprocess.CalledProcessError:
139
- raise GitAccessError("Failed to resolve git reference")
140
- try:
141
157
  _run_process(
142
- ["git", "checkout", git_ref], cwd=str(dest_dir.absolute())
158
+ ["git", "fetch", "origin"], cwd=str(dest_dir.absolute())
143
159
  )
144
- except subprocess.CalledProcessError as e:
145
- # Check error message to determine if it's a network issue or ref not found
146
- if "unable to access" in str(
147
- e.stderr
148
- ) or "fatal: unable to access repository" in str(e.stderr):
149
- raise GitAccessError("Failed to resolve git reference")
150
- else:
151
- raise GitAccessError(f"Commit SHA '{git_ref}' not found")
160
+ _run_process(["git", "checkout", git_ref], cwd=str(dest_dir.absolute()))
152
161
  # if no ref, stay on whatever the clone gave us/current commit
153
162
  # return the resolved sha
154
163
  resolved_sha = _run_process(
155
164
  ["git", "rev-parse", "HEAD"], cwd=str(dest_dir.absolute())
156
165
  ).strip()
157
166
  return GitCloneResult(git_sha=resolved_sha, git_ref=git_ref)
167
+ except GitAccessError:
168
+ # Re-raise enriched errors from _run_process directly
169
+ raise
158
170
  except subprocess.TimeoutExpired:
159
171
  raise GitAccessError("Timeout while cloning repository")
160
172