cleanup operaiton

pull/1175/head
Kye Gomez 4 days ago
parent e7b43eef1e
commit 97ebbb9e55

@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry] [tool.poetry]
name = "swarms" name = "swarms"
version = "8.5.4" version = "8.6.0"
description = "Swarms - TGSC" description = "Swarms - TGSC"
license = "MIT" license = "MIT"
authors = ["Kye Gomez <kye@swarms.world>"] authors = ["Kye Gomez <kye@swarms.world>"]

@ -57,7 +57,10 @@ def test_initialization():
) )
assert len(agent_rearrange.agents) == 3 assert len(agent_rearrange.agents) == 3
assert agent_rearrange.flow == "ResearchAgent -> WriterAgent -> ReviewerAgent" assert (
agent_rearrange.flow
== "ResearchAgent -> WriterAgent -> ReviewerAgent"
)
assert agent_rearrange.max_loops == 1 assert agent_rearrange.max_loops == 1
assert agent_rearrange.verbose is True assert agent_rearrange.verbose is True
print("✓ test_initialization passed") print("✓ test_initialization passed")
@ -74,7 +77,10 @@ def test_initialization_with_team_awareness():
verbose=True, verbose=True,
) )
assert agent_rearrange.flow == "ResearchAgent -> WriterAgent -> ReviewerAgent" assert (
agent_rearrange.flow
== "ResearchAgent -> WriterAgent -> ReviewerAgent"
)
print("✓ test_initialization_with_team_awareness passed") print("✓ test_initialization_with_team_awareness passed")
@ -317,7 +323,9 @@ def test_get_agent_sequential_awareness():
verbose=True, verbose=True,
) )
awareness = agent_rearrange.get_agent_sequential_awareness("WriterAgent") awareness = agent_rearrange.get_agent_sequential_awareness(
"WriterAgent"
)
assert awareness is not None assert awareness is not None
assert isinstance(awareness, str) assert isinstance(awareness, str)
print("✓ test_get_agent_sequential_awareness passed") print("✓ test_get_agent_sequential_awareness passed")
@ -506,9 +514,9 @@ def main():
test_complete_workflow, test_complete_workflow,
] ]
print("="*60) print("=" * 60)
print("Running AgentRearrange Tests") print("Running AgentRearrange Tests")
print("="*60) print("=" * 60)
for test in tests: for test in tests:
try: try:
@ -516,9 +524,9 @@ def main():
except Exception as e: except Exception as e:
print(f"{test.__name__} failed: {e}") print(f"{test.__name__} failed: {e}")
print("="*60) print("=" * 60)
print("All tests completed!") print("All tests completed!")
print("="*60) print("=" * 60)
if __name__ == "__main__": if __name__ == "__main__":

