Skip to content

Commit

Permalink
Merge 32b599d into 9dba014
Browse files Browse the repository at this point in the history
  • Loading branch information
cobycloud authored Dec 18, 2024
2 parents 9dba014 + 32b599d commit 6a52217
Show file tree
Hide file tree
Showing 67 changed files with 2,718 additions and 432 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/test_changed_files.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ jobs:
run-tests:
needs: detect-changed-files
runs-on: ubuntu-latest
permissions:
issues: write
contents: read
if: ${{ needs.detect-changed-files.outputs.matrix != '[]' }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -134,9 +137,21 @@ jobs:
cd pkgs/${{ matrix.package_tests.package }}
poetry install --no-cache --all-extras -vv
- name: Run all tests for the package
- name: Run tests and save results
run: |
echo "Running tests for package: ${{ matrix.package_tests.package }}"
echo "Test files: ${{ matrix.package_tests.tests }}"
cd pkgs/${{ matrix.package_tests.package }}
poetry run pytest ${{ matrix.package_tests.tests }}
poetry run pytest ${{ matrix.package_tests.tests }} --tb=short --json-report --json-report-file=pytest_results.json || true
- name: Process test results and manage issues
if: always()
env:
DEEPINFRA_API_KEY: ${{ secrets.DEEPINFRA_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
run: |
cd pkgs/swarmauri # Change to the directory containing pyproject.toml
poetry run python ../../scripts/rag_issue_manager.py --results-file=pytest_results.json --package=${{ matrix.package_tests.package }}
1 change: 1 addition & 0 deletions pkgs/community/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ flake8 = "^7.0"
pytest = "^8.0"
pytest-asyncio = ">=0.24.0"
pytest-xdist = "^3.6.1"
pytest-json-report = "^1.5.0"
python-dotenv = "*"

[build-system]
Expand Down
1 change: 1 addition & 0 deletions pkgs/core/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ flake8 = "^7.0" # Add flake8 as a development dependency
pytest = "^8.0" # Ensure pytest is also added if you run tests
pytest-asyncio = ">=0.24.0"
pytest-xdist = "^3.6.1"
pytest-json-report = "^1.5.0"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
7 changes: 5 additions & 2 deletions pkgs/core/swarmauri_core/ComponentBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,16 @@ class ResourceTypes(Enum):
VECTOR = "Vector"
VCM = "VCM"
DATA_CONNECTOR = "DataConnector"
TRANSPORT = "Transport"
FACTORY = "Factory"

PIPELINE = "Pipeline"
SERVICE_REGISTRY = "ServiceRegistry"
CONTROL_PANEL = "ControlPanel"
TASK_MGT_STRATEGY = "TaskMgtStrategy"

def generate_id() -> str:
return str(uuid4())


class ComponentBase(BaseModel):
name: Optional[str] = None
id: str = Field(default_factory=generate_id)
Expand Down
57 changes: 57 additions & 0 deletions pkgs/core/swarmauri_core/control_panels/IControlPanel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
from abc import ABC, abstractmethod
from typing import Any, List


class IControlPlane(ABC):
"""
Abstract base class for ControlPlane.
"""

@abstractmethod
def create_agent(self, name: str, role: str) -> Any:
"""
Create an agent with the given name and role.
"""
pass

@abstractmethod
def remove_agent(self, name: str) -> None:
"""
Remove the agent with the specified name.
"""
pass

@abstractmethod
def list_active_agents(self) -> List[str]:
"""
List all active agent names.
"""
pass

@abstractmethod
def submit_tasks(self, tasks: List[Any]) -> None:
"""
Submit one or more tasks to the task management strategy for processing.
"""
pass

@abstractmethod
def process_tasks(self) -> None:
"""
Process and assign tasks from the queue, then transport them to their assigned services.
"""
pass

@abstractmethod
def distribute_tasks(self, task: Any) -> None:
"""
Distribute tasks using the task strategy.
"""
pass

@abstractmethod
def orchestrate_agents(self, task: Any) -> None:
"""
Orchestrate agents for task distribution.
"""
pass
Empty file.
57 changes: 57 additions & 0 deletions pkgs/core/swarmauri_core/pipelines/IPipeline.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
from abc import ABC, abstractmethod
from typing import Any, Callable, List
from enum import Enum


class PipelineStatus(Enum):
"""
Enum representing the status of a pipeline execution.
"""

PENDING = "pending"
RUNNING = "running"
COMPLETED = "completed"
FAILED = "failed"
STOPPED = "stopped"


class IPipeline(ABC):
"""
Interface defining core methods for pipeline execution and management.
"""

@abstractmethod
def add_task(self, task: Callable, *args: Any, **kwargs: Any) -> None:
"""
Add a task to the pipeline.
:param task: Callable task to be executed
:param args: Positional arguments for the task
:param kwargs: Keyword arguments for the task
"""
pass

@abstractmethod
def execute(self, *args: Any, **kwargs: Any) -> List[Any]:
"""
Execute the entire pipeline.
:return: List of results from pipeline execution
"""
pass

@abstractmethod
def get_status(self) -> PipelineStatus:
"""
Get the current status of the pipeline.
:return: Current pipeline status
"""
pass

@abstractmethod
def reset(self) -> None:
"""
Reset the pipeline to its initial state.
"""
pass
Empty file.
43 changes: 43 additions & 0 deletions pkgs/core/swarmauri_core/service_registries/IServiceRegistry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from abc import ABC, abstractmethod
from typing import Dict, Any, List, Optional


class IServiceRegistry(ABC):
"""
Abstract base class for service registries.
"""

@abstractmethod
def register_service(self, name: str, details: Dict[str, Any]) -> None:
"""
Register a new service with the given name and details.
"""
pass

@abstractmethod
def get_service(self, name: str) -> Optional[Dict[str, Any]]:
"""
Retrieve a service by its name.
"""
pass

@abstractmethod
def get_services_by_roles(self, roles: List[str]) -> List[str]:
"""
Get services filtered by their roles.
"""
pass

@abstractmethod
def unregister_service(self, name: str) -> None:
"""
unregister the service with the given name.
"""
pass

@abstractmethod
def update_service(self, name: str, details: Dict[str, Any]) -> None:
"""
Update the details of the service with the given name.
"""
pass
Empty file.
65 changes: 15 additions & 50 deletions pkgs/core/swarmauri_core/swarms/ISwarm.py
Original file line number Diff line number Diff line change
@@ -1,67 +1,32 @@
from abc import ABC, abstractmethod
from typing import Any, List, Dict
from datetime import datetime
from swarmauri_core.agents.IAgent import IAgent
from swarmauri_core.chains.ICallableChain import ICallableChain
from typing import Any, Dict, List, Optional, Union

class ISwarm(ABC):
"""
Interface for a Swarm, representing a collective of agents capable of performing tasks, executing callable chains, and adaptable configurations.
"""

# Abstract properties and setters
@property
@abstractmethod
def id(self) -> str:
"""Unique identifier for the factory instance."""
pass

@id.setter
@abstractmethod
def id(self, value: str) -> None:
pass

@property
@abstractmethod
def name(self) -> str:
pass

@name.setter
@abstractmethod
def name(self, value: str) -> None:
pass
class ISwarm(ABC):
"""Abstract base class for swarm implementations"""

@property
@abstractmethod
def type(self) -> str:
async def exec(
self,
input_data: Union[str, List[str]],
**kwargs: Dict[str, Any],
) -> Any:
"""Execute swarm tasks with given input"""
pass

@type.setter
@abstractmethod
def type(self, value: str) -> None:
def get_swarm_status(self) -> Dict[int, Any]:
"""Get status of all agents in the swarm"""
pass

@property
@abstractmethod
def date_created(self) -> datetime:
def agents(self) -> List[Any]:
"""Get list of agents in the swarm"""
pass

@property
@abstractmethod
def last_modified(self) -> datetime:
def queue_size(self) -> int:
"""Get size of task queue"""
pass

@last_modified.setter
@abstractmethod
def last_modified(self, value: datetime) -> None:
pass

def __hash__(self):
"""
The __hash__ method allows objects of this class to be used in sets and as dictionary keys.
__hash__ should return an integer and be defined based on immutable properties.
This is generally implemented directly in concrete classes rather than in the interface,
but it's declared here to indicate that implementing classes must provide it.
"""
pass

73 changes: 0 additions & 73 deletions pkgs/core/swarmauri_core/swarms/ISwarmAgentRegistration.py

This file was deleted.

Loading

0 comments on commit 6a52217

Please sign in to comment.