feat&fix: update environment configuration for Docker compatibility and enhance result path handling
This commit is contained in:
11
monitor/.env
11
monitor/.env
@@ -2,10 +2,13 @@
|
||||
# Do not write any secret keys or sensitive information here.
|
||||
|
||||
# Monitor configuration
|
||||
TASK_CONFIG_PATH=../evaluation_examples/test_small.json
|
||||
TASK_CONFIG_PATH=../evaluation_examples/test_all.json
|
||||
EXAMPLES_BASE_PATH=../evaluation_examples/examples
|
||||
RESULTS_BASE_PATH=../results_operator_aws/pyautogui/screenshot/computer-use-preview
|
||||
MAX_STEPS=50
|
||||
RESULTS_BASE_PATH=../results_operator_aws
|
||||
ACTION_SPACE=pyautogui
|
||||
OBSERVATION_TYPE=screenshot
|
||||
MODEL_NAME=computer-use-preview
|
||||
MAX_STEPS=150
|
||||
FLASK_PORT=80
|
||||
FLASK_HOST=0.0.0.0
|
||||
FLASK_DEBUG=false
|
||||
FLASK_DEBUG=true
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
monitor:
|
||||
build:
|
||||
@@ -9,10 +7,11 @@ services:
|
||||
- "${FLASK_PORT:-8080}:8080"
|
||||
volumes:
|
||||
- .:/app/monitor
|
||||
- ../evaluation_examples:/app/evaluation_examples
|
||||
- ../results_operator_aws:/app/results_operator_aws
|
||||
- ${TASK_CONFIG_PATH:-../evaluation_examples/test_all.json}:/app/evaluation_examples/test.json
|
||||
- ${EXAMPLES_BASE_PATH:-../evaluation_examples/examples}:/app/evaluation_examples/examples
|
||||
- ${RESULTS_BASE_PATH:-../results_operator_aws}:/app/results
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
- FLASK_ENV=production
|
||||
- MONITOR_IN_DOCKER=true
|
||||
restart: unless-stopped
|
||||
|
||||
@@ -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