Browse Source

agent单元测试

xueyiming 1 week ago
parent
commit
e50bc0df86
1 changed files with 4 additions and 10 deletions
  1. 4 10
      pqai_agent_server/task_server.py

+ 4 - 10
pqai_agent_server/task_server.py

@@ -196,12 +196,12 @@ class TaskManager:
         }
 
     def create_task(self, agent_id: int) -> Dict:
-        """创建新任务并添加100个子任务"""
+        """创建新任务"""
 
         conn = self.db.get_connection()
         try:
             conn.begin()
-            # TODO 插入任务
+            # TODO 插入任务 当前测试模拟
             with conn.cursor() as cursor:
                 cursor.execute(
                     f"""INSERT INTO {self.test_task_table} (agent_id, status, create_user, update_user) VALUES (%s, %s, %s, %s)""",
@@ -209,7 +209,7 @@ class TaskManager:
                 )
             task_id = cursor.lastrowid
             task_conversations = []
-            # TODO 具体的数据集信息
+            # TODO 查询具体的数据集信息后插入
             i = 0
             for _ in range(30):
                 i = i + 1
@@ -379,15 +379,9 @@ class TaskManager:
                 # 更新子任务状态为运行中
                 self.update_task_conversations_status(task_conversation['id'],
                                                       TestTaskConversationsStatus.RUNNING.value)
-
                 try:
                     # 模拟任务执行 - 在实际应用中替换为实际业务逻辑
-
-                    # 再次检查任务是否被取消
-                    # if self.task_events[task_id].is_set():
-                    #     self.update_task_conversations_status(subtask['id'], 'cancelled')
-                    #     break
-                    # TODO 实际任务执行
+                    # TODO 后续改成实际任务执行
                     time.sleep(1)
                     score = random.random()
                     # 更新子任务状态为已完成