Merge remote-tracking branch 'upstream/feat/aws-provider-support'
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -195,4 +195,6 @@ vmware_vm_data
|
|||||||
# result
|
# result
|
||||||
**/result*/**/*
|
**/result*/**/*
|
||||||
|
|
||||||
.vscode
|
.vscode
|
||||||
|
|
||||||
|
dataimpulse_proxy_config.json
|
||||||
@@ -21,11 +21,20 @@ from requests_toolbelt.multipart.encoder import MultipartEncoder
|
|||||||
|
|
||||||
from desktop_env.controllers.python import PythonController
|
from desktop_env.controllers.python import PythonController
|
||||||
from desktop_env.evaluators.metrics.utils import compare_urls
|
from desktop_env.evaluators.metrics.utils import compare_urls
|
||||||
|
from desktop_env.providers.aws.proxy_pool import get_global_proxy_pool, init_proxy_pool, ProxyInfo
|
||||||
|
|
||||||
|
import dotenv
|
||||||
|
# Load environment variables from .env file
|
||||||
|
dotenv.load_dotenv()
|
||||||
|
|
||||||
|
CLIENT_PASSWORD = os.getenv("CLIENT_PASSWORD", "password") # Default password for sudo operations
|
||||||
|
PROXY_CONFIG_FILE = os.getenv("PROXY_CONFIG_FILE", "dataimpulse_proxy_config.json") # Default proxy config file
|
||||||
|
|
||||||
logger = logging.getLogger("desktopenv.setup")
|
logger = logging.getLogger("desktopenv.setup")
|
||||||
|
|
||||||
FILE_PATH = os.path.dirname(os.path.abspath(__file__))
|
FILE_PATH = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
|
init_proxy_pool(PROXY_CONFIG_FILE) # initialize the global proxy pool
|
||||||
|
|
||||||
class SetupController:
|
class SetupController:
|
||||||
def __init__(self, vm_ip: str, server_port: int = 5000, chromium_port: int = 9222, vlc_port: int = 8080, cache_dir: str = "cache"):
|
def __init__(self, vm_ip: str, server_port: int = 5000, chromium_port: int = 9222, vlc_port: int = 8080, cache_dir: str = "cache"):
|
||||||
@@ -360,6 +369,51 @@ class SetupController:
|
|||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
logger.error("An error occurred while trying to send the request: %s", e)
|
logger.error("An error occurred while trying to send the request: %s", e)
|
||||||
|
|
||||||
|
def _proxy_setup(self, client_password: str = CLIENT_PASSWORD):
|
||||||
|
"""Setup system-wide proxy configuration using proxy pool
|
||||||
|
|
||||||
|
Args:
|
||||||
|
client_password (str): Password for sudo operations, defaults to "password"
|
||||||
|
"""
|
||||||
|
# Get proxy from global proxy pool
|
||||||
|
proxy_pool = get_global_proxy_pool()
|
||||||
|
current_proxy = proxy_pool.get_next_proxy()
|
||||||
|
|
||||||
|
if not current_proxy:
|
||||||
|
logger.error("No proxy available from proxy pool")
|
||||||
|
raise Exception("No proxy available from proxy pool")
|
||||||
|
|
||||||
|
# Format proxy URL
|
||||||
|
proxy_url = proxy_pool._format_proxy_url(current_proxy)
|
||||||
|
logger.info(f"Setting up proxy: {current_proxy.host}:{current_proxy.port}")
|
||||||
|
|
||||||
|
# Configure system proxy environment variables
|
||||||
|
proxy_commands = [
|
||||||
|
f"echo '{client_password}' | sudo -S bash -c \"echo 'export http_proxy={proxy_url}' >> /etc/environment\"",
|
||||||
|
f"echo '{client_password}' | sudo -S bash -c \"echo 'export https_proxy={proxy_url}' >> /etc/environment\"",
|
||||||
|
f"echo '{client_password}' | sudo -S bash -c \"echo 'export HTTP_PROXY={proxy_url}' >> /etc/environment\"",
|
||||||
|
f"echo '{client_password}' | sudo -S bash -c \"echo 'export HTTPS_PROXY={proxy_url}' >> /etc/environment\"",
|
||||||
|
]
|
||||||
|
|
||||||
|
# Execute all proxy configuration commands
|
||||||
|
for cmd in proxy_commands:
|
||||||
|
try:
|
||||||
|
self._execute_setup([cmd], shell=True)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Failed to execute proxy setup command: {e}")
|
||||||
|
proxy_pool.mark_proxy_failed(current_proxy)
|
||||||
|
raise
|
||||||
|
|
||||||
|
# Reload environment variables
|
||||||
|
reload_cmd = "source /etc/environment"
|
||||||
|
try:
|
||||||
|
logger.info(f"Proxy setup completed successfully for {current_proxy.host}:{current_proxy.port}")
|
||||||
|
proxy_pool.mark_proxy_success(current_proxy)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Failed to reload environment variables: {e}")
|
||||||
|
proxy_pool.mark_proxy_failed(current_proxy)
|
||||||
|
raise
|
||||||
|
|
||||||
# Chrome setup
|
# Chrome setup
|
||||||
def _chrome_open_tabs_setup(self, urls_to_open: List[str]):
|
def _chrome_open_tabs_setup(self, urls_to_open: List[str]):
|
||||||
host = self.vm_ip
|
host = self.vm_ip
|
||||||
|
|||||||
@@ -191,6 +191,10 @@ class DesktopEnv(gym.Env):
|
|||||||
logger.info("Setting up environment...")
|
logger.info("Setting up environment...")
|
||||||
self.setup_controller.setup(self.config)
|
self.setup_controller.setup(self.config)
|
||||||
logger.info("Environment setup complete.")
|
logger.info("Environment setup complete.")
|
||||||
|
|
||||||
|
if task_config.get("proxy", False):
|
||||||
|
# If using proxy, set up the proxy configuration
|
||||||
|
self.setup_controller._proxy_setup()
|
||||||
|
|
||||||
observation = self._get_obs()
|
observation = self._get_obs()
|
||||||
return observation
|
return observation
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ DEFAULT_REGION = "us-east-1"
|
|||||||
# todo: public the AMI images
|
# todo: public the AMI images
|
||||||
# ami-05e7d7bd279ea4f14
|
# ami-05e7d7bd279ea4f14
|
||||||
IMAGE_ID_MAP = {
|
IMAGE_ID_MAP = {
|
||||||
"us-east-1": "ami-02fea2e5b77c79c17",
|
"us-east-1": "ami-00d1fe56632acbefd",
|
||||||
"ap-east-1": "ami-0c092a5b8be4116f5",
|
"ap-east-1": "ami-0c092a5b8be4116f5",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
{
|
{
|
||||||
"type": "launch",
|
"type": "launch",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"command": "VLC_VERBOSE=-1 vlc"
|
"command": "VLC_VERBOSE=-1 vlc --no-audio --no-video-title-show",
|
||||||
|
"shell": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -39,7 +40,8 @@
|
|||||||
{
|
{
|
||||||
"type": "launch",
|
"type": "launch",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"command": "vlc"
|
"command": "vlc --no-audio --no-video-title-show",
|
||||||
|
"shell": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -29,12 +29,8 @@
|
|||||||
{
|
{
|
||||||
"type": "launch",
|
"type": "launch",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"command": [
|
"command": "VLC_VERBOSE=-1 vlc --no-audio --no-video-title-show --start-time=10 /home/user/Desktop/Colorful-Flowers.mp3",
|
||||||
"VLC_VERBOSE=-1",
|
"shell": true
|
||||||
"vlc",
|
|
||||||
"--start-time=10",
|
|
||||||
"/home/user/Desktop/Colorful-Flowers.mp3"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -95,7 +91,8 @@
|
|||||||
{
|
{
|
||||||
"type": "launch",
|
"type": "launch",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"command": "vlc"
|
"command": "vlc --no-audio --no-video-title-show",
|
||||||
|
"shell": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -18,7 +18,8 @@
|
|||||||
{
|
{
|
||||||
"type": "launch",
|
"type": "launch",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"command": "VLC_VERBOSE=-1 vlc"
|
"command": "VLC_VERBOSE=-1 vlc --no-audio --no-video-title-show",
|
||||||
|
"shell": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
{
|
{
|
||||||
"type": "launch",
|
"type": "launch",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"command": "VLC_VERBOSE=-1 vlc"
|
"command": "VLC_VERBOSE=-1 vlc --no-audio --no-video-title-show",
|
||||||
|
"shell": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
{
|
{
|
||||||
"type": "launch",
|
"type": "launch",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"command": "VLC_VERBOSE=-1 vlc"
|
"command": "VLC_VERBOSE=-1 vlc --no-audio --no-video-title-show",
|
||||||
|
"shell": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
{
|
{
|
||||||
"type": "launch",
|
"type": "launch",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"command": "VLC_VERBOSE=-1 vlc"
|
"command": "VLC_VERBOSE=-1 vlc --no-audio --no-video-title-show",
|
||||||
|
"shell": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,12 +18,8 @@
|
|||||||
{
|
{
|
||||||
"type": "launch",
|
"type": "launch",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"command": [
|
"command": "VLC_VERBOSE=-1 vlc --no-audio --no-video-title-show --start-time=15 '/home/user/Desktop/Gen 2.mp4'",
|
||||||
"VLC_VERBOSE=-1",
|
"shell": true
|
||||||
"vlc",
|
|
||||||
"--start-time=15",
|
|
||||||
"/home/user/Desktop/Gen 2.mp4"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,12 +18,8 @@
|
|||||||
{
|
{
|
||||||
"type": "launch",
|
"type": "launch",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"command": [
|
"command": "VLC_VERBOSE=-1 vlc --no-audio --no-video-title-show --start-time=73 '/home/user/Desktop/Baby Justin Bieber.mp4'",
|
||||||
"VLC_VERBOSE=-1",
|
"shell": true
|
||||||
"vlc",
|
|
||||||
"--start-time=73",
|
|
||||||
"/home/user/Desktop/Baby Justin Bieber.mp4"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
{
|
{
|
||||||
"type": "launch",
|
"type": "launch",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"command": "VLC_VERBOSE=-1 vlc"
|
"command": "VLC_VERBOSE=-1 vlc --no-audio --no-video-title-show",
|
||||||
|
"shell": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -39,7 +40,8 @@
|
|||||||
{
|
{
|
||||||
"type": "launch",
|
"type": "launch",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"command": "vlc"
|
"command": "vlc --no-audio --no-video-title-show",
|
||||||
|
"shell": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
{
|
{
|
||||||
"type": "launch",
|
"type": "launch",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"command": "VLC_VERBOSE=-1 vlc"
|
"command": "VLC_VERBOSE=-1 vlc --no-audio --no-video-title-show",
|
||||||
|
"shell": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -39,7 +40,8 @@
|
|||||||
{
|
{
|
||||||
"type": "launch",
|
"type": "launch",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"command": "vlc"
|
"command": "vlc --no-audio --no-video-title-show",
|
||||||
|
"shell": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -18,11 +18,8 @@
|
|||||||
{
|
{
|
||||||
"type": "launch",
|
"type": "launch",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"command": [
|
"command": "VLC_VERBOSE=-1 vlc --no-audio --no-video-title-show /home/user/Desktop/flipped_1984_Apple_Macintosh_Commercial.mp4",
|
||||||
"VLC_VERBOSE=-1",
|
"shell": true
|
||||||
"vlc",
|
|
||||||
"/home/user/Desktop/flipped_1984_Apple_Macintosh_Commercial.mp4"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
{
|
{
|
||||||
"type": "launch",
|
"type": "launch",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"command": "VLC_VERBOSE=-1 vlc"
|
"command": "VLC_VERBOSE=-1 vlc --no-audio --no-video-title-show",
|
||||||
|
"shell": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
{
|
{
|
||||||
"type": "launch",
|
"type": "launch",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"command": "VLC_VERBOSE=-1 vlc"
|
"command": "VLC_VERBOSE=-1 vlc --no-audio --no-video-title-show",
|
||||||
|
"shell": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
{
|
{
|
||||||
"type": "launch",
|
"type": "launch",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"command": "VLC_VERBOSE=-1 vlc"
|
"command": "VLC_VERBOSE=-1 vlc --no-audio --no-video-title-show",
|
||||||
|
"shell": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -39,7 +40,8 @@
|
|||||||
{
|
{
|
||||||
"type": "launch",
|
"type": "launch",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"command": "vlc"
|
"command": "vlc --no-audio --no-video-title-show",
|
||||||
|
"shell": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -18,14 +18,8 @@
|
|||||||
{
|
{
|
||||||
"type": "launch",
|
"type": "launch",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"command": [
|
"command": "VLC_VERBOSE=-1 vlc --no-audio --no-video-title-show --start-time=120.5 --stop-time=121 --play-and-pause '/home/user/Desktop/Interstellar Movie - Official Trailer.mp4'",
|
||||||
"VLC_VERBOSE=-1",
|
"shell": true
|
||||||
"vlc",
|
|
||||||
"--start-time=120.5",
|
|
||||||
"--stop-time=121",
|
|
||||||
"--play-and-pause",
|
|
||||||
"/home/user/Desktop/Interstellar Movie - Official Trailer.mp4"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
{
|
{
|
||||||
"type": "launch",
|
"type": "launch",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"command": "VLC_VERBOSE=-1 vlc"
|
"command": "VLC_VERBOSE=-1 vlc --no-audio --no-video-title-show",
|
||||||
|
"shell": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -39,7 +40,8 @@
|
|||||||
{
|
{
|
||||||
"type": "launch",
|
"type": "launch",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"command": "vlc"
|
"command": "vlc --no-audio --no-video-title-show",
|
||||||
|
"shell": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -18,14 +18,8 @@
|
|||||||
{
|
{
|
||||||
"type": "launch",
|
"type": "launch",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"command": [
|
"command": "VLC_VERBOSE=-1 vlc --no-audio --no-video-title-show --start-time=120.5 --stop-time=121 --play-and-pause '/home/user/Desktop/Interstellar Movie - Official Trailer.mp4'",
|
||||||
"VLC_VERBOSE=-1",
|
"shell": true
|
||||||
"vlc",
|
|
||||||
"--start-time=120.5",
|
|
||||||
"--stop-time=121",
|
|
||||||
"--play-and-pause",
|
|
||||||
"/home/user/Desktop/Interstellar Movie - Official Trailer.mp4"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,10 +19,13 @@ The monitor can be configured by editing the `.env` file in the monitor director
|
|||||||
|
|
||||||
| Variable | Description | Default Value |
|
| Variable | Description | Default Value |
|
||||||
|----------|-------------|---------------|
|
|----------|-------------|---------------|
|
||||||
| TASK_CONFIG_PATH | Path to the task configuration JSON file | ../evaluation_examples/test_small.json |
|
| TASK_CONFIG_PATH | Path to the task configuration file | ../evaluation_examples/test.json |
|
||||||
| EXAMPLES_BASE_PATH | Base path for task example files | ../evaluation_examples/examples |
|
| EXAMPLES_BASE_PATH | Base path for example files | ../evaluation_examples/examples |
|
||||||
| RESULTS_BASE_PATH | Base path for execution results | ../results_operator_aws/pyautogui/screenshot/computer-use-preview |
|
| RESULTS_BASE_PATH | Base path for storing results | ../results |
|
||||||
| MAX_STEPS | Maximum steps to display for a task | 50 |
|
| ACTION_SPACE | Action space type (e.g., pyautogui, keyboard) | pyautogui |
|
||||||
|
| OBSERVATION_TYPE | Type of observation (e.g., screenshot, video) | screenshot |
|
||||||
|
| MODEL_NAME | Name of the model to use for task execution | computer-use-preview |
|
||||||
|
| MAX_STEPS | Maximum steps to display for a task | 150 |
|
||||||
| FLASK_PORT | Port for the web server | 80 |
|
| FLASK_PORT | Port for the web server | 80 |
|
||||||
| FLASK_HOST | Host address for the web server | 0.0.0.0 |
|
| FLASK_HOST | Host address for the web server | 0.0.0.0 |
|
||||||
| FLASK_DEBUG | Enable debug mode (true/false) | false |
|
| FLASK_DEBUG | Enable debug mode (true/false) | false |
|
||||||
@@ -30,13 +33,16 @@ The monitor can be configured by editing the `.env` file in the monitor director
|
|||||||
For example:
|
For example:
|
||||||
```bash
|
```bash
|
||||||
# .env
|
# .env
|
||||||
TASK_CONFIG_PATH=../evaluation_examples/test_small.json
|
TASK_CONFIG_PATH=../evaluation_examples/test.json
|
||||||
EXAMPLES_BASE_PATH=../evaluation_examples/examples
|
EXAMPLES_BASE_PATH=../evaluation_examples/examples
|
||||||
RESULTS_BASE_PATH=../results_operator_aws/pyautogui/screenshot/computer-use-preview
|
RESULTS_BASE_PATH=../results
|
||||||
MAX_STEPS=50
|
ACTION_SPACE=pyautogui
|
||||||
|
OBSERVATION_TYPE=screenshot
|
||||||
|
MODEL_NAME=computer-use-preview
|
||||||
|
MAX_STEPS=150
|
||||||
FLASK_PORT=80
|
FLASK_PORT=80
|
||||||
FLASK_HOST=0.0.0.0
|
FLASK_HOST=0.0.0.0
|
||||||
FLASK_DEBUG=false
|
FLASK_DEBUG=true
|
||||||
```
|
```
|
||||||
|
|
||||||
## Running with Docker
|
## Running with Docker
|
||||||
|
|||||||
@@ -12,8 +12,11 @@ from dotenv import load_dotenv
|
|||||||
# Load environment variables from .env file
|
# Load environment variables from .env file
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|
||||||
# {task_type}_{task_id}: status_dict
|
# {task_type}_{task_id}: (status_dict, timestamp)
|
||||||
|
# For "Done" status, we need to verify it for a period to ensure it doesn't change to "Error"
|
||||||
TASK_STATUS_CACHE = {}
|
TASK_STATUS_CACHE = {}
|
||||||
|
# Time in seconds to consider "Done" status as stable (default: 30s)
|
||||||
|
DONE_STABILITY_PERIOD = int(os.getenv("DONE_STABILITY_PERIOD", "30"))
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
@@ -26,14 +29,14 @@ if MONITOR_IN_DOCKER:
|
|||||||
RESULTS_BASE_PATH = "/app/results"
|
RESULTS_BASE_PATH = "/app/results"
|
||||||
else:
|
else:
|
||||||
# Load configuration from environment variables
|
# Load configuration from environment variables
|
||||||
TASK_CONFIG_PATH = os.getenv("TASK_CONFIG_PATH", "../evaluation_examples/test_small.json")
|
TASK_CONFIG_PATH = os.getenv("TASK_CONFIG_PATH", "../evaluation_examples/test.json")
|
||||||
EXAMPLES_BASE_PATH = os.getenv("EXAMPLES_BASE_PATH", "../evaluation_examples/examples")
|
EXAMPLES_BASE_PATH = os.getenv("EXAMPLES_BASE_PATH", "../evaluation_examples/examples")
|
||||||
RESULTS_BASE_PATH = os.getenv("RESULTS_BASE_PATH", "../results")
|
RESULTS_BASE_PATH = os.getenv("RESULTS_BASE_PATH", "../results")
|
||||||
|
|
||||||
ACTION_SPACE=os.getenv("ACTION_SPACE", "pyautogui")
|
ACTION_SPACE=os.getenv("ACTION_SPACE", "pyautogui")
|
||||||
OBSERVATION_TYPE=os.getenv("OBSERVATION_TYPE", "screenshot")
|
OBSERVATION_TYPE=os.getenv("OBSERVATION_TYPE", "screenshot")
|
||||||
MODEL_NAME=os.getenv("MODEL_NAME", "computer-use-preview")
|
MODEL_NAME=os.getenv("MODEL_NAME", "computer-use-preview")
|
||||||
MAX_STEPS = int(os.getenv("MAX_STEPS", "50"))
|
MAX_STEPS = int(os.getenv("MAX_STEPS", "150"))
|
||||||
|
|
||||||
RESULTS_PATH = os.path.join(RESULTS_BASE_PATH, ACTION_SPACE, OBSERVATION_TYPE, MODEL_NAME)
|
RESULTS_PATH = os.path.join(RESULTS_BASE_PATH, ACTION_SPACE, OBSERVATION_TYPE, MODEL_NAME)
|
||||||
|
|
||||||
@@ -177,9 +180,24 @@ def get_task_status_brief(task_type, task_id):
|
|||||||
# Generate cache key based on task type and ID
|
# Generate cache key based on task type and ID
|
||||||
cache_key = f"{task_type}_{task_id}"
|
cache_key = f"{task_type}_{task_id}"
|
||||||
|
|
||||||
# Check if the status is already cached
|
# Check if the status is already cached
|
||||||
|
current_time = time.time()
|
||||||
|
last_cache_time = None
|
||||||
if cache_key in TASK_STATUS_CACHE:
|
if cache_key in TASK_STATUS_CACHE:
|
||||||
return TASK_STATUS_CACHE[cache_key]
|
cached_status, cached_time = TASK_STATUS_CACHE[cache_key]
|
||||||
|
last_cache_time = cached_time
|
||||||
|
# If cached status is "Done", check if it's within the stability period
|
||||||
|
if cached_status["status"].startswith("Done"):
|
||||||
|
# If within stability period, recalculate status to ensure it's correct
|
||||||
|
if current_time - cached_time < DONE_STABILITY_PERIOD:
|
||||||
|
# Status is still in verification period, refresh it
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
# Status is stable, return from cache
|
||||||
|
return cached_status
|
||||||
|
else:
|
||||||
|
# For non-Done status (like Error), just return from cache
|
||||||
|
return cached_status
|
||||||
|
|
||||||
result_dir = os.path.join(RESULTS_PATH, task_type, task_id)
|
result_dir = os.path.join(RESULTS_PATH, task_type, task_id)
|
||||||
|
|
||||||
@@ -293,7 +311,8 @@ def get_task_status_brief(task_type, task_id):
|
|||||||
|
|
||||||
# Cache the status if it is done or error
|
# Cache the status if it is done or error
|
||||||
if status.startswith("Done") or status == "Error":
|
if status.startswith("Done") or status == "Error":
|
||||||
TASK_STATUS_CACHE[cache_key] = status_dict
|
current_time = last_cache_time if last_cache_time else current_time
|
||||||
|
TASK_STATUS_CACHE[cache_key] = (status_dict, current_time)
|
||||||
|
|
||||||
return status_dict
|
return status_dict
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user