worker_manager.py 749 B

123456789101112131415161718192021222324252627282930313233343536
  1. from abc import ABC, abstractmethod
  2. from typing import Any, Optional, Set
  3. import torch
  4. class AbstractWorkerManager(ABC):
  5. def __init__(self, device: torch.device):
  6. self.device = device
  7. @property
  8. @abstractmethod
  9. def is_enabled(self) -> bool:
  10. ...
  11. @abstractmethod
  12. def set_active_adapters(self, requests: Set[Any],
  13. mapping: Optional[Any]) -> None:
  14. ...
  15. @abstractmethod
  16. def add_adapter(self, adapter_request: Any) -> bool:
  17. ...
  18. @abstractmethod
  19. def remove_adapter(self, adapter_id: int) -> bool:
  20. ...
  21. @abstractmethod
  22. def remove_all_adapters(self):
  23. ...
  24. @abstractmethod
  25. def list_adapters(self) -> Set[int]:
  26. ...