SPARKNET / tests /unit /test_basic.py
MHamdan's picture
Initial commit: SPARKNET framework
a9dc537
"""
Quick test of SPARKNET core functionality
"""
import asyncio
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent))
from src.llm.ollama_client import OllamaClient
from src.utils.gpu_manager import get_gpu_manager
from src.tools.gpu_tools import GPUMonitorTool
from loguru import logger
async def test_ollama():
"""Test Ollama client"""
print("\n=== Testing Ollama Client ===")
client = OllamaClient(default_model="gemma2:2b")
# Test simple generation
response = client.generate(
prompt="Say 'Hello from SPARKNET!' and nothing else.",
temperature=0.1,
)
print(f"Response: {response[:100]}")
return True
async def test_gpu():
"""Test GPU manager"""
print("\n=== Testing GPU Manager ===")
gpu_manager = get_gpu_manager()
print(gpu_manager.monitor())
return True
async def test_tools():
"""Test tools"""
print("\n=== Testing Tools ===")
gpu_tool = GPUMonitorTool()
result = await gpu_tool.execute()
print(f"Tool Success: {result.success}")
print(f"Output Preview: {result.output[:200] if result.output else 'None'}")
return True
async def main():
"""Run all tests"""
print("="*60)
print("SPARKNET Basic Functionality Test")
print("="*60)
try:
# Test GPU
await test_gpu()
# Test Ollama
await test_ollama()
# Test Tools
await test_tools()
print("\n" + "="*60)
print("✓ All tests passed!")
print("="*60)
except Exception as e:
print(f"\n✗ Test failed: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
asyncio.run(main())