2023-08-20 22:53:35 -07:00
|
|
|
from abc import ABC, abstractmethod
|
2023-08-22 17:11:20 -07:00
|
|
|
from .compute_kernel import compute_task
|
2023-08-20 22:53:35 -07:00
|
|
|
|
|
|
|
|
class compute_node(ABC):
|
2023-08-22 17:11:20 -07:00
|
|
|
@abstractmethod
|
|
|
|
|
async def push_task(self,task:compute_task,proiority:int = 0):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
async def remove_task(self,task_id:str):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def get_task_state(self,task_id:str):
|
|
|
|
|
pass
|
|
|
|
|
|
2023-08-20 22:53:35 -07:00
|
|
|
@abstractmethod
|
|
|
|
|
def display(self) -> str:
|
|
|
|
|
pass
|
|
|
|
|
|
2023-08-22 17:11:20 -07:00
|
|
|
@abstractmethod
|
|
|
|
|
def get_capacity(self):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def is_support(self,task_type:str) -> bool:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def is_local(self) -> bool:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def is_trusted(self) -> bool:
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def get_fee_type(self) -> str:
|
|
|
|
|
return "free"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-08-20 22:53:35 -07:00
|
|
|
class local_compute_node(compute_node):
|
|
|
|
|
def display(self) -> str:
|
|
|
|
|
return super().display()
|
|
|
|
|
|
2023-08-22 17:11:20 -07:00
|
|
|
def is_local(self) -> bool:
|
|
|
|
|
return True
|
|
|
|
|
|
2023-08-20 22:53:35 -07:00
|
|
|
|