abstract swarm

Former-commit-id: ca606fb92e
discord-bot-framework
Kye 1 year ago
parent d8fdbc1951
commit a0643d9357

@ -1,5 +1,5 @@
from abc import ABC, abstractmethod
from typing import Optional, List
from typing import Optional, List, Dict, Any
from swarms.workers.base import AbstractWorker
class AbstractSwarm(ABC):
@ -73,3 +73,89 @@ class AbstractSwarm(ABC):
"""Autoscaler that acts like kubernetes for autonomous agents"""
pass
@abstractmethod
def get_worker_by_id(self, id: str) -> "AbstractWorker":
"""Locate a worker by id"""
pass
@abstractmethod
def get_worker_by_name(self, name: str) -> "AbstractWorker":
"""Locate a worker by name"""
pass
@abstractmethod
def assign_task(self, worker: "AbstractWorker", task: Any) -> Dict:
"""Assign a task to a worker"""
pass
@abstractmethod
def get_all_tasks(self, worker: "AbstractWorker", task: Any):
"""Get all tasks"""
@abstractmethod
def get_finished_tasks(self) -> List[Dict]:
"""Get all finished tasks"""
pass
@abstractmethod
def get_pending_tasks(self) -> List[Dict]:
"""Get all pending tasks"""
pass
@abstractmethod
def pause_worker(self, worker: "AbstractWorker", worker_id: str):
"""Pause a worker"""
pass
@abstractmethod
def resume_worker(self, worker: "AbstractWorker", worker_id: str):
"""Resume a worker"""
pass
@abstractmethod
def stop_worker(self, worker: "AbstractWorker", worker_id: str):
"""Stop a worker"""
pass
@abstractmethod
def restart_worker(self, worker: "AbstractWorker"):
"""Restart worker"""
pass
@abstractmethod
def scale_up(self, num_worker: int):
"""Scale up the number of workers"""
pass
@abstractmethod
def scale_down(self, num_worker: int):
"""Scale down the number of workers"""
pass
@abstractmethod
def scale_to(self, num_worker: int):
"""Scale to a specific number of workers"""
pass
@abstractmethod
def get_all_workers(self) -> List["AbstractWorker"]:
"""Get all workers"""
pass
@abstractmethod
def get_swarm_size(self) -> int:
"""Get the size of the swarm"""
pass
@abstractmethod
def get_swarm_status(self) -> Dict:
"""Get the status of the swarm"""
pass
@abstractmethod
def save_swarm_state(self):
"""Save the swarm state"""
pass

Loading…
Cancel
Save