@ -37,6 +37,7 @@ def create_sample_agents():
), ),
] ]
# ============================================================================ # ============================================================================
# Initialization Tests # Initialization Tests
# ============================================================================ # ============================================================================
@ -114,7 +115,9 @@ def test_initialization_with_heavy_swarm_config():
assert router.swarm_type == "HeavySwarm" assert router.swarm_type == "HeavySwarm"
assert router.heavy_swarm_loops_per_agent == 2 assert router.heavy_swarm_loops_per_agent == 2
assert router.heavy_swarm_question_agent_model_name == "gpt-4o-mini" assert (
router.heavy_swarm_question_agent_model_name == "gpt-4o-mini"
)
assert router.heavy_swarm_worker_model_name == "gpt-4o-mini" assert router.heavy_swarm_worker_model_name == "gpt-4o-mini"
assert router.heavy_swarm_swarm_show_output is False assert router.heavy_swarm_swarm_show_output is False
@ -132,6 +135,7 @@ def test_initialization_with_agent_rearrange_config():
assert router.swarm_type == "AgentRearrange" assert router.swarm_type == "AgentRearrange"
assert router.rearrange_flow == "ResearchAgent -> CodeAgent" assert router.rearrange_flow == "ResearchAgent -> CodeAgent"
# ============================================================================ # ============================================================================
# Configuration Tests # Configuration Tests
# ============================================================================ # ============================================================================
@ -160,6 +164,7 @@ def test_initialization_with_worker_tools():
assert router.worker_tools == [] assert router.worker_tools == []
# ============================================================================ # ============================================================================
# Document Management Tests # Document Management Tests
# ============================================================================ # ============================================================================
@ -193,6 +198,7 @@ def test_router_with_documents():
assert router.documents[0].file_path == "/path/to/doc1.txt" assert router.documents[0].file_path == "/path/to/doc1.txt"
assert router.documents[1].file_path == "/path/to/doc2.txt" assert router.documents[1].file_path == "/path/to/doc2.txt"
# ============================================================================ # ============================================================================
# Configuration Class Tests # Configuration Class Tests
# ============================================================================ # ============================================================================
@ -249,6 +255,7 @@ def test_router_with_config():
assert router.swarm_type == config.swarm_type assert router.swarm_type == config.swarm_type
assert router.rules == config.rules assert router.rules == config.rules
# ============================================================================ # ============================================================================
# Basic Execution Tests # Basic Execution Tests
# ============================================================================ # ============================================================================
@ -297,6 +304,7 @@ def test_run_with_none_task():
result = router.run(None) result = router.run(None)
assert result is not None assert result is not None
# ============================================================================ # ============================================================================
# Batch Processing Tests # Batch Processing Tests
# ============================================================================ # ============================================================================
@ -335,6 +343,7 @@ def test_batch_run_with_no_agents():
with pytest.raises(RuntimeError): with pytest.raises(RuntimeError):
router.batch_run(["Test task"]) router.batch_run(["Test task"])
# ============================================================================ # ============================================================================
# Call Method Tests # Call Method Tests
# ============================================================================ # ============================================================================
@ -366,6 +375,7 @@ def test_call_with_image():
result = router("Describe this image", img=None) result = router("Describe this image", img=None)
assert result is not None assert result is not None
# ============================================================================ # ============================================================================
# Output Type Tests # Output Type Tests
# ============================================================================ # ============================================================================
@ -385,6 +395,7 @@ def test_different_output_types():
result = router.run("Simple test task") result = router.run("Simple test task")
assert result is not None assert result is not None
# ============================================================================ # ============================================================================
# Error Handling Tests # Error Handling Tests
# ============================================================================ # ============================================================================
@ -413,9 +424,12 @@ def test_invalid_swarm_type():
) )
# But should raise ValueError during execution when creating swarm # But should raise ValueError during execution when creating swarm
with pytest.raises(ValueError, match="Invalid swarm type: InvalidSwarmType"): with pytest.raises(
ValueError, match="Invalid swarm type: InvalidSwarmType"
):
router.run("Test task") router.run("Test task")
# ============================================================================ # ============================================================================
# Integration Tests # Integration Tests
# ============================================================================ # ============================================================================

@ -6,7 +6,7 @@ from typing import Any, Callable, Dict, List
from dotenv import load_dotenv from dotenv import load_dotenv
from loguru import logger from loguru import logger
from swarms.structs import ( from swarms import (
Agent, Agent,
AgentRearrange, AgentRearrange,
ConcurrentWorkflow, ConcurrentWorkflow,
@ -19,8 +19,9 @@ from swarms.structs import (
SequentialWorkflow, SequentialWorkflow,
SpreadSheetSwarm, SpreadSheetSwarm,
SwarmRouter, SwarmRouter,
HierarchicalSwarm,
) )
from swarms.structs.hiearchical_swarm import HierarchicalSwarm
from swarms.structs.tree_swarm import ForestSwarm, Tree, TreeAgent from swarms.structs.tree_swarm import ForestSwarm, Tree, TreeAgent
load_dotenv() load_dotenv()
@ -35,10 +36,18 @@ def write_markdown_report(
results: List[Dict[str, Any]], filename: str results: List[Dict[str, Any]], filename: str
): ):
"""Write test results to a markdown file""" """Write test results to a markdown file"""
if not os.path.exists("test_runs"): workspace_dir = os.getenv("WORKSPACE_DIR")
os.makedirs("test_runs") if not workspace_dir:
raise ValueError(
"WORKSPACE_DIR environment variable is not set"
)
test_runs_dir = os.path.join(workspace_dir, "test_runs")
if not os.path.exists(test_runs_dir):
os.makedirs(test_runs_dir)
with open(f"test_runs/{filename}.md", "w") as f: file_path = os.path.join(test_runs_dir, f"{filename}.md")
with open(file_path, "w") as f:
f.write("# Swarms Comprehensive Test Report\n\n") f.write("# Swarms Comprehensive Test Report\n\n")
f.write( f.write(
f"Test Run: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n\n" f"Test Run: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n\n"
Loading…
Cancel
Save