worker_manager.py 889 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from abc import ABC, abstractmethod
from typing import Any, Optional, Set

import torch


class AbstractWorkerManager(ABC):

    def __init__(self, device: torch.device):
        self.device = device

    @property
    @abstractmethod
    def is_enabled(self) -> bool:
15
        raise NotImplementedError
16
17
18
19

    @abstractmethod
    def set_active_adapters(self, requests: Set[Any],
                            mapping: Optional[Any]) -> None:
20
        raise NotImplementedError
21
22
23

    @abstractmethod
    def add_adapter(self, adapter_request: Any) -> bool:
24
        raise NotImplementedError
25
26
27

    @abstractmethod
    def remove_adapter(self, adapter_id: int) -> bool:
28
        raise NotImplementedError
29
30

    @abstractmethod
31
32
    def remove_all_adapters(self) -> None:
        raise NotImplementedError
33
34
35

    @abstractmethod
    def list_adapters(self) -> Set[int]:
36
        raise NotImplementedError