Refactor the code to make it comply with PEP-8 standards:Convert all class definitions to CamelCase style.

(issue 37)
This commit is contained in:
Liu Zhicong
2023-08-23 11:19:16 -07:00
parent 23963adc6e
commit 5454009e7b
21 changed files with 601 additions and 603 deletions
+12 -12
View File
@@ -3,25 +3,25 @@ from typing import Optional
import logging
import asyncio
from .agent import agent_prompt
from .compute_node import compute_node
from .agent import AgentPrompt
from .compute_node import ComputeNode
logger = logging.getLogger(__name__)
# How to dispatch different computing tasks (some tasks may contain a large amount of state for correct execution)
# to suitable computing nodes, achieving a balance of speed, cost, and power consumption,
# is the CORE GOAL of the entire computing task schedule system (aios_kernel).
class compute_task(ABC):
class ComputeTask(ABC):
@abstractmethod
def display(self) -> str:
pass
class compute_kernel:
class ComputeKernel:
_instance = None
def __new__(cls):
if cls._instance is None:
cls._instance = super(compute_kernel, cls).__new__(cls)
cls._instance = super(ComputeKernel, cls).__new__(cls)
return cls._instance
def __init__(self) -> None:
@@ -29,7 +29,7 @@ class compute_kernel:
self.is_start = False
pass
def run(self,task:compute_task) -> None:
def run(self,task:ComputeTask) -> None:
# check there is compute node can support this task
if self.is_task_support(task) is False:
logger.error(f"task {task.display()} is not support by any compute node")
@@ -47,31 +47,31 @@ class compute_kernel:
async def _run_task_loop():
while True:
task = self.task_queue.pop(0)
c_node:compute_node= await self._schedule(task)
c_node:ComputeNode= await self._schedule(task)
c_node.push_task(task)
asyncio.create_task(_run_task_loop())
async def _schedule(self,task) -> compute_node:
async def _schedule(self,task) -> ComputeNode:
pass
def add_compute_node(self,node:compute_node):
def add_compute_node(self,node:ComputeNode):
pass
def disable_compute_node(self,):
pass
def is_task_support(self,task:compute_task) -> bool:
def is_task_support(self,task:ComputeTask) -> bool:
pass
# friendly interface for use:
def llm_completion(self,prompt:agent_prompt,mode_name:Optional[str] = None,max_token:int = 0) -> compute_task:
def llm_completion(self,prompt:AgentPrompt,mode_name:Optional[str] = None,max_token:int = 0) -> ComputeTask:
# craete a llm_work_task ,push on queue's end
# then task_schedule would run this task.(might schedule some work_task to another host)
pass
async def do_llm_completion(self,prompt:agent_prompt,mode_name:Optional[str] = None,max_token:int = 0) -> str:
async def do_llm_completion(self,prompt:AgentPrompt,mode_name:Optional[str] = None,max_token:int = 0) -> str:
pass