Refactor examples; Start to load examples into benchmark; vlc initialization

This commit is contained in:
Timothyxxx
2023-12-25 00:24:13 +08:00
parent 4782b687b9
commit 236fcb0938
16 changed files with 56 additions and 52 deletions

View File

@@ -0,0 +1 @@

View File

@@ -4,6 +4,7 @@ import json
from typing import Dict, List from typing import Dict, List
from typing import Any from typing import Any
class SetupController: class SetupController:
def __init__(self, http_server: str): def __init__(self, http_server: str):
self.http_server = http_server + "/setup" self.http_server = http_server + "/setup"

View File

@@ -20,6 +20,7 @@ from desktop_env.evaluators import metrics, getters
Metric = Callable[[Any, Any], float] Metric = Callable[[Any, Any], float]
Getter = Callable[[gym.Env, Dict[str, Any]], Any] Getter = Callable[[gym.Env, Dict[str, Any]], Any]
def _execute_command(command: List[str]) -> None: def _execute_command(command: List[str]) -> None:
if command[:4] == ["vmrun", "-T", "ws", "start"]: if command[:4] == ["vmrun", "-T", "ws", "start"]:
p = subprocess.Popen(command) p = subprocess.Popen(command)
@@ -168,8 +169,9 @@ class DesktopEnv(gym.Env):
self._step_no = 0 self._step_no = 0
print("Setup new temp dir...") print("Setup new temp dir...")
self.tmp_dir = tempfile.mkdtemp( prefix="{:d}.{:}.".format(self._traj_no, self.task_id) self.tmp_dir = tempfile.mkdtemp(
, dir=self.tmp_dir_base prefix="{:d}.{:}.".format(self._traj_no, self.task_id),
dir=self.tmp_dir_base
) )
os.makedirs(os.path.join(self.tmp_dir, "screenshots")) os.makedirs(os.path.join(self.tmp_dir, "screenshots"))

View File

@@ -47,7 +47,6 @@ def capture_screen_with_cursor():
# Ensure the screenshots directory exists # Ensure the screenshots directory exists
os.makedirs(os.path.dirname(file_path), exist_ok=True) os.makedirs(os.path.dirname(file_path), exist_ok=True)
# fixme: This is a temporary fix for the cursor not being captured on Windows and Linux # fixme: This is a temporary fix for the cursor not being captured on Windows and Linux
if user_platform == "Windows" or user_platform == "Linux": if user_platform == "Windows" or user_platform == "Linux":
def _download_image(url, path): def _download_image(url, path):

View File

@@ -10,7 +10,7 @@
"files": [ "files": [
{ {
"url": "https://drive.usercontent.google.com/download?id=1rwhniaClEkF8XFzdfaNUA6GmAiy4syMZ&export=download&authuser=0&confirm=t&uuid=6fdd5b04-85f4-45e1-ad74-368f8f2a82ab&at=APZUnTUP-JxPxLfNls6jXWghblQ5:1701766091851", "url": "https://drive.usercontent.google.com/download?id=1rwhniaClEkF8XFzdfaNUA6GmAiy4syMZ&export=download&authuser=0&confirm=t&uuid=6fdd5b04-85f4-45e1-ad74-368f8f2a82ab&at=APZUnTUP-JxPxLfNls6jXWghblQ5:1701766091851",
"path": "C:\\Users\\tianbaox\\Desktop\\Quarterly_Product_Sales_by_Zone.xlsx" "path": "Desktop/Quarterly_Product_Sales_by_Zone.xlsx"
} }
] ]
} }
@@ -18,7 +18,7 @@
{ {
"type": "open", "type": "open",
"parameters": { "parameters": {
"path": "C:\\Users\\tianbaox\\Desktop\\Quarterly_Product_Sales_by_Zone.xlsx" "path": "Desktop/Quarterly_Product_Sales_by_Zone.xlsx"
} }
} }
], ],
@@ -35,7 +35,7 @@
}, },
"result": { "result": {
"type": "vm_file", "type": "vm_file",
"path": "C:\\Users\\tianbaox\\Desktop\\Quarterly_Product_Sales_by_Zone.xlsx", "path": "Desktop/Quarterly_Product_Sales_by_Zone.xlsx",
"dest": "Quarterly_Product_Sales_by_Zone.xlsx" "dest": "Quarterly_Product_Sales_by_Zone.xlsx"
} }
} }

11
main.py
View File

@@ -7,13 +7,14 @@ def human_agent():
Runs the Gym environment with human input. Runs the Gym environment with human input.
""" """
with open("evaluation_examples/examples/f9584479-3d0d-4c79-affa-9ad7afdd8850.json", "r") as f: with open("evaluation_examples/examples/libreoffice_calc/f9584479-3d0d-4c79-affa-9ad7afdd8850.json", "r") as f:
example = json.load(f) example = json.load(f)
example["snapshot"] = "base_setup" example["snapshot"] = "base_setup2"
env = DesktopEnv( path_to_vm=r"C:\Users\tianbaox\Documents\Virtual Machines\Ubuntu\Ubuntu.vmx" env = DesktopEnv(
, action_space="computer_13" path_to_vm=r"C:\Users\tianbaox\Documents\Virtual Machines\Ubuntu\Ubuntu.vmx",
, task_config=example action_space="computer_13",
task_config=example
) )
# reset the environment to certain snapshot # reset the environment to certain snapshot