Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/praisonai/praisonai/integrations/managed_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,9 +599,11 @@ def _install_packages(self) -> None:
subprocess.run(cmd, check=True, capture_output=True, timeout=120)
logger.info("[local_managed] host pip install completed")
except subprocess.CalledProcessError as e:
logger.warning("[local_managed] pip install failed: %s", e.stderr)
except subprocess.TimeoutExpired:
logger.warning("[local_managed] pip install timed out")
raise RuntimeError(
f"pip install failed for {pip_pkgs}: {e.stderr.decode(errors='replace')}"
) from e
except subprocess.TimeoutExpired as e:
raise RuntimeError(f"pip install timed out after 120s for {pip_pkgs}") from e
else:
# Sandbox installation via compute provider
self._install_packages_in_compute(pip_pkgs)
Expand Down Expand Up @@ -629,10 +631,14 @@ def _install_packages_in_compute(self, pip_pkgs: List[str]) -> None:
if result.get("exit_code", 0) == 0:
logger.info("[local_managed] compute pip install completed")
else:
logger.warning("[local_managed] compute pip install failed: %s", result.get("stderr", ""))
raise RuntimeError(
f"pip install failed in compute for {pip_pkgs}: {result.get('stderr', '')}"
)

except Exception as e:
logger.warning("[local_managed] compute pip install error: %s", e)
if "pip install failed in compute" in str(e):
raise # Re-raise RuntimeError from above
raise RuntimeError(f"pip install error in compute for {pip_pkgs}: {e}") from e
Comment on lines 638 to +641
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Fragile string-matching to detect self-raised RuntimeError

if "pip install failed in compute" in str(e) is brittle β€” any future edit to the error message string (or an unrelated RuntimeError whose text happens to contain that substring) will silently break the re-raise path. Using isinstance(e, RuntimeError) or, better, restructuring with a flag variable or separate try/except blocks would remove the ambiguity entirely.


def _ensure_agent(self) -> Any:
"""Create or return the inner PraisonAI Agent."""
Expand Down
Loading
Loading