EvoCUA Update (2025.01.05) (#412)
* evocua init * setup max_token * evocua update --------- Co-authored-by: xuetaofeng <xuetaofeng@meituan.com> Co-authored-by: Tianbao Xie <47296835+Timothyxxx@users.noreply.github.com>
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
--test_all_meta_path evaluation_examples/test_nogdrive.json \
|
||||
--max_steps 50 \
|
||||
--num_envs 30 \
|
||||
--temperature 0.01 \
|
||||
--max_history_turns 4 \
|
||||
--coordinate_type relative \
|
||||
--resize_factor 32 \
|
||||
@@ -63,6 +64,42 @@ active_environments = []
|
||||
processes = []
|
||||
is_terminating = False
|
||||
|
||||
|
||||
# Thread-local storage for task context (works per-process in multiprocessing)
|
||||
import threading
|
||||
_task_context = threading.local()
|
||||
|
||||
def get_task_context():
|
||||
"""Get current task context from thread-local storage."""
|
||||
return getattr(_task_context, 'context', {'domain': None, 'example_id': None})
|
||||
|
||||
def set_task_context(domain: str, example_id: str):
|
||||
"""Set current task context in thread-local storage."""
|
||||
_task_context.context = {'domain': domain, 'example_id': example_id}
|
||||
|
||||
def clear_task_context():
|
||||
"""Clear current task context."""
|
||||
if hasattr(_task_context, 'context'):
|
||||
delattr(_task_context, 'context')
|
||||
|
||||
class TaskContextFilter(logging.Filter):
|
||||
"""Filter to add domain and example_id to log records."""
|
||||
def filter(self, record):
|
||||
ctx = get_task_context()
|
||||
domain = ctx.get('domain')
|
||||
example_id = ctx.get('example_id')
|
||||
if domain and example_id:
|
||||
record.domain = domain
|
||||
record.example_id = example_id
|
||||
# Add prefix to message
|
||||
if hasattr(record, 'msg') and isinstance(record.msg, str):
|
||||
if not record.msg.startswith(f"[{domain}/{example_id}]"):
|
||||
record.msg = f"[{domain}/{example_id}] {record.msg}"
|
||||
else:
|
||||
record.domain = domain or "N/A"
|
||||
record.example_id = example_id or "N/A"
|
||||
return True
|
||||
|
||||
# load the environment variables from .env file
|
||||
if os.path.exists(".env"):
|
||||
from dotenv import load_dotenv
|
||||
@@ -169,6 +206,12 @@ file_handler.setFormatter(formatter)
|
||||
debug_handler.setFormatter(formatter)
|
||||
stdout_handler.setFormatter(formatter)
|
||||
|
||||
# Add task context filter to all handlers
|
||||
task_filter = TaskContextFilter()
|
||||
file_handler.addFilter(task_filter)
|
||||
debug_handler.addFilter(task_filter)
|
||||
stdout_handler.addFilter(task_filter)
|
||||
|
||||
stdout_handler.addFilter(logging.Filter("desktopenv"))
|
||||
|
||||
logger.addHandler(file_handler)
|
||||
@@ -213,6 +256,7 @@ def run_env_tasks(task_queue: Queue, args: argparse.Namespace, shared_scores: li
|
||||
enable_proxy=True,
|
||||
client_password=args.client_password
|
||||
)
|
||||
|
||||
active_environments.append(env)
|
||||
|
||||
logger.info(f"Process {current_process().name} started.")
|
||||
@@ -222,6 +266,7 @@ def run_env_tasks(task_queue: Queue, args: argparse.Namespace, shared_scores: li
|
||||
except Exception:
|
||||
break
|
||||
domain, example_id = item
|
||||
set_task_context(domain, example_id)
|
||||
try:
|
||||
config_file = os.path.join(
|
||||
args.test_config_base_dir, f"examples/{domain}/{example_id}.json"
|
||||
@@ -273,12 +318,14 @@ def run_env_tasks(task_queue: Queue, args: argparse.Namespace, shared_scores: li
|
||||
import traceback
|
||||
logger.error(f"Exception in {current_process().name} {domain}/{example_id}: {e}")
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
try:
|
||||
env.controller.end_recording(
|
||||
os.path.join(example_result_dir, "recording.mp4")
|
||||
)
|
||||
except Exception as rec_e:
|
||||
logger.error(f"Failed to end recording: {rec_e}")
|
||||
|
||||
with open(os.path.join(example_result_dir, "traj.jsonl"), "a") as f:
|
||||
f.write(json.dumps({"Error": f"{domain}/{example_id} - {e}"}))
|
||||
f.write("\n")
|
||||
@@ -286,6 +333,8 @@ def run_env_tasks(task_queue: Queue, args: argparse.Namespace, shared_scores: li
|
||||
logger.error(f"Task-level error in {current_process().name}: {e}")
|
||||
import traceback
|
||||
logger.error(traceback.format_exc())
|
||||
finally:
|
||||
clear_task_context()
|
||||
except Exception as e:
|
||||
logger.error(f"Process-level error in {current_process().name}: {e}")
|
||||
import traceback
|
||||
|
||||
Reference in New Issue
Block a user