feat&fix: enhance task status handling and update logging configuration
This commit is contained in:
@@ -1,28 +1,15 @@
|
||||
import base64
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import tempfile
|
||||
import time
|
||||
import xml.etree.ElementTree as ET
|
||||
from http import HTTPStatus
|
||||
from io import BytesIO
|
||||
from typing import Dict, List
|
||||
|
||||
import backoff
|
||||
import dashscope
|
||||
import google.generativeai as genai
|
||||
import openai
|
||||
import requests
|
||||
import tiktoken
|
||||
from PIL import Image
|
||||
from google.api_core.exceptions import InvalidArgument, ResourceExhausted, InternalServerError, BadRequest
|
||||
from groq import Groq
|
||||
from requests.exceptions import SSLError
|
||||
from typing import Any, Optional, Union, Tuple
|
||||
|
||||
from mm_agents.accessibility_tree_wrap.heuristic_retrieve import filter_nodes, draw_bounding_boxes
|
||||
from mm_agents.prompts import SYS_PROMPT_IN_SCREENSHOT_OUT_CODE, SYS_PROMPT_IN_SCREENSHOT_OUT_ACTION, \
|
||||
SYS_PROMPT_IN_A11Y_OUT_CODE, SYS_PROMPT_IN_A11Y_OUT_ACTION, \
|
||||
SYS_PROMPT_IN_BOTH_OUT_CODE, SYS_PROMPT_IN_BOTH_OUT_ACTION, \
|
||||
|
||||
@@ -122,6 +122,8 @@ def get_task_status(task_type, task_id):
|
||||
status = "Error"
|
||||
elif log_data.get("exit_condition") and "message_exit: True" in log_data.get("exit_condition", ""):
|
||||
status = "Done (Message Exit)"
|
||||
elif log_data.get("exit_condition") and "thought_exit: True" in log_data.get("exit_condition", ""):
|
||||
status = "Done (Thought Exit)"
|
||||
elif len(steps) >= MAX_STEPS:
|
||||
status = "Done (Max Steps)"
|
||||
else:
|
||||
@@ -231,6 +233,8 @@ def get_task_status_brief(task_type, task_id):
|
||||
log_tail = result.stdout
|
||||
if "message_exit: True" in log_tail:
|
||||
status = "Done (Message Exit)"
|
||||
elif "thought_exit: True" in log_tail:
|
||||
status = "Done (Thought Exit)"
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
@@ -85,6 +85,7 @@ function updateTaskStatus(data) {
|
||||
case 'Done':
|
||||
case 'Done (Message Exit)':
|
||||
case 'Done (Max Steps)':
|
||||
case 'Done (Thought Exit)':
|
||||
statusClass = 'status-completed';
|
||||
statusIcon = 'fa-check-circle';
|
||||
break;
|
||||
@@ -183,7 +184,7 @@ function updateStatistics(data) {
|
||||
tasks.forEach(task => {
|
||||
if (task.status.status === 'Running' || task.status.status === 'Preparing' || task.status.status === 'Initializing') {
|
||||
activeTasks++;
|
||||
} else if (task.status.status === 'Done' || task.status.status === 'Done (Message Exit)' || task.status.status === 'Done (Max Steps)') {
|
||||
} else if (task.status.status === 'Done' || task.status.status === 'Done (Message Exit)' || task.status.status === 'Done (Max Steps)' || task.status.status === 'Done (Thought Exit)') {
|
||||
completedTasks++;
|
||||
// Calculate score if task is completed
|
||||
if (task.status.result) {
|
||||
@@ -241,7 +242,7 @@ function renderTasks(data) {
|
||||
if (currentFilter === 'active') {
|
||||
filteredTasks = tasks.filter(task => ['Running', 'Preparing', 'Initializing'].includes(task.status.status));
|
||||
} else if (currentFilter === 'completed') {
|
||||
filteredTasks = tasks.filter(task => task.status.status === 'Done' || task.status.status === 'Done (Message Exit)' || task.status.status === 'Done (Max Steps)');
|
||||
filteredTasks = tasks.filter(task => task.status.status === 'Done' || task.status.status === 'Done (Message Exit)' || task.status.status === 'Done (Max Steps)'|| task.status.status === 'Done (Thought Exit)');
|
||||
} else if (currentFilter === 'error') {
|
||||
filteredTasks = tasks.filter(task => task.status.status === 'Error');
|
||||
}
|
||||
@@ -264,7 +265,7 @@ function renderTasks(data) {
|
||||
tasks.forEach(task => {
|
||||
if (task.status.status === 'Running' || task.status.status === 'Preparing' || task.status.status === 'Initializing') {
|
||||
runningCount++;
|
||||
} else if (task.status.status === 'Done' || task.status.status === 'Done (Message Exit)' || task.status.status === 'Done (Max Steps)') {
|
||||
} else if (task.status.status === 'Done' || task.status.status === 'Done (Message Exit)' || task.status.status === 'Done (Max Steps)' || task.status.status === 'Done (Thought Exit)') {
|
||||
completedCount++;
|
||||
} else if (task.status.status === 'Error') {
|
||||
errorCount++;
|
||||
@@ -346,6 +347,7 @@ function renderTasks(data) {
|
||||
case 'Done':
|
||||
case 'Done (Message Exit)':
|
||||
case 'Done (Max Steps)':
|
||||
case 'Done (Thought Exit)':
|
||||
statusClass = 'status-completed';
|
||||
statusIcon = 'fa-check-circle';
|
||||
break;
|
||||
|
||||
@@ -173,7 +173,7 @@ pre {
|
||||
.status-not-started { background: linear-gradient(135deg, #f0f0f0, #e6e6e6); color: #555; }
|
||||
.status-preparing, .status-initializing { background: linear-gradient(135deg, #fff7e0, #ffe8a3); color: #8a6d00; }
|
||||
.status-running { background: linear-gradient(135deg, #e3f2fd, #bbdefb); color: #0d47a1; }
|
||||
.status-done, .status-done-message-exit, .status-done-max-steps { background: linear-gradient(135deg, #e8f5e9, #c8e6c9); color: #1b5e20; }
|
||||
.status-done, .status-done-message-exit, .status-done-max-steps, .status-done-thought-exit { background: linear-gradient(135deg, #e8f5e9, #c8e6c9); color: #1b5e20; }
|
||||
.status-error { background: linear-gradient(135deg, #ffebee, #ffcdd2); color: #b71c1c; }
|
||||
|
||||
.step-intent {
|
||||
|
||||
@@ -41,6 +41,11 @@
|
||||
<i class="fas fa-question-circle"></i>
|
||||
<span class="tooltip-text">Maximum steps reached, task completed</span>
|
||||
</span>
|
||||
{% elif task_status.status == 'Done (Thought Exit)' %}
|
||||
<span class="tooltip">
|
||||
<i class="fas fa-question-circle"></i>
|
||||
<span class="tooltip-text">Task completed with a thought exit condition</span>
|
||||
</span>
|
||||
{% endif %}
|
||||
</dd>
|
||||
<dt>Current Step</dt>
|
||||
|
||||
@@ -33,41 +33,29 @@ if os.path.exists(".env"):
|
||||
|
||||
# Logger Configs {{{ #
|
||||
logger = logging.getLogger()
|
||||
logger.setLevel(logging.DEBUG)
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
datetime_str: str = datetime.datetime.now().strftime("%Y%m%d@%H%M%S")
|
||||
|
||||
file_handler = logging.FileHandler(
|
||||
os.path.join("logs", "normal-{:}.log".format(datetime_str)), encoding="utf-8"
|
||||
)
|
||||
debug_handler = logging.FileHandler(
|
||||
os.path.join("logs", "debug-{:}.log".format(datetime_str)), encoding="utf-8"
|
||||
)
|
||||
stdout_handler = logging.StreamHandler(sys.stdout)
|
||||
sdebug_handler = logging.FileHandler(
|
||||
os.path.join("logs", "sdebug-{:}.log".format(datetime_str)), encoding="utf-8"
|
||||
)
|
||||
|
||||
|
||||
file_handler.setLevel(logging.INFO)
|
||||
debug_handler.setLevel(logging.DEBUG)
|
||||
stdout_handler.setLevel(logging.INFO)
|
||||
sdebug_handler.setLevel(logging.DEBUG)
|
||||
|
||||
formatter = logging.Formatter(
|
||||
fmt="\x1b[1;33m[%(asctime)s \x1b[31m%(levelname)s \x1b[32m%(module)s/%(lineno)d-%(processName)s\x1b[1;33m] \x1b[0m%(message)s"
|
||||
)
|
||||
file_handler.setFormatter(formatter)
|
||||
debug_handler.setFormatter(formatter)
|
||||
stdout_handler.setFormatter(formatter)
|
||||
sdebug_handler.setFormatter(formatter)
|
||||
|
||||
stdout_handler.addFilter(logging.Filter("desktopenv"))
|
||||
sdebug_handler.addFilter(logging.Filter("desktopenv"))
|
||||
|
||||
logger.addHandler(file_handler)
|
||||
logger.addHandler(debug_handler)
|
||||
logger.addHandler(stdout_handler)
|
||||
logger.addHandler(sdebug_handler)
|
||||
# }}} Logger Configs #
|
||||
|
||||
logger = logging.getLogger("desktopenv.experiment")
|
||||
|
||||
Reference in New Issue
Block a user