MCPcopy Index your code
hub / github.com/OpenBMB/ChatDev / _run_uv_command

Function _run_uv_command

functions/function_calling/uv_related.py:151–197  ·  view source on GitHub ↗
(
    cmd: List[str],
    workspace_root: Path,
    *,
    step: str | None = None,
    env: Dict[str, str] | None = None,
    timeout: float | None = None,
)

Source from the content-addressed store, hash-verified

149
150
151def _run_uv_command(
152 cmd: List[str],
153 workspace_root: Path,
154 *,
155 step: str | None = None,
156 env: Dict[str, str] | None = None,
157 timeout: float | None = None,
158) -> Dict[str, Any]:
159 timeout_value = _DEFAULT_TIMEOUT if timeout is None else timeout
160 env_vars = None if env is None else {**os.environ, **env}
161 try:
162 completed = subprocess.run(
163 cmd,
164 cwd=str(workspace_root),
165 capture_output=True,
166 text=True,
167 timeout=timeout_value,
168 check=False,
169 env=env_vars,
170 )
171 except FileNotFoundError as exc:
172 raise RuntimeError("uv command not found in PATH") from exc
173 except subprocess.TimeoutExpired as exc:
174 stdout_text = exc.stdout
175 if stdout_text is None:
176 stdout_text = getattr(exc, "output", "") or ""
177 stderr_text = exc.stderr or ""
178 message = _build_timeout_message(step, timeout_value, stdout_text, stderr_text)
179 return {
180 "command": cmd,
181 "stdout": stdout_text,
182 "stderr": stderr_text,
183 "returncode": None,
184 "step": step,
185 "timed_out": True,
186 "timeout": timeout_value,
187 "error": message,
188 }
189
190 return {
191 "command": cmd,
192 "stdout": completed.stdout or "",
193 "stderr": completed.stderr or "",
194 "returncode": completed.returncode,
195 # "cwd": str(workspace_root),
196 "step": step,
197 }
198
199
200def install_python_packages(

Callers 3

install_python_packagesFunction · 0.85
init_python_envFunction · 0.85
uv_runFunction · 0.85

Calls 2

_build_timeout_messageFunction · 0.85
runMethod · 0.45

Tested by

no test coverage detected