feat&fix: update environment configuration for Docker compatibility and enhance result path handling
This commit is contained in:
@@ -17,12 +17,26 @@ TASK_STATUS_CACHE = {}
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
# Load configuration from environment variables
|
||||
TASK_CONFIG_PATH = os.getenv("TASK_CONFIG_PATH", "../evaluation_examples/test_small.json")
|
||||
EXAMPLES_BASE_PATH = os.getenv("EXAMPLES_BASE_PATH", "../evaluation_examples/examples")
|
||||
RESULTS_BASE_PATH = os.getenv("RESULTS_BASE_PATH", "../results_operator_aws/pyautogui/screenshot/computer-use-preview")
|
||||
MONITOR_IN_DOCKER = os.getenv("MONITOR_IN_DOCKER", "false").lower() == "true"
|
||||
|
||||
if MONITOR_IN_DOCKER:
|
||||
# If running in Docker, use default paths
|
||||
TASK_CONFIG_PATH = "/app/evaluation_examples/test.json"
|
||||
EXAMPLES_BASE_PATH = "/app/evaluation_examples/examples"
|
||||
RESULTS_BASE_PATH = "/app/results"
|
||||
else:
|
||||
# Load configuration from environment variables
|
||||
TASK_CONFIG_PATH = os.getenv("TASK_CONFIG_PATH", "../evaluation_examples/test_small.json")
|
||||
EXAMPLES_BASE_PATH = os.getenv("EXAMPLES_BASE_PATH", "../evaluation_examples/examples")
|
||||
RESULTS_BASE_PATH = os.getenv("RESULTS_BASE_PATH", "../results")
|
||||
|
||||
ACTION_SPACE=os.getenv("ACTION_SPACE", "pyautogui")
|
||||
OBSERVATION_TYPE=os.getenv("OBSERVATION_TYPE", "screenshot")
|
||||
MODEL_NAME=os.getenv("MODEL_NAME", "computer-use-preview")
|
||||
MAX_STEPS = int(os.getenv("MAX_STEPS", "50"))
|
||||
|
||||
RESULTS_PATH = os.path.join(RESULTS_BASE_PATH, ACTION_SPACE, OBSERVATION_TYPE, MODEL_NAME)
|
||||
|
||||
def load_task_list():
|
||||
with open(TASK_CONFIG_PATH, 'r') as f:
|
||||
return json.load(f)
|
||||
@@ -35,7 +49,7 @@ def get_task_info(task_type, task_id):
|
||||
return None
|
||||
|
||||
def get_task_status(task_type, task_id):
|
||||
result_dir = os.path.join(RESULTS_BASE_PATH, task_type, task_id)
|
||||
result_dir = os.path.join(RESULTS_PATH, task_type, task_id)
|
||||
|
||||
if not os.path.exists(result_dir):
|
||||
return {
|
||||
@@ -167,7 +181,7 @@ def get_task_status_brief(task_type, task_id):
|
||||
if cache_key in TASK_STATUS_CACHE:
|
||||
return TASK_STATUS_CACHE[cache_key]
|
||||
|
||||
result_dir = os.path.join(RESULTS_BASE_PATH, task_type, task_id)
|
||||
result_dir = os.path.join(RESULTS_PATH, task_type, task_id)
|
||||
|
||||
if not os.path.exists(result_dir):
|
||||
return {
|
||||
@@ -367,7 +381,7 @@ def api_tasks_brief():
|
||||
@app.route('/task/<task_type>/<task_id>/screenshot/<path:filename>')
|
||||
def task_screenshot(task_type, task_id, filename):
|
||||
"""Get task screenshot"""
|
||||
screenshot_path = os.path.join(RESULTS_BASE_PATH, task_type, task_id, filename)
|
||||
screenshot_path = os.path.join(RESULTS_PATH, task_type, task_id, filename)
|
||||
if os.path.exists(screenshot_path):
|
||||
return send_file(screenshot_path, mimetype='image/png')
|
||||
else:
|
||||
@@ -376,7 +390,7 @@ def task_screenshot(task_type, task_id, filename):
|
||||
@app.route('/task/<task_type>/<task_id>/recording')
|
||||
def task_recording(task_type, task_id):
|
||||
"""Get task recording video"""
|
||||
recording_path = os.path.join(RESULTS_BASE_PATH, task_type, task_id, "recording.mp4")
|
||||
recording_path = os.path.join(RESULTS_PATH, task_type, task_id, "recording.mp4")
|
||||
if os.path.exists(recording_path):
|
||||
response = send_file(recording_path, mimetype='video/mp4')
|
||||
# Add headers to improve mobile compatibility
|
||||
|
||||
Reference in New Issue
Block a user