ver Jan5th
debugged
This commit is contained in:
60
main.py
60
main.py
@@ -1,21 +1,57 @@
|
||||
import json
|
||||
from desktop_env.envs.desktop_env import DesktopEnv
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import datetime
|
||||
|
||||
# Logger Configs {{{ #
|
||||
logger = logging.getLogger()
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
datetime_str: str = datetime.datetime.now().strftime("%Y%m%d@%H%M%S")
|
||||
|
||||
file_handler = logging.FileHandler(os.path.join("logs", "normal-{:}.log".format(datetime_str)))
|
||||
debug_handler = logging.FileHandler(os.path.join("logs", "debug-{:}.log".format(datetime_str)))
|
||||
stdout_handler = logging.StreamHandler(sys.stdout)
|
||||
sdebug_handler = logging.FileHandler(os.path.join("logs", "sdebug-{:}.log".format(datetime_str)))
|
||||
|
||||
file_handler.setLevel(logging.INFO)
|
||||
debug_handler.setLevel(logging.DEBUG)
|
||||
stdout_handler.setLevel(logging.INFO)
|
||||
sdebug_handler.setLevel(logging.DEBUG)
|
||||
|
||||
formatter = logging.Formatter(fmt="\x1b[1;33m[%(asctime)s \x1b[31m%(levelname)s \x1b[32m%(module)s/%(lineno)d-%(processName)s\x1b[1;33m] \x1b[0m%(message)s")
|
||||
file_handler.setFormatter(formatter)
|
||||
debug_handler.setFormatter(formatter)
|
||||
stdout_handler.setFormatter(formatter)
|
||||
sdebug_handler.setFormatter(formatter)
|
||||
|
||||
stdout_handler.addFilter(logging.Filter("desktopenv"))
|
||||
sdebug_handler.addFilter(logging.Filter("desktopenv"))
|
||||
|
||||
logger.addHandler(file_handler)
|
||||
logger.addHandler(debug_handler)
|
||||
logger.addHandler(stdout_handler)
|
||||
logger.addHandler(sdebug_handler)
|
||||
# }}} Logger Configs #
|
||||
|
||||
logger = logging.getLogger("desktopenv.main")
|
||||
|
||||
def human_agent():
|
||||
"""
|
||||
Runs the Gym environment with human input.
|
||||
"""
|
||||
|
||||
with open("evaluation_examples/examples/libreoffice_calc/f9584479-3d0d-4c79-affa-9ad7afdd8850.json", "r") as f:
|
||||
with open("evaluation_examples/examples/thunderbird/7b6c7e24-c58a-49fc-a5bb-d57b80e5b4c3.json", "r") as f:
|
||||
example = json.load(f)
|
||||
example["snapshot"] = "Snapshot 10"
|
||||
example["snapshot"] = "Snapshot 13"
|
||||
|
||||
env = DesktopEnv( path_to_vm="/home/david/vmware/KUbuntu 64-bit/KUbuntu 64-bit.vmx"
|
||||
, action_space="computer_13"
|
||||
, task_config=example
|
||||
)
|
||||
|
||||
# reset the environment to certain snapshot
|
||||
observation = env.reset()
|
||||
done = False
|
||||
@@ -38,24 +74,26 @@ def human_agent():
|
||||
# "action_type": 0,
|
||||
# "click_type": 3,
|
||||
# }
|
||||
print(trajectory[i])
|
||||
logger.info(trajectory[i])
|
||||
|
||||
observation, reward, done, info = env.step(trajectory[i], pause=5)
|
||||
print("Observation:", observation)
|
||||
print("Reward:", reward)
|
||||
print("Info:", info)
|
||||
logger.info("Observation: %s", observation)
|
||||
logger.info("Reward: %.2f", reward)
|
||||
logger.info("Info: %s", info)
|
||||
|
||||
print("================================\n")
|
||||
logger.info("================================\n")
|
||||
|
||||
if done:
|
||||
print("The episode is done.")
|
||||
logger.info("The episode is done.")
|
||||
break
|
||||
|
||||
result = env.evaluate()
|
||||
print("Result:", result)
|
||||
logger.info("Result: %.2f", result)
|
||||
|
||||
#input("PAUSING")
|
||||
|
||||
env.close()
|
||||
print("Environment closed.")
|
||||
logger.info("Environment closed.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user