fix Desktop path error, revise main.py and update google writer tutorial

This commit is contained in:
rhythmcao
2024-02-06 21:45:03 +08:00
parent df5594b645
commit 8b42d699af
61 changed files with 201 additions and 191 deletions

18
main.py
View File

@@ -4,7 +4,7 @@ import logging
import os
import sys
import time
import argparse
from desktop_env.envs.desktop_env import DesktopEnv
# Logger Configs {{{ #
@@ -46,18 +46,28 @@ def human_agent():
"""
Runs the Gym environment with human input.
"""
parser = argparse.ArgumentParser()
parser.add_argument('-p', '--path', type=str, required=True, help="Path to the virtual machine .vmx file.")
parser.add_argument('-s', '--snapshot', type=str, help="Name of the snapshot to restore.")
parser.add_argument('-e', '--example', type=str, help="Path to the example json file.")
args = parser.parse_args(sys.argv[1:])
with open("evaluation_examples/examples/libreoffice_writer/6a33f9b9-0a56-4844-9c3f-96ec3ffb3ba2.json", "r") as f:
example_path = args.example if args.example is not None and os.path.exists(args.example) else \
'evaluation_examples/examples/libreoffice_writer/6a33f9b9-0a56-4844-9c3f-96ec3ffb3ba2.json'
with open(example_path, "r") as f:
example = json.load(f)
example["snapshot"] = "exp_v1"
# change to your customized snapshot
if args.snapshot is not None: example["snapshot"] = args.snapshot
assert os.path.exists(args.path), "The specified path to the .vmx file does not exist."
env = DesktopEnv(
path_to_vm=r"C:\Users\tianbaox\Documents\Virtual Machines\Ubuntu\Ubuntu.vmx",
path_to_vm=args.path,
action_space="computer_13",
task_config=example
)
# reset the environment to certain snapshot
observation = env.reset()
logger.info('\x1b[32m[TASK INSTRUCTION]: \x1b[32;3m%s\x1b[0m', example["instruction"])
done = False
trajectory = [