(
args: argparse.Namespace,
agent: Agent | PromptAgent | TeacherForcingAgent,
config_file_list: list[str],
)
| 219 | |
| 220 | |
| 221 | def test( |
| 222 | args: argparse.Namespace, |
| 223 | agent: Agent | PromptAgent | TeacherForcingAgent, |
| 224 | config_file_list: list[str], |
| 225 | ) -> None: |
| 226 | scores = [] |
| 227 | max_steps = args.max_steps |
| 228 | |
| 229 | early_stop_thresholds = { |
| 230 | "parsing_failure": args.parsing_failure_th, |
| 231 | "repeating_action": args.repeating_action_failure_th, |
| 232 | } |
| 233 | |
| 234 | env = ScriptBrowserEnv( |
| 235 | headless=not args.render, |
| 236 | slow_mo=args.slow_mo, |
| 237 | observation_type=args.observation_type, |
| 238 | current_viewport_only=args.current_viewport_only, |
| 239 | viewport_size={ |
| 240 | "width": args.viewport_width, |
| 241 | "height": args.viewport_height, |
| 242 | }, |
| 243 | save_trace_enabled=args.save_trace_enabled, |
| 244 | sleep_after_execution=args.sleep_after_execution, |
| 245 | ) |
| 246 | |
| 247 | for config_file in tqdm(config_file_list): |
| 248 | try: |
| 249 | # if True: |
| 250 | # render_helper = RenderHelper( |
| 251 | # config_file, args.result_dir, args.action_set_tag |
| 252 | # ) |
| 253 | |
| 254 | # get intent |
| 255 | with open(config_file) as f: |
| 256 | _c = json.load(f) |
| 257 | intent = _c["intent"] |
| 258 | task_id = _c["task_id"] |
| 259 | # automatically login |
| 260 | if _c["storage_state"]: |
| 261 | cookie_file_name = os.path.basename(_c["storage_state"]) |
| 262 | comb = get_site_comb_from_filepath(cookie_file_name) |
| 263 | temp_dir = tempfile.mkdtemp() |
| 264 | # subprocess to renew the cookie |
| 265 | subprocess.run( |
| 266 | [ |
| 267 | "python", |
| 268 | "browser_env/auto_login.py", |
| 269 | "--auth_folder", |
| 270 | temp_dir, |
| 271 | "--site_list", |
| 272 | *comb, |
| 273 | ] |
| 274 | ) |
| 275 | _c["storage_state"] = f"{temp_dir}/{cookie_file_name}" |
| 276 | assert os.path.exists(_c["storage_state"]) |
| 277 | # update the config file |
| 278 | config_file = f"{temp_dir}/{os.path.basename(config_file)}" |
no test coverage detected