Skip to content

Commit ae0f7bd

Browse files
fix: address reviewer feedback - improve skip guards and test parametrization
- Fix Ollama skip guard: move requests import inside try-catch for consistency - Remove unnecessary google.generativeai import guard in Gemini example (litellm handles via REST) - Parametrize compute provider test to reduce duplication and cover more providers Co-authored-by: Mervin Praison <MervinPraison@users.noreply.github.com>
1 parent 6b3a999 commit ae0f7bd

3 files changed

Lines changed: 16 additions & 21 deletions

File tree

examples/python/managed-agents/provider/runtime_local_gemini.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,8 @@
1111
print("[skip] GEMINI_API_KEY or GOOGLE_API_KEY not set")
1212
sys.exit(0)
1313

14-
try:
15-
import google.generativeai
16-
except ImportError:
17-
print("[skip] google-generativeai SDK not installed")
18-
sys.exit(0)
14+
# Note: google.generativeai SDK is not required - litellm handles Gemini via REST API
15+
# Only GEMINI_API_KEY/GOOGLE_API_KEY is needed for the gemini/ model prefix
1916

2017
# Heavy imports only after skip-guards pass
2118
from praisonai import Agent

examples/python/managed-agents/provider/runtime_local_ollama.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,20 @@
55
"""
66
import os
77
import sys
8-
import requests
98

109
# Skip guards - exit cleanly if prerequisites not met
11-
# Check if Ollama daemon is running
10+
# Check if requests is available and Ollama daemon is running
11+
try:
12+
import requests
13+
except ImportError:
14+
print("[skip] requests library not installed")
15+
sys.exit(0)
16+
1217
try:
1318
response = requests.get("http://localhost:11434/api/tags", timeout=2)
14-
if response.status_code != 200:
15-
raise Exception("Ollama not responding")
16-
except Exception:
19+
except requests.RequestException:
20+
response = None
21+
if response is None or response.status_code != 200:
1722
print("[skip] Ollama daemon not running at localhost:11434")
1823
sys.exit(0)
1924

tests/unit/integrations/test_backend_semantics.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,22 +94,15 @@ def test_managed_agent_deprecation_warnings():
9494
assert "LocalAgent" in str(w[0].message)
9595

9696

97-
def test_managed_agent_compute_provider_warnings():
98-
"""Test that ManagedAgent(provider='modal'|'e2b'|...) emits DeprecationWarning and returns LocalManagedAgent."""
97+
@pytest.mark.parametrize("provider", ["modal", "e2b", "docker", "flyio", "daytona"])
98+
def test_managed_agent_compute_provider_warnings(provider):
99+
"""Test that ManagedAgent(provider=<compute>) emits DeprecationWarning and returns LocalManagedAgent."""
99100
from praisonai.integrations.managed_agents import ManagedAgent
100101
from praisonai.integrations.managed_local import LocalManagedAgent
101102

102103
# Compute providers should emit DeprecationWarning and return LocalManagedAgent (backward compatibility)
103104
with pytest.warns(DeprecationWarning, match="compute.*deprecated"):
104-
obj = ManagedAgent(provider="modal")
105-
assert isinstance(obj, LocalManagedAgent)
106-
107-
with pytest.warns(DeprecationWarning, match="compute.*deprecated"):
108-
obj = ManagedAgent(provider="e2b")
109-
assert isinstance(obj, LocalManagedAgent)
110-
111-
with pytest.warns(DeprecationWarning, match="compute.*deprecated"):
112-
obj = ManagedAgent(provider="docker")
105+
obj = ManagedAgent(provider=provider)
113106
assert isinstance(obj, LocalManagedAgent)
114107

115108

0 commit comments

Comments
 (0)